<%@ 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/calendar.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/plaatsselector.inc" -->
<!-- #include file="../Shared/afdelingselector.inc" -->
<!-- #include file="../Shared/functieselector.inc" -->

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

var prsName;
var prsFirstName;
var prsNR;
var prsLogin;
var prsEmail;

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 vinkje
var inactief = (getQParamInt("inactief", 0) == 1); // Alleen inactieve vinkje
var unconfirmedUsers = (getQParamInt("unconfirmed_users", 0) == 1);
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();
      }

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

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

      $(function() {<% if (autosearch) { %> document.forms.u2.submit();<%}%>});
    </script>
  </head>
  <body id="searchbody">
    <form name="u2" target="workFrame" action="prs_perslid_search_list.asp" method="get">
      <% SEARCH_PAGE_START({ header: L("lcl_filterblok") }); %>
<%      SEARCH_BLOCK_START();%>
            <tr>
              <td class="label"><label for="prsName"><%=L("lcl_prs_person_achternaam")%></label></td>
              <td><input type="text" class="fld wildcard" name="prsName" value="<%=safe.htmlattr(prsName)%>"></td>
            </tr>
            <tr>
              <td class="label"><label for="prsFirstName"><%=L("lcl_prs_person_voornaam")%></label></td>
              <td><input type="text" class="fld wildcard" name="prsFirstName" value="<%=safe.htmlattr(prsFirstName)%>"></td>
            </tr>
            <tr>
              <td class="label"><label for="prsNR"><%=L("lcl_prs_person_nr")%></label></td>
              <td><input type="text" class="fld wildcard" name="prsNR" value="<%=safe.htmlattr(prsNR)%>"></td>
            </tr>
<%
    				FCLTfunctieselector("func", "sgFunc" ,
                          {  label: L("lcl_prs_person_function"),
                             whenEmpty: L("lcl_search_generic")
                          });

            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")
                               });
            RWCHECKBOXTR("inactief", "fldinactief", L("prs_perslid_inactief"), (inactief ? 1 : 0));
SEARCH_BLOCK_END();
SEARCH_BLOCK_START();
%>
                <tr>
                  <td class="label"><label for="prsLogin"><%=L("lcl_prs_person_login")%></label></td>
                  <td><input type="text" class="fld wildcard" name="prsLogin" value="<%=safe.htmlattr(prsLogin)%>"></td>
                </tr>

                <tr>
                  <td class="label"><label for="prsEmail"><%=L("lcl_prs_person_email")%></label></td>
                  <td><input type="text" class="fld wildcard" name="prsEmail" value="<%=safe.htmlattr(prsEmail)%>"></td>
                </tr>
<%
          if (S("prs_perslid_datums") == 1) {
            FCLTcalendar("prsEnddate",
              { label : L("lcl_prs_person_einddatum"),
                initEmpty: true
              });
          }

            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
                                                                filtercode: "FAC",
                                                                onDisChange: "onPlaatsChange()",
                                                                onLocChange: "onPlaatsChange()",
                                                                onGebChange: "onPlaatsChange()"
                                                              });
            RWCHECKBOXTR("altloc", "fld", L("lcl_prs_alt_loc"), (altloc ? 1 : 0));
            RWCHECKBOXTR("unconfirmedusers", "fld", L("lcl_prs_flags_unapproved_m"), (unconfirmedUsers ? 1 : 0));
            if (user.has("WEB_FACFAC"))
            {
              RWCHECKBOXTR("apionly", "fld", "*FACFAC: Alleen met APIKEY", 0);
            }
SEARCH_BLOCK_END();

var buttons =  [ {title: L("lcl_overview_list"), action:"doSubmit()", id:"bSearch", icon: "fa-clipboard-list", importance: 1 },
                  {title: L("lcl_shared_advanced"), action:"myModal()", id:"bAdvanced", icon: "fa-filter", importance: 3 } ];

SIMPLE_BLOCK_START();
    CreateButtons(buttons, { entersubmit: true, showIcons: true } );
SIMPLE_BLOCK_END();
SEARCH_PAGE_END();
%>
      </form>

    <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>
<% ASPPAGE_END(); %>
