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

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

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

var afd_niveau = getQParamInt("deplevel", -1);
var dep_key;
var autosearch = getQParamInt("autosearch", 0) == 1;

var autfunction = "WEB_PRSUSE";
var authparams = user.checkAutorisation(autfunction);
%>

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

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

      $(function() {<% if (autosearch) { %> document.forms.u2.submit();<%}%>});
    </script>
  </head>

  <body id="searchbody">
    <form name="u2" target="workFrame" action="prs_afdeling_search_list.asp" method="get">
    <% SEARCH_PAGE_START({ header: L("lcl_filterblok") });
        SEARCH_BLOCK_START();%>
        <input type="hidden" name="afd_niveau" value="<%=afd_niveau%>">
              <tr class="primsearch">
                <td class="label"><label for="deptName"><%=L("lcl_prs_dept_name")%></label></td>
                <td><input type="text" class="fld wildcard" id="deptName" name="deptName" value=""></td>
              </tr>
              <tr class="primsearch">
                <td class="label"><label for="deptDesc"><%=L("lcl_prs_dept_desc")%></label></td>
                <td><input class="fld wildcard" type="text" id="deptDesc" name="deptDesc" value=""></td>
              </tr>
                <%
                if (afd_niveau == 1)
                {
                  sql = "SELECT prs_bedrijf_key,"
                      + "       prs_bedrijf_naam"
                      + "  FROM prs_bedrijf"
                      + " WHERE prs_bedrijf_verwijder IS NULL AND prs_bedrijf_intern = 1"
                      + (authparams.PRSreadlevel >= 0 ? " AND prs_bedrijf_key = " + user.afdeling().prs_bedrijf_key() : "")
                      + " ORDER BY prs_bedrijf_naam_upper";

                  FCLTselector("bdr_key", sql,
                  {  label: L("lcl_prs_dept_company"),
                     emptyOption: "",
                     trclass: "primsearch",
                     whenEmpty: L("lcl_search_generic")
                  });
                }
                else if (afd_niveau > 1)
                {
                  FCLTafdelingselector("dep_key",
                                       "dep_key",
                                       { departmentKey: dep_key,
                                         filtercode:(afd_niveau - 1),
                                         label: L("lcl_dep_name_level" + (afd_niveau - 1)),
                                         trclass: "primsearch",
                                         autlevel: authparams.PRSreadlevel, // Was voorheen niet aanwezig
                                         whenEmpty: L("lcl_search_generic")
                                       });
                }
                FCLTkostenplaatsselector("prs_kstpl",
                                         "prs_kstpl",
                                         user_key,
                                         { label: L("lcl_prs_dept_kosten"),
                                           whenEmpty: L("lcl_search_generic"),
                                           trclass: "primsearch",
                                           filtercode: "A"
                                         });
      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(); %>
