Added toll type assignment based on country templates
This commit is contained in:
parent
aafdffb8b6
commit
c09364234d
|
|
@ -24,6 +24,7 @@
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
James Rose <james.o.rose@gmail.com>
|
James Rose <james.o.rose@gmail.com>
|
||||||
Philippe Rioual <bhouba@gmail.com>
|
Philippe Rioual <bhouba@gmail.com>
|
||||||
|
Riccardo Granchi <riccardo.granchi@nems.it>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$text['title-dialplan-outbound-add']['en-us'] = "Outbound Call Routing";
|
$text['title-dialplan-outbound-add']['en-us'] = "Outbound Call Routing";
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
James Rose <james.o.rose@gmail.com>
|
James Rose <james.o.rose@gmail.com>
|
||||||
|
Riccardo Granchi <riccardo.granchi@nems.it>
|
||||||
*/
|
*/
|
||||||
include "root.php";
|
include "root.php";
|
||||||
require_once "resources/require.php";
|
require_once "resources/require.php";
|
||||||
|
|
@ -405,27 +406,18 @@ else {
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
|
|
||||||
if (strlen($custom_outbound_prefix) > 0) {
|
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
|
||||||
$dialplan_detail_type = 'set';
|
|
||||||
$dialplan_detail_data = 'outbound_prefix='.$custom_outbound_prefix;
|
|
||||||
$dialplan_detail_order = '025';
|
|
||||||
$dialplan_detail_group = '';
|
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($gateway_type != "transfer") {
|
if ($gateway_type != "transfer") {
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'set';
|
$dialplan_detail_type = 'set';
|
||||||
$dialplan_detail_data = 'hangup_after_bridge=true';
|
$dialplan_detail_data = 'hangup_after_bridge=true';
|
||||||
$dialplan_detail_order = '030';
|
$dialplan_detail_order = '025';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
|
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'set';
|
$dialplan_detail_type = 'set';
|
||||||
$dialplan_detail_data = 'effective_caller_id_name=${outbound_caller_id_name}';
|
$dialplan_detail_data = 'effective_caller_id_name=${outbound_caller_id_name}';
|
||||||
$dialplan_detail_order = '035';
|
$dialplan_detail_order = '030';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
|
|
||||||
|
|
@ -437,21 +429,21 @@ else {
|
||||||
else {
|
else {
|
||||||
$dialplan_detail_data = 'effective_caller_id_number=${outbound_caller_id_number}';
|
$dialplan_detail_data = 'effective_caller_id_number=${outbound_caller_id_number}';
|
||||||
}
|
}
|
||||||
$dialplan_detail_order = '040';
|
$dialplan_detail_order = '035';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
|
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'set';
|
$dialplan_detail_type = 'set';
|
||||||
$dialplan_detail_data = 'inherit_codec=true';
|
$dialplan_detail_data = 'inherit_codec=true';
|
||||||
$dialplan_detail_order = '045';
|
$dialplan_detail_order = '040';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
|
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'set';
|
$dialplan_detail_type = 'set';
|
||||||
$dialplan_detail_data = 'continue_on_fail=true';
|
$dialplan_detail_data = 'continue_on_fail=true';
|
||||||
$dialplan_detail_order = '050';
|
$dialplan_detail_order = '045';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
}
|
}
|
||||||
|
|
@ -460,7 +452,7 @@ else {
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'enum';
|
$dialplan_detail_type = 'enum';
|
||||||
$dialplan_detail_data = $prefix_number."$1 e164.org";
|
$dialplan_detail_data = $prefix_number."$1 e164.org";
|
||||||
$dialplan_detail_order = '055';
|
$dialplan_detail_order = '050';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
}
|
}
|
||||||
|
|
@ -469,11 +461,22 @@ else {
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'limit';
|
$dialplan_detail_type = 'limit';
|
||||||
$dialplan_detail_data = "hash \${domain} outbound ".$limit." !USER_BUSY";
|
$dialplan_detail_data = "hash \${domain} outbound ".$limit." !USER_BUSY";
|
||||||
$dialplan_detail_order = '060';
|
$dialplan_detail_order = '055';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($custom_outbound_prefix) > 0) {
|
||||||
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
|
$dialplan_detail_type = 'set';
|
||||||
|
$dialplan_detail_data = 'outbound_prefix='.$custom_outbound_prefix;
|
||||||
|
$dialplan_detail_order = '060';
|
||||||
|
$dialplan_detail_group = '';
|
||||||
|
$dialplan_detail_break = '';
|
||||||
|
$dialplan_detail_inline = 'true';
|
||||||
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data, $dialplan_detail_break, $dialplan_detail_inline);
|
||||||
|
}
|
||||||
|
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'bridge';
|
$dialplan_detail_type = 'bridge';
|
||||||
$dialplan_detail_data = $action_data;
|
$dialplan_detail_data = $action_data;
|
||||||
|
|
@ -988,4 +991,4 @@ function type_onchange(dialplan_detail_type) {
|
||||||
|
|
||||||
//show the footer
|
//show the footer
|
||||||
require_once "resources/footer.php";
|
require_once "resources/footer.php";
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
--
|
||||||
|
-- FusionPBX
|
||||||
|
-- Version: MPL 1.1
|
||||||
|
--
|
||||||
|
-- The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
-- 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
-- the License. You may obtain a copy of the License at
|
||||||
|
-- http://www.mozilla.org/MPL/
|
||||||
|
--
|
||||||
|
-- Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
-- for the specific language governing rights and limitations under the
|
||||||
|
-- License.
|
||||||
|
--
|
||||||
|
-- The Original Code is FusionPBX
|
||||||
|
--
|
||||||
|
-- The Initial Developer of the Original Code is
|
||||||
|
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
|
-- Copyright (C) 2010-2014
|
||||||
|
-- the Initial Developer. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- Contributor(s):
|
||||||
|
-- Riccardo Granchi <riccardo.granchi@nems.it>
|
||||||
|
|
||||||
|
--debug
|
||||||
|
debug["toll_type"] = false
|
||||||
|
|
||||||
|
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1))
|
||||||
|
dofile(scripts_dir .. "/resources/functions/explode.lua")
|
||||||
|
|
||||||
|
--create the api object and get variables
|
||||||
|
api = freeswitch.API()
|
||||||
|
uuid = argv[1]
|
||||||
|
|
||||||
|
if not uuid or uuid == "" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
--Define templates for every toll type for your country
|
||||||
|
function get_toll_types_it()
|
||||||
|
if (debug["toll_type"]) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] using IT toll types\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
templates["mobile"] = "[35]%d%d%d%d%d%d+"
|
||||||
|
templates["landline"] = "0[123456789]%d+"
|
||||||
|
templates["international"] = "00%d+"
|
||||||
|
templates["tollfree"] = "119|1[3456789]%d|19[24]%d|192[01]%d%d|800%d%d%d%d%d+|803%d%d%d+|456%d%d%d%d%d%d+|11[2345678]|15%d%d|116%d%d%d|196%d%d"
|
||||||
|
templates["sharedcharge"] = "84[0178]%d%d%d%d+|199%d%d%d%d%d+|178%d%d%d%d%d+|12%d%d|10%d%d%d+|1482|149%d+|4[012]%d+|70%d%d%d%d%d+"
|
||||||
|
templates["premium"] = "89[2459]%d%d%d+|16[456]%d%d%d+|144%d%d%d+|4[346789]%d%d+"
|
||||||
|
templates["unknown"] = "%d%d+"
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_toll_types_us()
|
||||||
|
if (debug["toll_type"]) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] using US toll types\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
templates["unknown"] = "%d+"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
called = api:executeString("uuid_getvar " .. uuid .. " destination_number")
|
||||||
|
prefix = api:executeString("uuid_getvar " .. uuid .. " outbound_prefix")
|
||||||
|
country = api:executeString("uuid_getvar " .. uuid .. " default_country")
|
||||||
|
|
||||||
|
template_indexes = { "mobile", "landline", "international", "tollfree", "sharedcharge", "premium", "unknown"}
|
||||||
|
templates = {}
|
||||||
|
local toll_type = "unknown"
|
||||||
|
|
||||||
|
if ((prefix == nil) or (string.len(prefix) == 0) or (prefix == "_undef_") ) then
|
||||||
|
prefix = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if ((country ~= nil) and (string.len(country) > 0)) then
|
||||||
|
--set templates for default country
|
||||||
|
if country == "IT" then get_toll_types_it()
|
||||||
|
elseif country == "US" then get_toll_types_us()
|
||||||
|
else
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] toll type: " .. toll_type .. "\n")
|
||||||
|
return toll_type
|
||||||
|
end
|
||||||
|
|
||||||
|
--test templates matching to set correct toll_type
|
||||||
|
local found = false
|
||||||
|
for i,label in pairs(template_indexes) do
|
||||||
|
template = templates[label]
|
||||||
|
if (debug["toll_type"]) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] checking toll type " .. label .. " template: " .. template .. "\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
--Doing split on | character
|
||||||
|
parts = explode("|", template)
|
||||||
|
|
||||||
|
for index,part in pairs(parts) do
|
||||||
|
pattern = "^" .. prefix .. part .. "$"
|
||||||
|
if (debug["toll_type"]) then
|
||||||
|
--freeswitch.consoleLog("NOTICE", "[toll_type_assignment] checking toll type " .. label .. " pattern: " .. pattern .. "\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( string.match(called, pattern) ~= nil ) then
|
||||||
|
if (debug["toll_type"]) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] destination number " .. called .. " matches " .. label .. " pattern: " .. pattern .. "\n")
|
||||||
|
end
|
||||||
|
toll_type = label
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (found) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] toll type: " .. toll_type .. "\n")
|
||||||
|
return toll_type
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
|
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
|
||||||
|
Riccardo Granchi <riccardo.granchi@nems.it>
|
||||||
*/
|
*/
|
||||||
require_once "root.php";
|
require_once "root.php";
|
||||||
require_once "resources/require.php";
|
require_once "resources/require.php";
|
||||||
|
|
@ -2158,7 +2159,7 @@ function dialplan_add($domain_uuid, $dialplan_uuid, $dialplan_name, $dialplan_or
|
||||||
unset($sql);
|
unset($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dialplan_detail_add($domain_uuid, $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data, $dialplan_detail_break) {
|
function dialplan_detail_add($domain_uuid, $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data, $dialplan_detail_break, $dialplan_detail_inline) {
|
||||||
global $db;
|
global $db;
|
||||||
$dialplan_detail_uuid = uuid();
|
$dialplan_detail_uuid = uuid();
|
||||||
$sql = "insert into v_dialplan_details ";
|
$sql = "insert into v_dialplan_details ";
|
||||||
|
|
@ -2171,7 +2172,8 @@ function dialplan_detail_add($domain_uuid, $dialplan_uuid, $dialplan_detail_tag,
|
||||||
$sql .= "dialplan_detail_order, ";
|
$sql .= "dialplan_detail_order, ";
|
||||||
$sql .= "dialplan_detail_type, ";
|
$sql .= "dialplan_detail_type, ";
|
||||||
$sql .= "dialplan_detail_data, ";
|
$sql .= "dialplan_detail_data, ";
|
||||||
$sql .= "dialplan_detail_break ";
|
$sql .= "dialplan_detail_break, ";
|
||||||
|
$sql .= "dialplan_detail_inline ";
|
||||||
$sql .= ") ";
|
$sql .= ") ";
|
||||||
$sql .= "values ";
|
$sql .= "values ";
|
||||||
$sql .= "(";
|
$sql .= "(";
|
||||||
|
|
@ -2189,10 +2191,16 @@ function dialplan_detail_add($domain_uuid, $dialplan_uuid, $dialplan_detail_tag,
|
||||||
$sql .= "'".check_str($dialplan_detail_type)."', ";
|
$sql .= "'".check_str($dialplan_detail_type)."', ";
|
||||||
$sql .= "'".check_str($dialplan_detail_data)."', ";
|
$sql .= "'".check_str($dialplan_detail_data)."', ";
|
||||||
if (strlen($dialplan_detail_break) == 0) {
|
if (strlen($dialplan_detail_break) == 0) {
|
||||||
|
$sql .= "null, ";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql .= "'".check_str($dialplan_detail_break)."', ";
|
||||||
|
}
|
||||||
|
if (strlen($dialplan_detail_inline) == 0) {
|
||||||
$sql .= "null ";
|
$sql .= "null ";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql .= "'".check_str($dialplan_detail_break)."' ";
|
$sql .= "'".check_str($dialplan_detail_inline)."' ";
|
||||||
}
|
}
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
$db->exec(check_sql($sql));
|
$db->exec(check_sql($sql));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue