From b0d5b7223e87f9abf8c5f199bac542ab3cfdb0d0 Mon Sep 17 00:00:00 2001 From: Luis Date: Wed, 27 Nov 2019 13:21:05 +0100 Subject: [PATCH] Added report template regex to MR --- pandora_console/extras/mr/33.sql | 1 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 ++ pandora_console/include/functions_agents.php | 21 +++++++++++++++++++ pandora_console/pandoradb.sql | 1 + 4 files changed, 25 insertions(+) diff --git a/pandora_console/extras/mr/33.sql b/pandora_console/extras/mr/33.sql index 09054044a0..3a25268e6d 100644 --- a/pandora_console/extras/mr/33.sql +++ b/pandora_console/extras/mr/33.sql @@ -1,5 +1,6 @@ START TRANSACTION; +ALTER TABLE `treport_template` ADD COLUMN `agent_regex` varchar(600) NOT NULL default ''; ALTER TABLE `tlayout_template_data` ADD COLUMN `cache_expiration` INTEGER UNSIGNED NOT NULL DEFAULT 0; INSERT INTO `ttipo_modulo` VALUES diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index ae080bbefc..e7f00559f9 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -764,6 +764,8 @@ CREATE TABLE IF NOT EXISTS `treport_template` ( `footer` MEDIUMTEXT default NULL, `custom_font` varchar(200) default NULL, `metaconsole` tinyint(1) DEFAULT 0, + `agent_regex` varchar(600) NOT NULL default '', + PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 3419fbf8da..732bee643e 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3509,6 +3509,27 @@ function agents_get_status_animation($up=true) } +function agents_get_agent_id_by_alias_regex($alias_regex, $flag='i', $limit=0) +{ + $agents_id = []; + $all_agents = agents_get_agents(false, ['id_agente', 'alias']); + $agent_match = '/'.$alias_regex.'/'.$flag; + + foreach ($all_agents as $agent) { + $result_agent_match = preg_match($agent_match, $agent['alias']); + if ($result_agent_match) { + $agents_id[] = $agent['id_agente']; + $i++; + if ($i === $limit) { + break; + } + } + } + + return $agents_id; +} + + /** * Return if an agent is SAP or or an a agent SAP list. * If function receive false, you will return all SAP agents, diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 312eb937ec..1a163d7699 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2952,6 +2952,7 @@ CREATE TABLE IF NOT EXISTS `treport_template` ( `footer` MEDIUMTEXT default NULL, `custom_font` varchar(200) default NULL, `metaconsole` tinyint(1) DEFAULT 0, + `agent_regex` varchar(600) BINARY NOT NULL default '', PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8;