<?php
session_start();

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

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

$dal = new DAL();
$sql = "SELECT OS.id,        OS.operation_id as fkid, " .
       "SU.id AS name_id,    SU.name AS name_id_text, " .
       "SU.longaxis,         '' AS longaxis_text, " .
       "SU.shortaxis,        '' AS shortaxis_text, " .
       "P.location,          '' AS location_text, " .
       "SU.longdirection_id, '' AS longdirection_id_text, " .
       "SU.mapareaid,        '' AS mapareaid_descr_text, " .
       "P.topography_id,     '' AS topography_id_text, " .
       "P.landuse_id,        '' AS landuse_id_text, " .
       "P.geomorphology_id,  '' AS geomorphology_id_text, " .
       "P.namedfeature_id,   '' AS namedfeature_id_text, " .
       "P.descr,             '' AS descr_text " .
       "FROM spatialunit SU, part P, operationspatialunit OS " .
       "WHERE OS.id = $os_id AND SU.id = OS.spatialunit_id " .
       "AND P.spatialunit_id = SU.id " . 
       "LIMIT 1";
$result = $dal->query($sql);

$os_id = $result->id;
$_SESSION['operationspatialunit'] = $os_id;

echo json_encode($result);

?>

