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

     File:        cnt_delete.asp
*/ %>

<%
var JSON_Result = true;
%>

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

<%
protectRequest.validateToken();
/***** Get webform parameters *****/
/***** End get webform parameters *****/

var cnt_key = getFParamInt("cnt_key");
var result = { success: false};

var cnt_info = cnt.cnt_contract_info(cnt_key);
var this_cnt = cnt.func_enabled_contract(cnt_key, cnt_info); // Wat heb ik zoal aan rechten op dit contract?

if (this_cnt.canDelete) // Kan ik dit contract verwijderen?
{
  sql = "UPDATE cnt_contract_object"
      + " SET cnt_contract_object_verwijder = SYSDATE"
      + " WHERE cnt_contract_key = " + cnt_key;
  oRs = Oracle.Execute(sql);

  sql = "UPDATE cnt_contract_plaats"
      + " SET cnt_contract_plaats_verwijder = SYSDATE"
      + " WHERE cnt_contract_key = " + cnt_key;
  oRs = Oracle.Execute(sql);

  sql = "UPDATE cnt_contract"
      + " SET cnt_contract_verwijder = SYSDATE"
      + " where cnt_contract_key = " + cnt_key;
  oRs = Oracle.Execute(sql);

  sql = "SELECT cnt_contract_nummer_intern"
      + " FROM CNT_CONTRACT"
      + " WHERE cnt_contract_verwijder IS NOT NULL"
      + " AND cnt_contract_key = " + cnt_key;
  oRs = Oracle.Execute(sql);

  if (!oRs.eof)
  {
    cnt.trackcontractverwijderen(cnt_key);
    result.message = L("lcl_cnt_deleted").format(oRs("cnt_contract_nummer_intern").value);
    result.success = true;
  }
  else
  {
    result.message = L("lcl_cnt_delete_failed");
    oRs.Close();
  }
}
else
{
  result.message = L("lcl_cnt_Del_Fails_Auth");
}

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