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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "summaryid")
    $id = $paramValue;
  else if ($paramName == "field")
    $field = $paramValue;
}

$dal = new DAL();

if ($field == 'sumOperationDefinitions') {

  $sql = "SELECT OP.id, OP.name AS 'Operation Name', " .
         "(CASE WHEN OT.id IS NULL THEN '' 
                ELSE OT.descr END) AS 'Operation Type' " .
         "FROM operation OP " .
         "LEFT JOIN operationtype OT ON OT.id = OP.operationtype_id " .
         "WHERE OP.projectparcel_id = $id " ;
         "ORDER BY OP.name " ;
}       

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

echo json_encode($result);

?>

