<%@ LANGUAGE = JavaScript %>
<% /*
    $Revision$
    $Id$

    File:           fac_delete.asp
    Description:    Verwijderen fac-object

    Parameters:     key
                    level: "FM" "AD" "KD" "AP"
    Context:        Vanuit show-scherm
    Result:         JSON object
    Note:

*/
var JSON_Result = true;
%>

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

<%
protectRequest.validateToken();
// TODO: Nauwkeuriger controleren
var autfunction="WEB_PRSSYS";
var level = getFParam("level");
if (level == "AD")
    var autfunction="WEB_ALGMSU";

var authParams = user.checkAutorisation(autfunction);


if (level == "BM")
  var bmname = getFParam("key");
else
  var key = getFParamInt("key");

var table = {FM : "FAC_MENU",
             AD : "MLD_ADRES",
             KD : "FAC_KENMERKDOMEIN",
             BM : "FAC_BOOKMARK",
             AP : "FAC_API"}[level];

if ((table == "FAC_MENU") || (table == "FAC_API"))
{
  sql = "DELETE FROM " + table
      + " WHERE " + table + "_key=" + key;
}
else if (table == "FAC_BOOKMARK")
{
  sql = "DELETE " + table
      + " WHERE " + table + "_id = " + safe.quoted_sql(bmname);
}
else
{
  sql = "UPDATE " + table
      + "   SET " + table + "_VERWIJDER = " + "SYSDATE"
      + " WHERE " + table + "_key IN (" + key + ")";
}

result = { success: true, deleted: true };
var err = Oracle.Execute(sql, true);
if (err.friendlyMsg)
{
  result.message = err.friendlyMsg;
  result.success = false;
  result.deleted = false;
}

Response.Write(JSON.stringify(result));
%><% ASPPAGE_END(); %> 
