<?php

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

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

$dal = new DAL();

$sql = "SELECT PF.id, FO.name AS text " .
       "FROM (parcelfop PF, fop FO) " .
       "LEFT JOIN spatialunitfop SF ON SF.spatialunit_id = $su_id " .
       "AND PF.id = SF.parcelfop_id " .
       "WHERE PF.parcel_id = $pa_id AND FO.id = PF.fop_id " .
       "AND SF.id IS NULL " .
       "ORDER BY FO.name ";
$result = $dal->query($sql);

echo json_encode($result);

?>

