<?php
session_start();

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

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

$dal = new DAL();
$sql = "SELECT SU.id, " .
       "PS.projectparcel_id as fkid, '' AS fkid_text, " .
       "PS.projectparcel_id as projectparcel_fk, '' AS projectparcel_fk_text, " .
       "1 AS completeInd     ,'' AS completeInd_text, " .
       "SU.name AS name,     SU.name AS name_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, projectparcelspatialunit PS " .
       "WHERE SU.id = $su_id AND P.spatialunit_id = SU.id " . 
       "AND PS.spatialunit_id = SU.id LIMIT 1";
$result = $dal->query($sql);

$_SESSION['propertypart'] = $su_id;

echo json_encode($result);

?>

