From a5626ea2ddc161affc60eb340ba00247ad18f3e6 Mon Sep 17 00:00:00 2001 From: luis daniel lucio quiroz Date: Sun, 13 Jul 2014 23:22:15 +0000 Subject: [PATCH] set carrier and accountcode for incoming routes if data exists --- app/destinations/destination_edit.php | 26 ++++++++ app/dialplan_inbound/dialplan_inbound_add.php | 64 ++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index be80312b77..ccb7fd2eb2 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -214,6 +214,32 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //increment the dialplan detail order $dialplan_detail_order = $dialplan_detail_order + 10; + + //set the call accountcode + if (strlen($destination_accountcode) > 0) { + $dialplan["dialplan_details"][$y]["domain_uuid"] = $_SESSION['domain_uuid']; + $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "accountcode=$destination_accountcode"; + $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; + $y++; + + //increment the dialplan detail order + $dialplan_detail_order = $dialplan_detail_order + 10; + } + + //set the call carrier + if (strlen($destination_carrier) > 0) { + $dialplan["dialplan_details"][$y]["domain_uuid"] = $_SESSION['domain_uuid']; + $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "carrier=$destination_carrier"; + $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; + $y++; + + //increment the dialplan detail order + $dialplan_detail_order = $dialplan_detail_order + 10; + } } //add fax detection diff --git a/app/dialplan_inbound/dialplan_inbound_add.php b/app/dialplan_inbound/dialplan_inbound_add.php index fd634dbf2f..474f6beef0 100644 --- a/app/dialplan_inbound/dialplan_inbound_add.php +++ b/app/dialplan_inbound/dialplan_inbound_add.php @@ -22,6 +22,7 @@ Contributor(s): Mark J Crane + Luis Daniel Lucio Quiroz */ include "root.php"; require_once "resources/require.php"; @@ -79,6 +80,9 @@ require_once "resources/paging.php"; //$action_application_2 = check_str($_POST["action_application_2"]); //$action_data_2 = check_str($_POST["action_data_2"]); + $destination_carrier = ''; + $destination_accountcode = ''; + //use the destination_uuid to set the condition_expression_1 if (strlen($destination_uuid) > 0) { $sql = "select * from v_destinations "; @@ -91,13 +95,15 @@ require_once "resources/paging.php"; foreach ($result as &$row) { $condition_expression_1 = $row["destination_number"]; $fax_uuid = $row["fax_uuid"]; + $destination_carrier = $row["destination_carrier"]; + $destination_accountcode = $row["destination_accountcode"]; } } unset ($prep_statement); } if (permission_exists("inbound_route_advanced") && $action == "advanced") { - //allow users in the superadmin group advanced control + //Allow users with group advanced control, not always superadmin. You may change this in group permitions } else { if (strlen($condition_field_1) == 0) { $condition_field_1 = "destination_number"; } @@ -283,6 +289,60 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { unset($sql); } + //set accountcode + if (strlen($destination_accountcode) > 0) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'set', "; + $sql .= "'accountcode=$destination_accountcode', "; + $sql .= "'62' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //set carrier + if (strlen($destination_carrier) > 0) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'set', "; + $sql .= "'carrier=$destination_carrier', "; + $sql .= "'64' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + //set limit if (strlen($limit) > 0) { $dialplan_detail_uuid = uuid(); @@ -946,4 +1006,4 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?>