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


     File:         prs_edit_dienst_save.asp
     Description:  SUBMIT-form
     Parameters:


     Context:
     Note:
*/ %>

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

<% FCLTHeader.Requires({ plugins:["jQuery"]}) %>
<%
  var dloc_key = getQParamInt("dloc_key", -1);
  var dienst_key = getFParamInt("prs_dnstkey", -1);
  var bedrijf_key = getFParamInt("prs_bdrkey", -1);
  __Log ("keys zijn: " + dienst_key + " " + bedrijf_key + " !!!");

  var fields = [{ dbs: "prs_bedrijf_key", typ: "key",  frm: "prs_bdrkey" },
                { dbs: "prs_dienst_key", typ: "key",  frm: "prs_dnstkey" }];

  var warning = "";

  if (dloc_key > 0)
    {
      sql = buildUpdate("prs_bedrijfdienstlocatie", fields)
          + "     prs_bedrijfdienstlocatie_key = " + dloc_key;

      var err= Oracle.Execute(sql,true);
      if (err.friendlyMsg)
         warning = err.friendlyMsg;
    }
  else
    {
      fields.push({  dbs: "prs_bedrijfdienstlocatie_key",         typ: "key",      seq: "prs_s_prs_bedrijfdienstloc_key" });
      var regIns = buildInsert("prs_bedrijfdienstlocatie", fields);
      var dloc_key = regIns.sequences["prs_bedrijfdienstlocatie_key"];

      sql = regIns.sql;
      var err = Oracle.Execute(sql, true);
      if (err.friendlyMsg)
          warning = err.friendlyMsg
    }
%>
<html>
  <head>
    <%  FCLTHeader.Generate() %>
    <script>
        $(function ()
        {
          FcltMgr.closeDetail(window, { dloc_key: <%=dloc_key%>,
                                        dienst_key: <%=dienst_key%>,
                                        bedrijf_key: <%=bedrijf_key%>,
                                        warning: "<%=safe.jsstring(warning)%>",
                                        keepForm: <%=warning?"true":"false"%>
                                       });
        });
    </script>
  </head>
  <body>
  </body>
</html>
<% ASPPAGE_END(); %> 
