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

View File

@ -71,17 +71,44 @@
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_name';
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dialplan_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_dialplans';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'dialplan_uuid';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'destination_type';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'destination_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the name.';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the type.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'destination_number';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'destination_number';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the number.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_caller_id_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the caller id name.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_caller_id_number';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the caller id number.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_context';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the context.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_extension';
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_app';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the extension.';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the application.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_data';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the data.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';

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";
@ -30,7 +54,7 @@ require_once "includes/paging.php";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " Used to provide a simple way of directing a call through the dialplan to find its destination.<br /><br />\n";
echo " Inbound destinations are the DID/DDI, DNIS or Alias for inbound calls.<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
@ -52,7 +76,7 @@ require_once "includes/paging.php";
}
//prepare to page the results
$rows_per_page = 10;
$rows_per_page = 150;
$param = "";
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
@ -60,10 +84,10 @@ require_once "includes/paging.php";
$offset = $rows_per_page * $page;
//get the list
$sql = " select * from v_destinations ";
$sql .= " where domain_uuid = '$domain_uuid' ";
$sql = "select * from v_destinations ";
$sql .= "where domain_uuid = '$domain_uuid' ";
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= " limit $rows_per_page offset $offset ";
$sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll();
@ -77,9 +101,9 @@ require_once "includes/paging.php";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('destination_name', 'Name', $order_by, $order);
echo th_order_by('destination_type', 'Name', $order_by, $order);
echo th_order_by('destination_number', 'Destination', $order_by, $order);
echo th_order_by('destination_context', 'Context', $order_by, $order);
echo th_order_by('destination_extension', 'Extension', $order_by, $order);
echo th_order_by('destination_enabled', 'Enabled', $order_by, $order);
echo th_order_by('destination_description', 'Description', $order_by, $order);
echo "<td align='right' width='42'>\n";
@ -89,9 +113,9 @@ require_once "includes/paging.php";
if ($result_count > 0) {
foreach($result as $row) {
echo "<tr >\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_name']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_type']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_number']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_context']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_extension']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_enabled']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_description']."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n";

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";
@ -14,22 +38,23 @@ if (count($_GET)>0) {
$id = check_str($_GET["id"]);
}
if (strlen($id)>0) {
$sql = "";
$sql .= "delete from v_destinations ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and destination_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
}
//delete the destination
if (strlen($id)>0) {
$sql .= "delete from v_destinations ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and destination_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
}
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=destinations.php\">\n";
echo "<div align='center'>\n";
echo "Delete Complete\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
//redirect the browser
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=destinations.php\">\n";
echo "<div align='center'>\n";
echo "Delete Complete\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
?>

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";