From 2f595926571a02919910dc47b9c5a7ff08169496 Mon Sep 17 00:00:00 2001 From: mdtrooper <tres.14159@gmail.com> Date: Thu, 22 Apr 2010 18:50:00 +0000 Subject: [PATCH] 2010-04-22 Miguel de Dios <miguel.dedios@artica.es> * 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". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2594 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++++ pandora_console/include/javascript/pandora.js | 45 +++++++++++++++++++ .../operation/agentes/ver_agente.php | 15 +++++++ 3 files changed, 69 insertions(+) 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 <miguel.dedios@artica.es> + + * 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 <miguel.dedios@artica.es> * 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 <option val="NNN"></option> + idAgents.push($(val).val()); + }); + + $('#module').attr ('disabled', 1); + $('#module').empty (); + $('#module').append ($('<option></option>').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 ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true)); + } + else { + $('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true)); + } + jQuery.each (data, function (i, val) { + s = js_html_entity_decode(val); + $('#module').append ($('<option></option>').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');