<?php

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

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

$dal = new DAL();
$setupSql = "SELECT filename AS 'File Name', Export " .
         "FROM misprocedure WHERE id = 33 LIMIT 1";
$setups = $dal->query($setupSql);

$row = get_object_vars($setups);
$props = array_keys($row);
$union = "";
$sql = "";

foreach ($props as $prop) {
  $value = $setups->$prop;    
  $sql .= $union . "SELECT '$prop' AS Property, '$value' AS Value, 'Report' AS Type " ; 
  $union = "UNION ALL ";
}

$paramSql = "SELECT parameters " .
            "FROM misprocedure WHERE id = $mp_id LIMIT 1 " ;
$params = $dal->query($paramSql)->parameters;

$props = explode(",", $params);

foreach ($props as $prop) {
  $sql .= $union . "SELECT '$prop' AS Property, '' AS Value, 'Query' AS Type " ; 
}

$properties = $dal->query($sql);

echo json_encode($properties);

?>