diff --git a/pandora_console/extensions/agents_alerts.php b/pandora_console/extensions/agents_alerts.php
index 5e8da46aaa..8d05430ef5 100755
--- a/pandora_console/extensions/agents_alerts.php
+++ b/pandora_console/extensions/agents_alerts.php
@@ -41,6 +41,7 @@ extensions_add_operation_menu_option(
'view'
);
+// If sec2 parameter come with this page info.
if ($sec2 === 'extensions/agents_alerts') {
extensions_add_main_function('mainAgentsAlerts');
}
@@ -53,8 +54,10 @@ if ($sec2 === 'extensions/agents_alerts') {
*/
function mainAgentsAlerts()
{
+ global $ajaxPage;
// This page.
$thisOwnPage = 'index.php?sec=view&sec2=extensions/agents_alerts';
+ // Ajax variables.
$ajaxPage = 'extensions/agents_alerts';
$pageName = '[AgentsAlerts]';
// Control call flow.
diff --git a/pandora_console/include/class/AgentsAlerts.class.php b/pandora_console/include/class/AgentsAlerts.class.php
index bc500cdb06..5bc613ace7 100644
--- a/pandora_console/include/class/AgentsAlerts.class.php
+++ b/pandora_console/include/class/AgentsAlerts.class.php
@@ -138,7 +138,7 @@ class AgentsAlerts extends HTML
// Show Modules without alerts table.
$this->showWithoutAlertModules = isset($_POST['show-modules-without-alerts']);
// Selected group.
- $this->groupId = (int) get_parameter('filter-groups', 0);
+ $this->groupId = (int) get_parameter('group-id', 0);
// Create alert token.
$this->createAlert = (int) get_parameter('create_alert', 0);
// View token (for full screen view).
@@ -210,10 +210,8 @@ class AgentsAlerts extends HTML
$table = new stdClass();
- $group_id = $this->groupId;
-
- if ($group_id > 0) {
- $grupo = ' AND tagente.id_grupo = '.$group_id;
+ if ($this->groupId > 0) {
+ $grupo = ' AND tagente.id_grupo = '.$this->groupId;
} else {
$grupo = '';
}
@@ -554,11 +552,14 @@ class AgentsAlerts extends HTML
);
$templates_raw = db_get_all_rows_sql($sql);
+
+ if (empty($templates_raw)) {
+ $templates_raw = [];
+ }
}
- if (empty($templates_raw)) {
- $templates_raw = [];
- }
+ // Is needed sort templates for show in the row.
+ sort($templates);
$alerts = [];
$ntemplates = 0;
@@ -569,10 +570,11 @@ class AgentsAlerts extends HTML
html_print_anchor(
[
'href' => sprintf(
- 'index.php?sec=extensions&sec2=extensions/agents_alerts&hor_offset=%s&offset=%s&group_id=%s',
+ 'index.php?sec=extensions&sec2=extensions/agents_alerts&hor_offset=%s&offset=%s&group-id=%s&pure=%s',
$new_hor_offset,
$this->offset,
- $this->groupId
+ $this->groupId,
+ $this->selectedFullScreen
),
'content' => html_print_image(
'images/arrow_left_green.png',
@@ -619,10 +621,11 @@ class AgentsAlerts extends HTML
html_print_anchor(
[
'href' => sprintf(
- 'index.php?sec=extensions&sec2=extensions/agents_alerts&hor_offset=%s&offset=%s&group_id=%s',
+ 'index.php?sec=extensions&sec2=extensions/agents_alerts&hor_offset=%s&offset=%s&group-id=%s&pure=%s',
$new_hor_offset,
$this->offset,
- $this->groupId
+ $this->groupId,
+ $this->selectedFullScreen
),
'content' => html_print_image(
'images/arrow_right_green.png',
@@ -640,23 +643,26 @@ class AgentsAlerts extends HTML
echo '';
foreach ($agents as $agent) {
+ // Flag for fired alerts.
+ $anyfired = false;
+ // Get aliases.
$alias = db_get_row('tagente', 'id_agente', $agent['id_agente']);
echo '
';
// Name of the agent.
echo ''.$alias['alias'].' | ';
-
// Alerts of the agent.
- $anyfired = false;
foreach ($templates as $tid => $tname) {
+ $anyfired = 0;
+
if ($tname == '') {
continue;
}
echo '';
- if (isset($agent_alerts[$agent['nombre']][$tid])) {
- foreach ($agent_alerts[$agent['nombre']][$tid] as $alert) {
- if ($alert['times_fired'] > 0) {
+ if (isset($agent_alerts[$alias['alias']][$tid])) {
+ foreach ($agent_alerts[$alias['alias']][$tid] as $alert) {
+ if ((int) $alert['times_fired'] > 0) {
$anyfired = true;
}
}
@@ -677,14 +683,14 @@ class AgentsAlerts extends HTML
'id' => 'line_header_'.$temp['id'],
'class' => 'status_rounded_rectangles text_inside',
'style' => $cellstyle,
- 'content' => count($agent_alerts[$agent['nombre']][$tid]),
+ 'content' => count($agent_alerts[$alias['alias']][$tid]),
],
true
),
]
);
- $this->printAlertsSummaryModalWindow($uniqid, $agent_alerts[$agent['nombre']][$tid]);
+ $this->printAlertsSummaryModalWindow($uniqid, $agent_alerts[$alias['alias']][$tid]);
}
echo ' | ';
@@ -769,9 +775,9 @@ class AgentsAlerts extends HTML
$headerInputs[] = [
'label' => __('Group'),
- 'id' => 'select-filter-groups',
+ 'id' => 'select-group-id',
'arguments' => [
- 'name' => 'filter-groups',
+ 'name' => 'group-id',
'type' => 'select_groups',
'input_class' => 'flex-row',
'class' => '',
@@ -1002,7 +1008,9 @@ class AgentsAlerts extends HTML
($('#refresh-rate').val() * 1000));
-
+ $('#checkbox-show-modules-without-alerts').click(function(){
+ $('#form-header-filters').submit();
+ });
//Get max width of name of modules
max_width = 0;
@@ -1022,211 +1030,8 @@ class AgentsAlerts extends HTML
$("#div_module_r_" + id).css('margin-top', (max_width - 20) + 'px');
$("#div_module_r_" + id).show();
});
-
- var refr = '';
- var pure = '';
- var href =' ';
-
- if (pure) {
- var startCountDown = function (duration, cb) {
- $('div.vc-countdown').countdown('destroy');
- if (!duration) return;
- var t = new Date();
- t.setTime(t.getTime() + duration * 1000);
- $('div.vc-countdown').countdown({
- until: t,
- format: 'MS',
- layout: '(%M%nn%M:%S%nn%S ) ',
- alwaysExpire: true,
- onExpiry: function () {
- $('div.vc-countdown').countdown('destroy');
- url = js_html_entity_decode( href ) + duration;
- $(document).attr ("location", url);
- }
- });
- }
-
- if(refr>0){
- startCountDown(refr, false);
- }
-
- var controls = document.getElementById('vc-controls');
- autoHideElement(controls, 1000);
-
- $('select#refresh').change(function (event) {
- refr = Number.parseInt(event.target.value, 10);
- startCountDown(refr, false);
- });
- }
- else {
-
- var agentes_id = $("#id_agents2").val();
- var id_agentes = getQueryParam("full_agents_id");
- if (agentes_id === null && id_agentes !== null) {
- id_agentes = id_agentes.split(";")
- id_agentes.forEach(function(element) {
- $("#id_agents2 option[value="+ element +"]").attr("selected",true);
- });
-
- selection_agent_module();
- }
-
- $('#refresh').change(function () {
- $('#hidden-vc_refr').val($('#refresh option:selected').val());
- });
- }
-
- /*
- $("#group_id").change (function () {
- jQuery.post ("ajax.php",
- {"page" : "operation/agentes/ver_agente",
- "get_agents_group_json" : 1,
- "id_group" : this.value,
- "privilege" : "AW",
- "keys_prefix" : "_",
- "recursion" : $('#checkbox-recursion').is(':checked')
- },
- function (data, status) {
- $("#id_agents2").html('');
- $("#module").html('');
- jQuery.each (data, function (id, value) {
- // Remove keys_prefix from the index
- id = id.substring(1);
-
- option = $("")
- .attr ("value", value["id_agente"])
- .html (value["alias"]);
- $("#id_agents").append (option);
- $("#id_agents2").append (option);
- });
- },
- "json"
- );
- });
-
- $("#checkbox-recursion").change (function () {
- jQuery.post ("ajax.php",
- {"page" : "operation/agentes/ver_agente",
- "get_agents_group_json" : 1,
- "id_group" : $("#group_id").val(),
- "privilege" : "AW",
- "keys_prefix" : "_",
- "recursion" : $('#checkbox-recursion').is(':checked')
- },
- function (data, status) {
- $("#id_agents2").html('');
- $("#module").html('');
- jQuery.each (data, function (id, value) {
- // Remove keys_prefix from the index
- id = id.substring(1);
-
- option = $("")
- .attr ("value", value["id_agente"])
- .html (value["alias"]);
- $("#id_agents").append (option);
- $("#id_agents2").append (option);
- });
- },
- "json"
- );
- });
-
- $("#modulegroup").change (function () {
- jQuery.post ("ajax.php",
- {"page" : "operation/agentes/ver_agente",
- "get_modules_group_json" : 1,
- "id_module_group" : this.value,
- "id_agents" : $("#id_agents2").val(),
- "selection" : $("#selection_agent_module").val()
- },
- function (data, status) {
- $("#module").html('');
- if(data){
- jQuery.each (data, function (id, value) {
- option = $("")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
- $("#module").append (option);
- });
- }
- },
- "json"
- );
- });
-
- $("#id_agents2").click (function(){
- selection_agent_module();
- });
-*/
- $("#selection_agent_module").change(function() {
- jQuery.post ("ajax.php",
- {"page" : "operation/agentes/ver_agente",
- "get_modules_group_json" : 1,
- "id_module_group" : $("#modulegroup").val(),
- "id_agents" : $("#id_agents2").val(),
- "selection" : $("#selection_agent_module").val()
- },
- function (data, status) {
- $("#module").html('');
- if(data){
- jQuery.each (data, function (id, value) {
- option = $("")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
- $("#module").append (option);
- });
- }
- },
- "json"
- );
- });
});
- function selection_agent_module() {
- jQuery.post ("ajax.php",
- {"page" : "operation/agentes/ver_agente",
- "get_modules_group_json" : 1,
- "id_module_group" : $("#modulegroup").val(),
- "id_agents" : $("#id_agents2").val(),
- "selection" : $("#selection_agent_module").val()
- },
- function (data, status) {
- $("#module").html('');
- if(data){
- jQuery.each (data, function (id, value) {
- option = $("")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
- $("#module").append (option);
- });
-
- var id_modules = getQueryParam("full_modules_selected");
- if(id_modules !== null) {
- id_modules = id_modules.split(";");
- id_modules.forEach(function(element) {
- $("#module option[value="+ element +"]").attr("selected",true);
- });
- }
- }
- },
- "json"
- );
- }
-
-
-
- function getQueryParam (key) {
- var pattern = "[?&]" + key + "=([^]*)";
- var regex = new RegExp(pattern);
- var url = unescape(window.location.href);
- var results = regex.exec(url);
- if (results === null) {
- return null;
- } else {
- return results[1];
- }
- }
-
function show_alerts_details(id) {
$("#alerts_details_"+id).dialog({
resizable: true,
@@ -1253,35 +1058,7 @@ class AgentsAlerts extends HTML
background: "black"
}
});
- }
-
- // checkbox-slides_ids
- $(document).ready(function () {
- $('#checkbox-show-modules-without-alerts').click(function(){
- $('#form-header-filters').submit();
- });
-
- $('#checkbox-slides_ids').click(function(){
- if ($('#checkbox-slides_ids').prop('checked')){
- var url = location.href.replace("&show_modules=true", "");
- location.href = url+"&show_modules=true";
- } else {
- var url = location.href.replace("&show_modules=true", "");
- var re = /&offset=\d*/g;
- location.href = url.replace(re, "");
- }
- });
-
- $('#group_id').change(function(){
- if(location.href.indexOf("extensions/agents_modules") == -1){
- var regx = /&group_id=\d*/g;
- var url = location.href.replace(regx, "");
- location.href = url+"&group_id="+$("#group_id").val();
- }
- });
-
- });
-
+ }