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

    File:               fac_setting_save
    Status:             95%
    Description:        SUBMIT-form

    Parameters:
    Context:
    Note:

     SUBMIT-form
*/ %>

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

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

var authPRSSYS = user.checkAutorisation("WEB_PRSSYS");
var authFACFAC = user.checkAutorisation("WEB_FACFAC", true);
var authFACTAB = user.checkAutorisation("WEB_FACTAB", true);

var sql = "SELECT * FROM fac_setting s"
      + " WHERE fac_setting_key ="+fac_key;

var oRs = Oracle.Execute(sql);

var functie_key = oRs("fac_functie_key").Value;
var sname = oRs("fac_setting_name").value;

var isProtected = (functie_key != authPRSSYS.autfunctionkey);
canChange = (!isProtected ||
             authFACFAC && functie_key == authFACFAC.autfunctionkey ||
             authFACTAB && (functie_key == authFACTAB.autfunctionkey || sname == 'flexfilespath'))

user.auth_required_or_abort(canChange);

var pvalue = getFParam("pvalue", "");
if (oRs("fac_setting_type").value == 'float')
{
  pvalue = pvalue.replace(",", ".");
}

var fields =  [ { dbs: "fac_setting_pvalue", typ: "varchar",  val: pvalue, len: 4000 },
                { dbs: "fac_setting_datum",  typ: "sql",      val: "SYSDATE" },
                { dbs: "prs_perslid_key",    typ: "key",      val: user_key  }];

var warning = "";

sql = buildUpdate("fac_setting", fields)
    + "     fac_setting_key = " + fac_key;

var err = Oracle.Execute(sql, true);
if (err.friendlyMsg)
    warning = err.friendlyMsg;
settings.loadSET(true); // Forceer caching opnieuw

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