From 5c73ea7bbbbffc593a6ed760af7a75b9e005ae97 Mon Sep 17 00:00:00 2001 From: fusionate Date: Mon, 13 May 2024 12:17:14 -0600 Subject: [PATCH] Destination Summary: Mitigate PHP 8.x warnings, fix search criteria on CSV export. --- app/destinations/destination_summary.php | 78 +++++++++++-------- .../resources/classes/destinations.php | 7 +- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/app/destinations/destination_summary.php b/app/destinations/destination_summary.php index 960342ecd9..753593549a 100644 --- a/app/destinations/destination_summary.php +++ b/app/destinations/destination_summary.php @@ -44,9 +44,11 @@ //retrieve submitted data if (!empty($_REQUEST)) { - $quick_select = $_REQUEST['quick_select']; - $start_stamp_begin = $_REQUEST['start_stamp_begin']; - $start_stamp_end = $_REQUEST['start_stamp_end']; + $quick_select = $_REQUEST['quick_select'] ?? ''; + if (empty($quick_select)) { + $start_stamp_begin = $_REQUEST['start_stamp_begin'] ?? ''; + $start_stamp_end = $_REQUEST['start_stamp_end'] ?? ''; + } //$include_internal = $_REQUEST['include_internal']; } else { @@ -56,9 +58,13 @@ //get the summary $destination = new destinations; $destination->domain_uuid = $_SESSION['domain_uuid']; - $destination->quick_select = $quick_select; - $destination->start_stamp_begin = $start_stamp_begin ?? null; - $destination->start_stamp_end = $start_stamp_end ?? null; + if (!empty($quick_select)) { + $destination->quick_select = $quick_select; + } + else { + $destination->start_stamp_begin = $start_stamp_begin ?? ''; + $destination->start_stamp_end = $start_stamp_end ?? ''; + } //$destination->include_internal = $include_internal ?? null; $summary = $destination->destination_summary(); @@ -71,32 +77,36 @@ //show the column names on the first line $z = 0; - foreach($summary[1] as $key => $val) { - if ($z == 0) { - echo '"'.$key.'"'; - } - else { - echo ',"'.$key.'"'; - } - $z++; - } - echo "\n"; - - //add the values to the csv - $x = 0; - foreach($summary as $users) { - $z = 0; - foreach($users as $key => $val) { + if (!empty($summary) && is_array($summary)) { + foreach ($summary[1] as $key => $val) { if ($z == 0) { - echo '"'.$summary[$x][$key].'"'; + echo '"'.$key.'"'; } else { - echo ',"'.$summary[$x][$key].'"'; + echo ',"'.$key.'"'; } $z++; } echo "\n"; - $x++; + } + + //add the values to the csv + $x = 0; + if (!empty($summary) && is_array($summary)) { + foreach ($summary as $users) { + $z = 0; + foreach ($users as $key => $val) { + if ($z == 0) { + echo '"'.$summary[$x][$key].'"'; + } + else { + echo ',"'.$summary[$x][$key].'"'; + } + $z++; + } + echo "\n"; + $x++; + } } exit; } @@ -138,13 +148,13 @@ echo "
\n"; echo " \n"; echo "
\n"; echo " \n"; @@ -205,7 +215,7 @@ echo " ".$text['label-description']."\n"; echo " \n"; - if (is_array($summary)) { + if (!empty($summary) && is_array($summary)) { foreach ($summary as $key => $row) { echo "\n"; if (!empty($_GET['show']) && $_GET['show'] === "all" && permission_exists('destination_summary_all')) { @@ -231,4 +241,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/destinations/resources/classes/destinations.php b/app/destinations/resources/classes/destinations.php index 2e35fe439d..7cf115607c 100644 --- a/app/destinations/resources/classes/destinations.php +++ b/app/destinations/resources/classes/destinations.php @@ -34,10 +34,13 @@ if (!class_exists('destinations')) { class destinations { /** - * destinations array + * declare public variables */ public $destinations; public $domain_uuid; + public $start_stamp_begin; + public $start_stamp_end; + public $quick_select; /** * declare private variables @@ -1132,7 +1135,7 @@ if (!class_exists('destinations')) { } //build the date range - if ((!empty($this->start_stamp_begin) && strlen($this->start_stamp_begin) > 0) || !empty($this->start_stamp_end)) { + if (!empty($this->start_stamp_begin) || !empty($this->start_stamp_end)) { unset($this->quick_select); if (strlen($this->start_stamp_begin) > 0 && !empty($this->start_stamp_end)) { $sql_date_range = " and start_stamp between :start_stamp_begin::timestamptz and :start_stamp_end::timestamptz \n";