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

     File:               PRJ/rap_prj7_save.asp
     Description:
     Parameters:
     Note:
*/ %>

<%
var JSON_Result = true;
%>

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

<%
protectRequest.validateToken();
/***** Get webform parameters *****/
var actie = getFParam("actie");
/***** End get webform parameters *****/


function doRemove()
{
// ==========================
// Actie: doremove (verwijder een PRJ_RUIMTE)
// ==========================
  var room_key = getFParamInt("room_key");      // PRJ_RUIMTE_KEY
  sql = "UDPATE prj_ruimte "
      + "   SET prj_ruimte_verwijder = SYSDATE"
      + " WHERE prs_ruimte_key = " + room_key;
  Oracle.Execute(sql);
}

function doAdd()
{
// ==========================
// Actie: doadd (voeg een PRJ_RUIMTE toe a.h.v. een CAD_IMP_CONTOUR record)
// ==========================
  var scenario_key = getFParamInt("scenario_key");
  var vkey = getFParamInt("vkey");
  var cad_imp_key = getFParamInt("cad_imp_key");      // CAD_IMP_CONTOUR_KEY
  sql = "INSERT INTO prj_ruimte( prj_scenario_key"
                            + ", alg_verdieping_key"
                            + ", prj_ruimte_nr"
                            + ", prj_ruimte_bruto_vloeropp) "
      + " SELECT " + scenario_key
             + "," + vKey
             + ", cad_imp_contour_nr"
             + ", cad_imp_contour_opp"
      + "   FROM CAD_IMP_CONTOUR"
      + "  WHERE cad_imp_contour_key = " + cad_imp_key;
  Oracle.Execute(sql);
}



var message = "";
switch (actie)
{
  case 'doremove': doRemove();
       break;
  case 'doadd': doAdd();
       break;
}
var result = {message: message};
Response.Write(JSON.stringify(result));
Response.End;
%>
<% ASPPAGE_END(); %> 
