Added new general table view to html

This commit is contained in:
Arturo Gonzalez 2017-05-11 14:00:59 +02:00
parent 46e16f65ea
commit 77a563eb29
4 changed files with 101 additions and 43 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'];
@ -1468,6 +1471,20 @@ You can of course remove the warnings, that's why we include the source and do n
<td><?php html_print_checkbox('show_in_two_columns', 1, $show_in_two_columns, false,
false, 'if ($(\'input[name=show_in_two_columns]\').is(\':checked\')) $(\'input[name=show_in_landscape]\').attr(\'checked\', false);');?></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>
@ -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");

View File

@ -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);

View File

@ -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]) {

View File

@ -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];
}