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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "string")
    $name = $paramValue;
  else if ($paramName == "sequenceid")
    $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 = '$name' ";
$result = $dal->query($sql);

if (null == $result)
  $next_name = $name;
else
  $next_name = "";

echo json_encode($next_name);

?>

