<?php
session_start();

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

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

if ($sl_id > 0) {
  $dal = new DAL();

  $sql = "SELECT SL.id, " .
         "PS.projectparcel_is AS projectparcel_fk,  '' AS projectparcel_fk_text, " .
         "CS.culturalunit_id AS sitedefinition_fk, '' AS sitedefinition_fk_text, " . 
         "POS.projectworkdayoperation_id AS dailyoperation_fk, '' AS dailyoperation_fk_text, " . 
         "SU.name,              '' AS name_text, " .
         "SU.mapaid,            '' AS mapid_text, " .
         "PO.device_id,         '' AS device_id_text, " .
         "PO.pos,               '' AS pos_text " .
         "FROM spatialunitlot SL, spatialunit SU, culturalunitspatialunit CS, " .
         "projectworkdayoperationspatialunit POS, projectparcelspatialunit PS, " .
         "spatialunitpoints SP, points PO " . 
         "WHERE SL.id = $sl_id AND SU.id = SL.spatialunit_id " . 
         "AND PS.spatialunit_id = SU.id AND CS.spatialunit_id = SU.id " .
         "AND POS.spatialunit_id = SU.id AND SP.spatialunit_id = CS.spatialunit_id " .
         "AND PO.id = SP.points_id LIMIT 1 " ; 
  $result = $dal->query($sql);
}

$_SESSION['shoveltest'] = $sl_id;

echo json_encode($result);

?>

