Multilinguified Hot Desking, fixed bug where editing an existing Extension detected its own Unique ID and prevented the update.

This commit is contained in:
Nate Jones 2013-06-06 21:31:19 +00:00
parent 0976891947
commit a6a04c3bb2
4 changed files with 100 additions and 43 deletions

View File

@ -0,0 +1,40 @@
<?php
//Hot Desking
$text['title-hot_desking']['en-us'] = 'Hot Desking';
$text['header-hot_desking']['en-us'] = 'Hot Desking';
$text['header-message']['en-us'] = 'Message';
$text['description-hot_desking']['en-us'] = 'Login into hot desking with an ID and your voicemail password to direct your calls to a remote extension. Then make and receive calls as if you were at your extension. ';
$text['label-extension']['en-us'] = 'Extension';
$text['label-unique_id']['en-us'] = 'Unique ID';
$text['label-forward_to']['en-us'] = 'Forward To';
$text['label-description']['en-us'] = 'Description';
$text['label-voicemail_password']['en-us'] = 'Voicemail Password';
$text['label-dial_string']['en-us'] = 'Dial String';
$text['description-extension-add']['en-us'] = 'Select the extension number.';
$text['description-extension-edit']['en-us'] = 'Extension number.';
$text['description-unique_id']['en-us'] = 'A unique NUMERIC ID to identify the extension and domain.';
$text['description-voicemail_password']['en-us'] = 'Enter the voicemail password here.';
$text['description-password']['en-us'] = 'Password';
$text['description-dial_string']['en-us'] = 'Location of the endpoint.';
$text['button-add']['en-us'] = 'Add';
$text['button-edit']['en-us'] = 'Edit';
$text['button-delete']['en-us'] = 'Delete';
$text['button-back']['en-us'] = 'Back';
$text['button-save']['en-us'] = 'Save';
$text['confirm-delete']['en-us'] = 'Do you really want to delete this?';
$text['message-add']['en-us'] = 'Add Completed';
$text['message-update']['en-us'] = 'Update Completed';
$text['message-delete']['en-us'] = 'Delete Completed';
$text['message-required']['en-us'] = 'Please provide: ';
$text['message-unique']['en-us'] = 'The Unique ID is not unique. Please provide a numeric ID not already in use by a different extension.';
?>

View File

@ -34,6 +34,12 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
if (count($_GET)>0) {
$id = check_str($_GET["id"]);
}
@ -78,10 +84,10 @@ if (count($_GET)>0) {
echo "<div align='center'>\n";
echo " <table width='40%'>\n";
echo " <tr>\n";
echo " <th align='left'>Message</th>\n";
echo " <th align='left'>".$text['header-message']."</th>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='row_style1'><strong>Delete Complete</strong></td>\n";
echo " <td class='row_style1'><strong>".$text['message-delete']."</strong></td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <br />\n";

View File

@ -33,6 +33,12 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//set the action as an add or an update
if (isset($_REQUEST["id"])) {
$action = "update";
@ -54,18 +60,18 @@ else {
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//check for all required data
//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
if (strlen($extension_uuid) == 0) { $msg .= "Please provide the extension<br>\n"; }
if (strlen($unique_id) == 0) { $msg .= "Please provide the unique ID.<br>\n"; }
//get the number of rows in v_extensions
if (strlen($extension_uuid) == 0) { $msg .= $text['message-required'].$text['label-extension']."<br>\n"; }
if (strlen($unique_id) == 0) { $msg .= $text['message-required'].$text['label-unique_id']."<br>\n"; }
//get the number of rows in v_extensions
$sql = "select count(*) as num_rows from v_extensions ";
$sql .= "where unique_id = '".$unique_id."' ";
$sql .= "where unique_id = '".$unique_id."' and ";
$sql .= "extension_uuid <> '".$extension_uuid."'";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) {
$msg .= "The ID is not unqiue please provide a unique ID.<br>\n";
$msg .= $text['message-unique']."<br>\n";
}
}
unset($prep_statement, $result);
@ -88,7 +94,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
else {
//if the user_context was not set then set the default value
if (strlen($user_context) == 0) {
if (strlen($user_context) == 0) {
if (count($_SESSION["domains"]) > 1) {
$user_context = $_SESSION['domain_name'];
}
@ -152,14 +158,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<div align='center'>\n";
echo " <table width='40%'>\n";
echo " <tr>\n";
echo " <th align='left'>Message</th>\n";
echo " <th align='left'>".$text['header-message']."</th>\n";
echo " </tr>\n";
echo " <tr>\n";
if ($action == "add") {
echo " <td class='row_style1'><strong>Add Complete</strong></td>\n";
echo " <td class='row_style1'><strong>".$text['message-add']."</strong></td>\n";
}
if ($action == "update") {
echo " <td class='row_style1'><strong>Update Complete</strong></td>\n";
echo " <td class='row_style1'><strong>".$text['message-update']."</strong></td>\n";
}
echo " </tr>\n";
echo " </table>\n";
@ -230,17 +236,17 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td width='30%' nowrap='nowrap' align='left' valign='top'>\n";
echo " <b>Hot Desking</b>\n";
echo " <b>".$text['header-hot_desking']."</b>\n";
echo " </td>\n";
echo " <td width='70%' align='right' valign='top'>\n";
echo " <input type='submit' name='submit' class='btn' value='Save'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='index.php'\" value='Back'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='index.php'\" value='".$text['button-back']."'>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " Extension:\n";
echo " ".$text['label-extension'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if ($action == "add") {
@ -265,48 +271,48 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
unset($sql, $result, $result_count);
echo "</select><br />\n";
echo "Select the extension number.\n";
echo $text['description-extension-add']."\n";
}
if ($action == "update") {
echo " $extension<br />\n";
echo "Extension number.\n";
echo $text['description-extension-edit']."\n";
}
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Unique ID:\n";
echo " ".$text['label-unique_id'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='unique_id' autocomplete='off' maxlength='255' value=\"$unique_id\">\n";
echo "<br />\n";
echo "A unique ID to identify the extension and domain.\n";
echo $text['description-unique_id']."\n";
echo "</td>\n";
echo "</tr>\n";
if ($action == "update") {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Voicemail Password:\n";
echo " ".$text['label-voicemail_password'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='password' name='vm_password' id='vm_password' onfocus=\"document.getElementById('show_vm_password').innerHTML = 'Password: '+document.getElementById('vm_password').value;\" maxlength='255' value='$vm_password'>\n";
echo " <input class='formfld' type='password' name='vm_password' id='vm_password' onfocus=\"document.getElementById('show_vm_password').innerHTML = '".$text['description-password'].": '+document.getElementById('vm_password').value;\" maxlength='255' value='$vm_password'>\n";
echo "<br />\n";
echo "<span onclick=\"document.getElementById('show_vm_password').innerHTML = ''\">Enter the voicemail password here. </span><span id='show_vm_password'></span>\n";
echo "<span onclick=\"document.getElementById('show_vm_password').innerHTML = ''\">".$text['description-voicemail_password']." </span><span id='show_vm_password'></span>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Dial String:\n";
echo " ".$text['label-dial_string'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dial_string' maxlength='255' value=\"$dial_string\">\n";
echo "<br />\n";
echo "Location of the endpoint.\n";
echo $text['description-dial_string']."\n";
echo "</td>\n";
echo "</tr>\n";

View File

@ -33,7 +33,16 @@ else {
echo "access denied";
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
require_once "includes/header.php";
$page["title"] = $text['title-hot_desking'];
require_once "includes/paging.php";
//get the http values and set them as variables
@ -52,14 +61,14 @@ require_once "includes/paging.php";
//show the content header
echo "<table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'><b>Hot Desking</b><br>\n";
echo " Login into hot desking with an ID and your voicemail password to direct your calls to a remote extension. Then make and receive calls as if you were at your extension.\n";
echo " <td align='left'><b>".$text['header-hot_desking']."</b><br>\n";
echo " ".$text['description-hot_desking']."\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br />";
//get the number of rows in v_extensions
//get the number of rows in v_extensions
$sql = "select count(*) as num_rows from v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and unique_id is not null ";
@ -81,8 +90,8 @@ require_once "includes/paging.php";
$param = "";
if (!isset($_GET['page'])) { $_GET['page'] = 0; }
$_GET['page'] = check_str($_GET['page']);
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $_GET['page'];
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $_GET['page'];
//get the extension list
$sql = "select * from v_extensions ";
@ -108,15 +117,13 @@ 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('extension', 'Extension', $order_by, $order);
echo th_order_by('unique_id', 'Unique ID', $order_by, $order);
echo th_order_by('dial_user', 'Forward To', $order_by, $order);
//echo th_order_by('dial_domain', 'Domain', $order_by, $order);
//echo th_order_by('call_group', 'Domain', $order_by, $order);
echo th_order_by('description', 'Description', $order_by, $order);
echo th_order_by('extension', $text['label-extension'], $order_by, $order);
echo th_order_by('unique_id', $text['label-unique_id'], $order_by, $order);
echo th_order_by('dial_user', $text['label-forward_to'], $order_by, $order);
echo th_order_by('description', $text['label-description'], $order_by, $order);
echo "<td align='right' width='42'>\n";
if (permission_exists('extension_add')) {
echo " <a href='extension_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " <a href='extension_edit.php' alt='".$text['message-add']."'>$v_link_label_add</a>\n";
}
echo "</td>\n";
echo "<tr>\n";
@ -132,15 +139,13 @@ require_once "includes/paging.php";
else {
echo " <td valign='top' class='".$row_style[$c]."'>&nbsp;</td>\n";
}
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['dial_domain']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['domain_uuid']."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg' width='30%'>".$row['description']."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n";
if (permission_exists('extension_edit')) {
echo " <a href='extension_edit.php?id=".$row['extension_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
echo " <a href='extension_edit.php?id=".$row['extension_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
}
if (permission_exists('extension_delete')) {
echo " <a href='extension_delete.php?id=".$row['extension_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
echo " <a href='extension_delete.php?id=".$row['extension_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
@ -157,7 +162,7 @@ require_once "includes/paging.php";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>\n";
if (permission_exists('extension_add')) {
echo " <a href='extension_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " <a href='extension_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
}
echo " </td>\n";
echo " </tr>\n";