From fe581ec210cc69965d5b50dee8b40084a02e46b8 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Fri, 7 Mar 2025 12:47:25 +0000 Subject: [PATCH 1/3] Actualizar incoming.php --- incoming.php | 90 ++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/incoming.php b/incoming.php index 5bd4d54..63dadc0 100755 --- a/incoming.php +++ b/incoming.php @@ -19,48 +19,48 @@ $countryCode = Agi::get('agi_arg_1'); // Formats the caller phone number if (preg_match('/^\\+/', $callerId)) { - $callerId = '00'. substr($callerId, 1); + $callerId = '00'. substr($callerId, 1); } elseif (!preg_match('/^00/', $callerId) && $countryCode) { - $prefix = $db->getValue( - 'SELECT prefix FROM prefix WHERE country = #', - [$countryCode] - ); - if ($prefix) - $callerId = $prefix . $callerId; + $prefix = $db->getValue( + 'SELECT prefix FROM prefix WHERE country = #', + [$countryCode] + ); + if ($prefix) + $callerId = $prefix . $callerId; } $countryPrefix = $db->getValue('SELECT defaultPrefix FROM config'); $prefixLen = strlen($countryPrefix); if (substr($callerId, 0, $prefixLen) === $countryPrefix) - $callerId = substr($callerId, $prefixLen); + $callerId = substr($callerId, $prefixLen); // Checks schedules if ($countryCode) { - $isInSchedule = $db->getValue( - 'SELECT COUNT(*) > 0 FROM pbx.schedule - WHERE weekDays & (1 << WEEKDAY(CURDATE())) - AND country = # - AND TIME(NOW()) BETWEEN startTime AND endTime', - [$countryCode] - ); + $isInSchedule = $db->getValue( + 'SELECT COUNT(*) > 0 FROM pbx.schedule + WHERE weekDays & (1 << WEEKDAY(CURDATE())) + AND country = # + AND TIME(NOW()) BETWEEN startTime AND endTime', + [$countryCode] + ); - if ($isInSchedule) { - $isOutOfHours = $db->getValue( - 'SELECT COUNT(*) > 0 FROM pbx.holiday - WHERE country = # - AND `day` = CURDATE()', - [$countryCode] - ); - } else - $isOutOfHours = true; + if ($isInSchedule) { + $isOutOfHours = $db->getValue( + 'SELECT COUNT(*) > 0 FROM pbx.holiday + WHERE country = # + AND `day` = CURDATE()', + [$countryCode] + ); + } else + $isOutOfHours = true; - if ($isOutOfHours) { - Agi::exec('SET VARIABLE MACRO out-of-ours'); - exit; - } + if ($isOutOfHours) { + Agi::exec('SET VARIABLE MACRO out-of-ours'); + exit; + } } // Gets the client from the phone number @@ -68,27 +68,27 @@ if ($countryCode) { $clientId = $db->getValue('SELECT clientFromPhone(#)', [$callerId]); if ($clientId) { - $client = $db->getObject( - 'SELECT d.pbxQueue, c.id, d.notificationEmail - FROM vn.client c - JOIN vn.worker w ON w.id = c.salesPersonFk - JOIN vn.business b ON b.id = w.businessFk - JOIN vn.department d ON d.id = b.departmentFk - WHERE c.id= #',[$clientId] - ); + $client = $db->getObject( + 'SELECT d.pbxQueue, c.id, d.notificationEmail + FROM vn.client c + JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN vn.business b ON b.id = w.businessFk + JOIN vn.department d ON d.id = b.departmentFk + WHERE c.id= #',[$clientId] + ); - if ($client) { - Agi::exec('SET VARIABLE MACRO queue'); - Agi::exec("SET VARIABLE ARG1 \"{$client->pbxQueue}\""); - Agi::exec("SET VARIABLE ARG2 \"Client {$client->id}\""); - Agi::exec("SET VARIABLE ARG3 \"{$client->id}\""); - Agi::exec("SET VARIABLE ARG4 \"{$client->notificationEmail}\""); - } + if ($client) { + Agi::exec('SET VARIABLE MACRO queue'); + Agi::exec("SET VARIABLE ARG1 \"{$client->pbxQueue}\""); + Agi::exec("SET VARIABLE ARG2 \"Client {$client->id}\""); + Agi::exec("SET VARIABLE ARG3 \"{$client->id}\""); + Agi::exec("SET VARIABLE ARG4 \"{$client->notificationEmail}\""); + } } // Checks if phone number is on the blacklist if ($db->getValue('SELECT COUNT(*) > 0 FROM blacklist WHERE phone = #', [$callerId])) { - Agi::exec('HANGUP'); - exit; + Agi::exec('HANGUP'); + exit; } From bce6df9e0e9ff123827989e58323a436c3b1db06 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Fri, 7 Mar 2025 12:50:36 +0000 Subject: [PATCH 2/3] Actualizar incoming.php --- incoming.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/incoming.php b/incoming.php index 63dadc0..450a801 100755 --- a/incoming.php +++ b/incoming.php @@ -35,7 +35,12 @@ $prefixLen = strlen($countryPrefix); if (substr($callerId, 0, $prefixLen) === $countryPrefix) $callerId = substr($callerId, $prefixLen); +// Checks if phone number is on the blacklist +if ($db->getValue('SELECT COUNT(*) > 0 FROM blacklist WHERE phone = #', [$callerId])) { + Agi::exec('HANGUP'); + exit; + // Checks schedules if ($countryCode) { From 9e09ce6afc7b75d49dcb5fd8c371cbcab760b68a Mon Sep 17 00:00:00 2001 From: Juan Ferrer Date: Fri, 7 Mar 2025 13:01:39 +0000 Subject: [PATCH 3/3] Update incoming.php --- incoming.php | 101 ++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/incoming.php b/incoming.php index 450a801..44e88dd 100755 --- a/incoming.php +++ b/incoming.php @@ -19,53 +19,55 @@ $countryCode = Agi::get('agi_arg_1'); // Formats the caller phone number if (preg_match('/^\\+/', $callerId)) { - $callerId = '00'. substr($callerId, 1); + $callerId = '00'. substr($callerId, 1); } elseif (!preg_match('/^00/', $callerId) && $countryCode) { - $prefix = $db->getValue( - 'SELECT prefix FROM prefix WHERE country = #', - [$countryCode] - ); - if ($prefix) - $callerId = $prefix . $callerId; + $prefix = $db->getValue( + 'SELECT prefix FROM prefix WHERE country = #', + [$countryCode] + ); + if ($prefix) + $callerId = $prefix . $callerId; } $countryPrefix = $db->getValue('SELECT defaultPrefix FROM config'); $prefixLen = strlen($countryPrefix); if (substr($callerId, 0, $prefixLen) === $countryPrefix) - $callerId = substr($callerId, $prefixLen); + $callerId = substr($callerId, $prefixLen); + // Checks if phone number is on the blacklist if ($db->getValue('SELECT COUNT(*) > 0 FROM blacklist WHERE phone = #', [$callerId])) { - Agi::exec('HANGUP'); - exit; - + Agi::exec('HANGUP'); + exit; +} + // Checks schedules if ($countryCode) { - $isInSchedule = $db->getValue( - 'SELECT COUNT(*) > 0 FROM pbx.schedule - WHERE weekDays & (1 << WEEKDAY(CURDATE())) - AND country = # - AND TIME(NOW()) BETWEEN startTime AND endTime', - [$countryCode] - ); + $isInSchedule = $db->getValue( + 'SELECT COUNT(*) > 0 FROM pbx.schedule + WHERE weekDays & (1 << WEEKDAY(CURDATE())) + AND country = # + AND TIME(NOW()) BETWEEN startTime AND endTime', + [$countryCode] + ); - if ($isInSchedule) { - $isOutOfHours = $db->getValue( - 'SELECT COUNT(*) > 0 FROM pbx.holiday - WHERE country = # - AND `day` = CURDATE()', - [$countryCode] - ); - } else - $isOutOfHours = true; + if ($isInSchedule) { + $isOutOfHours = $db->getValue( + 'SELECT COUNT(*) > 0 FROM pbx.holiday + WHERE country = # + AND `day` = CURDATE()', + [$countryCode] + ); + } else + $isOutOfHours = true; - if ($isOutOfHours) { - Agi::exec('SET VARIABLE MACRO out-of-ours'); - exit; - } + if ($isOutOfHours) { + Agi::exec('SET VARIABLE MACRO out-of-ours'); + exit; + } } // Gets the client from the phone number @@ -73,27 +75,20 @@ if ($countryCode) { $clientId = $db->getValue('SELECT clientFromPhone(#)', [$callerId]); if ($clientId) { - $client = $db->getObject( - 'SELECT d.pbxQueue, c.id, d.notificationEmail - FROM vn.client c - JOIN vn.worker w ON w.id = c.salesPersonFk - JOIN vn.business b ON b.id = w.businessFk - JOIN vn.department d ON d.id = b.departmentFk - WHERE c.id= #',[$clientId] - ); + $client = $db->getObject( + 'SELECT d.pbxQueue, c.id, d.notificationEmail + FROM vn.client c + JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN vn.business b ON b.id = w.businessFk + JOIN vn.department d ON d.id = b.departmentFk + WHERE c.id= #',[$clientId] + ); - if ($client) { - Agi::exec('SET VARIABLE MACRO queue'); - Agi::exec("SET VARIABLE ARG1 \"{$client->pbxQueue}\""); - Agi::exec("SET VARIABLE ARG2 \"Client {$client->id}\""); - Agi::exec("SET VARIABLE ARG3 \"{$client->id}\""); - Agi::exec("SET VARIABLE ARG4 \"{$client->notificationEmail}\""); - } -} - -// Checks if phone number is on the blacklist - -if ($db->getValue('SELECT COUNT(*) > 0 FROM blacklist WHERE phone = #', [$callerId])) { - Agi::exec('HANGUP'); - exit; + if ($client) { + Agi::exec('SET VARIABLE MACRO queue'); + Agi::exec("SET VARIABLE ARG1 \"{$client->pbxQueue}\""); + Agi::exec("SET VARIABLE ARG2 \"Client {$client->id}\""); + Agi::exec("SET VARIABLE ARG3 \"{$client->id}\""); + Agi::exec("SET VARIABLE ARG4 \"{$client->notificationEmail}\""); + } }