<%@ 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="alg.inc" -->
<!-- #include file="../Shared/afdelingselector.inc" -->

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

var locatie_key = getQParamInt("locatie_key", -1); // Locatie
var gebouw_key = getQParamInt("gebouw_key", -1); // Gebouw
var verdieping_key = getQParamInt("verdieping_key", -1); // Verdieping
var ruimte_key = getQParamInt("ruimte_key", -1); // ruimte
var ruimte_nr = getQParam("ruimte_nr", "");
var ruimte_use = getQParamInt("ruimte_use", -1); // Ruimtefunctie
var ruimte_descr = getQParam("ruimte_descr", "");
var autosearch = getQParamInt("autosearch", 0) == 1;
var alg_startlevel = getQParamInt("alg_startlevel", 2); // Startlevel van plaatsselector, default Locatie
var chkgeb = getQParamInt("chkgeb", 0) == 1;
var cnt_full = getQParamInt("cnt_full", 1);
var authparams = alg.checkAutorisation();

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

      async function myModal(init)
      {
          var lvl = "R";
          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_ruimte_search_list.asp" method="get">
<%
    SEARCH_PAGE_START({ header: L("lcl_filterblok") });
      SEARCH_BLOCK_START();
%>
        <input type="hidden" id="cnt_full" name="cnt_full" value="<%=cnt_full%>">
        <input type="hidden" id="chkgeb" name="chkgeb" value="<%=(chkgeb?1:0)%>">
<%
        FCLTplaatsselector( authparams.ALGreadlevel
                          , { locatiekey: locatie_key,
                              gebouwkey: gebouw_key,
                              verdiepingkey: verdieping_key,
                              ruimtekey: ruimte_key,
                              multitoggle: 6, // true|false (=all) or till alg_level_# (0-6)
                              startlevel: alg_startlevel, // locatie
                              eindlevel: 5, // ruimte
                              filtercode: "INCVR",
                              whenEmpty: L("lcl_search_generic")  // want filter
                             });
      SEARCH_BLOCK_END();
      SEARCH_BLOCK_START();
%>
        <tr class="primsearch">
          <td class="label"><label for="nr"><%=L("lcl_estate_ruimte_man_nr")%></label></td>
          <td><input type="text" class="fldsrch fldshort" name="nr" value="<%=safe.htmlattr(ruimte_nr)%>"></td>
        </tr>
        <tr class="primsearch">
          <td class="label"><label for="descr"><%=L("lcl_estate_ruimte_man_descr")%></label></td>
          <td><input type="text" class="fldsrch fldshort" name="descr" value="<%=safe.htmlattr(ruimte_descr)%>"></td>
        </tr>

<%
        sql = "SELECT   alg_srtruimte_key, "
            + lcl.xsqla("alg_srtruimte_omschrijving", "alg_srtruimte_key")
            + "    FROM alg_srtruimte "
            + "   WHERE alg_srtruimte_verwijder IS NULL "
            + "ORDER BY UPPER("+lcl.xsql("alg_srtruimte_omschrijving", "alg_srtruimte_key")+")";
        FCLTselector("srt",
                     sql,
                     { initKey: ruimte_use,
                       trclass: "primsearch",
                       label: L("lcl_estate_ruimte_man_sort"),
                       emptyOption: ""
                     });

        sql= "SELECT 1 FROM prs_ruimteafdeling WHERE prs_ruimteafdeling_verwijder is null AND ROWNUM = 1";
        oRs = Oracle.Execute(sql);
        var anyruimteafd = !oRs.eof;
        oRs.close();
        if (anyruimteafd)
        {
            FCLTafdelingselector("dept",
                                 "dept",
                                 { label: L("lcl_prs_organisatie"),
                                   autlevel: authparams.PRSreadlevel, // Was voorheen niet aanwezig
                                   multitoggle: true,
                                   whenEmpty: L("lcl_search_generic"),
                                   filtercode: "AR"
                                 });
        }
%>
        <!-- Vervallen ruimten -->
        <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_ruimte_vervallen_incl")%></label>
          </td>
        </tr>
<%
      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(); %>
