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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "scopeid")
    $pwo_id = $paramValue;
  else if ($paramName == "baseid")
    $pa_id = $paramValue;
}

$dal = new DAL();
$sql = "SELECT SU.id, SU.name, LA.descr, P.location " .
       "FROM (projectworkday PW, projectworkdayoperation PWO, " .
       "operationspatialunit OS, spatialunit SU, part P) " .
       "LEFT JOIN landuse LA ON LA.id = P.landuse_id " .
       "WHERE PW.parcel_id = $pa_id AND PWO.projectworkday_id = PW.id " .
       "AND OS.projectworkdayoperation_id = PWO.id AND SU.id = OS.spatialunit_id " .
       "AND SU.spatialunittype_id = 1 AND P.spatialunit_id = SU.id " ;
$result = $dal->query($sql);

echo json_encode($result);

?>

