diff --git a/app/bridges/resources/classes/bridges.php b/app/bridges/resources/classes/bridges.php index 85a2d23392..8fd620b4c1 100644 --- a/app/bridges/resources/classes/bridges.php +++ b/app/bridges/resources/classes/bridges.php @@ -69,7 +69,7 @@ if (!class_exists('bridges')) { if (is_array($records) && @sizeof($records) != 0) { //build the delete array - foreach($records as $x => $record) { + foreach ($records as $x => $record) { if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; diff --git a/app/calls/calls.php b/app/calls/calls.php index e2256f9195..340ab3a51e 100644 --- a/app/calls/calls.php +++ b/app/calls/calls.php @@ -28,6 +28,7 @@ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; + require_once "resources/paging.php"; //check permissions if (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb')) { @@ -38,28 +39,69 @@ exit; } -//get the domain_uuid from the session - $domain_uuid = $_SESSION['domain_uuid']; - -//handle search term - $search = $_GET["search"]; - if (strlen($search) > 0) { - $sql_mod = "and ( "; - $sql_mod .= "extension like :search "; - $sql_mod .= "or description like :search "; - $sql_mod .= ") "; - } - //add multi-lingual support $language = new text; $text = $language->get($_SESSION['domain']['language']['code'], 'app/calls'); -//begin the content - require_once "resources/header.php"; - require_once "resources/paging.php"; +//get posted data + if (is_array($_POST['extensions'])) { + $action = $_POST['action']; + $search = $_POST['search']; + $extensions = $_POST['extensions']; + } + +//toggle the call forward feature + if (permission_exists('call_forward')) { + if ($action == 'toggle_call_forward' && is_array($extensions) && @sizeof($extensions) != 0) { + //toggle + $obj = new call_forward; + $obj->toggle($extensions); + //redirect + header('Location: calls.php'.($search != '' ? '?search='.urlencode($search) : null)); + exit; + } + } + +//toggle the follow me feature + if (permission_exists('follow_me')) { + if ($action == 'toggle_follow_me' && is_array($extensions) && @sizeof($extensions) != 0) { + //toggle + $obj = new follow_me; + $obj->toggle($extensions); + //redirect + header('Location: calls.php'.($search != '' ? '?search='.urlencode($search) : null)); + exit; + } + } + +//toggle the do not disturb feature + if (permission_exists('do_not_disturb')) { + if ($action == 'toggle_do_not_disturb' && is_array($extensions) && @sizeof($extensions) != 0) { + //toggle + $obj = new do_not_disturb; + $obj->toggle($extensions); + //redirect + header('Location: calls.php'.($search != '' ? '?search='.urlencode($search) : null)); + exit; + } + } + +//get order and order by + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//handle search term + $search = strtolower($_GET["search"]); + if (strlen($search) > 0) { + $sql_search = "and ( "; + $sql_search .= "extension like :search "; + $sql_search .= "or lower(description) like :search "; + $sql_search .= ") "; + $parameters['search'] = '%'.$search.'%'; + } //define select count query - $sql = "select count(extension_uuid) as count from v_extensions "; + $sql = "select count(*) from v_extensions "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and enabled = 'true' "; if (!(if_group("admin") || if_group("superadmin"))) { @@ -78,13 +120,12 @@ $sql .= "and extension = 'disabled' "; } } - $sql .= $sql_mod; //add search mod from above + $sql .= $sql_search; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - if (strlen($search) > 0) { - $parameters['search'] = '%'.$search.'%'; - } $database = new database; - $result_count = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters, 'column'); + +//prepare to page the results if ($is_included) { $rows_per_page = 10; } @@ -94,138 +135,218 @@ $param = "&search=".$search; $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls_mini, $rows_per_page, $var_3) = paging($result_count, $param, $rows_per_page, true); - list($paging_controls, $rows_per_page, $var_3) = paging($result_count, $param, $rows_per_page); + list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); + list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; -//select the extensions - $sql = "select * from v_extensions "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and enabled = 'true' "; - if (!(if_group("admin") || if_group("superadmin"))) { - if (count($_SESSION['user']['extension']) > 0) { - $sql .= "and ("; - $x = 0; - foreach($_SESSION['user']['extension'] as $row) { - if ($x > 0) { $sql .= "or "; } - $sql .= "extension = '".$row['user']."' "; - $x++; - } - $sql .= ") "; - } - else { - //used to hide any results when a user has not been assigned an extension - $sql .= "and extension = 'disabled' "; - } - } - $sql .= $sql_mod; //add search mod from above - $sql .= "order by extension asc "; +//get the list + $sql = str_replace('count(*)', '*', $sql); + $sql .= order_by($order_by, $order, 'extension', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; $extensions = $database->select($sql, $parameters, 'all'); unset($parameters); -//set the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); -//start the content - echo "
| ";
- echo " ".$text['header-call_routing']." "; - echo " | \n";
- echo " \n";
- if ($result_count > 10 && $is_included) {
- echo " ";
- }
- if (!$is_included) {
- echo " \n";
- if ($paging_controls_mini != '') {
- echo "".$paging_controls_mini."\n";
+//include header
+ $document['title'] = $text['title'];
+ require_once "resources/header.php";
+
+//javascript for toggle select box
+ echo "\n";
+
+//show the content
+ if ($is_included) {
+ echo "".$text['header-call_routing']."\n";
+ if ($num_rows > 10) {
+ echo " \n";
+ echo button::create(['type'=>'button','label'=>$text['button-view_all'],'link'=>PROJECT_PATH.'/app/calls/calls.php']);
+ echo " \n";
}
- } echo " | \n";
- echo "
| ";
- if (!$is_included) {
- echo $text['description-call_routing']." "; } - echo " | \n";
- echo " |
| ".$text['table-extension']." | \n"; - if (permission_exists('call_forward')) { echo "".$text['label-call-forward']." | \n"; } - if (permission_exists('follow_me')) { echo "".$text['label-follow-me']." | \n"; } - if (permission_exists('do_not_disturb')) { echo "".$text['label-dnd']." | \n"; } - echo "".$text['label-description']." | \n"; - echo "\n"; + echo $text['description-call_routing']."\n"; + echo " |
|---|