From 3666da18c7ce592c8606f34de2925b6ad4facffa Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Thu, 3 Nov 2011 16:57:38 +0000 Subject: [PATCH] 2011-11-03 Juan Manuel Ramon * include/functions_reporting.php godmode/reporting/reporting_builder.preview.php: Changed begin date function in order to make it global for all items of a report. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5106 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++ .../reporting/reporting_builder.preview.php | 62 +++++++++++++++++-- .../include/functions_reporting.php | 27 +------- 3 files changed, 66 insertions(+), 29 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8861bb9e2e..0c577d91d4 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2011-11-03 Juan Manuel Ramon + + * include/functions_reporting.php + godmode/reporting/reporting_builder.preview.php: Changed begin date + function in order to make it global for all items of a report. + 2011-11-03 Juan Manuel Ramon * include/functions_graph.php diff --git a/pandora_console/godmode/reporting/reporting_builder.preview.php b/pandora_console/godmode/reporting/reporting_builder.preview.php index 93be29c991..31d4e1271e 100644 --- a/pandora_console/godmode/reporting/reporting_builder.preview.php +++ b/pandora_console/godmode/reporting/reporting_builder.preview.php @@ -43,6 +43,17 @@ if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! is_user $date = (string) get_parameter ('date', date ('Y-m-j')); $time = (string) get_parameter ('time', date ('h:iA')); +// Calculations in order to modify init date of the report +$date_init_less = strtotime(date ('Y-m-j')) - 86400; +$date_init = get_parameter('date_init', date ('Y-m-j', $date_init_less)); +$time_init = get_parameter('time_init', date ('h:iA')); +$datetime_init = strtotime ($date_init.' '.$time_init); +$enable_init_date = get_parameter('enable_init_date', 0); +$new_interval = $report['datetime'] - $datetime_init; +if ($new_interval != $content['period']) { + $content['period'] = $new_interval; +} + // Standard header $url = "index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id=$id_report&date=$date&time=$time"; @@ -61,8 +72,21 @@ $table->width = '99%'; $table->class = 'databox'; $table->style = array (); $table->style[0] = 'font-weight: bold'; +// Set initial conditions for these controls, later will be modified by javascript +if (!$enable_init_date){ + $table->style[3] = 'display: none'; + $table->style[4] = 'display: none'; + $table->style[5] = 'width: 380.583px'; +} +else{ + $table->style[3] = 'display: ""'; + $table->style[4] = 'display: ""'; + $table->style[5] = 'display: none'; +} + $table->size = array (); $table->size[0] = '50px'; +$table->colspan[0][1] = 4; $table->data = array (); $table->data[0][0] = html_print_image("images/reporting.png", true, array("width" => '32', "height" => '32')); if ($report['description'] != '') { @@ -70,14 +94,22 @@ if ($report['description'] != '') { } else { $table->data[0][1] = $report['name']; } + $table->data[1][0] = __('Date'); $table->data[1][1] = html_print_input_text ('date', $date, '', 12, 10, true). ' '; $table->data[1][1] .= html_print_input_text ('time', $time, '', 7, 7, true). ' '; $table->data[1][1] .= html_print_submit_button (__('Update'), 'date_submit', false, 'class="sub next"', true); +$table->data[1][2] = __('Set initial date of all reports') . html_print_checkbox('enable_init_date', 1, $enable_init_date, true); +$table->data[1][3] = '' . __('Date') . '' . ui_print_help_tip(__('This is the begin date for all reports'), true); +$table->data[1][4] = html_print_input_text ('date_init', $date_init, '', 12, 10, true). ' '; +$table->data[1][4] .= html_print_input_text ('time_init', $time_init, '', 7, 7, true). ' '; +$table->data[1][4] .= html_print_submit_button (__('Update'), 'date_submit_init', false, 'class="sub next"', true); +$table->data[1][5] = ''; echo '
'; html_print_table ($table); html_print_input_hidden ('id_report', $id_report); +echo '
'; echo '
'; echo html_print_image("images/wait.gif", true, array("border" => '0')) . '
'; @@ -94,15 +126,30 @@ ui_require_jquery_file ('timeentry'); ?> @@ -148,11 +195,18 @@ foreach ($contents as $content) { $table->colspan = array (); $table->rowstyle = array (); + // Calculate new inteval for all reports + if ($enable_init_date){ + $datetime_init = strtotime ($date_init.' '.$time_init); + $new_interval = $report['datetime'] - $datetime_init; + $content['period'] = $new_interval; + } + reporting_render_report_html_item ($content, $table, $report); echo '
'; html_print_table ($table); echo "
"; flush (); } -echo ''; + ?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 5606bc70c1..b7b64dfd34 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2068,15 +2068,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $agent_name = agents_get_name($content['id_agent']); } - // Calculations in order to modify init date of the report - $date_init = get_parameter('date_init_' . $content['id_rc'], date ('Y-m-j',$report['datetime'] - $content['period'])); - $time_init = get_parameter('time_init_' . $content['id_rc'], date ('h:iA',$report['datetime'] - $content['period'])); - $datetime_init = strtotime ($date_init.' '.$time_init); - $new_interval = $report['datetime'] - $datetime_init; - if ($new_interval != $content['period']) { - $content['period'] = $new_interval; - } - switch ($content["type"]) { case 1: case 'simple_graph': @@ -2401,7 +2392,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f metaconsole_restore_db(); } } -//html_debug_print($table1->data); + // SLA items sorted descending () if ($content['top_n'] == 2){ usort($table1->data, "sla_value_desc_cmp"); @@ -2410,7 +2401,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f else if ($content['top_n'] == 1){ usort($table1->data, "sla_value_asc_cmp"); } -//html_debug_print($table1->data); + // Delete temporary column used to sort SLA data for ($i=0; $i < count($table1->data); $i++) { unset($table1->data[$i][6]); @@ -4012,20 +4003,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f if (($config ['metaconsole'] == 1) && $server_name != '') { metaconsole_restore_db(); } - - // Adds date/time control to update initial interval report - $table->colspan[3][0] = 3; -// $table->data[3][0] = '
'; - $table->data[3][0] .= '' . __('Date') . '' . ui_print_help_tip(__('This is the report start date'), true) . '     '; - $table->data[3][0] .= html_print_input_text ('date_init_' . $content['id_rc'], $date_init, '', 12, 10, true). ' '; - $table->data[3][0] .= html_print_input_text ('time_init_' . $content['id_rc'], $time_init, '', 7, 7, true). ' '; - $table->data[3][0] .= html_print_submit_button (__('Update'), 'date_submit_init', false, 'class="sub next"', true); - $table->data[3][0] .= html_print_input_hidden ('id_report_content_' . $content['id_rc'], 1, true); - -/* if (!isset(get_parameter('id_rc_list')){ - $table->data[3][0] .= html_print_input_hidden ('id_rc_list', $id_rc_list . ',' . $content['id_rc'], true); - }*/ -// $table->data[3][0] .= '
'; } /**