From 77a563eb299bf7ca3070b78e72716a12ce342f2f Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 11 May 2017 14:00:59 +0200 Subject: [PATCH 1/2] Added new general table view to html --- .../reporting_builder.item_editor.php | 19 +++ .../godmode/reporting/reporting_builder.php | 2 + .../include/functions_reporting.php | 9 +- .../include/functions_reporting_html.php | 114 ++++++++++++------ 4 files changed, 101 insertions(+), 43 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 2e974b85fe..d303802475 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -120,6 +120,7 @@ switch ($action) { $description = null; $sql = null; $show_in_two_columns = 0; + $show_in_same_row = 0; $show_in_landscape = 0; $hide_notinit_agents = 0; $server_name = ''; @@ -158,6 +159,7 @@ switch ($action) { $description = null; $sql = null; $show_in_two_columns = 0; + $show_in_same_row = 0; $show_in_landscape = 0; $hide_notinit_agents = 0; $server_name = ''; @@ -182,6 +184,7 @@ switch ($action) { $style = json_decode(io_safe_output($item['style']), true); + $show_in_same_row = $style['show_in_same_row']; $show_in_two_columns = $style['show_in_two_columns']; $show_in_landscape = $style['show_in_landscape']; $hide_notinit_agents = $style['hide_notinit_agents']; @@ -1468,6 +1471,20 @@ You can of course remove the warnings, that's why we include the source and do n + + + + + + + + + @@ -2579,6 +2596,7 @@ function chooseType() { $("#row_exception_condition_value").hide(); $("#row_exception_condition").hide(); $("#row_show_in_two_columns").hide(); + $("#row_show_in_same_row").hide(); $("#row_show_in_landscape").hide(); $('#row_hide_notinit_agents').hide(); $("#row_module_group").hide(); @@ -2976,6 +2994,7 @@ function chooseType() { $("#row_order_uptodown").show(); $("#row_show_resume").show(); $("#row_show_in_two_columns").show(); + $("#row_show_in_same_row").show(); var checked = $("input[name='last_value']").prop("checked"); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 8bc38bdc78..b55741d45c 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1139,6 +1139,7 @@ switch ($action) { $style = array(); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); + $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); @@ -1459,6 +1460,7 @@ switch ($action) { $style = array(); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); + $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3d05c2099f..1b852c8b83 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -5471,9 +5471,8 @@ function reporting_availability_graph($report, $content, $pdf=false) { * */ function reporting_general($report, $content) { - global $config; - + $return = array(); $return['type'] = 'general'; $return['subtype'] = $content['group_by_agent']; @@ -5501,6 +5500,7 @@ function reporting_general($report, $content) { $return["max"]["formated_value"] = null; $return["max"]["agent"] = null; $return["max"]["module"] = null; + $return["show_in_same_row"] = $content['style']['show_in_same_row']; if (empty($content['subitems'])) { $generals = db_get_all_rows_filter( @@ -5692,8 +5692,9 @@ function reporting_general($report, $content) { $data = array(); $data['agent'] = $agent_name[$i]; $data['module'] = $module_name[$i]; - - + $data['id_agent_module'] = $id_agent_module[$i]; + $data['id_agent'] = agents_get_agent_id_by_module_id($id_agent_module[$i]); + $data['operator'] = ""; if ($content['period'] != 0) { switch ($operations[$i]) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index f6acad7fbe..a05f297312 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2578,50 +2578,86 @@ function get_agent_first_time ($agent_name) { } function reporting_html_general(&$table, $item) { - if (!empty($item["data"])) { + $data_in_same_row = $item['show_in_same_row']; switch ($item['subtype']) { case REPORT_GENERAL_NOT_GROUP_BY_AGENT: - $table1 = new stdClass(); - $table1->width = '99%'; - $table1->data = array (); - $table1->head = array (); - $table1->head[0] = __('Agent'); - $table1->head[1] = __('Module'); - if ($item['date']['period'] != 0) { - $table1->head[2] = __('Operation'); - } - $table1->head[3] = __('Value'); - $table1->style[0] = 'text-align: left'; - $table1->style[1] = 'text-align: left'; - $table1->style[2] = 'text-align: left'; - $table1->style[3] = 'text-align: left'; - - /* Begin - Order by agent */ - - foreach ($item['data'] as $key => $row) { - $aux[$key] = $row['agent']; - } - - array_multisort($aux, SORT_ASC, $item['data']); - - /* End - Order by agent */ - - foreach ($item['data'] as $row) { + if (!$data_in_same_row) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); if ($item['date']['period'] != 0) { - $table1->data[] = array( - $row['agent'], - $row['module'], - $row['operator'], - $row['formated_value']); + $table1->head[2] = __('Operation'); } - else { - $table1->data[] = array( - $row['agent'], - $row['module'], - $row['formated_value']); + $table1->head[3] = __('Value'); + $table1->style[0] = 'text-align: left'; + $table1->style[1] = 'text-align: left'; + $table1->style[2] = 'text-align: left'; + $table1->style[3] = 'text-align: left'; + + /* Begin - Order by agent */ + + foreach ($item['data'] as $key => $row) { + $aux[$key] = $row['agent']; + } + + array_multisort($aux, SORT_ASC, $item['data']); + + /* End - Order by agent */ + + foreach ($item['data'] as $row) { + if ($item['date']['period'] != 0) { + $table1->data[] = array( + $row['agent'], + $row['module'], + $row['operator'], + $row['formated_value']); + } + else { + $table1->data[] = array( + $row['agent'], + $row['module'], + $row['formated_value']); + } } } + else { + //html_debug($item['data']); + $order_data = array(); + foreach ($item['data'] as $row) { + $order_data[$row['id_agent']][$row['id_agent_module']][$row['operator']] = $row['formated_value']; + } + + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); + $table1->head[2] = __('Avg'); + $table1->head[3] = __('Max'); + $table1->head[4] = __('Min'); + $table1->style[0] = 'text-align: center'; + $table1->style[1] = 'text-align: center'; + $table1->style[2] = 'text-align: center'; + $table1->style[3] = 'text-align: center'; + $table1->style[4] = 'text-align: center'; + + foreach ($order_data as $id_agent => $row) { + foreach ($row as $id_module => $row2) { + $table1->data[] = array( + agents_get_alias($id_agent), + modules_get_agentmodule_name($id_module), + $row2['Rate'], + $row2['Maximum'], + $row2['Minimum']); + } + } + } + break; case REPORT_GENERAL_GROUP_BY_AGENT: $list_modules = array(); @@ -2639,9 +2675,9 @@ function reporting_html_general(&$table, $item) { $row = array(); $row['agent'] = $agent; - $table1->style['agent'] = 'text-align: left;'; + $table1->style['agent'] = 'text-align: center;'; foreach ($list_modules as $name) { - $table1->style[$name] = 'text-align: right;'; + $table1->style[$name] = 'text-align: center;'; if (isset($modules[$name])) { $row[$name] = $modules[$name]; } From 8653b8530c7dc86a40737d78e9e7d51b2d5ff5a1 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 11 May 2017 15:12:38 +0200 Subject: [PATCH 2/2] Removed trace --- pandora_console/include/functions_reporting_html.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index a05f297312..16a83b6526 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2625,7 +2625,6 @@ function reporting_html_general(&$table, $item) { } } else { - //html_debug($item['data']); $order_data = array(); foreach ($item['data'] as $row) { $order_data[$row['id_agent']][$row['id_agent_module']][$row['operator']] = $row['formated_value'];