Portions created by the Initial Developer are Copyright (C) 2008-2019 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb')) { //access granted } else { echo "access denied"; 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"; //define select count query $sql = "select count(extension_uuid) as count 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 $parameters['domain_uuid'] = $_SESSION['domain_uuid']; if (strlen($search) > 0) { $parameters['search'] = '%'.$search.'%'; } $database = new database; $result_count = $database->select($sql, $parameters, 'column'); if ($is_included) { $rows_per_page = 10; } else { $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; } $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); $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 "; $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"; //start the content echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
"; echo " ".$text['header-call_routing']."
"; echo "
\n"; if ($result_count > 10 && $is_included) { echo " "; } if (!$is_included) { echo "
\n"; echo " "; echo " "; echo "
\n"; if ($paging_controls_mini != '') { echo "".$paging_controls_mini."\n"; } } echo "
"; if (!$is_included) { echo $text['description-call_routing']."
"; } echo "
\n"; echo "
"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('call_forward')) { echo "\n"; } if (permission_exists('follow_me')) { echo "\n"; } if (permission_exists('do_not_disturb')) { echo "\n"; } echo "\n"; echo " \n"; echo "\n"; if (is_array($extensions)) { foreach($extensions as $row) { $tr_url = PROJECT_PATH."/app/calls/call_edit.php?id=".$row['extension_uuid']."&return_url=".urlencode($_SERVER['REQUEST_URI']); $tr_link = (permission_exists('call_forward') || permission_exists('follow_me') || permission_exists('do_not_disturb')) ? "href='".$tr_url."'" : null; echo "\n"; echo " \n"; if (permission_exists('call_forward')) { echo " "; } if (permission_exists('follow_me')) { if (is_uuid($row['follow_me_uuid'])) { //get destination count if enabled $follow_me_destination_count = 0; if ($row['follow_me_enabled'] == 'true') { $sql = "select count(follow_me_destination_uuid) as destination_count "; $sql .= "from v_follow_me_destinations "; $sql .= "where follow_me_uuid = :follow_me_uuid "; $sql .= "and domain_uuid = :domain_uuid "; $parameters['follow_me_uuid'] = $row['follow_me_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; $follow_me_destination_count = $database->select($sql, $parameters, 'column'); } } echo " \n"; } if (permission_exists('do_not_disturb')) { echo " "; } echo " \n"; echo " \n"; echo "\n"; $c = ($c) ? 0 : 1; } //end foreach unset($sql, $extensions); } //end if results echo "
".$text['table-extension']."".$text['label-call-forward']."".$text['label-follow-me']."".$text['label-dnd']."".$text['label-description']." 
".escape($row['extension'])."".(($row['forward_all_enabled'] == 'true') ? escape(format_phone($row['forward_all_destination'])) : ' ')."\n"; if ($row['follow_me_enabled'] == 'true' && $follow_me_destination_count > 0) { echo ' '.$text['label-enabled']." (".$follow_me_destination_count.")\n"; } else { echo "  \n"; } echo "".(($row['do_not_disturb'] == 'true') ? $text['label-enabled'] : ' ')."".escape($row['description'])." ".$v_link_label_edit."
"; echo "
"; if (strlen($paging_controls) > 0 && (!$is_included)) { echo "
".$paging_controls."
\n"; echo "

\n"; } if (!$is_included) { echo "
"; require_once "resources/footer.php"; } ?>