<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "checkval")
    $op_name = $paramValue;
  else if ($paramName == "baseid")
    $pa_id = $paramValue;
}

$dal = new DAL();

$sql = "SELECT OP.id " .
       "FROM operation OP, projectworkdayoperation PWO, projectworkday PW " .
       "WHERE PW.parcel_id = $pa_id AND PWO.projectworkday_id = PW.id " .
       "AND OP.id = PWO.operation_id AND OP.name = '$op_name' ";
$result = $dal->query($sql);

if (null == $result)
  $next_op_name = $op_name;
else
  $next_op_name = "";

echo json_encode($next_op_name);

?>

