From db7a5e121d68d7eba8092dbd8203ac182e187a0c Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 25 Sep 2023 17:10:43 +0200 Subject: [PATCH] Add the None option to the date filter to prioritize the period of the report items. --- pandora_console/include/functions_html.php | 1 + .../operation/reporting/reporting_viewer.php | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 8458dcfcc8..1c908b50d1 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -7286,6 +7286,7 @@ function html_print_select_date_range( $fields[SECONDS_1MONTH] = __('Last 30 days'); $fields['custom'] = __('Custom'); $fields['chose_range'] = __('Chose start/end date period'); + $fields['none'] = __('None'); $output = html_print_input_hidden('custom_date', $custom_date, true); $output .= '
'; diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index e3e07590ba..cc42d7e6ac 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -58,7 +58,7 @@ $datetime_end = strtotime($date_end.' '.$time_end); // Calculate new inteval for all reports. $custom_date = get_parameter('custom_date', 0); -$date = get_parameter('date', SECONDS_1DAY); +$date = get_parameter('date', 'none'); $date_text = get_parameter('date_text', SECONDS_1DAY); $custom_date_end = ''; @@ -111,6 +111,9 @@ if ($custom_date === '1') { $first_of_week = date('Y-m-d', strtotime('monday', strtotime('last week'))); $period = (strtotime($date_end) - strtotime($first_of_week)); } +} else if ($date === 'none') { + // Prioritize the report item period based on the current local date/time. + $date_end = date('Y/m/d H:i:s'); } else { $date_end = date('Y/m/d H:i:s'); $date_start = date('Y/m/d H:i:s', (strtotime($date_end) - $date)); @@ -315,12 +318,12 @@ if ($html_menu_export === ENTERPRISE_NOT_HOOK) { if ((bool) is_metaconsole() === true) { $table2->data[0][2] = html_print_label_input_block( __('Date').' ', - html_print_select_date_range('date', true, get_parameter('date', SECONDS_1DAY), $date_init, $time_init, date('Y/m/d'), date('H:i:s'), $date_text), + html_print_select_date_range('date', true, get_parameter('date', 'none'), $date_init, $time_init, date('Y/m/d'), date('H:i:s'), $date_text), ); } else { $table2->data[0][2] = html_print_label_input_block( __('Date').' ', - html_print_select_date_range('date', true, get_parameter('date', SECONDS_1DAY), $date_init, $time_init, date('Y/m/d'), date('H:i:s'), $date_text), + html_print_select_date_range('date', true, get_parameter('date', 'none'), $date_init, $time_init, date('Y/m/d'), date('H:i:s'), $date_text), ['label_class' => 'filter_label_position_before'] ); } @@ -451,7 +454,6 @@ $(document).ready (function () { $("#string_to").show(); $('#string_from').show(); $("#string_items").hide(); - console.log($(".filter_label_position_before").html()); } else { $("#string_to").hide(); $('#string_from').hide();