created new report item

This commit is contained in:
alejandro.campos@artica.es 2021-06-01 09:43:55 +02:00
parent 3362106afe
commit 9cbe6a2924
3 changed files with 88 additions and 46 deletions

View File

@ -3199,7 +3199,7 @@ $class = 'databox filters';
?> ?>
</td> </td>
</tr> </tr>
<?php hd($selected_agent_remote); ?>
<tr id="row_agent_remote_conf" class="datos"> <tr id="row_agent_remote_conf" class="datos">
<td class="bolder"> <td class="bolder">
<?php <?php

View File

@ -2266,7 +2266,7 @@ function reporting_event_report_module(
function reporting_agents_inventory($report, $content) function reporting_agents_inventory($report, $content)
{ {
global $config; global $config;
hd($content);
$return['name'] = $content['name']; $return['name'] = $content['name'];
$return['type'] = 'agents_inventory'; $return['type'] = 'agents_inventory';
$return['title'] = $content['name']; $return['title'] = $content['name'];
@ -2285,7 +2285,7 @@ function reporting_agents_inventory($report, $content)
$es_agent_group_filter = $external_source['agent_group_filter']; $es_agent_group_filter = $external_source['agent_group_filter'];
$es_users_groups = $external_source['users_groups']; $es_users_groups = $external_source['users_groups'];
$es_agent_remote_conf = $external_source['agent_remote_conf']; $es_agent_remote_conf = $external_source['agent_remote_conf'];
hd($es_agent_group_filter);
$search_sql = ''; $search_sql = '';
if ($es_custom_fields != '') { if ($es_custom_fields != '') {
@ -2301,24 +2301,23 @@ function reporting_agents_inventory($report, $content)
} }
if ($es_agent_version_filter != '') { if ($es_agent_version_filter != '') {
$search_sql .= ' AND tagente.agent_version = "'.$es_agent_version_filter.'"'; $search_sql .= ' AND tagente.agent_version LIKE "%'.$es_agent_version_filter.'%"';
} }
if ($es_agent_module_search_filter != '') { if ($es_agent_module_search_filter != '') {
$search_sql .= ' AND tam.nombre = '.$es_agent_module_search_filter; $search_sql .= ' AND tam.nombre LIKE "%'.$es_agent_module_search_filter.'%"';
} }
if ($es_agent_group_filter != 0) { if ($es_agent_group_filter != 0) {
$search_sql .= ' AND tagente.id_grupo = '.$es_agent_group_filter; $search_sql .= ' AND tagente.id_grupo = '.$es_agent_group_filter;
} }
hd($es_agent_remote); if ($es_agent_remote_conf != 0) {
if ($es_agent_remote_conf != '') {
$search_sql .= ' AND tagente.remote = '.$es_agent_remote_conf; $search_sql .= ' AND tagente.remote = '.$es_agent_remote_conf;
} }
$user_groups_to_sql = implode(',', array_keys(users_get_groups())); $user_groups_to_sql = implode(',', array_keys(users_get_groups()));
hd($search_sql);
$sql = sprintf( $sql = sprintf(
'SELECT DISTINCT(tagente.id_agente) AS id_agente, 'SELECT DISTINCT(tagente.id_agente) AS id_agente,
tagente.id_os, tagente.id_os,
@ -2347,6 +2346,20 @@ function reporting_agents_inventory($report, $content)
$search_sql $search_sql
); );
if (is_metaconsole()) {
$servers_ids = array_column(metaconsole_get_servers(), 'id');
} else {
$servers_ids = [0];
}
$return['data'] = [];
foreach ($servers_ids as $server_id) {
if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id($server_id);
metaconsole_connect($server);
}
$agents = db_get_all_rows_sql($sql); $agents = db_get_all_rows_sql($sql);
foreach ($agents as $key => $value) { foreach ($agents as $key => $value) {
@ -2389,7 +2402,12 @@ function reporting_agents_inventory($report, $content)
} }
} }
$return['data'] = $agents; $return['data'] = array_merge($return['data'], $agents);
if (is_metaconsole()) {
metaconsole_restore_db();
}
}
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }

View File

@ -1541,6 +1541,26 @@ function reporting_html_agents_inventory($table, $item, $pdf=0)
$column_value = ui_print_module_status((int) $data_field_value, true); $column_value = ui_print_module_status((int) $data_field_value, true);
} else if ($data_field_key === 'id_grupo') { } else if ($data_field_key === 'id_grupo') {
$column_value = ui_print_group_icon((int) $data_field_value, true); $column_value = ui_print_group_icon((int) $data_field_value, true);
} else if ($data_field_key === 'custom_fields') {
$custom_fields_value = [];
if (is_array($data_field_value)) {
foreach ($data_field_value as $value) {
$custom_fields_value[] = $value['name'].': '.$value['description'];
}
}
$column_value = implode(' / ', $custom_fields_value);
} else if ($data_field_key === 'secondary_groups') {
$custom_fields_value = [];
if (is_array($data_field_value)) {
foreach ($data_field_value as $value) {
$custom_fields_value[] = ui_print_group_icon((int) $value['id_group'], true);
}
}
$column_value = implode(' / ', $custom_fields_value);
} }
$row[] = $column_value; $row[] = $column_value;
@ -1553,6 +1573,8 @@ function reporting_html_agents_inventory($table, $item, $pdf=0)
} }
} }
hd('======', true);
hd($pdf, true);
if ($pdf === 0) { if ($pdf === 0) {
$table->colspan['permissions']['cell'] = 3; $table->colspan['permissions']['cell'] = 3;
$table->cellstyle['permissions']['cell'] = 'text-align: center;'; $table->cellstyle['permissions']['cell'] = 'text-align: center;';
@ -5903,6 +5925,8 @@ function reporting_html_permissions($table, $item, $pdf=0)
} }
} }
// hd("lllllp", true);
// hd($pdf, true);
if ($pdf === 0) { if ($pdf === 0) {
$table->colspan['permissions']['cell'] = 3; $table->colspan['permissions']['cell'] = 3;
$table->cellstyle['permissions']['cell'] = 'text-align: center;'; $table->cellstyle['permissions']['cell'] = 'text-align: center;';