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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selid")
    $ptr_id = $paramValue;
}

$dal = new DAL();

$sql = "SELECT PTR.id, PWP.absent AS awayfromwork, " . 
       "PR.name AS liveprojectname, PR.id AS rowliveprojectname, " .
       "parcel_id AS parcel_id, PTR.teamrole_id AS role_id, PTR.start_time AS rolestarttime, " .
       "PTR.end_time AS roleendtime, LPAD(PTR.break_dur, 5, '0') AS breakduration, LPAD(PTR.moduration, 5, '0') AS hoursduration, " .
       "PTR.billable AS billabletime, PTR.rationale AS statusrationale, PTR.note AS officenote " .
       "FROM loginworkday LW, workday WO, projectworkday PW, projectworkdaypersonnel PWP, " .
       "personnel PE, parcel PA, project PR, projectteamrole PTR " .
       "WHERE PTR.id = $ptr_id AND PW.id = PWP.projectworkday_id AND PTR.projectworkdaypersonnel_id = PWP.id " . 
       "AND PA.id = PW.parcel_id AND PR.id = PA.project_id LIMIT 1 ";
$result = $dal->query($sql);

echo json_encode($result);

?>

