Merge branch 'ent-7915-Error-SQL-en-filtro-de-custom-field-en-informe-de-inventario-de-agentes' into 'develop'
Ent 7915 error sql en filtro de custom field en informe de inventario de agentes See merge request artica/pandorafms!4375
This commit is contained in:
commit
f12f3d6cf4
|
@ -748,6 +748,7 @@ switch ($action) {
|
|||
$selected_agent_group_filter = $es['agent_group_filter'];
|
||||
$selected_agents_inventory_display_options = $es['agents_inventory_display_options'];
|
||||
$selected_agent_os_filter = $es['agent_os_filter'];
|
||||
$selected_agent_custom_fields = $es['agent_custom_fields'];
|
||||
$selected_agent_custom_field_filter = $es['agent_custom_field_filter'];
|
||||
$selected_agent_status_filter = $es['agent_status_filter'];
|
||||
$selected_agent_module_search_filter = $es['agent_module_search_filter'];
|
||||
|
@ -3158,6 +3159,28 @@ $class = 'databox filters';
|
|||
</tr>
|
||||
|
||||
<tr id="row_custom_field" class="datos">
|
||||
<td class="bolder">
|
||||
<?php
|
||||
echo __('Agent custom field');
|
||||
?>
|
||||
</td>
|
||||
<td >
|
||||
<?php
|
||||
html_print_select_from_sql(
|
||||
'SELECT id_field, name FROM tagent_custom_fields',
|
||||
'agent_custom_fields[]',
|
||||
$selected_agent_custom_fields,
|
||||
'',
|
||||
__('All'),
|
||||
'0',
|
||||
false,
|
||||
true
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_custom_field_filter" class="datos">
|
||||
<td class="bolder">
|
||||
<?php
|
||||
echo __('Agent custom field filter');
|
||||
|
@ -5485,6 +5508,7 @@ function chooseType() {
|
|||
$("#row_agent_server_filter").hide();
|
||||
$("#row_agent_group_filter").hide();
|
||||
$("#row_os").hide();
|
||||
$("#row_custom_field_filter").hide();
|
||||
$("#row_custom_field").hide();
|
||||
$("#row_agent_status").hide();
|
||||
$("#row_agent_version").hide();
|
||||
|
@ -6038,11 +6062,26 @@ function chooseType() {
|
|||
$("#row_group").show();
|
||||
$("#row_os").show();
|
||||
$("#row_custom_field").show();
|
||||
$("#row_custom_field_filter").show();
|
||||
$("#row_agent_status").show();
|
||||
$("#row_agent_version").show();
|
||||
$("#row_agent_remote_conf").show();
|
||||
$("#row_module_free_search").show();
|
||||
|
||||
if ($('#agent_custom_fields :selected').length > 0) {
|
||||
$('#text-agent_custom_field_filter').removeAttr('disabled');
|
||||
} else {
|
||||
$('#text-agent_custom_field_filter').prop('disabled', true);
|
||||
}
|
||||
|
||||
$("#agent_custom_fields").change(function(e) {
|
||||
if ($('#agent_custom_fields :selected').length > 0) {
|
||||
$('#text-agent_custom_field_filter').removeAttr('disabled');
|
||||
} else {
|
||||
$('#text-agent_custom_field_filter').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case 'inventory':
|
||||
|
|
|
@ -2219,6 +2219,7 @@ switch ($action) {
|
|||
$es['agents_inventory_display_options'] = get_parameter('agents_inventory_display_options');
|
||||
$es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter');
|
||||
$es['agent_os_filter'] = get_parameter('agent_os_filter');
|
||||
$es['agent_custom_fields'] = get_parameter('agent_custom_fields');
|
||||
$es['agent_status_filter'] = get_parameter('agent_status_filter');
|
||||
$es['agent_version_filter'] = get_parameter('agent_version_filter');
|
||||
$es['agent_module_search_filter'] = get_parameter('agent_module_search_filter');
|
||||
|
@ -2858,6 +2859,7 @@ switch ($action) {
|
|||
$es['agents_inventory_display_options'] = get_parameter('agents_inventory_display_options');
|
||||
$es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter');
|
||||
$es['agent_os_filter'] = get_parameter('agent_os_filter');
|
||||
$es['agent_custom_fields'] = get_parameter('agent_custom_fields');
|
||||
$es['agent_status_filter'] = get_parameter('agent_status_filter');
|
||||
$es['agent_version_filter'] = get_parameter('agent_version_filter');
|
||||
$es['agent_module_search_filter'] = get_parameter('agent_module_search_filter');
|
||||
|
|
|
@ -2285,6 +2285,7 @@ function reporting_agents_inventory($report, $content)
|
|||
|
||||
$external_source = io_safe_input(json_decode($content['external_source'], true));
|
||||
$es_agents_inventory_display_options = $external_source['agents_inventory_display_options'];
|
||||
$es_agent_custom_fields = $external_source['agent_custom_fields'];
|
||||
$es_custom_fields = $external_source['agent_custom_field_filter'];
|
||||
$es_os_filter = $external_source['agent_os_filter'];
|
||||
$es_agent_status_filter = $external_source['agent_status_filter'];
|
||||
|
@ -2299,10 +2300,20 @@ function reporting_agents_inventory($report, $content)
|
|||
$es_agents_inventory_display_options = [];
|
||||
}
|
||||
|
||||
$custom_field_sql = '';
|
||||
$search_sql = '';
|
||||
|
||||
if ($es_custom_fields != '') {
|
||||
$search_sql .= ' AND id_os = '.$es_custom_fields;
|
||||
if (!empty($es_agent_custom_fields)) {
|
||||
$custom_field_sql = 'INNER JOIN tagent_custom_data tacd ON tacd.id_agent = tagente.id_agente';
|
||||
if ($es_agent_custom_fields[0] != 0) {
|
||||
$custom_field_sql .= ' AND tacd.id_field IN ('.implode(',', $es_agent_custom_fields).')';
|
||||
}
|
||||
|
||||
if (!empty($es_custom_fields)) {
|
||||
$custom_field_sql .= ' AND tacd.description like "%'.$es_custom_fields.'%"';
|
||||
} else {
|
||||
$custom_field_sql .= ' AND tacd.description <> ""';
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('0', $es_os_filter) === false) {
|
||||
|
@ -2341,8 +2352,10 @@ function reporting_agents_inventory($report, $content)
|
|||
ON tagente.id_agente = tasg.id_agent
|
||||
LEFT JOIN tagente_modulo tam
|
||||
ON tam.id_agente = tagente.id_agente
|
||||
%s
|
||||
WHERE (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s))
|
||||
%s',
|
||||
$custom_field_sql,
|
||||
$user_groups_to_sql,
|
||||
$user_groups_to_sql,
|
||||
$search_sql
|
||||
|
|
Loading…
Reference in New Issue