Call Forward - List: Implement natural sorting of Extension column.

This commit is contained in:
fusionate 2023-10-19 16:48:45 +00:00
parent 1926e60b6e
commit a14dd3d71c
No known key found for this signature in database
1 changed files with 20 additions and 13 deletions

View File

@ -18,7 +18,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2021
Portions created by the Initial Developer are Copyright (C) 2008-2023
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -36,7 +36,8 @@
//check permissions
if (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb')) {
//access granted
} else {
}
else {
echo "access denied";
exit;
}
@ -78,8 +79,9 @@
}
//get order and order by
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
$order_by = $_GET["order_by"] ?? 'extension';
$order = $_GET["order"] ?? 'asc';
$sort = $order_by == 'extension' ? 'natural' : null;
//get the search
$search = strtolower($_GET["search"] ?? '');
@ -91,7 +93,8 @@
$sql = "select count(*) from v_extensions ";
if ($show === "all" && permission_exists('call_forward_all')) {
$sql .= "where true ";
} else {
}
else {
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
@ -154,7 +157,8 @@
$sql = "select * from v_extensions ";
if ($show == "all" && permission_exists('call_forward_all')) {
$sql .= "where true ";
} else {
}
else {
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
@ -178,19 +182,20 @@
$x++;
}
$sql .= ")";
} else {
}
else {
//used to hide any results when a user has not been assigned an extension
$sql .= "and extension = 'disabled' ";
}
}
$sql .= order_by($order_by, $order, 'extension', 'asc');
$sql .= order_by($order_by, $order, 'extension', 'asc', $sort);
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$extensions = $database->select($sql, $parameters ?? null, 'all');
unset($parameters);
//if there are no extensions then set to empty array
if($extensions === false) {
if ($extensions === false) {
$extensions = [];
}
@ -200,7 +205,7 @@
//include header
if (!$is_included) {
$document['title'] = $text['title-call_forward'];
$document['title'] = $text['title-call_forward'];
}
require_once "resources/header.php";
@ -215,7 +220,8 @@
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
} else {
}
else {
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>" . $text['header-call_forward'] . " (" . $num_rows . ")</b></div>\n";
echo " <div class='actions'>\n";
@ -274,7 +280,8 @@
echo "<th>" . $text['label-domain'] . "</th>\n";
}
}
echo " <th>" . $text['label-extension'] . "</th>\n";
echo th_order_by('extension', $text['label-extension'], $order_by, $order);
// echo " <th>" . $text['label-extension'] . "</th>\n";
if (permission_exists('call_forward')) {
echo " <th>" . $text['label-call_forward'] . "</th>\n";
}
@ -411,4 +418,4 @@
require_once "resources/footer.php";
}
?>
?>