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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selectid")
    $ci_id = $paramValue;
  else if ($paramName == "gensum")
    $genSum = $paramValue;
}

if ($ci_id > 0) {
  $dal = new DAL();
  $sql = "SELECT CI.id, " .
         "CI.mainmenu_id AS panelfolder_id, $genSum AS panelfolder_id_attr, " .
         "CI.controlobject_id,     CO.control AS controlobject_id_attr, " . 
         "CI.field,                CI.field AS field_attr, " .
         "CI.formhandler_id,       '' AS formhandler_id_attr, " . 
         "1 AS complete_ind,       '' AS complete_ind_attr " .
         "FROM controlfield CI, controlobject CO " .
         "WHERE CI.id = $ci_id AND CO.id = CI.controlobject_id LIMIT 1 " ;
  $result = $dal->query($sql);
}

if ($genSum == 0)
  $result->panelfolder_id = 0; 

$_SESSION['controlfield'] = $ci_id;

echo json_encode($result);

?>

