<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');
 
foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id")
    $co_id = $paramValue;
  else if ($paramName == "control")
    $control = $paramValue;
  else if ($paramName == "operation")
    $operation = $paramValue;
  else if ($paramName == "usage_note")
    $usage_note = $paramValue;
}

$dal = new DAL(); 
 
if ($co_id == 0) 
  $sql = "INSERT INTO controlobject " .
         "(control, operation, usage_note) " .
         "VALUES ('$control', '$operation', '$usage_note') ";
else
  $sql = "UPDATE controlobject " .
         "SET control='$control', operation='$operation', " .
         "usage_note='$usage_note' " .
         "WHERE id = $co_id ";

$result = $dal->query($sql);

echo json_encode($result);

?>

