Merge branch '851-new-report-type-max+min+avg-dev' into 'develop'

851 new report type max+min+avg dev

See merge request !463
This commit is contained in:
vgilc 2017-06-07 15:00:45 +02:00
commit 2ec69160e3
4 changed files with 101 additions and 40 deletions

View File

@ -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'];
@ -1480,6 +1483,20 @@ You can of course remove the warnings, that's why we include the source and do n
<td style="font-weight:bold;"><?php echo __('Show in two columns');?></td>
<td><?php html_print_checkbox('show_in_two_columns', 1, $show_in_two_columns);?></td>
</tr>
<tr id="row_show_in_same_row" style="" class="datos">
<td style="font-weight:bold;" class="datos">
<?php
echo __('Show in the same row');
ui_print_help_tip(__('Show one module per row with all its operations'));
?>
</td>
<td style="">
<?php
html_print_checkbox('show_in_same_row', '1', $show_in_same_row, false, false, '');
?>
</td>
</tr>
<tr id="row_sort" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Order') . ui_print_help_tip(__('SLA items sorted by fulfillment value'), true);?></td>
@ -2591,6 +2608,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_historical_db_check").hide();
$("#row_show_in_landscape").hide();
$('#row_hide_notinit_agents').hide();
@ -3025,6 +3043,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");

View File

@ -1140,6 +1140,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);
@ -1461,6 +1462,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);

View File

@ -5473,9 +5473,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'];
@ -5503,6 +5502,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(
@ -5696,8 +5696,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]) {

View File

@ -2578,46 +2578,85 @@ 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');
/* 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 {
$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();
@ -2635,9 +2674,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];
}
@ -3866,4 +3905,4 @@ function reporting_html_planned_downtimes_table ($planned_downtimes) {
return $downtimes_table;
}
?>
?>