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

     File:         bes_edit_srtprod_save.asp
     Description:  SUBMIT-form
*/ %>

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

<% FCLTHeader.Requires({ plugins:["jQuery"] }) %>
<%
  var srtprod_key = getQParamInt( "srtprod_key", "-1" );

  var fields =  [ { dbs: "bes_srtprod_omschrijving", typ: "varchar",  frm: "omschrijving" },
                  { dbs: "bes_srtprod_nr",           typ: "varchar",  frm: "srtprod_nr" },
                  { dbs: "bes_srtprod_eenheid",      typ: "varchar",  frm: "srtprod_eenheid" },
                  { dbs: "bes_grootheid_key",        typ: "key",      frm: "grootheid" },
                  { dbs: "bes_grootheid_getal",      typ: "number",   frm: "grootheid_getal" },
                  { dbs: "bes_srtprod_btw",          typ: "float",    frm: "btw" },
                  { dbs: "bes_srtprod_image",        typ: "varchar",  frm: "image" },
                  { dbs: "prs_bedrijf_key",          typ: "key",      frm: "lev_key" },
                  { dbs: "bes_srtprod_vervaldatum",  typ: "date",     frm: "verval" },
                  { dbs: "bes_srtprod_veelvoud",     typ: "number",   frm: "veelvoud" },
                  { dbs: "bes_srtprod_opmerking",    typ: "varchar",  frm: "opmerking", len: 2000 }];

var warning = "";
if (srtprod_key > 0)
  {
    sql = buildUpdate("bes_srtprod", fields)
        + "     bes_srtprod_key = " + srtprod_key;

    var err = Oracle.Execute(sql, true);
    if (err.friendlyMsg)
        warning = err.friendlyMsg;
  }
else
  {
    fields.push({  dbs: "bes_srtprod_key",         typ: "key",      seq: "bes_s_bes_srtprod_key" });
    var besIns = buildInsert("bes_srtprod", fields);
    var srtprod_key = besIns.sequences["bes_srtprod_key"];
    sql = besIns.sql;
    var err = Oracle.Execute(sql, true);
    if (err.friendlyMsg)
        warning = err.friendlyMsg;
  }
%>
<html>
  <head>
    <%  FCLTHeader.Generate() %>
    <script>
        $(document).ready(function () {
            FcltMgr.closeDetail(window, { srtprod_key: <%=srtprod_key%>,
                                          warning: "<%=safe.jsstring(warning)%>",
                                          keepForm: <%=warning?"true":"false"%>
                                         });
         } );
    </script>
  </head>
  <body>
  </body>
</html>
