<?php
session_start();

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

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

$dal = new DAL();

$sql = "SELECT CU.id,                            0 AS fkid, " . 
       "CU.name,                                 '' AS surname_text, " .
       "PW.projectparcel_id AS projectparcel_fk, '' AS projectparcel_fk_text, " .
       "PWO.id AS dailyoperation_fk,             '' AS dailyoperation_fk_text, " .
       "CS.spatialunit_id AS propertypart_fk,    '' AS propertypart_fk_text, " .
       "CU.id AS complete_ind,                   '' AS complete_ind_test " .
       "FROM culturalunit CU, culturalunitspatialunit CS, " .
       "projectworkdayoperation PWO, projectworkevent PW " .
       "WHERE CU.id = $cu_id AND CS.culturalunit_id = CU.id " .
       "AND PWO.id = CS.projectworkdayoperation_id " .
       "AND PW.id = PWO.projectworkevent_id " .
       "LIMIT 1 ";
$result = $dal->query($sql);

//$_SESSION['projectparcel'] = $result->projectparcel_fk;
//$_SESSION['propertypart'] = $result->propertypart_fk;
//$_SESSION['dailyoperation'] = $result->dailyoperation_fk;

echo json_encode($result);

?>

