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

    File:           prs_delete.asp
    Description:    Verwijderen alg-object

    Parameters:     key
                    level: "A" "P" "K" "G" "KPN"
    Context:        Vanuit show-schermen en of vanuit overzichten
    Result:         JSON object
    Note:

*/
var JSON_Result = true;
%>

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

<%
protectRequest.validateToken();

var ins_key_arr = getFParamIntArray("key");
var message = "";

var result = {};
var tobedeleted = 0;
var ingesloten = [];
// Bepaal de objecten in de selectie die
// ook echt verwijderd kunnen of mogen worden.
for (var i = 0; i < ins_key_arr.length; i++)
{
  this_ins = ins.func_enabled_deel(ins_key_arr[i]);
  if (this_ins.canDelete)
  {
    ingesloten.push(ins_key_arr[i]);
    tobedeleted++;
  }
}
user.anything_todo_or_abort(tobedeleted > 0); // We klagen niet over enkele wel en enkele niet

var level = getFParam("level");

var table = {D : "INS_DEEL"}[level];

sql = "UPDATE " + table
    + "   SET " + table + "_VERWIJDER = " + "SYSDATE"
    + " WHERE " + table + "_key IN (" + ingesloten + ")";

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

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