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

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

$dal = new DAL();
      
$sql = "SELECT CU.id, CU.name AS site_name, SU.name AS prop_part, " .
       "CU.descr AS cu_descr, IP.text AS int_descr " .
       "FROM projectworkday PW, projectworkdayoperation PWO, operationspatialunit OS, " . 
       "spatialunit SU, sitespatialunit SS, culturalunit CU " .
       "LEFT JOIN interpret IP ON IP.id = CU.interpret_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 SS.operationspatialunit_id  = OS.id " .
       "AND CU.id = SS.culturalunit_id " .
       "ORDER BY prop_part, site_name ";
$result = $dal->query($sql);

echo json_encode($result);

?>

