From e44526aa5ad23ca908efc9aa67b215bec3dbdb4d Mon Sep 17 00:00:00 2001 From: Conner Harkness Date: Thu, 4 Sep 2025 11:04:30 -0600 Subject: [PATCH] cleanup & bugfix for DisplayRowAs (formerly RowClass option), added source preview, added focused mode, moved view processing to bottom --- pages/run.php | 324 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 211 insertions(+), 113 deletions(-) diff --git a/pages/run.php b/pages/run.php index 24d3552..70ab7fd 100644 --- a/pages/run.php +++ b/pages/run.php @@ -14,13 +14,15 @@ $strInput = substr($strInput, strlen($strQueryDir) + 1); } - $strFind = shell_exec("find files/sql | grep -Ei \"\.sql$\""); + $strFind = shell_exec("find {$strQueryDir} | grep -Ei \"\.sql$\""); $varFiles = explode("\n", $strFind); $varFiles = array_filter($varFiles); array_walk($varFiles, "removeQueryDir"); $strSelection = implode("/", Request::getArgs()); + $strQueryPath = "{$strQueryDir}/{$strSelection}"; + $strQueryView = null; $varInputs = [[]]; $varRows = null; @@ -31,8 +33,9 @@ if ($strSelection !== null && strlen($strSelection) > 0) { - $strSelection = urldecode($strSelection); - $strFileData = file_get_contents("{$strQueryDir}/{$strSelection}"); + $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! @@ -158,21 +161,12 @@ try { - $varRows = $c->query("{$strQueryDir}/{$strSelection}", $varPosted); - $strView = "files/views/{$strSelection}.php"; + $varRows = $c->query($strQueryPath, $varPosted); + $strQueryView = "{$strQueryPath}.php"; // Allow returning the data as JSON for APIs, maybe: if (strtolower($strFormat) == "json") Respond::json($varRows); - - // Load a custom view if there is one: - if (file_exists($strView)) - { - ob_clean(); - require $strView; - ob_end_flush(); - exit; - } } catch (Exception $x) { @@ -190,16 +184,18 @@ } // Fancier title processing: - $strTitle = null; + $strTitle = "Select Report"; + + if ($strSelection !== null && strlen($strSelection) > 0) + $strTitle = $strSelection; + if (array_key_exists("title", $varOptions)) $strTitle = $varOptions["title"]; - - $strTitle = $strTitle ?? $strSelection ?? "Report"; ?> @@ -220,6 +216,14 @@ + +
@@ -245,7 +249,7 @@
-
+
@@ -352,7 +356,16 @@
- Execute + 0): ?> + + + + + Reset
@@ -380,10 +393,18 @@ ?> -
+
+ + + $a): ?>
@@ -401,6 +422,30 @@
+ + 0): ?> + + + +
+
+
+ +
+ +
+
+
+
+ + +
@@ -414,10 +459,10 @@ foreach ($varRow1 as $k => $v) $varColumns[] = $k; - $strRowClass = null; - if (array_key_exists("rowclass", $varOptions)) - if (preg_match("/^col\-/i", $varOptions["rowclass"])) - $strRowClass = $varOptions["rowclass"]; + $strDisplayRowAs = null; + if (array_key_exists("displayrowas", $varOptions)) + if (preg_match("/^col\-/i", $varOptions["displayrowas"])) + $strDisplayRowAs = $varOptions["displayrowas"]; ?>
@@ -443,71 +488,10 @@
- - -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- - - - - -
- - - - - - - - - - - +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + 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) + $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; + ?> + + + + + + + + + +
+ +
@@ -596,6 +663,11 @@ fnShowPage("#page-output"); $("#table").exportCSV({name: ""}); }; + + fnGetRowAsQueryString = function() + { + + }; }); @@ -607,6 +679,15 @@ + + + + @@ -636,3 +717,20 @@ }); + + + + + + + +