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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selectid")
    $ow_id = $paramValue;
}

$dal = new DAL();

$sql = "SELECT OW.id, " .
       "OW.teamrole_id,  '' AS teamrole_id_text, " .
       "OW.startime, OW.startime AS startime_text, " .
       "OW.stoptime, OW.stoptime AS stoptime_text, " .
       "LPAD(OW.breakdur, 5, '0') AS breakdur, '' AS breakdur_text, " .
       "LPAD(OW.duration, 5, '0') AS duration, '' AS duration_text, " .
       "OW.billable, " . 
       "(CASE WHEN billable = 1 THEN 'Yes' ELSE 'No' END) AS billable_text, " . 
       "OW.billrationale, OW.billrationale AS billrationale_text, " .
       "OW.note, OW.note AS note_text " .
       "FROM officeworkrole OW, projectparcel PP, parcel PA, project PR " .
       "WHERE OW.id = $ow_id AND PP.id = OW.projectparcel_id " .
       "AND PA.id = PP.parcel_id AND PR.id = PP.project_id LIMIT 1 ";
$result = $dal->query($sql);

echo json_encode($result);

?>

