Remodel the destinations table rename several fields and add new fields.

This commit is contained in:
Mark Crane
2012-10-23 10:00:03 +00:00
parent 4d6205656d
commit e501279cff
4 changed files with 223 additions and 63 deletions
+118 -34
View File
@@ -1,4 +1,28 @@
<?php
/*
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>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
@@ -21,9 +45,12 @@ else {
//get http post variables and set them to php variables
if (count($_POST)>0) {
$destination_name = check_str($_POST["destination_name"]);
$dialplan_uuid = check_str($_POST["dialplan_uuid"]);
$destination_type = check_str($_POST["destination_type"]);
$destination_number = check_str($_POST["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_context = check_str($_POST["destination_context"]);
$destination_extension = check_str($_POST["destination_extension"]);
$destination_enabled = check_str($_POST["destination_enabled"]);
$destination_description = check_str($_POST["destination_description"]);
}
@@ -36,9 +63,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
//check for all required data
//if (strlen($destination_name) == 0) { $msg .= "Please provide: Name<br>\n"; }
//if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID<br>\n"; }
//if (strlen($destination_type) == 0) { $msg .= "Please provide: Name<br>\n"; }
//if (strlen($destination_number) == 0) { $msg .= "Please provide: Extension<br>\n"; }
//if (strlen($destination_caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name<br>\n"; }
//if (strlen($destination_caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number<br>\n"; }
//if (strlen($destination_context) == 0) { $msg .= "Please provide: Context<br>\n"; }
//if (strlen($destination_extension) == 0) { $msg .= "Please provide: Extension<br>\n"; }
//if (strlen($destination_enabled) == 0) { $msg .= "Please provide: Enabled<br>\n"; }
//if (strlen($destination_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
@@ -60,20 +90,30 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql = "insert into v_destinations ";
$sql .= "(";
$sql .= "domain_uuid, ";
if (strlen($dialplan_uuid) > 0) {
$sql .= "dialplan_uuid, ";
}
$sql .= "destination_uuid, ";
$sql .= "destination_name, ";
$sql .= "destination_type, ";
$sql .= "destination_number, ";
$sql .= "destination_caller_id_name, ";
$sql .= "destination_caller_id_number, ";
$sql .= "destination_context, ";
$sql .= "destination_extension, ";
$sql .= "destination_enabled, ";
$sql .= "destination_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
if (strlen($dialplan_uuid) > 0) {
$sql .= "'$dialplan_uuid', ";
}
$sql .= "'".uuid()."', ";
$sql .= "'$destination_name', ";
$sql .= "'$destination_type', ";
$sql .= "'$destination_number', ";
$sql .= "'$destination_caller_id_name', ";
$sql .= "'$destination_caller_id_number', ";
$sql .= "'$destination_context', ";
$sql .= "'$destination_extension', ";
$sql .= "'$destination_enabled', ";
$sql .= "'$destination_description' ";
$sql .= ")";
@@ -91,9 +131,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if ($action == "update") {
$sql = "update v_destinations set ";
$sql .= "destination_name = '$destination_name', ";
if (strlen($dialplan_uuid) > 0) {
$sql .= "dialplan_uuid = '$dialplan_uuid', ";
}
$sql .= "destination_type = '$destination_type', ";
$sql .= "destination_number = '$destination_number', ";
$sql .= "destination_caller_id_name = '$destination_caller_id_name', ";
$sql .= "destination_caller_id_number = '$destination_caller_id_number', ";
$sql .= "destination_context = '$destination_context', ";
$sql .= "destination_extension = '$destination_extension', ";
$sql .= "destination_enabled = '$destination_enabled', ";
$sql .= "destination_description = '$destination_description' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
@@ -122,9 +167,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$prep_statement->execute();
$result = $prep_statement->fetchAll();
foreach ($result as &$row) {
$destination_name = $row["destination_name"];
$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"];
$destination_context = $row["destination_context"];
$destination_extension = $row["destination_extension"];
$destination_enabled = $row["destination_enabled"];
$destination_description = $row["destination_description"];
break; //limit to 1 row
@@ -132,6 +180,10 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
unset ($prep_statement);
}
//set the defaults
if (strlen($destination_type) == 0) { $destination_type = 'inbound'; }
if (strlen($destination_context) == 0) { $destination_context = 'public'; }
//show the header
require_once "includes/header.php";
@@ -146,12 +198,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
if ($action == "add") {
echo "<td align='left' width='30%' nowrap='nowrap'><b>Destination Add</b></td>\n";
}
if ($action == "update") {
echo "<td align='left' width='30%' nowrap='nowrap'><b>Destination Edit</b></td>\n";
}
echo "<td align='left' width='30%' nowrap='nowrap'><b>Destination</b></td>\n";
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='destinations.php'\" value='Back'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
@@ -162,12 +209,59 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Name:\n";
echo " Type:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='destination_name' maxlength='255' value=\"$destination_name\">\n";
echo " <select class='formfld' name='destination_type'>\n";
echo " <option value=''></option>\n";
if ($destination_type == "inbound") {
echo " <option value='inbound' selected='selected'>inbound</option>\n";
}
else {
echo " <option value='inbound'>inbound</option>\n";
}
if ($destination_type == "outbound") {
echo " <option value='outbound' selected='selected'>outbound</option>\n";
}
else {
echo " <option value='outbound'>outbound</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo "Enter the name.\n";
echo "Select the type.\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Destination:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='destination_number' maxlength='255' value=\"$destination_number\">\n";
echo "<br />\n";
echo "Enter the destination.\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Caller ID Name:\n";
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 "Enter the caller id name.\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Caller ID Number:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='destination_caller_id_number' maxlength='255' value=\"$destination_caller_id_number\">\n";
echo "<br />\n";
echo "Enter the caller id number.\n";
echo "</td>\n";
echo "</tr>\n";
@@ -182,17 +276,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Extension:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='destination_extension' maxlength='255' value=\"$destination_extension\">\n";
echo "<br />\n";
echo "Enter the extension.\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Enabled:\n";
@@ -201,13 +284,13 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo " <select class='formfld' name='destination_enabled'>\n";
echo " <option value=''></option>\n";
if ($destination_enabled == "true") {
echo " <option value='true' SELECTED >true</option>\n";
echo " <option value='true' selected='selected'>true</option>\n";
}
else {
echo " <option value='true'>true</option>\n";
}
if ($destination_enabled == "false") {
echo " <option value='false' SELECTED >false</option>\n";
echo " <option value='false' selected='selected'>false</option>\n";
}
else {
echo " <option value='false'>false</option>\n";
@@ -231,6 +314,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
if ($action == "update") {
echo " <input type='hidden' name='dialplan_uuid' value='$dialplan_uuid'>\n";
echo " <input type='hidden' name='destination_uuid' value='$destination_uuid'>\n";
}
echo " <input type='submit' name='submit' class='btn' value='Save'>\n";