<%@ LANGUAGE = JavaScript %>
<% /*
     $Revision$
     $Id$

    File:               prs_perslid_search.asp
    Description:        Search filters for persons list
    Parameters:
    Context:
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/plaatsselector.inc" -->
<!-- #include file="../Shared/afdelingselector.inc" -->

<%
FCLTHeader.Requires({ plugins:["jQuery", "kenmerk"] });

var prsName;
var prsNR;
var prsLogin;

var district_key = getQParamInt("dis_key", -1);
var locatie_key = getQParamInt("loc_key", -1);
var gebouw_key = getQParamInt("bld_key", -1);

var autosearch = getQParamInt("autosearch", 0) == 1;
var altloc = (getQParamInt("altloc", 0) == 1); // Ook alternatieve locaties

var autfunction = "WEB_PRSUSE"; // stelling: als je MAN hebt moet je ook maar USE krijgen
var authparams = user.checkAutorisation(autfunction);

%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
      function doSubmit()
      {
          doSubmitWithKenmerken();
      }

      function myModal()
      {
        var lvl = "P";
        var key = 0;
        var prs_key = "";
        var url = "load_kenmerk.asp?disc=" + "&urole=bo" + "&advanced=1" + "&link_key=" + prs_key + "&niveau=" + lvl;
        var titel = "<%=L("lcl_properties")%>";
        showKenmerkModal(url, titel)
      }

      function onPlaatsChange()
      {
        $("#altloc").prop('checked', true);
      }

      $(document).ready(function() {<% if (autosearch) { %> document.forms.u2.submit();<%}%>});
    </script>
  </head>
  <body id="searchbody">
    <div id="search">
      <form name="u2" target="workFrame" action="prs_perslid_search_list.asp" method="get">
<%      BLOCK_START("searchtable", L("lcl_filterblok"));%>
        <tr>
          <td  class="searchkolom1">
            <table>
            <tr>
              <td class="label"><label for="prsName"><%=L("lcl_prs_person_name")%>:</label></td>
              <td><input type="text" class="fldsrch" name="prsName" value="<%=safe.htmlattr(prsName)%>"></td>
            </tr>
            <tr>
              <td class="label"><label for="prsNR"><%=L("lcl_prs_person_nr")%>:</label></td>
              <td><input type="text" class="fldsrch" name="prsNR" value="<%=safe.htmlattr(prsNR)%>"></td>
            </tr>
<%          sql = "SELECT prs_srtperslid_key"
                + ", " + lcl.xsqla("prs_srtperslid_omschrijving", "prs_srtperslid_key")
                + ", prs_bedrijf_key"
                + " FROM prs_v_aanwezigsrtperslid "
                + "ORDER BY prs_srtperslid_upper ";
            FCLTselector("func",
                         sql,
                         { label: L("lcl_prs_person_function"),
                           emptyOption: ""
                         });

            sql =  "SELECT   prs_bedrijf_key, "
                + "         prs_bedrijf_naam "
                + "    FROM prs_bedrijf "
                + "   WHERE prs_bedrijf_verwijder IS NULL AND prs_bedrijf_intern = 1 "
                + "ORDER BY prs_bedrijf_naam_upper ";

            FCLTselector("bdr_key", sql,
              {  label: L("lcl_prs_dept_company"),
                 emptyOption: "",
                 whenEmpty: L("lcl_search_generic")
              });

            FCLTafdelingselector("dept",
                               "dept",
                               { label: L("lcl_prs_organisatie"),
                                 autlevel: authparams.PRSreadlevel, // Was voorheen niet aanwezig
                                 whenEmpty: L("lcl_search_generic")
                               });
%>
            </table>
          </td>

          <td  class="searchkolom2">
            <table>
               <tr>
                  <td class="label"><label for="prsLogin"><%=L("lcl_prs_person_login")%>:</label></td>
                  <td><input type="text" class="fldsrch" name="prsLogin" value="<%=safe.htmlattr(prsLogin)%>"></td>
                </tr>
<%
            sql = "SELECT fac_profiel_key"
                + ", fac_profiel_omschrijving"
                + "  FROM fac_profiel"
                + " ORDER BY 2";
            oRs = Oracle.Execute(sql);
            if (!oRs.eof)
            {
              FCLTselector( "profielkey"
                          , sql
                          , { label: L("lcl_prs_profile")
                            , emptyOption: ""
                            });
            }
            oRs.Close();

%>
                    <%
                      FCLTplaatsselector(authparams.ALGreadlevel, {
                                                                districtkey: district_key,
                                                                locatiekey: locatie_key,
                                                                gebouwkey: gebouw_key,
                                                                startlevel: 1, // District
                                                                eindlevel: 3, // Gebouw
                                                                whenEmpty: L("lcl_search_generic"),  // want filter
                                                                onDisChange: "onPlaatsChange()",
                                                                onLocChange: "onPlaatsChange()",
                                                                onGebChange: "onPlaatsChange()"
                                                              });
                    %>
            </table>
          </td>
        </tr>
        <!-- Ook alternatieve locaties -->
        <tr>
          <td align=right><b></b></td>
          <td>
            <input type="checkbox" class="fldaltloc" name="altloc" id="altloc" value="1" <%=altloc? "checked" : ""%>>
            <label for="altloc"><%=L("lcl_prs_alt_loc")%></label>
        </tr>
<%      BLOCK_END();
        var buttons =  [ {title: L("lcl_search"), action:"doSubmit()", id:"bSearch" },
                         {title: L("lcl_obj_advanced"), action:"myModal()", id:"bAdvanced" } ];
        CreateButtons(buttons, { entersubmit: true } );
%>
      </form>
    </div>

    <div id="result">
      <iframe width="100%" height="100%"
              src="../Shared/empty.asp"
              name="workFrame" id="workFrame"
              onload='FcltMgr.iframeLoaded(this)'
              frameborder="0" scrolling="no">
      </iframe>
    </div>
  </body>
</html>
