From 369a7f8561ee653f665be90cd8e6a2ce4825af8d Mon Sep 17 00:00:00 2001 From: javilanz Date: Wed, 26 Jan 2011 13:40:17 +0000 Subject: [PATCH] 2011-01-26 Javier Lanz * include/functions_custom_graphs.php: Added 'date' parameter * operation/reporting/reporting_viewer.php: Longer text box * operation/reporting/graph_viewer.php: Added date control * godmode/reporting/reporting_builder.preview.php: Longer text box * godmode/reporting/graph_builder.preview.php: Added bottom controls Pending task: #3137696 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 ++ .../reporting/graph_builder.preview.php | 164 +++++++++++++++--- .../reporting/reporting_builder.preview.php | 2 +- .../include/functions_custom_graphs.php | 7 +- .../operation/reporting/graph_viewer.php | 46 ++++- .../operation/reporting/reporting_viewer.php | 2 +- 6 files changed, 202 insertions(+), 30 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c9128b21b7..4b718cbfdd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2011-01-26 Javier Lanz + + * include/functions_custom_graphs.php: Added 'date' parameter + * operation/reporting/reporting_viewer.php: Longer text box + * operation/reporting/graph_viewer.php: Added date control + * godmode/reporting/reporting_builder.preview.php: Longer text box + * godmode/reporting/graph_builder.preview.php: Added bottom controls + + Pending task: #3137696 + + 2011-01-25 Miguel de Dios * operation/search_results.php: added the tab to show search list for diff --git a/pandora_console/godmode/reporting/graph_builder.preview.php b/pandora_console/godmode/reporting/graph_builder.preview.php index dc43e2bda3..0c44b1b185 100644 --- a/pandora_console/godmode/reporting/graph_builder.preview.php +++ b/pandora_console/godmode/reporting/graph_builder.preview.php @@ -15,6 +15,8 @@ global $config; +require_once ('include/functions_custom_graphs.php'); + if (is_ajax ()) { $search_agents = (bool) get_parameter ('search_agents'); @@ -58,6 +60,56 @@ if (! give_acl ($config['id_user'], 0, "IW")) { } $id = (integer) get_parameter('id'); + +$sql="SELECT * FROM tgraph_source WHERE id_graph = $id_graph"; +$sources = get_db_all_rows_sql($sql); + +$sql="SELECT * FROM tgraph WHERE id_graph = $id_graph"; +$graph = get_db_row_sql($sql); + +$id_user = $graph["id_user"]; +$private = $graph["private"]; +$width = $graph["width"]; +$height = $graph["height"] + count($sources) * 10; + +$zoom = (int) get_parameter ('zoom', 0); + //Increase the height to fix the leyend rise +if ($zoom > 0) { + switch ($zoom) { + case 1: + $width = 500; + $height = 200 + count($sources) * 15; + break; + case 2: + $width = 650; + $height = 300 + count($sources) * 10; + break; + case 3: + $width = 770; + $height = 400 + count($sources) * 5; + break; + } +} + +// Get different date to search the report. +$date = (string) get_parameter ('date', date ('Y-m-j')); +$time = (string) get_parameter ('time', date ('h:iA')); +$unixdate = strtotime ($date.' '.$time); + +$period = (int) get_parameter ('period'); +if (! $period) + $period = $graph["period"]; +else + $period = 3600 * $period; + +$events = $graph["events"]; +$description = $graph["description"]; +$stacked = (int) get_parameter ('stacked', -1); +if ($stacked == -1) + $stacked = $graph["stacked"]; + +$name = $graph["name"]; + $graphRows = get_db_all_rows_sql("SELECT t1.*, (SELECT t3.nombre FROM tagente AS t3 @@ -82,31 +134,97 @@ foreach ($graphRows as $graphRow) { $agent_array[] = $graphRow['agent_name']; } -$graphInTgraph = get_db_row_sql("SELECT * FROM tgraph WHERE id_graph = " . $id); -$stacked = $graphInTgraph['stacked']; -$events = $graphInTgraph['events']; -$period = $graphInTgraph['period']; - $modules = implode(',', $module_array); $weights = implode(',', $weight_array); - echo ""; - echo "
"; - - $graph_width = get_db_sql ("SELECT width FROM tgraph WHERE id_graph = ".$id); - $graph_height= get_db_sql ("SELECT height FROM tgraph WHERE id_graph = ".$id); - - if(!empty($modules)) { - if ($config['flash_charts']) { - echo graphic_combined_module (explode (',', $modules), explode (',', $weights), $period, $graph_width, $graph_height, - 'Combined%20Sample%20Graph', '', $events, 0, 0, $stacked); - } else { - echo ""; - } - } - else { - echo "
".__('Empty graph')."
"; - } +echo ""; +echo "
"; - echo "
"; +if(!empty($modules)) { + if ($config['flash_charts']) { + echo graphic_combined_module (explode (',', $modules), explode (',', $weights), $period, $width, $height, + 'Combined%20Sample%20Graph', '', $events, 0, 0, $stacked, $unixdate); + } else { + echo ""; + } +} +else { + echo "
".__('Empty graph')."
"; +} +echo "
"; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
"; +echo "".__('Date').""." "; +echo ""; +echo print_input_text ('date', $date, '', 12, 10, true). ' '; +echo ""; +echo print_input_text ('time', $time, '', 7, 7, true). ' '; +echo ""; +echo "".__('Period').""; +echo ""; + +print_select (get_custom_graph_periods (), 'period', intval ($period / 3600), + '', '', 0, false, false, false); + +echo ""; +$stackeds = array (); +$stackeds[0] = __('Graph defined'); +$stackeds[0] = __('Area'); +$stackeds[1] = __('Stacked area'); +$stackeds[2] = __('Line'); +$stackeds[3] = __('Stacked line'); +print_select ($stackeds, 'stacked', $stacked , '', '', -1, false, false); + +echo ""; +$zooms = array(); +$zooms[0] = __('Graph defined'); +$zooms[1] = __('Zoom x1'); +$zooms[2] = __('Zoom x2'); +$zooms[3] = __('Zoom x3'); +print_select ($zooms, 'zoom', $zoom , '', '', 0); + +echo ""; +echo ""; +echo "
"; +echo "
"; + +/* We must add javascript here. Otherwise, the date picker won't +work if the date is not correct because php is returning. */ + +require_css_file ('datepicker'); +require_jquery_file ('ui.core'); +require_jquery_file ('ui.datepicker'); +require_jquery_file ('timeentry'); +?> + + +'.__('Invalid date selected').''; + return; +} +?> diff --git a/pandora_console/godmode/reporting/reporting_builder.preview.php b/pandora_console/godmode/reporting/reporting_builder.preview.php index 8665044379..1726b7b45a 100644 --- a/pandora_console/godmode/reporting/reporting_builder.preview.php +++ b/pandora_console/godmode/reporting/reporting_builder.preview.php @@ -70,7 +70,7 @@ if ($report['description'] != '') { $table->data[0][1] = $report['name']; } $table->data[1][0] = __('Date'); -$table->data[1][1] = print_input_text ('date', $date, '', 10, 10, true). ' '; +$table->data[1][1] = print_input_text ('date', $date, '', 12, 10, true). ' '; $table->data[1][1] .= print_input_text ('time', $time, '', 7, 7, true). ' '; $table->data[1][1] .= print_submit_button (__('Update'), 'date_submit', false, 'class="sub next"', true); diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index f80b9733bd..57bc495bf9 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -82,8 +82,9 @@ function get_user_custom_graphs ($id_user = 0, $only_names = false) { * @param $period Period of time to get data in seconds. * @param $stacked Wheter the graph is stacked or not. * @param $return Whether to return an output string or echo now (optional, echo by default). + * @param $date Date to start printing the graph */ -function print_custom_graph ($id_graph, $height, $width, $period, $stacked, $return = false) { +function print_custom_graph ($id_graph, $height, $width, $period, $stacked, $return = false, $date = 0) { global $config; $sources = get_db_all_rows_field_filter ('tgraph_source', 'id_graph', $id_graph); @@ -102,11 +103,11 @@ function print_custom_graph ($id_graph, $height, $width, $period, $stacked, $ret if ($config['flash_charts']) { $output = graphic_combined_module ($modules, $weights, $period, $width, $height, - '', '', 0, 0, 0, $stacked); + '', '', 0, 0, 0, $stacked, $date); } else { $modules = implode (',', $modules); $weights = implode (',', $weights); - $output = ''; + $output = ''; } if ($return) diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php index 1011541200..9987668443 100644 --- a/pandora_console/operation/reporting/graph_viewer.php +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -76,6 +76,12 @@ if ($view_graph) { break; } } + + // Get different date to search the report. + $date = (string) get_parameter ('date', date ('Y-m-j')); + $time = (string) get_parameter ('time', date ('h:iA')); + $unixdate = strtotime ($date.' '.$time); + $period = (int) get_parameter ('period'); if (! $period) $period = $graph["period"]; @@ -111,12 +117,22 @@ if ($view_graph) { echo ""; echo "
"; - print_custom_graph ($id_graph, $height, $width, $period, $stacked); + print_custom_graph ($id_graph, $height, $width, $period, $stacked, false, $unixdate); echo "
"; $period_label = human_time_description ($period); echo "
"; echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo "
"; + echo "
"; + echo "".__('Date').""." "; + echo ""; + echo print_input_text ('date', $date, '', 12, 10, true). ' '; + echo ""; + echo print_input_text ('time', $time, '', 7, 7, true). ' '; + echo ""; echo "".__('Period').""; echo ""; @@ -150,6 +166,32 @@ if ($view_graph) { echo "
"; echo "
"; + /* We must add javascript here. Otherwise, the date picker won't + work if the date is not correct because php is returning. */ + + require_css_file ('datepicker'); + require_jquery_file ('ui.core'); + require_jquery_file ('ui.datepicker'); + require_jquery_file ('timeentry'); + ?> + + + '.__('Invalid date selected').''; + return; + } return; } diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 548da7896b..d8c4d6f78c 100644 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -80,7 +80,7 @@ if ($report['description'] != '') { $table->data[0][1] = $report['name']; } $table->data[1][0] = __('Date'); -$table->data[1][1] = print_input_text ('date', $date, '', 10, 10, true). ' '; +$table->data[1][1] = print_input_text ('date', $date, '', 12, 10, true). ' '; $table->data[1][1] .= print_input_text ('time', $time, '', 7, 7, true). ' '; $table->data[1][1] .= print_submit_button (__('Update'), 'date_submit', false, 'class="sub next"', true);