<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "currid")
    $pr_id = $paramValue;
}

$dal = new DAL();
$sql = "SELECT PW.id, PR.name AS project, PR.refno AS ref_no, " .
       "PA.name AS parcel, WO.textdate AS workday " .
       "FROM projectworkday PW, workday WO, parcel PA, project PR " .
       "WHERE PR.id = $pr_id AND PA.project_id = PR.id AND PW.parcel_id = PA.id " .
       "AND PW.fieldwork_day = 1 AND PW.active = 1 AND WO.id = PW.workday_id " .
       "ORDER BY WO.date DESC";
$result = $dal->query($sql);

echo json_encode($result);

?>
