<?php
session_start();

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

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

if ($cu_id > 0) {
  $dal = new DAL();

  $sql = "SELECT CU.id, " .
         "CU.descr,                '' AS descr_text, " .
         "CU.mapareaid,            '' AS mapareaid_text, " .
         "CU.location,             '' AS location_text, " .
         "CU.longaxis,             '' AS longaxis_text, " . 
         "CU.shortaxis,            '' AS shortaxis_text, " .
         "CU.orientation_id,       '' AS orientation_id_text, " .
         "CU.planshape_id,         '' AS planshape_id_text, " .
         "CU.interpret_id,         '' AS interpret_id_text, " .
         "CU.rationale,            '' AS rationale_text, " .
         "CU.note,                 '' AS note_text, " .
         "S.topography_id,         '' AS topography_id_text, " .
         "S.bordenrationale_id,    '' AS bordenrationale_id_text, " .
         "S.bordenizable,          '' AS bordenizable_text, " .
         "S.recommended,           '' AS recommended_text " .
         "FROM culturalunit CU, site S " .
         "WHERE CU.id = $cu_id AND S.culturalunit_id = CU.id LIMIT 1 ";
  $result = $dal->query($sql);
}

//$cu_id = $result->id;

$_SESSION['sitedefinition'] = $cu_id;

echo json_encode($result);

?>

