<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selectid")
    $rq_id = $paramValue;
}

$dal = new DAL();
$sql = "SELECT RS.headercheck, RS.filename " .
       "FROM reportquerysetup RS, reportquery RQ " .
       "WHERE RQ.id = $rq_id AND RQ.reportquerysetup_id = RS.id LIMIT 1 " ;
$setup = $dal->query($sql);

$sql = "SELECT wherefields FROM reportquery WHERE id = $rq_id LIMIT 1 " ;
$fields = $dal->query($sql)->wherefields;
$fieldList = explode(",", $fields);

foreach ($fieldList as $field) {
  $setup->$field = "";
}

echo json_encode($setup);

?>

