diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php
index 791f09d2ab..7b507c578f 100644
--- a/pandora_console/godmode/agentes/agent_manager.php
+++ b/pandora_console/godmode/agentes/agent_manager.php
@@ -659,6 +659,13 @@ ui_require_jquery_file('bgiframe');
return
}
+ // On agent creation PHP will update the secondary groups table (not via AJAX)
+ if (id_agent == 0) {
+ agent_manager_add_secondary_groups_ui();
+ agent_manager_update_hidden_input_secondary();
+ return;
+ }
+
var selected_items = new Array();
$("#secondary_groups option:selected").each(function(){
selected_items.push($(this).val())
@@ -679,11 +686,7 @@ ui_require_jquery_file('bgiframe');
data: data,
success: function (data) {
if (data == 1) {
- // Move from one input to the other
- $("#secondary_groups_selected option[value=0]").remove()
- $("#secondary_groups option:selected").each(function() {
- $(this).remove().appendTo("#secondary_groups_selected")
- })
+ agent_manager_add_secondary_groups_ui();
} else {
console.error("Error in AJAX call to add secondary groups")
}
@@ -697,6 +700,13 @@ ui_require_jquery_file('bgiframe');
function agent_manager_remove_secondary_groups (event, id_agent) {
event.preventDefault();
+ // On agent creation PHP will update the secondary groups table (not via AJAX)
+ if (id_agent == 0) {
+ agent_manager_remove_secondary_groups_ui();
+ agent_manager_update_hidden_input_secondary();
+ return;
+ }
+
var selected_items = new Array();
$("#secondary_groups_selected option:selected").each(function(){
selected_items.push($(this).val())
@@ -717,18 +727,7 @@ ui_require_jquery_file('bgiframe');
data: data,
success: function (data) {
if (data == 1) {
- // Remove the groups selected if success
- $("#secondary_groups_selected option:selected").each(function(){
- $(this).remove().appendTo("#secondary_groups")
- })
-
- // Add none if empty select
- if ($("#secondary_groups_selected option").length == 0) {
- $("#secondary_groups_selected").append($('