0) { $strSelection = urldecode($strSelection); $strFileDataSource = file_get_contents("{$strQueryDir}/{$strSelection}"); $strFileData = $strFileDataSource; // Translate occurrences of {{ Date: next monday }} into yyyy-MM-dd format: // Can be used in string literals or default values in comments! preg_match_all( "/\{\{\s*?Date\:\s*?(.*)\s*?\}\}/i", $strFileData, $varDateReplacements); for ($i = 0; $i < count($varDateReplacements[0]); $i++) { try { $strMatch = $varDateReplacements[0][$i]; $strMatchSafe = preg_quote($strMatch); $strDateString = $varDateReplacements[1][$i]; $strFileData = preg_replace( "/{$strMatchSafe}/i", date_create($strDateString)->format("Y-m-d"), $strFileData); } catch (Exception $x) {} } // WARNING: Can be abused. // Translate occurrences of {{ SQL: select 'test' }} into the string value of the first cell of the first row: // Can be used in string literals or default values in comments! preg_match_all( "/\{\{\s*SQL\:\s*(.*)\s+?\}\}/i", $strFileData, $varSQLReplacements); for ($i = 0; $i < count($varSQLReplacements[0]); $i++) { try { $strMatch = $varSQLReplacements[0][$i]; $strMatchSafe = preg_quote($strMatch); $strSQLString = $varSQLReplacements[1][$i]; $varTempRows = $c->query($strSQLString); //Respond::json($varTempRows); $strFirstCell = ""; if (count($varTempRows) > 0) foreach ($varTempRows[0] as $k => $v) { $strFirstCell = $varTempRows[0][$k]; break; } $strFileData = preg_replace( "/{$strMatchSafe}/i", $strFirstCell, $strFileData); } catch (Exception $x) {} } // Get the inputs: preg_match_all( "/declare\s+\@([A-Za-z0-9]{1,})\s+(.+)\s+=\s+\?;(\s+-- ([A-Za-z0-9]{1,})\:\s(.*))?/i", $strFileData, $varInputs); // Get the options defined in comments: preg_match_all( "/--\s+([A-Za-z0-9]{1,})\:\s+(.+)/i", $strFileData, $varOptionMatches); if (count($varOptionMatches[0]) > 0) { for ($i = 0; $i < count($varOptionMatches[0]); $i++) { $strKey = strtolower($varOptionMatches[1][$i]); $strValue = $varOptionMatches[2][$i]; $varOptions[$strKey] = $strValue; } } if (array_key_exists("nosorting", $varOptions)) $intSortable = 0; if (array_key_exists("allow", $varOptions)) { $intAllowed = 0; $strAllowedObjects = strtolower($varOptions["allow"]); $varAllowedObjects = explode(",", $strAllowedObjects); $varUserObjects = []; if (class_exists("UserAuth")) { $varUser = UserAuth::getUser(); if ($varUser !== null) { foreach (UserAuth::getUserGroups() as $strGroup) $varUserObjects[] = strtolower($strGroup); $varUserObjects[] = strtolower($varUser["cn"]); } } foreach ($varAllowedObjects as $strObject) if (in_array($strObject, $varUserObjects)) $intAllowed = 1; } $intRun = Request::getParam("run"); $strFormat = Request::getParam("format"); //if (Request::posts("run_query")) if ($intRun !== null && $intRun == 1 && $intAllowed == 1) { $varPosted = Request::getParams(); // Remove these keys from submitted fields: foreach (["run", "format"] as $k) if (array_key_exists($k, $varPosted)) unset($varPosted[$k]); try { $varRows = $c->query($strQueryPath, $varPosted); $strQueryView = "{$strQueryPath}.php"; // Allow returning the data as JSON for APIs, maybe: if (strtolower($strFormat) == "json") Respond::json($varRows); } catch (Exception $x) { $strMessage = $x->getMessage(); $strError = $strMessage; $strError .= "\n\n"; $strFile = $x->getFile(); $intLine = $x->getLine(); $strError .= "#-1 {$strFile}({$intLine}): {$strMessage}\n"; $strError .= $x->getTraceAsString(); } } } // Fancier title processing: $strTitle = "Select Report"; if ($strSelection !== null && strlen($strSelection) > 0) $strTitle = $strSelection; if (array_key_exists("title", $varOptions)) $strTitle = $varOptions["title"]; ?> <?= $strTitle; ?>
No rows returned.
:
0): ?> 0) $strInputDefaultValue = $varInputs[5][$i]; $varInputOptions = []; if (strtolower($varInputs[4][$i]) == "options") { $strOptionsList = $varInputs[5][$i]; $varInputOptions = explode(",", $strOptionsList); } ?>
0): ?>
0): ?> Reset
The selected report requires being logged in as a user with permission to run it.
0) $varDirectories[$strDirectory] = 1; } ?>
$a): ?>
0): ?>
0): ?> $v) $varColumns[] = $k; $strDisplayRowAs = null; if (array_key_exists("displayrowas", $varOptions)) if (preg_match("/^col\-/i", $varOptions["displayrowas"])) $strDisplayRowAs = $varOptions["displayrowas"]; ?>

    $v): ?>
  • :
  • Printed:
  • Search:
0) $strCellClass = $strRowClass; if (strlen($strNextCellClass) > 0) $strCellClass = $strNextCellClass; // Allow SQL data to controll next cell class with _next_cell_class column: if (preg_match("/^_next_cell_class/i", $col)) $strNextCellClass = $r[$col]; // Hide columns that begin with underscore: if ($col[0] == "_") continue; ?>
0) $strCellClass = $strRowClass; if (strlen($strNextCellClass) > 0) $strCellClass = $strNextCellClass; // Allow SQL data to controll next cell class with _next_cell_class column: if (preg_match("/^_next_cell_class/i", $col)) $strNextCellClass = $r[$col]; // Hide columns that begin with underscore: if ($col[0] == "_") continue; ?>
0): ?> 0): ?> ">