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

    File:               res_select_arrangement.asp
    Remark:             provide selection of a package for reservation

    Parameters:         tijd: time of the reservation

    Context:            res_edit_objcat.asp

*/
 %>

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

<%
FCLTHeader.Requires({ plugins: ["jQuery"],
                      js: ["jquery-ui.js"],
                     css: [rooturl+"/appl/res/res.css"]});
%>

<html>
  <head>
<%  FCLTHeader.Generate();
    var discs = getQParamIntArray("discs", [-1]).join(",");
    var uren = parseInt(getQParam("tijd", "12:00").split(":")[0], 10);
    var minuten = parseInt(getQParam("tijd", "12:00").split(":")[1], 10);
    uren = uren.length==1 ? "0"+uren : uren;
    minuten = minuten.length==1 ? "0"+minuten : minuten;
%>
    <script type="text/javascript">

      function res_arr_submit()
      {
        FcltMgr.closeDetail(window, { success: true,
                                      arrangement_key: $("#arrangement").val(),
                                      arrangement_aantal: $("#aantal").val(),
                                      uren: $("#uren").val(),
                                      minuten: $("#minuten").val() } );
      }

      function res_arr_cancel()
      {
          FcltMgr.closeDetail(window, { cancel: true } );
      }

      function res_arr_remark()
      {
        $("div.readonly.opmerkingen").html($("option:selected").attr("title").replace(/\n/g, "<br>"));
        FcltMgr.resized();
      }

      $(function()
      {
        res_arr_remark();
      });
    </script>
  </head>

  <body class="fclt-modal" id="mod_resselectarrangement">
    <% MODAL_START(); %>
    <form name="u2" >
<%      MODAL_BLOCK_START("arrgArtikelen", L("res_arrangement"), {icon: "fa-shapes"});
        sql = "SELECT DISTINCT ar.res_arrangement_key, ar.res_arrangement_omschrijving, ar.res_arrangement_opmerking title "
            + "FROM   res_arrangement ar,  res_arrangement_artikel aa, res_artikel ra "
            + "WHERE  ra.res_discipline_key IN ("+discs+") "
            + "AND    aa.res_artikel_key = ra.res_artikel_key "
            + "AND    ar.res_arrangement_key = aa.res_arrangement_key "
            + "ORDER BY ar.res_arrangement_omschrijving";
        FCLTselector("arrangement",
                     sql,
                     { label: L("res_arrangement"),
                       extraParamValue: "title",
                       onChange: "res_arr_remark()"
                     });

        ROTEXTAREATR("opmerkingen", L("res_arrangement_opmerking"), "");
        RWFIELDTR("aantal", "fldshort", L("lcl_count"), 1, {datatype: "integer"});
%>      <tr>
          <td class="label"><%=L("lcl_time")%></td>
          <td><input type='number' id='uren'
                 class='fldtime'
                 name='uren'
                 value='<%=uren%>'
                 maxlength='2' size='2'>
              <input type='number' id='minuten'
                 class='fldtime'
                 name='minuten'
                 value='<%=minuten%>'
                 maxlength='2' size='2'>
          </td>
      </tr>
<%    MODAL_BLOCK_END();
      var buttons =  [];
      buttons.push({title: L("lcl_select"), action:"res_arr_submit()", singlepress: true, id: "btn_select_submit", importance: 1, icon: "fa-fclt-save"});
      buttons.push({title: L("lcl_cancel"),  action:"res_arr_cancel()", importance: 3, icon: "fa-fclt-cancel"});
      SIMPLE_BLOCK_START();
        CreateButtons(buttons);
      SIMPLE_BLOCK_END();
      IFACE.FORM_END(); %>
    </form>
    <% MODAL_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
