<?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, " .
       "SL.lot_id,          '' AS lot_id_text, " .
       "artifactdensity_id, '' AS artifactdensity_id_text, " . 
       "OA.activitytype_id, '' AS activitytype_id_text " .
       "OD.descr,           '' AS descr_text, " . 
       "OD.rationale,       '' AS rationale_text " .
       "FROM operationspatialunitactivity OA, operationactivitymod OM, " .
       "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 OM.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);

?>

