diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 40fe1f18fc..d642b33909 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2010-04-22 Miguel de Dios + + * include/javascript/pandora.js: added function + "agent_changed_by_multiple_agents" for query ajax with one or more agent + select. + + * operation/agentes/ver_agente.php: added ajax response to + "get_agent_modules_json_for_multiple_agents". + 2010-04-22 Miguel de Dios * include/javascript/tiny_mce/*: re-added (lost files) js library (BSD) for diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 37347ab12e..e90e1e2658 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -96,6 +96,51 @@ function agent_changed (event, id_agent, selected) { ); } +/** + * Fill up select box with id "module" with modules after agent has been selected, but this not empty the select box.s + * + * @param event that has been triggered + * @param id_agent Agent ID that has been selected + * @param selected Which module(s) have to be selected + */ +function agent_changed_by_multiple_agents (event, id_agent, selected) { + var idAgents = Array(); + + jQuery.each ($("#id_agents option:selected"), function (i, val) { + //val() because the var is same + idAgents.push($(val).val()); + }); + + $('#module').attr ('disabled', 1); + $('#module').empty (); + $('#module').append ($('').html ("Loading...").attr ("value", 0)); + jQuery.post ('ajax.php', + {"page": "operation/agentes/ver_agente", + "get_agent_modules_json_for_multiple_agents": 1, + "id_agent[]": idAgents + }, + function (data) { + $('#module').empty (); + + if (typeof($(document).data('text_for_module')) != 'undefined') { + $('#module').append ($('').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true)); + } + else { + $('#module').append ($('').html (data['any_text']).attr ("value", 0).attr('selected', true)); + } + jQuery.each (data, function (i, val) { + s = js_html_entity_decode(val); + $('#module').append ($('').html (s).attr ("value", val)); + $('#module').fadeIn ('normal'); + }); + if (selected != undefined) + $('#module').attr ('value', selected); + $('#module').attr ('disabled', 0); + }, + "json" + ); +} + /** * Autocomplete Agent box and module selector functions. diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index d848bea651..4e49e34b92 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -31,6 +31,7 @@ if (is_ajax ()) { $get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json'); $get_agent_status_tooltip = (bool) get_parameter ("get_agent_status_tooltip"); $get_agents_group_json = (bool) get_parameter ("get_agents_group_json"); + $get_agent_modules_json_for_multiple_agents = (bool) get_parameter("get_agent_modules_json_for_multiple_agents"); if ($get_agents_group_json) { $id_group = get_parameter('id_group'); @@ -49,6 +50,20 @@ if (is_ajax ()) { echo json_encode ($agent); return; } + + if ($get_agent_modules_json_for_multiple_agents) { + $idAgents = get_parameter('id_agent'); + + $nameModules = get_db_all_rows_sql('SELECT DISTINCT(nombre) FROM tagente_modulo WHERE id_agente IN (' . implode(',', $idAgents) . ')'); + + $result = array(); + foreach($nameModules as $nameModule) { + $result[] = $nameModule['nombre']; + } + + echo json_encode($result); + return; + } if ($get_agent_modules_json) { $id_agent = (int) get_parameter ('id_agent');