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

    File:               ins_history_add
    Description:        Interface to add a new value to the history of an object
    Parameters:
    Context:            From ins_verbruik_hisotry
    Note:

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

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

var inskenmerkkey = getQParamInt("inskenmerkkey", -1);
var inskenmerkdeelkey = getQParamInt("inskenmerkdeelkey", -1);
var insdeelkey = getQParamInt("insdeelkey", "");
var count = getQParamInt("count", -1)
var new_value = "";

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

      function doSubmit()
      {
        document.forms.u2.submit();
      }

      async function ins_submit()
      {
        if (!isGoodNumber($("#new_value").val(),true,true,-1,-1))
        {
          FcltMgr.alert(L("lcl_ins_bad_value"));
          return false;
        }

        document.activeElement.blur(); // trigger laatste onChanges
        if (!await validateForm("u2"))
          return false;
        document.forms.u2.submit();
      }

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

      $(function () { $("#new_value").focus() } );

    </script>
  </head>

  <body class="fclt-modal" target='hidFrame' id="mod_history">
  <% MODAL_START(); %>
    <form name=u2 method=post action="ins_history_add_save.asp">
<%    MODAL_BLOCK_START("", L("lcl_ins_history_add_value"), { icon: "fa-plus" });
      RWFIELDTR("new_value", "fldshort", L("lcl_obj_prop_value"), new_value, { required: true, maxlength: 10 });
      FCLTcalendar( "date",
                  { label : L("lcl_date"),
                    datum: new Date (),
                    required: true
                  });
%>
      <input type='hidden' id='count' name='count' value='<%=count%>'>
      <input type='hidden' id='insdeelkey' name='insdeelkey' value='<%=insdeelkey%>'>
      <input type='hidden' id='inskenmerkdeelkey' name='inskenmerkdeelkey' value='<%=inskenmerkdeelkey%>'>
      <input type='hidden' id='inskenmerkkey' name='inskenmerkkey' value='<%=inskenmerkkey%>'>
<%
      MODAL_BLOCK_END();
      var buttons =  [ {title: L("lcl_submit"), icon: "fa-fclt-save", action: "ins_submit()" }
                     , {title: L("lcl_cancel"), icon: "fa-fclt-cancel", action: "ins_cancel()" } ];
      SIMPLE_BLOCK_START();
        CreateButtons(buttons);
      SIMPLE_BLOCK_END();
IFACE.FORM_END();
%>
    </form>
    <% MODAL_END(); %>
    <iframe src="../Shared/empty.asp" frameborder="10" name="hidFrame" id="hidFrame" style="display:none"></iframe>
  </body>
</html>
<% ASPPAGE_END(); %>
