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

     File:        cnt_reject.asp
*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="cnt.inc" -->

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

var cnt_key_arr = getQParamIntArray("cnt_key");

var result = {};
var toberejected = 0;
var ingesloten = [];
// Bepaal de contracten in de selectie die
// ook echt afgekeurd kunnen of mogen worden.
for (var i = 0; i < cnt_key_arr.length; i++)
{
  var cnt_info = cnt.cnt_contract_info(cnt_key_arr[i]); // Globale variabele met alle cnt_contract informatie
  var this_cnt = cnt.func_enabled_contract(cnt_key_arr[i], cnt_info); // Wat heb ik zoal aan rechten op dit contract?
  if (this_cnt.canReject)
  {
    ingesloten.push(cnt_key_arr[i]);
    toberejected++;
  }
}
user.anything_todo_or_abort(toberejected > 0); // We klagen niet over enkele wel en enkele niet
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
      <script type="text/javascript">

        $(function()
        {
          $('textarea').resize(function () { FcltMgr.resized(window) } );
          $('textarea').autogrow();
        });

        async function cnt_reject()
        {
          // Standaard checks op verplichte velden, datum formaat, numeriek en float formaat, currency formaat.
          if (!await validateForm("rejectform"))
            return false;

          $.post($("form[name=rejectform]")[0].action, $("[name=rejectform]").serialize(), FcltCallbackClose, "json");;
          return true; // disable button
        }

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

      </script>
  </head>

  <body class="fclt-modal" id="rejectbody">
  <% MODAL_START(); %>
      <form id="rejectform" name="rejectform" action="cnt_reject_save.asp" method="post">
        <% MODAL_BLOCK_START("cntReject", L("lcl_cnt_reject_contracts") + ingesloten.join(","), {icon: "fa-times"}); %>
        <input type="hidden" name="cnt_key" value="<%=ingesloten.join(",")%>">
<%
        RWTEXTAREATR("opmerk",
                     "fldtxt required",
                     L("lcl_remark"),
                     "",
                     {html: "rows='8'"});
        MODAL_BLOCK_END();

        var buttons =  [ {title: L("lcl_reject"), icon: "fa-fclt-save", action: "cnt_reject()", singlepress: true, id: "btn_reject_submit"  },
                         {title: L("lcl_cancel"), icon: "fa-fclt-cancel", action: "cnt_cancel()" }];
        SIMPLE_BLOCK_START();
        CreateButtons(buttons);
        SIMPLE_BLOCK_END();
        IFACE.FORM_END(); %>
      </form>
    <% MODAL_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
