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
This commit is contained in:
parent
d7882076ff
commit
ccf3ef7205
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue