<?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, " .
       "CU.id AS name_id,        CU.name AS name_id_text, " . 
       "operationspatialunit_id, ''AS operationspatialunit_id_text, " .
       "descr,                   '' AS descr_text, " .
       "mapareaid,               '' AS mapareaid_text, " .
       "location,                '' AS location_text, " .
       "longaxis,                '' AS longaxis_text, " . 
       "shortaxis,               '' AS shortaxis_text, " .
       "orientation_id,          '' AS orientation_id_text, " .
       "planshape_id,            '' AS planshape_id_text, " .
       "interpret_id,            '' AS interpret_id_text, " .
       "rationale,               '' AS rationale_text, " .
       "CU.note,                 '' AS note_text, " .
       "topography_id,           '' AS topography_id_text, " .
       "stg2recommendation,      '' AS stg2recommendation_text, " .
       "recommendrationale_id,   '' AS recommendrationale_id_text, " .
       "bordenizable,            '' AS bordenizable_text, " .
       "bordenrationale_id,      '' AS bordenrationale_id_text " .
       "FROM culturalunit CU, sitespatialunit SS, site SI " .
       "WHERE CU.id = $cu_id AND SS.culturalunit_id = CU.id " .
       "AND SI.culturalunit_id = CU.id LIMIT 1 ";
$result = $dal->query($sql);

//$su_id = $result->spatialunit_id;

//$_SESSION['spatialunit'] = $su_id;

echo json_encode($result);

?>

