<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id") 
    $sl_id = $paramValue;  
} 
  
$dal = new DAL();

$sql = "SELECT SL.id AS spatialunitlot_id, OA.activitytype_id, " .
       "OD.descr AS int_descr, OD.rationale AS int_rationale " .
       "FROM operationspatialunitactivity OA, operationactivitydetail OD, " .
       "activitytype AT, operationspatialunit OS, spatialunitlot SL " . 
       "WHERE SL.id = $sl_id AND OS.id = SL.operationspatialunit_id " .
       "AND OA.operationspatialunit_id = OS.id AND AT.id = activitytype_id " .
       "AND OD.operationspatialunitactivity_id = OS.id LIMIT 1 ";
$result = $dal->query($sql);

if (NULL == $result)
  $result = (object)array("spatialunitlot_id"=>"0", "activitytype_id"=>"0", "int_descr"=>"", 
                          "int_rationale"=>"");

echo json_encode($result);

?>

