<?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_id_text, " .
       "PWO.id AS dailyoperation_id,          '' AS dailyoperation_id_text, " .
       "CS.spatialunit_id AS propertypart_id, '' AS propertypart_id_text, " .
       "1 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_id;
//$_SESSION['propertypart'] = $result->propertypart_id;
//$_SESSION['dailyoperation'] = $result->dailyoperation_id;

echo json_encode($result);

?>

