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

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

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

var autfunction = "WEB_INSMAN";  //TODO: vraag is dit de juiste authorisatie??
var authparams = user.checkAutorisation(autfunction);

%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
    </script>
  </head>
  <body id="searchbody">
    <div id="search">
      <form name="u2" target="workFrame" action="ins_verbruik_search_list.asp" method="get">
<%    BLOCK_START("searchtable", L("lcl_filterblok"));

      FCLTplaatsselector(authparams.ALGreadlevel, { startlevel: 2, // locatie
                                                    eindlevel: 2, // Locatie
                                                    whenEmpty: L("lcl_search_generic")  // want filter
                                                  });

      sql = " SELECT DISTINCT s.ins_srtdeel_key"
          + ", s.ins_srtdeel_code || ' ' || "+lcl.xsqla('s.ins_srtdeel_omschrijving', 's.ins_srtdeel_key')
          + ", s.ins_srtdeel_upper"
          + " FROM ins_v_aanwezigsrtdeel s"
          + ", ins_v_aanwezigsrtgroep g"
          + ", ins_v_srtdeel_kenmerk sk "
          + " WHERE s.ins_srtgroep_key = g.ins_srtgroep_key"
          + " AND sk.ins_srtdeel_key = s.ins_srtdeel_key"
          + " AND sk.ins_kenmerk_meetwaarde = 1"
          + " AND g.ins_discipline_key IN (SELECT gb.ins_discipline_key"
            + " FROM fac_v_webgebruiker gb"
            + ", fac_functie f"
            + " WHERE prs_perslid_key = " + user_key
            + " AND fac_functie_code = " + safe.quoted_sql(autfunction)
            + " AND f.fac_functie_key = gb.fac_functie_key"
            + " AND gb.FAC_GEBRUIKER_ALG_LEVEL_READ < 9)"
          + " ORDER BY 3";

      FCLTselector("srtdeel_key",
                   sql,
                   { label: L("lcl_obj_sort"),
                     emptyOption: ""
                   });
%>
      </form>
<%    BLOCK_END();

  var buttons =  [ {title: L("lcl_search"), action: "document.forms.u2.submit();", id: "bSearch" }];
  CreateButtons(buttons, { entersubmit: true });
%>
    </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>
