Added some things to agent_module report. Ticket #4183

This commit is contained in:
Arturo Gonzalez 2016-12-22 11:35:45 +01:00
parent 907ba03b1a
commit c3480f6c04
4 changed files with 47 additions and 11 deletions

View File

@ -1014,11 +1014,9 @@ You can of course remove the warnings, that's why we include the source and do n
<td style="font-weight:bold;"><?php echo __('Modules'); ?></td>
<td>
<?php
$all_modules = array();
foreach ($module as $id_modul) {
$all_modules[] = modules_get_agentmodule_name($id_modul);
}
html_print_select($all_modules, 'module[]', $module, $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
$all_modules = db_get_all_rows_sql("SELECT DISTINCT nombre, id_agente_modulo FROM tagente_modulo WHERE id_agente IN (" . implode(',', array_keys($agents)) . ")");
html_print_select($all_modules, 'module[]', "", $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
?>
</td>
</tr>
@ -1881,7 +1879,7 @@ $(document).ready (function () {
{"page" : "operation/agentes/ver_agente",
"get_modules_group_json" : 1,
"id_module_group" : this.value,
"id_agents" : $("#id_agents").val()
"id_agents" : $("#id_agents2").val()
},
function (data, status) {
$("#module").html('');

View File

@ -950,8 +950,12 @@ switch ($action) {
$good_format = true;
break;
case 'agent_module':
$es['id_agents'] = get_parameter('id_agents2');
$es['module'] = get_parameter('module', "");
$agents_to_report = get_parameter('id_agents2');
$modules_to_report = get_parameter('module', "");
$es['module'] = get_same_modules($agents_to_report, $modules_to_report);
$es['id_agents'] = $agents_to_report;
$values['external_source'] = json_encode($es);
$good_format = true;
break;
@ -1270,8 +1274,12 @@ switch ($action) {
$good_format = true;
break;
case 'agent_module':
$es['id_agents'] = get_parameter('id_agents');
$es['module'] = get_parameter('module', "");
$agents_to_report = get_parameter('id_agents2');
$modules_to_report = get_parameter('module', "");
$es['module'] = get_same_modules($agents_to_report, $modules_to_report);
$es['id_agents'] = $agents_to_report;
$values['external_source'] = json_encode($es);
$good_format = true;
break;

View File

@ -2480,4 +2480,25 @@ function modules_get_modules_name ($sql_from , $sql_conditions = '', $meta = fal
}
}
function get_same_modules ($agents, $modules) {
$modules_to_report = array();
if ($modules != "") {
foreach ($modules as $m) {
$module_name = modules_get_agentmodule_name($m);
foreach ($agents as $a) {
$module_in_agent = db_get_value_filter('id_agente_modulo',
'tagente_modulo', array('id_agente' => $a, 'nombre' => $module_name));
if ($module_in_agent) {
$modules_to_report[] = $module_in_agent;
}
}
}
}
$modules_to_report = array_merge($modules_to_report, $modules);
$modules_to_report = array_unique($modules_to_report);
return $modules_to_report;
}
?>

View File

@ -137,10 +137,19 @@ if (is_ajax ()) {
$filter_agent = " AND id_agente IN (" . $agents . ")";
}
$modules = db_get_all_rows_sql("SELECT nombre, id_agente_modulo FROM tagente_modulo WHERE 1 = 1" . $filter_agent . $filter_group);
$modules = db_get_all_rows_sql("SELECT DISTINCT nombre, id_agente_modulo FROM tagente_modulo WHERE 1 = 1" . $filter_agent . $filter_group);
if (empty($modules)) $modules = array();
foreach ($modules as $k => $v) {
for ($j = $k + 1; $j <= sizeof($modules); $j++) {
if ($modules[$j]['nombre'] == $v['nombre']) {
unset($modules[$j]);
}
}
}
foreach ($modules as $k => $v) {
$modules[$k] = io_safe_output($v);
}