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

    File:               fac_usrrap_search.asp
    Description:        Show the filter fields for the selected report
    Parameters:
        key:            usrrap_key
    Context:            Workframe for fac_usrrap.asp when  fac_functie_code==0 (Normal View)
                        (for fac_functie_code==2, stored procedure see usrreport_filterproc)
    Note:               A maximum of 4 filter fields is supported
                        FCLT_F_<columnname> are filter fields
                        FCLT_X_<columnname> are filter fields and will not be shown in result-list
                        FCLT_D_<columnname> is date fields, van-tot filterfields added,
                        HIDE_F_<columnname> will not be shown
                        FCLT_3D_USER_KEY
                        FCLT_3D_LOCATIE_KEY
                        FCLT_3D_AFDELING_KEY
                        FCLT_3D_DISCIPLINE_KEY
*/
%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/calendar.inc" -->
<!-- #include file="fac_usrrap.inc" -->

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

var usrrap_key = getQParamInt("usrrap_key");
var p_bAutolistbox = (getQParamInt("autolistbox", 0) == 1);
var p_bAutoexec = (getQParamInt("autoexec", 0) == 1)
// TODO: var p_rap_name = getQParam("rap_name", "");

var fac_usrrap = usrrap.fac_usrrap_info(usrrap_key);

%>
<html>
  <head>
<%  FCLTHeader.Generate() %>
    <script>
      // Button 'Uitvoeren' has been pressed
      function startSearch()
      {
        if (!validateForm("u2"))
          return false;

        document.forms.u2.submit();
      }

      function startAutoRefreshTimer()
      {
        if ($("#timeID").val() > 0)
        {
          clearInterval($("#timeID").val());
          $("#timeID").val(-1);
        }
        if ($("#autorefresh").val() == 1)
        {
          $("#timeID").val(setInterval('startSearch();', <%=S("usrrap_refreshrate")%> * 1000));
        }
      }

      function CheckForAutoFill()
      {
          if (<%=p_bAutolistbox?1:0%>)
              document.getElementById("fclt_f_colvalue1_q").onclick();
      }

      function CheckForAutoExecute()
      {
<%      if (p_bAutoexec)
        { %>
          startSearch();
<%      } %>
      }
    </script>
  </head>

  <body onload='CheckForAutoExecute();'>
    <div id="search">
      <form name="u2" method="get" action="fac_usrrap_list.asp" target="workFrame2" onsubmit='return false'>
          <input type="hidden" name="usrrap_key" value="<%=usrrap_key%>">
<%
          BLOCK_START("searchtable", L("lcl_filterblok"));
%>
          <tr><td colspan='2' id="usrrapinfo"><%=safe.html(fac_usrrap.info)%></td></tr>

<%      // Next create filter fields defined by column names
        var nr_charcols = 0;

        for (var i in fac_usrrap.columns)
        {
          var col = fac_usrrap.columns[i];
          if (col.filter == 'A') // Autofilter
          {
              nr_charcols++;
%>
            <tr>
              <td class="label">
                <label><%=safe.html(col.caption)%>:</label>
              </td>
              <td>
                  <input class="fldusrfilter" type="text"
                         id="<%="fclt_f_colvalue"+ nr_charcols%>" name="<%="fclt_f_colvalue"+ nr_charcols%>">
                  <select id="<%="fclt_f_colvalue" + nr_charcols + "_l"%>"
                          name="<%="fclt_f_colvalue" + nr_charcols + "_l"%>"
                          size="1" style="display:none;">
                  </select>
                  <img src="../Pictures/comment.png" id="<%="fclt_f_colvalue"+ nr_charcols+"_q"%>"
                       title="<%=L("lcl_usrrap_beware")%>"
                       style='cursor:pointer; margin-left:8px'
                       onclick="FillListbox('<%="fclt_f_colvalue" + nr_charcols%>','<%=col.column_name%>', <%=usrrap_key%>)">
                  <input type="hidden" id="<%="fclt_f_colname" + nr_charcols%>"
                         name="<%="fclt_f_colname" + nr_charcols%>" value="<%=col.column_name%>">
              </td>
            </tr>

<%        }
        }
        if (fac_usrrap.vraagbegindatum)
        {
          FCLTcalendar ("s_date", {initEmpty: 1, label: L("lcl_from"), volgnr: 1, required: true})
        }
        if (fac_usrrap.vraageinddatum)
        {
          FCLTcalendar ("e_date", {initEmpty: 1, label: L("lcl_to"), volgnr: 2, required: true})
        }

      BLOCK_END();
      var buttons =  [ {title: L("lcl_usrrap_uitvoeren"), action: "startSearch();startAutoRefreshTimer();" } ];
      CreateButtons(buttons, { entersubmit: true});
%>
        <input type="hidden" id="nr_charcols" name="nr_charcols" value="<%=nr_charcols%>">
      </form>
    </div> <!-- search -->
    <div id="result">
      <iframe width="100%" height="100%"
              src="../Shared/empty.asp"
              name="workFrame2" id="workFrame2"
              marginwidth="0" marginheight="0"
              onload="FcltMgr.iframeLoaded(this);FcltMgr.resized()"
              frameborder="0" scrolling="auto">
      </iframe>
    </div>

  </body>
</html>
