<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "summaryid")
    $oz_id = $paramValue;
}    
 
$dal = new DAL();
$sql = "SELECT OC.id AS id, " .
       "CONCAT(CO.firstname, ' ', CO.surname) AS 'Contact Name', " .
       "OZ.name AS 'Contact Organization', " .
       "OC.email AS 'Contact Email' " .
       "FROM contact CO, organizationcontact OC, organization OZ " .
       "WHERE OZ.id = $oz_id AND OC.organization_id = OZ.id " . 
       "AND CO.id = OC.contact_id " .
       "ORDER BY CO.surname ";
$result = $dal->query($sql);

echo json_encode($result);

?>

