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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "summaryid")
    $pa_id = $paramValue;
}

$dal = new DAL();

$sql = "SELECT PF.id, FO.name AS 'Feature Name', " .  
       "(CASE WHEN FT.descr IS NULL THEN '' ELSE FT.descr END) AS Type, " .
       "(CASE WHEN PF.fieldefined = 1 " . 
         "THEN 'Field' ELSE 'Office' END) AS Defined, " .
       "FO.mapareaid AS 'Map Id', " .
       "(CASE WHEN PF.fieldefined = 1 " .
         "THEN PF.field_descr ELSE PF.office_descr END) AS Description " .
       "FROM (parcelfop PF, fop FO)  " .
       "LEFT JOIN foptype FT ON FT.id = FO.foptype_id " .
       "WHERE PF.parcel_id = $pa_id AND FO.id = PF.fop_id " .
       "ORDER BY FO.name " ; 
$result = $dal->query($sql);

echo json_encode($result);

?>

