<?php

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

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

$dal = new DAL();

$sql = "SELECT LO.id, LO.name as text,
        CASE WHEN ST.relationship_id = null  " .
            "THEN 0 ELSE ST.relationship_id END as optionid " .
       "FROM operationspatialunit OS, spatialunitlot SL," .
       "lot LO, stratigraphy ST " .
       "WHERE OS.spatialunit_id = $su_id " .
       "AND SL.operationspatialunit_id AND LO.id = SL.lot_id " .
       "AND ST.spatialunitlot_id = SL.id " ;
$result = $dal->query($sql);

echo json_encode($result);

?>

