<%@ LANGUAGE = JavaScript %>
<% /*
     $Revision$
     $Id$

     File:          mld_fix_sla.asp
     Description:   Laat achteraf de geregistreerde startdatum/einddatum van een melding corrigeren
     Parameters:
         mld_key    Melding key van te wijzigen melding
     Context:
     Note:

*/ %>

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

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

var mld_key = getQParamInt("mld_key");
var this_mld = mld.func_enabled_melding(mld_key);
var mld_melding = mld.mld_melding_info(mld_key);
user.auth_required_or_abort(this_mld.canFixSLA);

var sql = "SELECT fac.gettrackingdate ('MLDAFM', " + mld_key + ") datum FROM DUAL";
var oRs = Oracle.Execute(sql);
var dt_afmeld = oRs("datum").Value == null?null:new Date(oRs("datum").Value);

var result = { success: false };
%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>

      <script type="text/javascript">
        function mld_cancel()
        {
            FcltMgr.closeDetail(window, { cancel: true } );
        }

        function mld_close(close)
        {
          if (!validateForm("u2"))
            return false;

          $.post($("form[name=fixform]")[0].action, $("[name=fixform]").serialize(), FcltCallbackClose, "json");

          return true; // disable button
        }
      </script>
  </head>

  <body class="modal" id="mod_mldfixsla">
    <form id="fixform" name="fixform" action="mld_fix_sla_save.asp?mld_key=<%=mld_key%>" method="post">
<%

      BLOCK_START("mldClose", L("lcl_mld_fix_sla"));

      // Calendar boven de opmerking houden zodat genoeg ruimte voor uitklappen
      var minDate = new Date(mld_melding.melddatum);
      minDate.setDate(minDate.getDate() - S("mld_fixdatums_marge"));
      var maxDate = new Date(mld_melding.melddatum);
      maxDate.setDate(maxDate.getDate() + S("mld_fixdatums_marge"));
      FCLTcalendar("date_from",
                   { datum    : mld_melding.melddatum,
                     label    : L("lcl_mld_startdate"),
                     minDate  : minDate,
                     maxDate  : maxDate,
                     timeField: true,
                     timeStep : 30, // fixed half uur. Je mag eventueel wel iets anders intikken
                     startTime: S("fac_t_startofworkday"),
                     endTime  : S("fac_t_endofworkday"),
                     required : true
                   });

      if (dt_afmeld)
      {
          var minDate = new Date(dt_afmeld);
          minDate.setDate(minDate.getDate() - S("mld_fixdatums_marge"));
          var maxDate = new Date(dt_afmeld);
          maxDate.setDate(maxDate.getDate() + S("mld_fixdatums_marge"));
          FCLTcalendar("date_to",
                       { datum    : dt_afmeld,
                         label    : L("lcl_mld_afgemeld"),
                         minDate  : minDate,
                         maxDate  : maxDate,
                         timeField: true,
                         timeStep : 30, // fixed half uur. Je mag eventueel wel iets anders intikken
                         startTime: S("fac_t_startofworkday"),
                         endTime  : S("fac_t_endofworkday"),
                         required : true
                       });
      }
      BLOCK_END();
      %><input type='hidden' name='orgdate' value='<%=mld_melding.melddatum.getTime()%>'><%
      var buttons =  [ {title: L("lcl_submit"), icon: "accept.png", action: "mld_close()", singlepress: true, id: "btn_close_submit" },
                       {title: L("lcl_cancel"), icon: "cancel.png", action: "mld_cancel()" } ];
      CreateButtons(buttons);
      IFACE.FORM_END();
%>
    </form>
  </body>
</html>

