'.__('No agents selected').'';
return false;
}
if (empty ($id_alert_template)) {
echo '
'.__('No alert selected').'
';
return false;
}
foreach($module_names as $module){
foreach($id_agents as $id_agent) {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
}
}
if(count($module_names) == 1 && $module_names[0] == '0'){
$modules_id = agents_common_modules ($id_agents, false, true);
}
$conttotal = 0;
$contsuccess = 0;
foreach($modules_id as $module){
$success = alerts_create_alert_agent_module ($module, $id_alert_template);
if($success)
$contsuccess ++;
$conttotal ++;
}
if ($countSuccess > 0) {
db_pandora_audit("Masive management", "Add alert", false, false, "Alert template: " . $id_alert_template . " Modules: " . json_encode($modules_id));
}
else {
db_pandora_audit("Masive management", "Fail try to add alert", false, false, "Alert template: " . $id_alert_template . " Modules: " . json_encode($modules_id));
}
ui_print_result_message ($contsuccess > 0,
__('Successfully added')."(".$contsuccess."/".$conttotal.")",
__('Could not be added'));
}
$id_group = (int) get_parameter ('id_group', -1);
$id_agents = get_parameter ('id_agents');
$module_names = get_parameter ('module');
$id_alert_template = (int) get_parameter ('id_alert_template');
$add = (bool) get_parameter_post ('add');
if ($add) {
process_manage_add ($id_alert_template, $id_agents, $module_names);
}
$groups = get_user_groups ();
$table->id = 'add_table';
$table->width = '95%';
$table->data = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; vertical-align:top';
$table->style[2] = 'font-weight: bold; vertical-align:top';
$table->size = array ();
$table->size[0] = '15%';
$table->size[1] = '40%';
$table->size[2] = '15%';
$table->size[3] = '40%';
$table->data = array ();
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', 0,
'', 'Select', -1, true, false, true, '', false);
$table->data[0][2] = '';
$table->data[0][3] = '';
$table->data[1][0] = __('Agents');
$table->data[1][0] .= '';
$table->data[1][0] .= html_print_image('images/spinner.png', true);
$table->data[1][0] .= '';
$agents_alerts = alerts_get_agents_with_alert_template ($id_alert_template, $id_group,
false, array ('tagente.nombre', 'tagente.id_agente'));
$agents = agents_get_agents();
$table->data[1][1] = html_print_select (index_array ($agents, 'id_agente', 'nombre'),
'id_agents[]', '', '', '', '', true, true, true, '', false);
$table->data[1][2] = __('Modules');
$table->data[1][3] = html_print_select (array(), 'module[]', '', false, '', '', true, true, false);
$templates = alerts_get_alert_templates (false, array ('id', 'name'));
$table->data[2][0] = __('Alert template');
$table->data[2][1] = html_print_select (index_array ($templates, 'id', 'name'),
'id_alert_template', $id_alert_template, false, __('Select'), 0, true);
$table->data[2][2] = '';
$table->data[2][3] = '';
echo '';
echo '
';
//Hack to translate text "none" in PHP to javascript
echo '' . __('None') . '';
ui_require_jquery_file ('form');
ui_require_jquery_file ('pandora.controls');
?>