2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
2012-10-23 12:00:03 +02:00
|
|
|
/*
|
|
|
|
|
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>
|
2015-01-16 01:21:02 +01:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2013-2015
|
2012-10-23 12:00:03 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2014-06-23 17:18:22 +02:00
|
|
|
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
|
2012-10-23 12:00:03 +02:00
|
|
|
*/
|
2012-06-04 16:58:40 +02:00
|
|
|
require_once "root.php";
|
2013-07-06 08:03:27 +02:00
|
|
|
require_once "resources/require.php";
|
2013-07-06 07:50:55 +02:00
|
|
|
require_once "resources/check_auth.php";
|
2013-05-08 01:38:12 +02:00
|
|
|
if (permission_exists('destination_add') || permission_exists('destination_edit')) {
|
2012-06-04 16:58:40 +02:00
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 03:12:41 +02:00
|
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")) {
|
2014-07-18 01:46:04 +02:00
|
|
|
require_once "app/billing/resources/functions/currency.php";
|
2014-07-24 05:06:33 +02:00
|
|
|
require_once "app/billing/resources/functions/rating.php";
|
2014-06-23 17:18:22 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-08 01:38:12 +02:00
|
|
|
//add multi-lingual support
|
2015-01-18 11:06:08 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2013-05-08 01:38:12 +02:00
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//action add or update
|
|
|
|
|
if (isset($_REQUEST["id"])) {
|
|
|
|
|
$action = "update";
|
|
|
|
|
$destination_uuid = check_str($_REQUEST["id"]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$action = "add";
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-22 09:17:04 +01:00
|
|
|
//get total destination count from the database, check limit, if defined
|
2015-03-31 00:57:12 +02:00
|
|
|
if (!permission_exists('destination_domain')) {
|
|
|
|
|
if ($action == 'add') {
|
|
|
|
|
if ($_SESSION['limit']['destinations']['numeric'] != '') {
|
|
|
|
|
$sql = "select count(*) as num_rows from v_destinations where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
|
|
|
|
$prep_statement = $db->prepare($sql);
|
|
|
|
|
if ($prep_statement) {
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
$total_destinations = $row['num_rows'];
|
|
|
|
|
}
|
|
|
|
|
unset($prep_statement, $row);
|
|
|
|
|
if ($total_destinations >= $_SESSION['limit']['destinations']['numeric']) {
|
|
|
|
|
$_SESSION['message_mood'] = 'negative';
|
|
|
|
|
$_SESSION['message'] = $text['message-maximum_destinations'].' '.$_SESSION['limit']['destinations']['numeric'];
|
|
|
|
|
header('Location: destinations.php');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-03-22 09:17:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//get http post variables and set them to php variables
|
2014-04-24 15:37:56 +02:00
|
|
|
if (count($_POST) > 0) {
|
2015-01-25 09:24:32 +01:00
|
|
|
//set the variables
|
|
|
|
|
$dialplan_uuid = check_str($_POST["dialplan_uuid"]);
|
|
|
|
|
$destination_type = check_str($_POST["destination_type"]);
|
|
|
|
|
$destination_number = check_str($_POST["destination_number"]);
|
|
|
|
|
$db_destination_number = check_str($_POST["db_destination_number"]);
|
|
|
|
|
$regex_destination_number = str_replace("+", "\\+", $destination_number);
|
|
|
|
|
$destination_caller_id_name = check_str($_POST["destination_caller_id_name"]);
|
|
|
|
|
$destination_caller_id_number = check_str($_POST["destination_caller_id_number"]);
|
|
|
|
|
$destination_cid_name_prefix = check_str($_POST["destination_cid_name_prefix"]);
|
|
|
|
|
$destination_context = check_str($_POST["destination_context"]);
|
|
|
|
|
$fax_uuid = check_str($_POST["fax_uuid"]);
|
|
|
|
|
$destination_enabled = check_str($_POST["destination_enabled"]);
|
|
|
|
|
$destination_description = check_str($_POST["destination_description"]);
|
|
|
|
|
$destination_sell = check_float($_POST["destination_sell"]);
|
|
|
|
|
$currency = check_str($_POST["currency"]);
|
|
|
|
|
$destination_buy = check_float($_POST["destination_buy"]);
|
|
|
|
|
$currency_buy = check_str($_POST["currency_buy"]);
|
|
|
|
|
$destination_accountcode = check_str($_POST["destination_accountcode"]);
|
|
|
|
|
$destination_carrier = check_str($_POST["destination_carrier"]);
|
|
|
|
|
|
|
|
|
|
//get the domain_uuid
|
|
|
|
|
if (permission_exists('destination_domain')) {
|
|
|
|
|
$domain_uuid = check_str($_POST["domain_uuid"]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$_POST["domain_uuid"] = $_SESSION['domain_uuid'];
|
|
|
|
|
$domain_uuid = $_SESSION['domain_uuid'];
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-09 21:41:34 +02:00
|
|
|
//unset the db_destination_number
|
|
|
|
|
unset($_POST["db_destination_number"]);
|
|
|
|
|
|
2014-04-24 15:37:56 +02:00
|
|
|
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-05-24 20:59:37 +02:00
|
|
|
//get the uuid
|
|
|
|
|
if ($action == "update") {
|
|
|
|
|
$destination_uuid = check_str($_POST["destination_uuid"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//check for all required data
|
|
|
|
|
$msg = '';
|
|
|
|
|
if (strlen($destination_type) == 0) { $msg .= $text['message-required']." ".$text['label-destination_type']."<br>\n"; }
|
|
|
|
|
if (strlen($destination_number) == 0) { $msg .= $text['message-required']." ".$text['label-destination_number']."<br>\n"; }
|
|
|
|
|
if (strlen($destination_context) == 0) { $msg .= $text['message-required']." ".$text['label-destination_context']."<br>\n"; }
|
|
|
|
|
if (strlen($destination_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; }
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-05-24 19:32:32 +02:00
|
|
|
//check for duplicates
|
2014-05-26 19:00:29 +02:00
|
|
|
if ($action == "add" || $destination_number != $db_destination_number) {
|
|
|
|
|
$sql = "select count(*) as num_rows from v_destinations ";
|
|
|
|
|
$sql .= "where destination_number = '".$destination_number."' ";
|
|
|
|
|
$prep_statement = $db->prepare($sql);
|
|
|
|
|
if ($prep_statement) {
|
2014-05-30 10:03:55 +02:00
|
|
|
$prep_statement->execute();
|
2014-05-26 19:00:29 +02:00
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
if ($row['num_rows'] > 0) {
|
|
|
|
|
$msg .= $text['message-duplicate']."<br>\n";
|
|
|
|
|
}
|
2014-07-23 22:06:09 +02:00
|
|
|
unset($prep_statement);
|
2014-05-24 19:32:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-24 20:59:37 +02:00
|
|
|
//show the message
|
2012-06-04 16:58:40 +02:00
|
|
|
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2013-07-06 08:21:12 +02:00
|
|
|
require_once "resources/persist_form_var.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<div align='center'>\n";
|
|
|
|
|
echo "<table><tr><td>\n";
|
|
|
|
|
echo $msg."<br />";
|
|
|
|
|
echo "</td></tr></table>\n";
|
|
|
|
|
persistformvar($_POST);
|
|
|
|
|
echo "</div>\n";
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add or update the database
|
|
|
|
|
if ($_POST["persistformvar"] != "true") {
|
2014-04-24 15:37:56 +02:00
|
|
|
|
2014-09-04 03:19:02 +02:00
|
|
|
//determine whether save the dialplan
|
|
|
|
|
foreach ($_POST["dialplan_details"] as $row) {
|
|
|
|
|
if (strlen($row["dialplan_detail_data"]) > 0) {
|
|
|
|
|
$add_dialplan = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-25 09:24:32 +01:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//add or update the dialplan if the destination number is set
|
2014-09-04 03:19:02 +02:00
|
|
|
if ($add_dialplan) {
|
2015-03-18 08:28:05 +01:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//get the array
|
|
|
|
|
$dialplan_details = $_POST["dialplan_details"];
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//remove the array from the HTTP POST
|
|
|
|
|
unset($_POST["dialplan_details"]);
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//array cleanup
|
2015-03-18 23:21:40 +01:00
|
|
|
foreach ($dialplan_details as $index => $row) {
|
2014-08-06 01:57:48 +02:00
|
|
|
//unset the empty row
|
|
|
|
|
if (strlen($row["dialplan_detail_data"]) == 0) {
|
2015-03-18 23:21:40 +01:00
|
|
|
unset($dialplan_details[$index]);
|
2014-08-06 01:57:48 +02:00
|
|
|
}
|
2014-04-24 15:37:56 +02:00
|
|
|
}
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//check to see if the dialplan exists
|
|
|
|
|
if (strlen($dialplan_uuid) > 0) {
|
2015-03-18 23:21:40 +01:00
|
|
|
$sql = "select dialplan_uuid, dialplan_name, dialplan_description from v_dialplans ";
|
2015-03-31 04:53:36 +02:00
|
|
|
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
|
|
|
|
if (!permission_exists('destination_domain')) {
|
|
|
|
|
$sql .= "and domain_uuid = '".$domain_uuid."' ";
|
|
|
|
|
}
|
2014-08-06 01:57:48 +02:00
|
|
|
$prep_statement = $db->prepare($sql);
|
|
|
|
|
if ($prep_statement) {
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
if (strlen($row['dialplan_uuid']) > 0) {
|
|
|
|
|
$dialplan_uuid = $row['dialplan_uuid'];
|
2015-03-18 23:21:40 +01:00
|
|
|
$dialplan_name = $row['dialplan_name'];
|
|
|
|
|
$dialplan_description = $row['dialplan_description'];
|
2014-08-06 01:57:48 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$dialplan_uuid = "";
|
|
|
|
|
}
|
|
|
|
|
unset($prep_statement);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$dialplan_uuid = "";
|
|
|
|
|
}
|
2014-04-25 03:48:20 +02:00
|
|
|
}
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//build the dialplan array
|
|
|
|
|
$dialplan["app_uuid"] = "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4";
|
|
|
|
|
if (strlen($dialplan_uuid) > 0) {
|
|
|
|
|
$dialplan["dialplan_uuid"] = $dialplan_uuid;
|
2014-04-25 03:48:20 +02:00
|
|
|
}
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["domain_uuid"] = $domain_uuid;
|
2015-03-18 23:21:40 +01:00
|
|
|
$dialplan["dialplan_name"] = ($dialplan_name != '') ? $dialplan_name : format_phone($destination_number);
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_number"] = $destination_number;
|
|
|
|
|
$dialplan["dialplan_context"] = $destination_context;
|
|
|
|
|
$dialplan["dialplan_continue"] = "false";
|
|
|
|
|
$dialplan["dialplan_order"] = "100";
|
|
|
|
|
$dialplan["dialplan_enabled"] = $destination_enabled;
|
2015-03-18 23:21:40 +01:00
|
|
|
$dialplan["dialplan_description"] = ($dialplan_description != '') ? $dialplan_description : $destination_description;
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan_detail_order = 10;
|
2014-08-08 03:16:30 +02:00
|
|
|
|
|
|
|
|
//add the public condition
|
|
|
|
|
$y = 0;
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-08 03:16:30 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "context";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "public";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$y++;
|
|
|
|
|
|
|
|
|
|
//increment the dialplan detail order
|
|
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
|
|
|
|
|
|
|
|
|
//check the destination number
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-08 03:16:30 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $regex_destination_number;
|
|
|
|
|
$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 caller id name prefix
|
|
|
|
|
if (strlen($destination_cid_name_prefix) > 0) {
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-08 03:16:30 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "effective_caller_id_name=".$destination_cid_name_prefix."#\${caller_id_name}";
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$y++;
|
2014-08-08 03:16:30 +02:00
|
|
|
|
|
|
|
|
//increment the dialplan detail order
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
2014-08-08 03:16:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//set the call accountcode
|
|
|
|
|
if (strlen($destination_accountcode) > 0) {
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-08 03:16:30 +02:00
|
|
|
$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;
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$y++;
|
2015-02-15 01:33:56 +01:00
|
|
|
|
2014-08-08 03:16:30 +02:00
|
|
|
//increment the dialplan detail order
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
2014-08-08 03:16:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//set the call carrier
|
|
|
|
|
if (strlen($destination_carrier) > 0) {
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-08 03:16:30 +02:00
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//add fax detection
|
|
|
|
|
if (strlen($fax_uuid) > 0) {
|
|
|
|
|
//get the fax information
|
|
|
|
|
$sql = "select * from v_fax ";
|
2015-03-31 04:53:36 +02:00
|
|
|
$sql .= "where fax_uuid = '".$fax_uuid."' ";
|
|
|
|
|
if (!permission_exists('destination_domain')) {
|
|
|
|
|
$sql .= "and domain_uuid = '".$domain_uuid."' ";
|
|
|
|
|
}
|
2014-08-06 01:57:48 +02:00
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
foreach ($result as &$row) {
|
|
|
|
|
$fax_extension = $row["fax_extension"];
|
|
|
|
|
$fax_destination_number = $row["fax_destination_number"];
|
|
|
|
|
$fax_name = $row["fax_name"];
|
|
|
|
|
$fax_email = $row["fax_email"];
|
|
|
|
|
$fax_pin_number = $row["fax_pin_number"];
|
|
|
|
|
$fax_caller_id_name = $row["fax_caller_id_name"];
|
|
|
|
|
$fax_caller_id_number = $row["fax_caller_id_number"];
|
|
|
|
|
$fax_forward_number = $row["fax_forward_number"];
|
|
|
|
|
$fax_description = $row["fax_description"];
|
|
|
|
|
}
|
|
|
|
|
unset ($prep_statement);
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//add set tone detect_hits=1
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "tone_detect_hits=1";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$y++;
|
2015-02-15 01:33:56 +01:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//increment the dialplan detail order
|
|
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
2015-02-15 01:33:56 +01:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
// execute on tone detect
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
2015-03-31 00:57:12 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "execute_on_tone_detect=transfer ".$fax_extension." XML \${domain_name}";
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$y++;
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//increment the dialplan detail order
|
|
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//add tone_detect fax 1100 r +5000
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "tone_detect";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "fax 1100 r +5000";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$y++;
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//increment the dialplan detail order
|
|
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
// execute on tone detect
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "sleep";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "3000";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$y++;
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-07-15 08:26:51 +02:00
|
|
|
//increment the dialplan detail order
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
2014-07-14 01:22:15 +02:00
|
|
|
}
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//add the actions
|
|
|
|
|
foreach ($dialplan_details as $row) {
|
|
|
|
|
if (strlen($row["dialplan_detail_data"]) > 1) {
|
|
|
|
|
$actions = explode(":", $row["dialplan_detail_data"]);
|
|
|
|
|
$dialplan_detail_type = array_shift($actions);
|
|
|
|
|
$dialplan_detail_data = join(':', $actions);
|
2014-08-07 18:11:10 +02:00
|
|
|
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
2014-08-06 01:57:48 +02:00
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $dialplan_detail_type;
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $dialplan_detail_data;
|
|
|
|
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
|
|
|
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
|
|
|
|
$y++;
|
|
|
|
|
}
|
2014-07-14 01:22:15 +02:00
|
|
|
}
|
2014-08-07 18:11:10 +02:00
|
|
|
|
|
|
|
|
//delete the previous details
|
2014-08-08 03:16:30 +02:00
|
|
|
if(strlen($dialplan_uuid) > 0) {
|
2014-08-07 18:11:10 +02:00
|
|
|
$sql = "delete from v_dialplan_details ";
|
2015-03-31 04:53:36 +02:00
|
|
|
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
|
|
|
|
if (!permission_exists('destination_domain')) {
|
|
|
|
|
$sql .= "and domain_uuid = '".$domain_uuid."' ";
|
|
|
|
|
}
|
|
|
|
|
echo $sql."<br><br>";
|
2014-08-07 18:11:10 +02:00
|
|
|
$db->exec(check_sql($sql));
|
|
|
|
|
unset($sql);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
//save the dialplan
|
|
|
|
|
$orm = new orm;
|
|
|
|
|
$orm->name('dialplans');
|
|
|
|
|
if (isset($dialplan["dialplan_uuid"])) {
|
|
|
|
|
$orm->uuid($dialplan["dialplan_uuid"]);
|
2014-07-02 08:21:20 +02:00
|
|
|
}
|
2014-08-06 01:57:48 +02:00
|
|
|
$orm->save($dialplan);
|
|
|
|
|
$dialplan_response = $orm->message;
|
|
|
|
|
|
|
|
|
|
//synchronize the xml config
|
|
|
|
|
save_dialplan_xml();
|
2014-08-08 03:16:30 +02:00
|
|
|
|
2015-01-15 20:33:27 +01:00
|
|
|
//clear the cache
|
|
|
|
|
$cache = new cache;
|
|
|
|
|
$cache->delete("dialplan:".$destination_context);
|
2014-07-02 08:40:28 +02:00
|
|
|
|
2014-08-06 01:57:48 +02:00
|
|
|
} //add or update the dialplan if the destination number is set
|
2015-03-18 08:28:05 +01:00
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
//remove empty dialplan details from POST array so doesn't attempt to insert below
|
|
|
|
|
unset($_POST["dialplan_details"]);
|
|
|
|
|
|
|
|
|
|
}
|
2014-04-27 00:50:52 +02:00
|
|
|
|
2014-04-24 15:37:56 +02:00
|
|
|
//get the destination_uuid
|
|
|
|
|
if (strlen($dialplan_response['uuid']) > 0) {
|
|
|
|
|
$_POST["dialplan_uuid"] = $dialplan_response['uuid'];
|
2013-01-21 19:19:13 +01:00
|
|
|
}
|
2014-04-27 00:50:52 +02:00
|
|
|
|
2014-04-24 15:37:56 +02:00
|
|
|
//save the destination
|
|
|
|
|
$orm = new orm;
|
|
|
|
|
$orm->name('destinations');
|
|
|
|
|
if (strlen($destination_uuid) > 0) {
|
|
|
|
|
$orm->uuid($destination_uuid);
|
2014-04-24 13:27:53 +02:00
|
|
|
}
|
2014-04-24 15:37:56 +02:00
|
|
|
$orm->save($_POST);
|
2014-08-02 12:39:49 +02:00
|
|
|
$message = $orm->message;
|
2014-04-24 15:37:56 +02:00
|
|
|
$destination_response = $orm->message;
|
2014-04-27 00:50:52 +02:00
|
|
|
|
2014-04-24 15:37:56 +02:00
|
|
|
//get the destination_uuid
|
|
|
|
|
if (strlen($destination_response['uuid']) > 0) {
|
|
|
|
|
$destination_uuid = $destination_response['uuid'];
|
2014-04-24 13:27:53 +02:00
|
|
|
}
|
2014-04-25 04:56:41 +02:00
|
|
|
|
2014-04-24 15:37:56 +02:00
|
|
|
//redirect the user
|
|
|
|
|
if ($action == "add") {
|
|
|
|
|
$_SESSION["message"] = $text['message-add'];
|
2014-07-24 05:06:33 +02:00
|
|
|
// billing
|
|
|
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){
|
|
|
|
|
$db2 = new database;
|
2015-03-31 04:53:36 +02:00
|
|
|
$db2->sql = "select currency, billing_uuid, balance from v_billings where type_value='$destination_accountcode'";
|
2014-07-24 05:06:33 +02:00
|
|
|
$db2->result = $db2->execute();
|
|
|
|
|
$default_currency = (strlen($_SESSION['billing']['currency']['text'])?$_SESSION['billing']['currency']['text']:'USD');
|
|
|
|
|
$billing_currency = (strlen($db2->result[0]['currency'])?$db2->result[0]['currency']:$default_currency);
|
|
|
|
|
$destination_sell_current_currency = currency_convert($destination_sell,$billing_currency,$currency);
|
2014-07-24 07:32:16 +02:00
|
|
|
$billing_uuid = $db2->result[0]['billing_uuid'];
|
|
|
|
|
$balance = $db2->result[0]['balance'];
|
2014-07-24 05:06:33 +02:00
|
|
|
unset($db2->sql, $db2->result);
|
2014-07-24 05:48:26 +02:00
|
|
|
|
2014-07-24 07:32:16 +02:00
|
|
|
$balance -= $destination_sell_current_currency;
|
2015-03-31 04:53:36 +02:00
|
|
|
$db2->sql = "update v_billings set balance = $balance, old_balance = $balance where type_value='$destination_accountcode'";
|
2014-07-24 05:48:26 +02:00
|
|
|
$db2->result = $db2->execute();
|
|
|
|
|
unset($db2->sql, $db2->result);
|
2014-07-24 07:32:16 +02:00
|
|
|
|
|
|
|
|
$billing_invoice_uuid = uuid();
|
|
|
|
|
$user_uuid = check_str($_SESSION['user_uuid']);
|
|
|
|
|
$settled=1;
|
2014-08-06 00:35:03 +02:00
|
|
|
$mc_gross = -1 * $destination_sell_current_currency;
|
2014-07-24 07:32:16 +02:00
|
|
|
$post_payload = serialize($_POST);
|
2015-03-31 04:53:36 +02:00
|
|
|
$db2->sql = "insert into v_billing_invoices (billing_invoice_uuid, billing_uuid, payer_uuid, billing_payment_date, settled, amount, debt, post_payload,plugin_used, domain_uuid) values ('$billing_invoice_uuid', '$billing_uuid', '$user_uuid', NOW(), $settled, $mc_gross, $balance, '$post_payload', 'DID $destination_number Assigment', '".$domain_uuid."' )";
|
2014-07-24 07:32:16 +02:00
|
|
|
$db2->result = $db2->execute();
|
|
|
|
|
unset($db2->sql, $db2->result);
|
2014-07-24 05:06:33 +02:00
|
|
|
}
|
2014-04-24 11:16:25 +02:00
|
|
|
}
|
2014-04-24 15:37:56 +02:00
|
|
|
if ($action == "update") {
|
|
|
|
|
$_SESSION["message"] = $text['message-update'];
|
2014-04-24 11:16:25 +02:00
|
|
|
}
|
2014-04-24 15:37:56 +02:00
|
|
|
header("Location: destination_edit.php?id=".$destination_uuid);
|
|
|
|
|
return;
|
2015-03-31 04:53:36 +02:00
|
|
|
|
2014-04-24 15:37:56 +02:00
|
|
|
} //if ($_POST["persistformvar"] != "true")
|
2014-04-24 11:16:25 +02:00
|
|
|
} //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0)
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//pre-populate the form
|
2014-04-24 11:16:25 +02:00
|
|
|
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
|
2012-06-04 16:58:40 +02:00
|
|
|
$destination_uuid = $_GET["id"];
|
2014-04-24 11:16:25 +02:00
|
|
|
$orm = new orm;
|
|
|
|
|
$orm->name('destinations');
|
|
|
|
|
$orm->uuid($destination_uuid);
|
|
|
|
|
$result = $orm->find()->get();
|
2012-06-04 16:58:40 +02:00
|
|
|
foreach ($result as &$row) {
|
2015-03-31 00:57:12 +02:00
|
|
|
if (permission_exists('destination_domain')) {
|
|
|
|
|
$domain_uuid = $row["domain_uuid"];
|
|
|
|
|
}
|
2012-10-23 12:00:03 +02:00
|
|
|
$dialplan_uuid = $row["dialplan_uuid"];
|
|
|
|
|
$destination_type = $row["destination_type"];
|
|
|
|
|
$destination_number = $row["destination_number"];
|
|
|
|
|
$destination_caller_id_name = $row["destination_caller_id_name"];
|
|
|
|
|
$destination_caller_id_number = $row["destination_caller_id_number"];
|
2014-08-02 06:41:00 +02:00
|
|
|
$destination_cid_name_prefix = $row["destination_cid_name_prefix"];
|
2012-06-04 16:58:40 +02:00
|
|
|
$destination_context = $row["destination_context"];
|
2012-11-13 03:18:57 +01:00
|
|
|
$fax_uuid = $row["fax_uuid"];
|
2012-06-04 16:58:40 +02:00
|
|
|
$destination_enabled = $row["destination_enabled"];
|
|
|
|
|
$destination_description = $row["destination_description"];
|
2014-06-23 17:18:22 +02:00
|
|
|
$currency = $row["currency"];
|
|
|
|
|
$destination_sell = $row["destination_sell"];
|
2014-07-24 05:06:33 +02:00
|
|
|
$destination_buy = $row["destination_buy"];
|
|
|
|
|
$currency_buy = $row["currency_buy"];
|
2014-07-14 00:29:25 +02:00
|
|
|
$destination_accountcode = $row["destination_accountcode"];
|
|
|
|
|
$destination_carrier = $row["destination_carrier"];
|
2012-06-04 16:58:40 +02:00
|
|
|
break; //limit to 1 row
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-24 11:16:25 +02:00
|
|
|
//get the dialplan details in an array
|
|
|
|
|
$sql = "select * from v_dialplan_details ";
|
2015-01-25 09:24:32 +01:00
|
|
|
$sql .= "where domain_uuid = '".$domain_uuid."' ";
|
2014-04-24 11:16:25 +02:00
|
|
|
$sql .= "and dialplan_uuid = '".$dialplan_uuid."' ";
|
|
|
|
|
$sql .= "order by dialplan_detail_group asc, dialplan_detail_order asc";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$dialplan_details = $prep_statement->fetchAll(PDO::FETCH_NAMED);;
|
|
|
|
|
unset ($prep_statement, $sql);
|
|
|
|
|
|
|
|
|
|
//add an empty row to the array
|
|
|
|
|
$x = count($dialplan_details);
|
|
|
|
|
$limit = $x + 1;
|
|
|
|
|
while($x < $limit) {
|
2015-01-25 09:24:32 +01:00
|
|
|
$dialplan_details[$x]['domain_uuid'] = $domain_uuid;
|
2014-04-24 11:16:25 +02:00
|
|
|
$dialplan_details[$x]['dialplan_uuid'] = $dialplan_uuid;
|
|
|
|
|
$dialplan_details[$x]['dialplan_detail_type'] = '';
|
|
|
|
|
$dialplan_details[$x]['dialplan_detail_data'] = '';
|
|
|
|
|
$dialplan_details[$x]['dialplan_detail_order'] = '';
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
unset($limit);
|
|
|
|
|
|
2012-10-23 12:00:03 +02:00
|
|
|
//set the defaults
|
|
|
|
|
if (strlen($destination_type) == 0) { $destination_type = 'inbound'; }
|
|
|
|
|
if (strlen($destination_context) == 0) { $destination_context = 'public'; }
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//show the header
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2013-05-08 01:38:12 +02:00
|
|
|
if ($action == "update") {
|
2014-07-10 02:32:50 +02:00
|
|
|
$document['title'] = $text['title-destination-edit'];
|
2013-05-08 01:38:12 +02:00
|
|
|
}
|
|
|
|
|
else if ($action == "add") {
|
2014-07-10 02:32:50 +02:00
|
|
|
$document['title'] = $text['title-destination-add'];
|
2013-05-08 01:38:12 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//show the content
|
|
|
|
|
echo "<form method='post' name='frm' action=''>\n";
|
2015-02-15 08:59:02 +01:00
|
|
|
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
if ($action == "add") {
|
2015-03-22 01:53:56 +01:00
|
|
|
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['header-destination-add']."</b></td>\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
}
|
|
|
|
|
if ($action == "update") {
|
2015-03-22 01:53:56 +01:00
|
|
|
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['header-destination-edit']."</b></td>\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
}
|
2015-03-22 01:53:56 +01:00
|
|
|
echo "<td width='70%' align='right' valign='top'>";
|
2015-03-31 00:57:12 +02:00
|
|
|
echo " <input type='button' class='btn' alt='".$text['button-back']."' onclick=\"window.location='destinations.php'\" value='".$text['button-back']."'>";
|
2014-04-27 00:50:52 +02:00
|
|
|
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
|
|
|
|
|
echo "</td>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td align='left' colspan='2'>\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
echo $text['description-destinations']."<br /><br />\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_type']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2012-10-23 12:00:03 +02:00
|
|
|
echo " <select class='formfld' name='destination_type'>\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
switch ($destination_type) {
|
|
|
|
|
case "inbound" : $selected[1] = "selected='selected'"; break;
|
|
|
|
|
case "outbound" : $selected[2] = "selected='selected'"; break;
|
2012-10-23 12:00:03 +02:00
|
|
|
}
|
2013-05-08 01:38:12 +02:00
|
|
|
echo " <option value='inbound' ".$selected[1].">".$text['option-type_inbound']."</option>\n";
|
|
|
|
|
echo " <option value='outbound' ".$selected[2].">".$text['option-type_outbound']."</option>\n";
|
|
|
|
|
unset($selected);
|
2012-10-23 12:00:03 +02:00
|
|
|
echo " </select>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<br />\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
echo $text['description-destination_type']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
2014-06-21 02:58:16 +02:00
|
|
|
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_number']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2014-12-21 07:18:18 +01:00
|
|
|
echo " <input class='formfld' type='text' name='destination_number' maxlength='255' value=\"$destination_number\" required='required'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<br />\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
echo $text['description-destination_number']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2013-11-06 16:50:57 +01:00
|
|
|
if (permission_exists('outbound_caller_id_select')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_caller_id_name']."\n";
|
2013-11-06 16:50:57 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='text' name='destination_caller_id_name' maxlength='255' value=\"$destination_caller_id_name\">\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-destination_caller_id_name']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2012-10-23 12:00:03 +02:00
|
|
|
|
2013-11-06 16:50:57 +01:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_caller_id_number']."\n";
|
2013-11-06 16:50:57 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2014-12-21 07:18:18 +01:00
|
|
|
echo " <input class='formfld' type='number' name='destination_caller_id_number' maxlength='255' min='0' step='1' value=\"$destination_caller_id_number\">\n";
|
2013-11-06 16:50:57 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-destination_caller_id_number']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
}
|
2012-10-23 12:00:03 +02:00
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_context']."\n";
|
2012-10-23 12:00:03 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='text' name='destination_context' maxlength='255' value=\"$destination_context\">\n";
|
|
|
|
|
echo "<br />\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
echo $text['description-destination_context']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2014-04-24 11:16:25 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-detail_action']."\n";
|
2014-04-24 11:16:25 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
|
|
|
|
|
echo " <table width='52%' border='0' cellpadding='2' cellspacing='0'>\n";
|
|
|
|
|
$x = 0;
|
2014-08-02 12:39:49 +02:00
|
|
|
$order = 10;
|
2014-04-24 11:16:25 +02:00
|
|
|
foreach($dialplan_details as $row) {
|
2014-12-10 05:43:27 +01:00
|
|
|
if ($row["dialplan_detail_tag"] != "condition") {
|
2015-03-24 00:57:27 +01:00
|
|
|
if ($row["dialplan_detail_tag"] == "action" && $row["dialplan_detail_type"] == "set" && strpos($row["dialplan_detail_data"], "accountcode") == 0) { continue; } //exclude set:accountcode actions
|
2014-08-03 08:43:49 +02:00
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td>\n";
|
2014-08-02 12:39:49 +02:00
|
|
|
if (strlen($row['dialplan_detail_uuid']) > 0) {
|
|
|
|
|
echo " <input name='dialplan_details[".$x."][dialplan_detail_uuid]' type='hidden' value=\"".$row['dialplan_detail_uuid']."\">\n";
|
|
|
|
|
}
|
|
|
|
|
echo " <input name='dialplan_details[".$x."][dialplan_detail_type]' type='hidden' value=\"".$row['dialplan_detail_type']."\">\n";
|
|
|
|
|
echo " <input name='dialplan_details[".$x."][dialplan_detail_order]' type='hidden' value=\"".$order."\">\n";
|
|
|
|
|
|
|
|
|
|
$data = $row['dialplan_detail_data'];
|
|
|
|
|
$label = explode("XML", $data);
|
2014-08-03 08:43:49 +02:00
|
|
|
$divider = ($row['dialplan_detail_type'] != '') ? ":" : null;
|
|
|
|
|
$detail_action = $row['dialplan_detail_type'].$divider.$row['dialplan_detail_data'];
|
2014-08-02 12:39:49 +02:00
|
|
|
switch_select_destination("dialplan", $label[0], "dialplan_details[".$x."][dialplan_detail_data]", $detail_action, "width: 60%;", $row['dialplan_detail_type']);
|
|
|
|
|
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " <td class='list_control_icons' style='width: 25px;'>";
|
|
|
|
|
if (strlen($row['destination_uuid']) > 0) {
|
|
|
|
|
echo "<a href='destination_delete.php?id=".$row['destination_uuid']."&destination_uuid=".$row['destination_uuid']."&a=delete' alt='delete' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
|
|
|
|
}
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
2014-04-24 11:16:25 +02:00
|
|
|
}
|
2014-08-02 12:39:49 +02:00
|
|
|
$order = $order + 10;
|
2014-04-24 11:16:25 +02:00
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2014-12-17 12:33:31 +01:00
|
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/fax/app_config.php")){
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-fax_uuid']."\n";
|
2014-12-17 12:33:31 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
$sql = "select * from v_fax ";
|
2015-01-25 09:24:32 +01:00
|
|
|
$sql .= "where domain_uuid = '".$domain_uuid."' ";
|
2014-12-17 12:33:31 +01:00
|
|
|
$sql .= "order by fax_name asc ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
echo " <select name='fax_uuid' id='fax_uuid' class='formfld' style='".$select_style."'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
foreach ($result as &$row) {
|
|
|
|
|
if ($row["fax_uuid"] == $fax_uuid) {
|
|
|
|
|
echo " <option value='".$row["fax_uuid"]."' selected='selected'>".$row["fax_extension"]." ".$row["fax_name"]."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='".$row["fax_uuid"]."'>".$row["fax_extension"]." ".$row["fax_name"]."</option>\n";
|
|
|
|
|
}
|
2012-11-13 03:18:57 +01:00
|
|
|
}
|
2014-12-17 12:33:31 +01:00
|
|
|
echo " </select>\n";
|
|
|
|
|
unset ($prep_statement, $extension);
|
|
|
|
|
echo " <br />\n";
|
|
|
|
|
echo " ".$text['description-fax_uuid']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2012-11-13 03:18:57 +01:00
|
|
|
}
|
|
|
|
|
|
2014-08-02 08:09:55 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_cid_name_prefix']."\n";
|
2014-08-02 08:09:55 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='text' name='destination_cid_name_prefix' maxlength='255' value=\"$destination_cid_name_prefix\">\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-destination_cid_name_prefix']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2014-06-23 17:18:22 +02:00
|
|
|
// billing
|
2014-07-17 22:47:35 +02:00
|
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){
|
2014-06-23 17:18:22 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-monthly_price']."\n";
|
2014-06-23 17:18:22 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2014-07-24 00:53:51 +02:00
|
|
|
echo " <input class='formfld' type='number' min='0' step='0.01' name='destination_sell' maxlength='255' value=\"$destination_sell\">\n";
|
2014-06-23 17:18:22 +02:00
|
|
|
currency_select($currency);
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-monthly_price']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2014-07-14 00:29:25 +02:00
|
|
|
|
2014-07-24 05:06:33 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-monthly_price_buy']."\n";
|
2014-07-24 05:06:33 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='number' min='0' step='0.01' name='destination_buy' maxlength='255' value=\"$destination_buy\">\n";
|
|
|
|
|
currency_select($currency_buy,0,'currency_buy');
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-monthly_price_buy']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2014-07-14 00:29:25 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-carrier']."\n";
|
2014-07-14 00:29:25 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='text' name='destination_carrier' maxlength='255' value=\"$destination_carrier\">\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-carrier']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
|
2014-07-15 08:26:51 +02:00
|
|
|
//set the default account code
|
2015-03-24 00:57:27 +01:00
|
|
|
if ($action == "add") { $destination_accountcode = $_SESSION['domain_name']; }
|
2014-06-23 17:18:22 +02:00
|
|
|
}
|
2014-07-15 08:19:19 +02:00
|
|
|
|
2014-07-14 00:29:25 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-account_code']."\n";
|
2014-07-14 00:29:25 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='text' name='destination_accountcode' maxlength='255' value=\"$destination_accountcode\">\n";
|
|
|
|
|
echo "<br />\n";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo $text['description-account_code']."\n";
|
2014-07-30 03:12:41 +02:00
|
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){
|
|
|
|
|
echo " ".$text['billing-warning'];
|
|
|
|
|
}
|
2014-07-14 00:29:25 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
|
2015-01-25 09:24:32 +01:00
|
|
|
if (permission_exists('destination_domain')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-domain']."\n";
|
2015-01-25 09:24:32 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <select class='formfld' name='domain_uuid'>\n";
|
|
|
|
|
if (strlen($domain_uuid) == 0) {
|
|
|
|
|
echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value=''>".$text['select-global']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
foreach ($_SESSION['domains'] as $row) {
|
|
|
|
|
if ($row['domain_uuid'] == $domain_uuid) {
|
|
|
|
|
echo " <option value='".$row['domain_uuid']."' selected='selected'>".$row['domain_name']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-domain_name']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-15 08:19:19 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_enabled']."\n";
|
2014-07-15 08:19:19 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <select class='formfld' name='destination_enabled'>\n";
|
|
|
|
|
switch ($destination_enabled) {
|
|
|
|
|
case "true" : $selected[1] = "selected='selected'"; break;
|
|
|
|
|
case "false" : $selected[2] = "selected='selected'"; break;
|
|
|
|
|
}
|
|
|
|
|
echo " <option value='true' ".$selected[1].">".$text['label-true']."</option>\n";
|
|
|
|
|
echo " <option value='false' ".$selected[2].">".$text['label-false']."</option>\n";
|
|
|
|
|
unset($selected);
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-destination_enabled']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-destination_description']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='text' name='destination_description' maxlength='255' value=\"$destination_description\">\n";
|
|
|
|
|
echo "<br />\n";
|
2013-05-08 01:38:12 +02:00
|
|
|
echo $text['description-destination_description']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td colspan='2' align='right'>\n";
|
|
|
|
|
if ($action == "update") {
|
2015-02-15 08:59:02 +01:00
|
|
|
echo " <input type='hidden' name='db_destination_number' value='$destination_number'>\n";
|
|
|
|
|
echo " <input type='hidden' name='dialplan_uuid' value='$dialplan_uuid'>\n";
|
|
|
|
|
echo " <input type='hidden' name='destination_uuid' value='$destination_uuid'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2015-02-15 10:20:19 +01:00
|
|
|
echo " <br>";
|
2015-02-15 08:59:02 +01:00
|
|
|
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>";
|
|
|
|
|
echo "</table>";
|
2015-02-15 08:59:02 +01:00
|
|
|
echo "<br><br>";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</form>";
|
|
|
|
|
|
|
|
|
|
//include the footer
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2014-08-02 12:39:49 +02:00
|
|
|
|
2015-01-25 09:24:32 +01:00
|
|
|
?>
|