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

    File:               fac_edit_bookmark_save
    Description:        SUBMIT-form

    Parameters:
    Context:
    Note:

     SUBMIT-form
*/ %>

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

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

// Autorisatie
var authparamsPRSSYS = user.checkAutorisation("WEB_PRSSYS");

var bkm_id = getFParam("bkm_id", "");
var path = getFParam("path");

// rooturl moet er af
if (path.substring(0, rooturl.length).toUpperCase() == rooturl.toUpperCase())
  path = path.substring(rooturl.length);

var fields =  [ { dbs: "fac_bookmark_naam",        typ: "varchar", frm: "naam",  len: 60 },
                { dbs: "fac_bookmark_path",        typ: "varchar", val: path,    len: 1000 },
                { dbs: "fac_bookmark_query",       typ: "varchar", frm: "query", len: 1000 },
                { dbs: "prs_perslid_key_auth",     typ: "key",     frm: "prskey_auth" },
                { dbs: "fac_bookmark_unauth_url",  typ: "varchar", frm: "unauth_url", len: 1000 },
                { dbs: "fac_bookmark_refreshtime", typ: "number",  frm: "refresh"},
                { dbs: "fac_bookmark_flags",       typ: "number",  val: 1+4} // Zichtbaar/wijzigbaar PRSSYS
              ];

var warning = "";
if (bkm_id != "")
{
  sql = buildUpdate("fac_bookmark", fields)
      + " fac_bookmark_id = " + safe.quoted_sql(bkm_id);

  var err = Oracle.Execute(sql, true);
  if (err.friendlyMsg)
      warning = err.friendlyMsg;
}
else
{
  bkm_id = shared.random(16);
  fields.push({ dbs: "fac_bookmark_id", typ: "varchar", val: bkm_id });
  fields.push({ dbs: "prs_perslid_key", typ: "key", val: user_key });
  var regIns = buildInsert("fac_bookmark", fields);
  sql = regIns.sql;
  var err = Oracle.Execute(sql, true);
  if (err.friendlyMsg)
    warning = err.friendlyMsg;
} %>

<html>
  <head>
    <%  FCLTHeader.Generate() %>
    <script type="text/javascript">
        $(function ()
        {
          FcltMgr.closeDetail(window, { bkm_id: "<%=safe.jsstring(bkm_id)%>",
                                        warning: "<%=safe.jsstring(warning)%>",
                                        keepForm: <%=warning? "true" : "false"%>,
                                        refresh: true
                                      });
        });
    </script>
  </head>

  <body>
  </body>
</html>
<% ASPPAGE_END(); %> 
