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

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

$dal = new DAL();

$sql = "SELECT PWO.id, OP.name AS 'Operation Name', " .
       "(CASE WHEN OT.id IS NULL THEN '' 
              ELSE OT.descr END) AS 'Operation Type', " .
       "(CASE WHEN PWO.starttime ='00:00' THEN '' 
              ELSE PWO.starttime END) AS 'Start Time', " .
       "(CASE WHEN PWO.duration = '0.00' THEN '' 
              ELSE PWO.duration END) AS 'Duration' " .
       "FROM projectworkdayoperation PWO, operation OP " .
       "LEFT JOIN operationtype OT ON OT.id = OP.operationtype_id " .
       "WHERE PWO.projectworkday_id = $pw_id AND OP.id = PWO.operation_id " .
       "ORDER BY starttime " ;
$result = $dal->query($sql);

echo json_encode($result);

?>

