Added new item type in reports

This commit is contained in:
alejandro.campos@artica.es 2021-05-14 14:54:09 +02:00
parent 3a76d6e680
commit 1c1e25e712
4 changed files with 235 additions and 1 deletions

View File

@ -3020,6 +3020,144 @@ $class = 'databox filters';
<td><?php html_print_checkbox_switch('pagebreak', 1, $pagebreak); ?></td> <td><?php html_print_checkbox_switch('pagebreak', 1, $pagebreak); ?></td>
</tr> </tr>
<tr id="row_os" class="datos">
<td class="bolder">
<?php
echo __('OS');
?>
</td>
<td>
<?php
html_print_select_from_sql(
'SELECT id_os, name FROM tconfig_os',
'id_os',
$id_os,
'',
'',
'0'
);
?>
</td>
</tr>
<tr id="row_custom_field" class="datos">
<td class="bolder">
<?php
echo __('Custom field');
?>
</td>
<td >
<?php
echo html_print_input_text(
'label',
$label,
'',
50,
255,
true,
false,
false,
'',
'fullwidth'
);
?>
</td>
</tr>
<tr id="row_agent_status" class="datos">
<td class="bolder">
<?php
echo __('Agent status');
?>
</td>
<td>
<?php
$fields = [];
$fields[AGENT_STATUS_NORMAL] = __('Normal');
$fields[AGENT_STATUS_WARNING] = __('Warning');
$fields[AGENT_STATUS_CRITICAL] = __('Critical');
$fields[AGENT_STATUS_UNKNOWN] = __('Unknown');
$fields[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$fields[AGENT_STATUS_NOT_INIT] = __('Not init');
html_print_select(
$fields,
'users_groups[]',
[],
'',
false,
'',
false,
false,
false,
'',
false,
'min-width: 180px'
);
?>
</td>
</tr>
<tr id="row_agent_version" class="datos">
<td class="bolder">
<?php
echo __('Agent version');
?>
</td>
<td >
<?php
echo html_print_input_text(
'agent_version',
'',
'',
50,
255,
true,
false,
false,
'',
'fullwidth'
);
?>
</td>
</tr>
<tr id="row_agent_remote_conf" class="datos">
<td class="bolder">
<?php
echo __('Agent has remote configuration').ui_print_help_tip(
__('Filter by agents by remote configuration enabled or disabled.'),
true
);
?>
</td>
<td><?php html_print_checkbox_switch('agent_remote_conf', 1, false); ?></td>
</tr>
<tr id="row_module_free_search" class="datos">
<td class="bolder">
<?php
echo __('Module search');
?>
</td>
<td>
<?php
echo html_print_input_text(
'module_search',
'',
'',
50,
255,
true,
false,
false,
'',
'fullwidth'
);
?>
</td>
</tr>
</tbody> </tbody>
</table> </table>
@ -5223,6 +5361,12 @@ function chooseType() {
$("#row_users").hide(); $("#row_users").hide();
$("#row_profiles_group").hide(); $("#row_profiles_group").hide();
$("#row_select_by_group").hide(); $("#row_select_by_group").hide();
$("#row_os").hide();
$("#row_custom_field").hide();
$("#row_agent_status").hide();
$("#row_agent_version").hide();
$("#row_agent_remote_conf").hide();
$("#row_module_free_search").hide();
// SLA list default state. // SLA list default state.
@ -5764,6 +5908,17 @@ function chooseType() {
break; break;
case 'agents_inventory':
$("#row_group").show();
$("#row_os").show();
$("#row_custom_field").show();
$("#row_status").show();
$("#row_agent_version").show();
$("#row_agent_remote_conf").show();
$("#row_module_free_search").show();
break;
case 'inventory': case 'inventory':
$("#row_description").show(); $("#row_description").show();
$("#row_group").show(); $("#row_group").show();

View File

@ -734,6 +734,13 @@ function reporting_make_reporting_data(
); );
break; break;
case 'agents_inventory':
$report['contents'][] = reporting_agents_inventory(
$report,
$content
);
break;
case 'inventory': case 'inventory':
$report['contents'][] = reporting_inventory( $report['contents'][] = reporting_inventory(
$report, $report,
@ -2256,6 +2263,12 @@ function reporting_event_report_module(
} }
function reporting_agents_inventory($report, $content)
{
hd($content);
}
function reporting_inventory_changes($report, $content, $type) function reporting_inventory_changes($report, $content, $type)
{ {
global $config; global $config;

View File

@ -247,7 +247,7 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
} }
$table->colspan['description_row']['description'] = 3; $table->colspan['description_row']['description'] = 3;
hd($item['type']);
switch ($item['type']) { switch ($item['type']) {
case 'availability': case 'availability':
default: default:
@ -377,6 +377,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agent_module($table, $item); reporting_html_agent_module($table, $item);
break; break;
case 'agents_inventory':
reporting_html_agents_inventory($table, $item);
break;
case 'inventory': case 'inventory':
reporting_html_inventory($table, $item); reporting_html_inventory($table, $item);
break; break;
@ -1425,6 +1429,63 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
} }
/**
* Print in html agents inventory
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param boolean $pdf Print pdf true or false.
*
* @return html
*/
function reporting_html_agents_inventory($table, $item, $pdf=0)
{
hd('agents inventory');
hd($item);
global $config;
if (empty($item['data']) === false) {
$table_data = new stdClass();
$table_data->width = '100%';
$table_data->headstyle = [];
$table_data->headstyle[0] = 'text-align: left;';
$table_data->style = [];
$table_data->style[0] = 'text-align: left;';
$table_data->head = [
__('Name'),
__('Date'),
__('Data'),
__('Status'),
];
$table_data->data = [];
$table_data->data[1][0] = $item['data']['agent_name'];
$table_data->data[1][0] .= ' / ';
$table_data->data[1][0] .= $item['data']['module_name'];
$table_data->data[1][1] = date(
'Y-m-d H:i:s',
$item['data']['utimestamp']
);
}
if ($pdf === 0) {
$table->colspan['last_value']['cell'] = 3;
$table->cellstyle['last_value']['cell'] = 'text-align: center;';
$table->data['last_value']['cell'] = html_print_table(
$table_data,
true
);
} else {
return html_print_table(
$table_data,
true
);
}
}
/** /**
* Print in html inventory changes reports * Print in html inventory changes reports
* *

View File

@ -848,6 +848,11 @@ function reports_get_report_types($template=false, $not_editor=false)
'name' => __('Group event report'), 'name' => __('Group event report'),
]; ];
$types['agents_inventory'] = [
'optgroup' => __('Inventory'),
'name' => __('Agents inventory'),
];
if ($config['enterprise_installed']) { if ($config['enterprise_installed']) {
$types['inventory'] = [ $types['inventory'] = [
'optgroup' => __('Inventory'), 'optgroup' => __('Inventory'),