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

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

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

var locatie_key = getQParamInt("locatie_key", -1); // locatie
var vak_code = getQParam("vak_code", "");
var ter_func_key = getQParamInt("ter_func_key", -1);
var verantw_key  = getQParamInt("verantw",  -1); // Terrein verantwoordelijke
var autosearch = getQParamInt("autosearch", 0) == 1;
var alg_startlevel = getQParamInt("alg_startlevel", 2); // Startlevel van plaatsselector, default Locatie
var authparams = alg.checkAutorisation();

%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">

      function doSubmit()
      {
          // Submitten met kenmerken
          doSubmitWithKenmerken();
      }

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

      $(function()
      {
          <% if (autosearch) { %> document.forms.u2.submit();<%}%>
      });
    </script>
  </head>
  <body id="searchbody">
    <form name="u2" target="workFrame" action="alg_terreinsector_search_list.asp" method="get">
<%
    SEARCH_PAGE_START({ header: L("lcl_filterblok") });
      SEARCH_BLOCK_START();
        //               <!-- Locatie, gebouw en verdieping -->
        FCLTplaatsselector( authparams.ALGreadlevel
                          , { locatiekey: locatie_key,
                              startlevel: alg_startlevel, // locatie
                              eindlevel: 2, // locatie
                              whenEmpty: L("lcl_search_generic")
                            });
        sql = "SELECT   alg_srtterreinsector_key, "
            + lcl.xsqla('alg_srtterreinsec_omschrijving', 'alg_srtterreinsector_key')
            + "    FROM alg_v_aanwezigsrtterreinsector "
            + "ORDER BY UPPER("+lcl.xsql('alg_srtterreinsec_omschrijving', 'alg_srtterreinsector_key')+")";

        FCLTselector("srt",
                     sql,
                     { initKey: ter_func_key,
                       label: L("lcl_estate_terreinsector_man_sort"),
                       emptyOption: "",
                       trclass: "primsearch",
                       initEmpty: true
                     });
%>
        </tr>
        <!-- Vervallen terreinen -->
        <tr class="primsearch">
          <td></td>
          <td align=left>
            <input type="checkbox" class="fld" name="expAlgIncl" id="expAlgIncl" value="1" >
            <label for="expAlgIncl"><%=L("lcl_alg_terreinsector_vervallen_incl")%></label>
          </td>
        </tr>
<%
      SEARCH_BLOCK_END();
      SEARCH_BLOCK_START();
%>
        <!-- Zoektekst -->
        <tr class="primsearch">
          <td class="label"><label for="descr"><%=L("lcl_estate_terreinsector_man_code")%></label></td>
          <td><input type="text" class="fld" name="descr" value="<%=safe.htmlattr(vak_code)%>"></td>
        </tr>

        <!-- Terrein beheerder -->
<%      // Dit veld is alleen zichtbaar indien er minimaal één terreinbeheerder geconfigureerd is (suppressNoValues).
        FCLTpersoonselector("verantw",
                            "sgVerantw",
                            { perslidKey: verantw_key,
                              label: L("lcl_alg_ter_verantw"),
                              filtercode: "TV", // Terrein Verantwoordelijke
                              trclass: "primsearch",
                              suppressNoValues: true,
                              whenEmpty: L("lcl_search_generic")  // want filter
                            });
      SEARCH_BLOCK_END();

      SIMPLE_BLOCK_START();
        var buttons = [ {title: L("lcl_overview_list"), action: "doSubmit()", id: "bSearch", importance: 1, icon: "fa-clipboard-list" }
                      , {title: L("lcl_shared_advanced"), action: "myModal()", id:"bAdvanced", importance: 3, icon: "fa-filter" }
                      ];
        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(); %>
