2012-06-04 16:58:40 +02:00
< ? 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 >
2017-09-24 01:41:44 +02:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2017
2012-06-04 16:58:40 +02:00
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
*/
2016-08-05 03:47:40 +02:00
//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 ;
}
2012-06-04 16:58:40 +02:00
2017-09-24 01:41:44 +02:00
//get the domain_uuid from the session
$domain_uuid = $_SESSION [ 'domain_uuid' ];
2012-10-06 20:00:11 +02:00
2016-03-04 03:01:58 +01:00
//handle search term
$search = check_str ( $_GET [ " search " ]);
if ( strlen ( $search ) > 0 ) {
$sql_mod = " and ( " ;
$sql_mod .= " extension like '% " . $search . " %' " ;
$sql_mod .= " or description like '% " . $search . " %' " ;
$sql_mod .= " ) " ;
}
2012-10-09 00:04:57 +02:00
//add multi-lingual support
2015-01-18 11:06:08 +01:00
$language = new text ;
2015-01-29 20:31:06 +01:00
$text = $language -> get ( $_SESSION [ 'domain' ][ 'language' ][ 'code' ], 'app/calls' );
2012-06-04 16:58:40 +02:00
2012-10-09 00:04:57 +02:00
//begin the content
2013-07-06 08:29:50 +02:00
require_once " resources/header.php " ;
require_once " resources/paging.php " ;
2012-06-04 16:58:40 +02:00
2016-03-25 23:29:20 +01:00
//define select count query
$sql = " select count(extension_uuid) as count from v_extensions " ;
$sql .= " where domain_uuid = ' " . $domain_uuid . " ' " ;
2012-06-04 16:58:40 +02:00
$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' " ;
}
}
2016-03-04 03:01:58 +01:00
$sql .= $sql_mod ; //add search mod from above
2012-06-04 16:58:40 +02:00
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
2016-03-25 23:29:20 +01:00
$row = $prep_statement -> fetch ( PDO :: FETCH_NAMED );
$result_count = $row [ 'count' ];
unset ( $prep_statement , $row );
2012-06-04 16:58:40 +02:00
2016-03-30 00:28:17 +02:00
if ( $is_included ) {
2016-03-04 03:01:58 +01:00
$rows_per_page = 10 ;
}
else {
2016-03-29 07:02:11 +02:00
$rows_per_page = ( $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] != '' ) ? $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] : 50 ;
2016-03-04 03:01:58 +01:00
}
$param = " &search= " . $search ;
2012-06-04 16:58:40 +02:00
$page = $_GET [ 'page' ];
2014-04-27 04:16:36 +02:00
if ( strlen ( $page ) == 0 ) { $page = 0 ; $_GET [ 'page' ] = 0 ; }
2016-03-25 23:29:20 +01:00
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 );
2014-04-27 04:16:36 +02:00
$offset = $rows_per_page * $page ;
2012-06-04 16:58:40 +02:00
2018-07-05 23:21:09 +02:00
//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
2016-03-29 11:49:41 +02:00
$sql .= ' order by extension asc' ;
2016-03-25 23:29:20 +01:00
$sql .= " limit " . $rows_per_page . " offset " . $offset . " " ;
2012-06-04 16:58:40 +02:00
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
2018-07-05 23:21:09 +02:00
$extensions = $prep_statement -> fetchAll ( PDO :: FETCH_NAMED );
2012-06-04 16:58:40 +02:00
unset ( $prep_statement , $sql );
2018-07-05 23:21:09 +02:00
//set the row style
2012-06-04 16:58:40 +02:00
$c = 0 ;
$row_style [ " 0 " ] = " row_style0 " ;
$row_style [ " 1 " ] = " row_style1 " ;
2016-08-05 03:47:40 +02:00
//start the content
echo " <table cellpadding='0' cellspacing='0' border='0' width='100%'> \n " ;
echo " <tr> \n " ;
echo " <td valign='top'> " ;
echo " <b> " . $text [ 'header-call_routing' ] . " </b><br /> " ;
echo " </td> \n " ;
echo " <td valign='top' style='text-align: right; white-space: nowrap;'> \n " ;
2016-03-30 00:28:17 +02:00
if ( $result_count > 10 && $is_included ) {
echo " <input id='btn_viewall_callrouting' type='button' class='btn' value=' " . $text [ 'button-view_all' ] . " ' onclick= \" document.location.href=' " . PROJECT_PATH . " /app/calls/calls.php'; \" > " ;
}
if ( ! $is_included ) {
2016-04-08 19:00:58 +02:00
echo " <form method='get' action='' style='display: inline-block;'> \n " ;
2018-06-05 21:25:09 +02:00
echo " <input type='text' class='txt' style='width: 150px' name='search' value=' " . escape ( $search ) . " '> " ;
2016-03-04 03:01:58 +01:00
echo " <input type='submit' class='btn' name='submit' value=' " . $text [ 'button-search' ] . " '> " ;
2016-04-07 22:14:32 +02:00
echo " </form> \n " ;
2016-03-04 03:01:58 +01:00
if ( $paging_controls_mini != '' ) {
echo " <span style='margin-left: 15px;'> " . $paging_controls_mini . " </span> \n " ;
}
2016-08-05 03:47:40 +02:00
} echo " </td> \n " ;
echo " </tr> \n " ;
echo " <tr> \n " ;
echo " <td colspan='2' valign='top'> " ;
if ( ! $is_included ) {
echo $text [ 'description-call_routing' ] . " <br /> " ;
2016-03-04 03:01:58 +01:00
}
2016-08-05 03:47:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </table> \n " ;
echo " <br /> " ;
2016-03-04 03:01:58 +01:00
2014-06-21 09:04:04 +02:00
echo " <table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2012-10-24 09:02:52 +02:00
echo " <th> " . $text [ 'table-extension' ] . " </th> \n " ;
2016-03-30 00:28:17 +02:00
if ( permission_exists ( 'call_forward' )) { echo " <th> " . $text [ 'label-call-forward' ] . " </th> \n " ; }
if ( permission_exists ( 'follow_me' )) { echo " <th> " . $text [ 'label-follow-me' ] . " </th> \n " ; }
if ( permission_exists ( 'do_not_disturb' )) { echo " <th> " . $text [ 'label-dnd' ] . " </th> \n " ; }
if ( ! $is_included ) {
echo " <th class='hidden-xs'> " . $text [ 'table-description' ] . " </th> \n " ;
}
echo " <td class='list_control_icon'> </td> \n " ;
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
2018-07-05 23:21:09 +02:00
if ( is_array ( $extensions )) {
foreach ( $extensions as $row ) {
2016-03-30 00:28:17 +02:00
$tr_url = PROJECT_PATH . " /app/calls/call_edit.php?id= " . $row [ 'extension_uuid' ] . " &return_url= " . urlencode ( $_SERVER [ 'REQUEST_URI' ]);
2014-06-21 10:52:47 +02:00
$tr_link = ( permission_exists ( 'call_forward' ) || permission_exists ( 'follow_me' ) || permission_exists ( 'do_not_disturb' )) ? " href=' " . $tr_url . " ' " : null ;
2014-06-21 09:04:04 +02:00
echo " <tr " . $tr_link . " > \n " ;
2017-09-24 01:41:44 +02:00
echo " <td valign='top' class=' " . $row_style [ $c ] . " '><a " . $tr_link . " > " . escape ( $row [ 'extension' ]) . " </a></td> \n " ;
2016-03-30 00:28:17 +02:00
if ( permission_exists ( 'call_forward' )) {
2017-09-24 01:41:44 +02:00
echo " <td valign='top' class=' " . $row_style [ $c ] . " '> " . (( $row [ 'forward_all_enabled' ] == 'true' ) ? escape ( format_phone ( $row [ 'forward_all_destination' ])) : ' ' ) . " </td> " ;
2016-03-30 00:28:17 +02:00
}
if ( permission_exists ( 'follow_me' )) {
if ( $row [ 'follow_me_uuid' ] != '' ) {
//check if follow me is enabled
$sql = " select follow_me_enabled from v_follow_me where follow_me_uuid = ' " . $row [ 'follow_me_uuid' ] . " ' and domain_uuid = ' " . $domain_uuid . " ' " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$row_x = $prep_statement -> fetch ( PDO :: FETCH_NAMED );
$follow_me_enabled = ( $row_x [ 'follow_me_enabled' ] == 'true' ) ? true : false ;
unset ( $sql , $prep_statement , $row_x );
//get destination count if enabled
if ( $follow_me_enabled ) {
$sql = " select count(follow_me_destination_uuid) as destination_count from v_follow_me_destinations where follow_me_uuid = ' " . $row [ 'follow_me_uuid' ] . " ' and domain_uuid = ' " . $domain_uuid . " ' " ;
$prep_statement = $db -> prepare ( check_sql ( $sql ));
$prep_statement -> execute ();
$row_x = $prep_statement -> fetch ( PDO :: FETCH_NAMED );
$follow_me_destination_count = $row_x [ 'destination_count' ];
unset ( $sql , $prep_statement , $row_x );
}
}
else {
$follow_me_enabled = false ;
}
echo " <td valign='top' class=' " . $row_style [ $c ] . " '> " . (( $follow_me_enabled ) ? $text [ 'label-enabled' ] . " ( " . $follow_me_destination_count . " ) " : ' ' ) . " </td> " ;
}
if ( permission_exists ( 'do_not_disturb' )) {
echo " <td valign='top' class=' " . $row_style [ $c ] . " '> " . (( $row [ 'do_not_disturb' ] == 'true' ) ? $text [ 'label-enabled' ] : ' ' ) . " </td> " ;
}
if ( ! $is_included ) {
2017-09-24 01:41:44 +02:00
echo " <td valign='top' class='row_stylebg hidden-xs'> " . escape ( $row [ 'description' ]) . " </td> \n " ;
2016-03-30 00:28:17 +02:00
}
echo " <td class='list_control_icon'><a href=' " . $tr_url . " ' alt=' " . $text [ 'button-edit' ] . " '> " . $v_link_label_edit . " </a></td> \n " ;
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
2016-03-30 00:28:17 +02:00
$c = ( $c ) ? 0 : 1 ;
2012-06-04 16:58:40 +02:00
} //end foreach
2018-07-05 23:21:09 +02:00
unset ( $sql , $extensions );
2012-06-04 16:58:40 +02:00
} //end if results
echo " </table> " ;
2016-03-30 00:28:17 +02:00
echo " <br /> " ;
2016-03-04 03:01:58 +01:00
2016-03-30 00:28:17 +02:00
if ( strlen ( $paging_controls ) > 0 && ( ! $is_included )) {
2016-03-04 03:01:58 +01:00
echo " <center> " . $paging_controls . " </center> \n " ;
2016-03-30 00:28:17 +02:00
echo " <br /><br /> \n " ;
2016-03-04 03:01:58 +01:00
}
2012-06-04 16:58:40 +02:00
2016-03-30 00:28:17 +02:00
if ( ! $is_included ) {
echo " <br /> " ;
2013-07-06 08:29:50 +02:00
require_once " resources/footer.php " ;
2012-06-04 16:58:40 +02:00
}
2016-08-05 03:47:40 +02:00
?>