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

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

$dal = new DAL();

$sql = "SELECT PWO.id, WO.textdate, OP.name AS 'Operation Name', " .
       "(CASE WHEN OT.id IS NULL THEN '' 
              ELSE OT.descr END) AS 'Operation Type' " .
       "FROM (projectworkdayoperation PWO, operation OP, projectworkevent PW, workday WO) " .
       "LEFT JOIN operationtype OT ON OT.id = OP.operationtype_id " .
       "WHERE PWO.operation_id = $op_id AND OP.id = PWO.operation_id " .
       "AND PW.id = PWO.projectworkevent_id AND WO.id = PW.workday_id " .
       "ORDER BY WO.date " ;
$result = $dal->query($sql);

echo json_encode($result);

?>

