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

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

if ($ow_id > 0) {
  $dal = new DAL();

  $sql = "SELECT OW.id, " . 
         "OW.workday_id,       '' AS workday_id_text, " . 
         "(CASE WHEN OW.teamrole_id = 7 THEN 1 ELSE 0 END) AS absent, " . 
         "(CASE WHEN OW.teamrole_id = 7 THEN 'Yes' ELSE 'No' END) AS absent_text, " .
         "PR.id AS project_id, PR.name AS project_id_text,  " .
         "OW.projectparcel_id, PA.name AS parcel_id_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);

?>

