<%@language="javascript"%>
<% /*
     $Revision$
     $Id$

     File:               prj_search.asp
     Description:        Filterscherm voor overzicht verhuisscenario's
     Parameters:         scenario             Scenario
                         locatie_key          Locatie
                         gebouw_key           Gebouw
                         mld_key              Verhuisaanvraag
     Globals:
     Context:
     Note:
*/ %>

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

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

var scenario = getQParam("scenario", ""); // Scenario
var loc_key = getQParamInt("locatie_key", -1); // Locatie
var bld_key = getQParamInt("gebouw_key", -1); // Gebouw
var mld_key = getQParamInt("mld_key", -1); // Verhuisaanvraag

var autfunction = "WEB_PRJBOF";

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

<html>
  <head>
<%  FCLTHeader.Generate() %>
    <script type="text/javascript">
      function doSubmit()
      {
        document.forms.u2.submit();
      }
    </script>
  </head>

  <body id="searchbody">
    <form name="u2" target="workFrame" action="prj_search_list.asp" method="get">
        <% SEARCH_PAGE_START({ header: L("lcl_filterblok") });
        SEARCH_BLOCK_START();%>
            <!-- Scenario -->
            <tr class="primsearch">
              <td class="label"><label for="scenario"><%=L("lcl_prj_scenario")%></label></td>
              <td><input type="text" class="fld wildcard" name="scenario" value="<%=safe.htmlattr(scenario)%>"></td>
            </tr>

            <!-- Verhuisaanvraag -->
<%          sql = "SELECT mld_melding_key"
                + ", m.mld_melding_key || '-' || "+lcl.xsqla('stdm.mld_stdmelding_omschrijving','stdm.mld_stdmelding_key')
                + " FROM mld_melding m"
                + ", mld_stdmelding stdm"
                + " WHERE stdm.mld_stdmelding_key = m.mld_stdmelding_key"
                + ((authparams.ALGreadlevel > -1)
                  ? " AND mld_alg_locatie_key IN"
                    + " (SELECT alg_locatie_key"
                    + " FROM fac_v_my_locations"
                    + " WHERE prs_perslid_key = " + user_key
                    + " AND niveau = " + authparams.ALGreadlevel + ")"
                  : "")
                + " AND stdm.mld_ins_discipline_key = " + S("prj_discipline_key")
                + " AND m.mld_melding_status IN (4, 7)"
                + " ORDER BY 1"
            FCLTselector("verhuisaanvraag",
                         sql,
                         { initKey: mld_key,
                           label: L("lcl_prj_verhuisaanvraag"),
                           trclass: "primsearch",
                           emptyOption: "",
                           initEmpty: true
                         });
SEARCH_BLOCK_END();
SEARCH_BLOCK_START();

%>

            <!-- Locatie en gebouw -->
<%          FCLTplaatsselector(authparams.ALGreadlevel,
                               { locatiekey: loc_key,
                                 gebouwkey: bld_key,
                                 startlevel: 2, // locatie
                                 eindlevel: 3, // gebouw
                                 whenEmpty: L("lcl_search_generic"),  // want filter
                                 filtercode: "EXP"
                               }); %>
<%    SEARCH_BLOCK_END();

      var buttons =  [ {title: L("lcl_overview_list"), action: "doSubmit()", icon: "fa-clipboard-list" } ];

      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>
      </iframe>
    </div>

  </body>
</html>
<% ASPPAGE_END(); %>
