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

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

$dal = new DAL();

if ($field == 'sumControlInstances') {

  if ($id > 0) {
    $sql = "SELECT CI.id, SPACE(0) AS 'select', instance, CO.control  " .
           "FROM controlinstance CI, controlobject CO " .
           "WHERE CI.mainmenu_id = $id AND CI.controlobject_id = CO.id " .
           "ORDER BY CO.control, CI.location ";
    $result = $dal->query($sql);
  }           
}

echo json_encode($result);

?>

