Added report template regex to MR

This commit is contained in:
Luis 2019-11-27 13:21:05 +01:00 committed by Daniel Rodriguez
parent b64218cedb
commit b0d5b7223e
4 changed files with 25 additions and 0 deletions

View File

@ -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

View File

@ -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;

View File

@ -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,

View File

@ -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;