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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "scopeid")
    $pw_id = $paramValue;
  else if ($paramName == "baseid")
    $pr_id = $paramValue;
}

$dal = new DAL();

$sql = "SELECT OP.id, OP.name AS descr, (CASE WHEN (PW.id = $pw_id) THEN 'disabled' ELSE '' END) AS attribute " .
       "FROM parcel PA, projectworkday PW, projectworkdayoperation PWO, operation OP " .
       "WHERE PA.project_id = $pr_id AND PW.parcel_id = PA.id " .
       "AND PWO.projectworkday_id = PW.id AND OP.id = PWO.operation_id " .
       "ORDER BY OP.name " ;
$result = $dal->query($sql);

echo json_encode($result);

?>

