fixed error in view agent/module
This commit is contained in:
parent
5db7f93b53
commit
bf29d4c5f9
|
@ -148,19 +148,18 @@ function mainAgentsModules() {
|
|||
$agents = agents_get_group_agents($group_id);
|
||||
if ((empty($agents)) || $agents == -1) $agents = array();
|
||||
$filter_agents_label = '<b>'.__('Agents').'</b>';
|
||||
$filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, "min-width: 180px");
|
||||
$filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, "min-width: 180px; max-width: 200px;");
|
||||
|
||||
//type show
|
||||
$selection = array(0 => __('Show common modules'),
|
||||
1=> __('Show all modules'));
|
||||
$filter_type_show_label = '<b>'.__('Show common modules').'</b>';
|
||||
$filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', "", 0, true, false, true, '', false, "min-width: 180px");
|
||||
$filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', "", 0, true, false, true, '', false, "min-width: 180px;");
|
||||
|
||||
//modules
|
||||
$all_modules = db_get_all_rows_sql("SELECT DISTINCT nombre, id_agente_modulo FROM tagente_modulo WHERE id_agente IN (" . implode(',', array_keys($agents)) . ")");
|
||||
|
||||
$all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false);
|
||||
$filter_modules_label = '<b>'.__('Module').'</b>';
|
||||
$filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', __('None'), 0, true, true, true, '', false, "min-width: 180px");
|
||||
$filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, true, '', false, "min-width: 180px; max-width: 200px;");
|
||||
|
||||
//update
|
||||
$filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true);
|
||||
|
@ -618,7 +617,6 @@ extensions_add_main_function('mainAgentsModules');
|
|||
);
|
||||
});
|
||||
|
||||
selection_agent_module();
|
||||
});
|
||||
|
||||
function selection_agent_module() {
|
||||
|
@ -643,4 +641,4 @@ extensions_add_main_function('mainAgentsModules');
|
|||
"json"
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</script>
|
|
@ -2522,4 +2522,79 @@ function agents_get_agent_custom_field ($agent_id, $custom_field_name) {
|
|||
return db_get_value_sql($sql);
|
||||
}
|
||||
|
||||
function select_modules_for_agent_group($id_group, $id_agents, $selection, $return=true){
|
||||
$agents = implode(",", $id_agents);
|
||||
|
||||
$filter_group = "";
|
||||
$filter_agent = "";
|
||||
|
||||
if ($id_group != 0) {
|
||||
$filter_group = " AND id_module_group = ". $id_group;
|
||||
}
|
||||
if ($agents != null) {
|
||||
$filter_agent = " AND id_agente IN (" . $agents . ")";
|
||||
}
|
||||
|
||||
if ($selection == 1 || (count($id_agents) == 1)) {
|
||||
$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();
|
||||
|
||||
$found = array();
|
||||
foreach ($modules as $i=>$row) {
|
||||
$check = $row['nombre'];
|
||||
if (@$found[$check]++) {
|
||||
unset($modules[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$modules = db_get_all_rows_sql("SELECT nombre, id_agente_modulo FROM tagente_modulo WHERE 1 = 1" . $filter_agent . $filter_group);
|
||||
|
||||
if (empty($modules)) $modules = array();
|
||||
|
||||
foreach ($modules as $m) {
|
||||
$is_in_all_agents = true;
|
||||
$module_name = modules_get_agentmodule_name($m['id_agente_modulo']);
|
||||
foreach ($id_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) {
|
||||
$is_in_all_agents = false;
|
||||
}
|
||||
}
|
||||
if ($is_in_all_agents) {
|
||||
$modules_to_report[] = $m;
|
||||
}
|
||||
}
|
||||
$modules = $modules_to_report;
|
||||
|
||||
$found = array();
|
||||
if (is_array($modules) || is_object($modules)){
|
||||
foreach ($modules as $i=>$row) {
|
||||
$check = $row['nombre'];
|
||||
if (@$found[$check]++) {
|
||||
unset($modules[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($modules) || is_object($modules)){
|
||||
foreach ($modules as $k => $v) {
|
||||
$modules[$k] = io_safe_output($v);
|
||||
}
|
||||
}
|
||||
|
||||
if($return == false){
|
||||
foreach ($modules as $value) {
|
||||
$modules_array[$value['id_agente_modulo']] = $value['nombre'];
|
||||
}
|
||||
return $modules_array;
|
||||
}
|
||||
else{
|
||||
echo json_encode($modules);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -126,71 +126,8 @@ if (is_ajax ()) {
|
|||
$id_group = (int) get_parameter('id_module_group');
|
||||
$id_agents = get_parameter('id_agents');
|
||||
$selection = get_parameter('selection');
|
||||
if(isset($id_agents)){
|
||||
$agents = implode(",", $id_agents);
|
||||
}
|
||||
|
||||
$filter_group = "";
|
||||
$filter_agent = "";
|
||||
|
||||
if ($id_group != 0) {
|
||||
$filter_group = " AND id_module_group = ". $id_group;
|
||||
}
|
||||
if ($agents != null) {
|
||||
$filter_agent = " AND id_agente IN (" . $agents . ")";
|
||||
}
|
||||
|
||||
if ($selection == 1 || (count($id_agents) == 1)) {
|
||||
$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();
|
||||
|
||||
$found = array();
|
||||
foreach ($modules as $i=>$row) {
|
||||
$check = $row['nombre'];
|
||||
if (@$found[$check]++) {
|
||||
unset($modules[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$modules = db_get_all_rows_sql("SELECT nombre, id_agente_modulo FROM tagente_modulo WHERE 1 = 1" . $filter_agent . $filter_group);
|
||||
|
||||
if (empty($modules)) $modules = array();
|
||||
|
||||
foreach ($modules as $m) {
|
||||
$is_in_all_agents = true;
|
||||
$module_name = modules_get_agentmodule_name($m['id_agente_modulo']);
|
||||
foreach ($id_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) {
|
||||
$is_in_all_agents = false;
|
||||
}
|
||||
}
|
||||
if ($is_in_all_agents) {
|
||||
$modules_to_report[] = $m;
|
||||
}
|
||||
}
|
||||
$modules = $modules_to_report;
|
||||
|
||||
$found = array();
|
||||
if (is_array($modules) || is_object($modules)){
|
||||
foreach ($modules as $i=>$row) {
|
||||
$check = $row['nombre'];
|
||||
if (@$found[$check]++) {
|
||||
unset($modules[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($modules) || is_object($modules)){
|
||||
foreach ($modules as $k => $v) {
|
||||
$modules[$k] = io_safe_output($v);
|
||||
}
|
||||
}
|
||||
echo json_encode($modules);
|
||||
return;
|
||||
select_modules_for_agent_group($id_group, $id_agents, $selection);
|
||||
}
|
||||
|
||||
if ($get_agent_json) {
|
||||
|
|
Loading…
Reference in New Issue