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 "