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

     File:               mld_reschedule.asp
     Description:        Herplan de actiedatum van een melding. Hierbij kan tevens een notitie ingevuld worden.
     Parameters:         mld_melding_key

     Context:            Vanuit mld_list.ja
                         Vanuit mld_show_melding.js
     Note:

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

FCLTHeader.Requires({ plugins: ["jQuery"]
                    , js: ["date.js", "jquery.timepicker-table.js"]
                    , css: ["timePicker-table.css"]
                    });

var mld_key_arr = getQParamIntArray("mld_key");
var ingesloten = [];

for (var i=0; i < mld_key_arr.length; i++)
{
  var this_mld = mld.func_enabled_melding(mld_key_arr[i]);
  if (this_mld.canHerplan)
  { // Bepaal welke meldingen herpland mogen worden.
    ingesloten.push(mld_key_arr[i]);
  }
}

%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>

    <script type="text/javascript">
        $(function()
        {
          $('textarea').resize(function () { FcltMgr.resized(window) } );
          $('textarea').autogrow();
        });

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

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

        function mld_cancel()
        {
          FcltMgr.closeDetail(window, { cancel: true } );
        }
    </script>
  </head>

  <body class="fclt-modal" id="mod_reopenbody">
    <% MODAL_START(); %>
      <form id="rescheduleform" name="rescheduleform" action="mld_reschedule_save.asp?mld_key=<%=ingesloten%>" method="post">
<%
        if (ingesloten.length == 1)
        {
          var mld_info = mld.mld_melding_info(ingesloten[0]);
          var actiondate_is_today = (mld_info.actiedatum? mld_info.actiedatum.midnight().getTime() == new Date().midnight().getTime() : false);
          var v_actiedatum = mld_info.actiedatum;
          var v_title = " " + (mld_info.prefix || "") + ingesloten[0];
        }
        else
        {
          var actiondate_is_today = false;
          var v_actiedatum = null;
          var v_title = " " + L("lcl_alg_multi_edit").toLowerCase();
        }

        MODAL_BLOCK_START("mldReschedule", L("lcl_reschedule") + v_title, { icon: "fa-calendar-pen" });
          var buttons = [];
          if (ingesloten.length == 0)
          {
            ROFIELD("fldoms", "", L("lcl_reschedule_warning"));
          }
          else
          {
            buttons.push({title: L("lcl_reschedule"), icon: "fa-fclt-save", action: "mld_reschedule()", singlepress: true, id: "btn_reschedule_submit", importance: 1 });
            FCLTcalendar( "actiondate",
                          { label        : L("lcl_mld_actiondate"),
                            datum        : v_actiedatum,
                            minDate      : null,
                            timeField    : true,
                            timeStep     : 15,
                            startTime    : S("fac_t_startofworkday"),
                            endTime      : S("fac_t_endofworkday"),
                            readonly     : false,
                            trclass      : "tractiondate" + (actiondate_is_today? " today" : ""),
                            trhidden     : false, // De hele tr moet hidden en niet alleen het inputveld als in readonly mode
                            required     : true,
                            initEmpty    : v_actiedatum == null,
                            initTimeEmpty: v_actiedatum == null
                          });

            RWTEXTAREATR("opmerk", "fldtxt", L("lcl_mld_note"), "", {html: "rows='8'"});
          }
        MODAL_BLOCK_END();

        buttons.push({title: L("lcl_cancel"), icon: "fa-fclt-cancel", action: "mld_cancel()", importance: 3 });

        SIMPLE_BLOCK_START();
            CreateButtons(buttons);
        SIMPLE_BLOCK_END();
        IFACE.FORM_END(); %>
      </form>
    <% MODAL_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
