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

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

<%
var JSON_Result = true;
%>

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

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


function doPlace()
{
  note_key = getFParamInt("note_key");
  room_key = getFParamInt("room_key", "NULL"); // Doen we nog niets mee
  dwgX = getFParam("dwgX");
  dwgY = getFParam("dwgY");

  var sql = "SELECT *"
          + "  FROM prj_scenario_note"
          + " WHERE prj_scenario_note_key = " + note_key;
  if (Oracle.Execute(sql).eof)
    sql = "INSERT INTO prj_scenario_note "
        + " ( prj_scenario_note_key"
        + " , prj_scenario_note_dwgX"
        + " , prj_scenario_note_dwgY"
        + " , alg_verdieping_key"
        + " , prj_ruimte_key"
        + ") VALUES"
        + " (" + prj_scenario_note_key
        + " ," + dwgX
        + " ," + dwgY
        + " ," + floorKey
        + " ," + room_key
        + " )"
  else
    sql = "UPDATE prj_scenario_note"
        + "   SET prj_scenario_note_dwgX = " + dwgX
        + "     , prj_scenario_note_dwgY = " + dwgY
        + "     , prj_ruimte_key = " + room_key
        + " WHERE prj_scenario_note_key = " + note_key
  Oracle.Execute(sql)
}


var message = "";
switch (actie)
{
  case 'doplace': doPlace();
       break;
}
var result = {message: message, success: true};
Response.Write(JSON.stringify(result));
Response.End;
%>
