2013-05-29 06:34:28 +02:00
< ? php
2012-06-04 16:58:40 +02:00
/*
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 >
2023-06-05 20:41:28 +02:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2023
2012-06-04 16:58:40 +02:00
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
2014-07-14 01:22:15 +02:00
Luis Daniel Lucio Quiroz < dlucio @ okay . com . mx >
2014-11-05 10:05:35 +01:00
Riccardo Granchi < riccardo . granchi @ nems . it >
2012-06-04 16:58:40 +02:00
*/
2016-10-14 16:09:05 +02:00
2022-10-11 00:35:14 +02:00
//includes files
2023-06-15 19:28:23 +02:00
require_once dirname ( __DIR__ , 2 ) . " /resources/require.php " ;
2016-10-14 16:09:05 +02:00
require_once " resources/check_auth.php " ;
2020-01-11 22:32:19 +01:00
require_once " resources/paging.php " ;
2016-10-14 16:09:05 +02:00
//check permissions
if ( permission_exists ( 'inbound_route_add' )) {
//access granted
}
else {
echo $text [ 'label-access-denied' ];
exit ;
}
2012-06-04 16:58:40 +02:00
2012-11-24 23:59:08 +01:00
//add multi-lingual support
2015-01-18 11:06:08 +01:00
$language = new text ;
$text = $language -> get ();
2013-05-29 06:34:28 +02:00
2023-06-03 01:01:15 +02:00
//set the defaults
$dialplan_name = '' ;
$dialplan_description = '' ;
2023-06-03 01:08:11 +02:00
$condition_expression_1 = '' ;
$condition_expression_2 = '' ;
$action_2 = '' ;
2023-06-03 01:01:15 +02:00
$limit = '' ;
2012-06-04 16:58:40 +02:00
//get the http get values and set them as php variables
2023-06-03 01:01:15 +02:00
$order_by = $_GET [ " order_by " ] ? ? '' ;
$order = $_GET [ " order " ] ? ? '' ;
$action = $_GET [ " action " ] ? ? '' ;
2012-06-04 16:58:40 +02:00
2020-02-07 20:24:36 +01:00
//initialize the destinations object
$destination = new destinations ;
2012-06-04 16:58:40 +02:00
//get the http post values and set them as php variables
2023-06-16 01:44:40 +02:00
if ( ! empty ( $_POST ) && count ( $_POST ) > 0 ) {
2019-08-05 21:33:45 +02:00
$dialplan_name = $_POST [ " dialplan_name " ];
$caller_id_outbound_prefix = $_POST [ " caller_id_outbound_prefix " ];
$limit = $_POST [ " limit " ];
$public_order = $_POST [ " public_order " ];
2023-06-16 01:44:40 +02:00
$condition_field_1 = $_POST [ " condition_field_1 " ] ? ? null ;
$condition_expression_1 = $_POST [ " condition_expression_1 " ] ? ? null ;
$condition_field_2 = $_POST [ " condition_field_2 " ] ? ? null ;
$condition_expression_2 = $_POST [ " condition_expression_2 " ] ? ? null ;
2019-08-05 21:33:45 +02:00
$destination_uuid = $_POST [ " destination_uuid " ];
2024-09-06 07:37:34 +02:00
2019-08-05 21:33:45 +02:00
$action_1 = $_POST [ " action_1 " ];
2016-10-14 16:11:52 +02:00
//$action_1 = "transfer:1001 XML default";
$action_1_array = explode ( " : " , $action_1 );
$action_application_1 = array_shift ( $action_1_array );
$action_data_1 = join ( ':' , $action_1_array );
2024-09-06 07:37:34 +02:00
2023-06-16 01:44:40 +02:00
$action_2 = $_POST [ " action_2 " ] ? ? '' ;
2016-10-14 16:11:52 +02:00
//$action_2 = "transfer:1001 XML default";
$action_2_array = explode ( " : " , $action_2 );
$action_application_2 = array_shift ( $action_2_array );
$action_data_2 = join ( ':' , $action_2_array );
2024-09-06 07:37:34 +02:00
2019-08-05 21:33:45 +02:00
//$action_application_1 = $_POST["action_application_1"];
//$action_data_1 = $_POST["action_data_1"];
//$action_application_2 = $_POST["action_application_2"];
//$action_data_2 = $_POST["action_data_2"];
2024-09-06 07:37:34 +02:00
2016-10-14 16:11:52 +02:00
$destination_carrier = '' ;
$destination_accountcode = '' ;
2024-09-06 07:37:34 +02:00
2016-10-14 16:11:52 +02:00
//use the destination_uuid to set the condition_expression_1
2019-08-05 21:33:45 +02:00
if ( is_uuid ( $destination_uuid )) {
2016-10-14 16:11:52 +02:00
$sql = " select * from v_destinations " ;
2019-08-05 21:33:45 +02:00
$sql .= " where domain_uuid = :domain_uuid " ;
$sql .= " and destination_uuid = :destination_uuid " ;
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$parameters [ 'destination_uuid' ] = $destination_uuid ;
$database = new database ;
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
$destination_number = $row [ " destination_number " ];
$condition_expression_1 = $row [ " destination_number " ];
$fax_uuid = $row [ " fax_uuid " ];
2023-06-16 01:44:40 +02:00
$destination_carrier = $row [ " destination_carrier " ] ? ? null ;
2019-08-05 21:33:45 +02:00
$destination_accountcode = $row [ " destination_accountcode " ];
2012-12-23 11:17:29 +01:00
}
2019-08-05 21:33:45 +02:00
unset ( $sql , $parameters , $row );
2012-12-23 11:17:29 +01:00
}
2024-09-06 07:37:34 +02:00
2016-10-14 16:11:52 +02:00
if ( permission_exists ( " inbound_route_advanced " ) && $action == " advanced " ) {
//allow users with group advanced control, not always superadmin. You may change this in group permissions
2012-06-04 16:58:40 +02:00
}
2016-10-14 16:11:52 +02:00
else {
2023-05-05 18:46:37 +02:00
if ( empty ( $condition_field_1 )) { $condition_field_1 = " destination_number " ; }
2016-10-14 16:11:52 +02:00
if ( is_numeric ( $condition_expression_1 )) {
//the number is numeric
$condition_expression_1 = str_replace ( " + " , " \ + " , $condition_expression_1 );
$condition_expression_1 = '^(' . $condition_expression_1 . ')$' ;
}
}
2023-06-16 01:44:40 +02:00
$dialplan_enabled = $_POST [ " dialplan_enabled " ] ? ? 'false' ;
2019-08-12 01:22:16 +02:00
$dialplan_description = $_POST [ " dialplan_description " ];
2023-05-05 18:46:37 +02:00
if ( empty ( $dialplan_enabled )) { $dialplan_enabled = " true " ; } //set default to enabled
2012-06-04 16:58:40 +02:00
}
2016-10-14 16:09:05 +02:00
//process the http post data
2023-05-05 18:46:37 +02:00
if ( count ( $_POST ) > 0 && empty ( $_POST [ " persistformvar " ])) {
2016-10-14 16:11:52 +02:00
2020-01-11 22:32:19 +01:00
//validate the token
$token = new token ;
if ( ! $token -> validate ( $_SERVER [ 'PHP_SELF' ])) {
message :: add ( $text [ 'message-invalid_token' ], 'negative' );
header ( 'Location: ' . PROJECT_PATH . '/app/dialplans/dialplans.php?app_uuid=c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' );
exit ;
}
2016-10-14 16:11:52 +02:00
//check for all required data
2023-06-16 01:44:40 +02:00
$msg = '' ;
2023-05-05 18:46:37 +02:00
if ( empty ( $domain_uuid )) { $msg .= " " . $text [ 'label-required-domain_uuid' ] . " <br> \n " ; }
if ( empty ( $dialplan_name )) { $msg .= " " . $text [ 'label-required-dialplan_name' ] . " <br> \n " ; }
if ( empty ( $condition_field_1 )) { $msg .= " " . $text [ 'label-required-condition_field_1' ] . " <br> \n " ; }
if ( empty ( $condition_expression_1 )) { $msg .= " " . $text [ 'label-required-condition_expression_1' ] . " <br> \n " ; }
if ( empty ( $action_application_1 )) { $msg .= " " . $text [ 'label-required-action_application_1' ] . " <br> \n " ; }
//if (empty($limit)) { $msg .= "Please provide: Limit<br>\n"; }
//if (empty($dialplan_enabled)) { $msg .= "Please provide: Enabled True or False<br>\n"; }
//if (empty($dialplan_description)) { $msg .= "Please provide: Description<br>\n"; }
if ( ! empty ( $msg ) && empty ( $_POST [ " persistformvar " ])) {
2016-10-14 16:11:52 +02:00
require_once " resources/header.php " ;
require_once " resources/persist_form_var.php " ;
echo " <div align='center'> \n " ;
echo " <table><tr><td> \n " ;
echo $msg . " <br /> " ;
echo " </td></tr></table> \n " ;
persistformvar ( $_POST );
require_once " resources/footer.php " ;
return ;
}
2012-06-04 16:58:40 +02:00
2016-10-14 16:11:52 +02:00
//remove the invalid characters from the extension name
$dialplan_name = str_replace ( " " , " _ " , $dialplan_name );
$dialplan_name = str_replace ( " / " , " " , $dialplan_name );
2012-06-04 16:58:40 +02:00
2016-10-14 16:11:52 +02:00
//set the context
$context = '$${domain_name}' ;
2014-07-14 01:22:15 +02:00
2016-10-24 06:00:04 +02:00
//set the uuids
2016-10-14 16:11:52 +02:00
$dialplan_uuid = uuid ();
2016-10-24 06:00:04 +02:00
$app_uuid = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ;
$domain_uuid = $_SESSION [ 'domain_uuid' ];
//build the array
$x = 0 ;
$array [ 'dialplans' ][ $x ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'app_uuid' ] = $app_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_name' ] = $dialplan_name ;
$array [ 'dialplans' ][ $x ][ 'dialplan_number' ] = $destination_number ;
$array [ 'dialplans' ][ $x ][ 'dialplan_order' ] = $public_order ;
$array [ 'dialplans' ][ $x ][ 'dialplan_continue' ] = 'false' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_context' ] = 'public' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_enabled' ] = $dialplan_enabled ;
$array [ 'dialplans' ][ $x ][ 'dialplan_description' ] = $dialplan_description ;
2012-06-04 16:58:40 +02:00
2016-10-14 16:11:52 +02:00
//add condition 1
2016-10-24 06:00:04 +02:00
$y = 0 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'condition' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = $condition_field_1 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = $condition_expression_1 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2014-11-05 10:05:35 +01:00
2016-10-14 16:11:52 +02:00
//add condition 2
2023-05-05 18:46:37 +02:00
if ( ! empty ( $condition_field_2 )) {
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'condition' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = $condition_field_2 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = $condition_expression_2 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
2015-01-18 13:05:21 +01:00
2016-10-14 16:11:52 +02:00
//set accountcode
2023-05-05 18:46:37 +02:00
if ( ! empty ( $destination_accountcode )) {
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'set' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = 'accountcode=' . $destination_accountcode ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
2013-01-13 13:45:53 +01:00
2016-10-14 16:11:52 +02:00
//set carrier
2023-05-05 18:46:37 +02:00
if ( ! empty ( $destination_carrier )) {
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'set' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = 'carrier=' . $destination_carrier ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
2013-01-13 13:45:53 +01:00
2016-10-14 16:11:52 +02:00
//set limit
2023-05-05 18:46:37 +02:00
if ( ! empty ( $limit )) {
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'limit' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = " hash \$ { domain_name} inbound " . $limit . " !USER_BUSY " ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
2013-01-13 13:45:53 +01:00
2016-10-14 16:11:52 +02:00
//set redial outbound prefix
2023-05-05 18:46:37 +02:00
if ( ! empty ( $caller_id_outbound_prefix )) {
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'set' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = " effective_caller_id_number= " . $caller_id_outbound_prefix . " \$ { caller_id_number} " ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
//set fax_uuid
2019-08-05 21:33:45 +02:00
if ( is_uuid ( $fax_uuid )) {
2016-10-24 06:00:04 +02:00
2016-10-14 16:11:52 +02:00
//get the fax information
$sql = " select * from v_fax " ;
2019-08-05 21:33:45 +02:00
$sql .= " where domain_uuid = :domain_uuid " ;
$sql .= " and fax_uuid = :fax_uuid " ;
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$parameters [ 'fax_uuid' ] = $fax_uuid ;
$database = new database ;
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
2016-10-14 16:11:52 +02:00
$fax_extension = $row [ " fax_extension " ];
$fax_destination_number = $row [ " fax_destination_number " ];
$fax_name = $row [ " fax_name " ];
$fax_email = $row [ " fax_email " ];
$fax_pin_number = $row [ " fax_pin_number " ];
$fax_caller_id_name = $row [ " fax_caller_id_name " ];
$fax_caller_id_number = $row [ " fax_caller_id_number " ];
$fax_forward_number = $row [ " fax_forward_number " ];
$fax_description = $row [ " fax_description " ];
}
2019-08-05 21:33:45 +02:00
unset ( $sql , $parameters , $row );
2016-10-14 16:11:52 +02:00
//add set codec_string=PCMU,PCMA
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'set' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = 'codec_string=PCMU,PCMA' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
//add set tone_detect_hits=1
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'set' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = 'tone_detect_hits=1' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
//add execute_on_tone_detect
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'set' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = " execute_on_tone_detect=transfer " . $fax_extension . " XML " . $_SESSION [ " context " ];
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
//add tone_detect fax 1100 r +5000
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'tone_detect' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = 'fax 1100 r +5000' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
//add sleep to provide time for fax detection
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'sleep' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = '3000' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
//set codec_string=${ep_codec_string}
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'export' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = 'codec_string=\${ep_codec_string}' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
2015-01-18 13:05:21 +01:00
2016-10-14 16:11:52 +02:00
//set answer
$tmp_app = false ;
if ( $action_application_1 == " ivr " ) { $tmp_app = true ; }
if ( $action_application_2 == " ivr " ) { $tmp_app = true ; }
if ( $action_application_1 == " conference " ) { $tmp_app = true ; }
if ( $action_application_2 == " conference " ) { $tmp_app = true ; }
if ( $tmp_app ) {
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = 'answer' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = '' ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
unset ( $tmp_app );
2012-12-23 11:17:29 +01:00
2016-10-14 16:11:52 +02:00
//add action 1
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
2020-02-07 20:24:36 +01:00
if ( $destination -> valid ( $action_application_1 . ':' . $action_data_1 )) {
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = $action_application_1 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = $action_data_1 ;
}
2016-10-24 06:00:04 +02:00
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2012-06-04 16:58:40 +02:00
2016-10-14 16:11:52 +02:00
//add action 2
2023-05-05 18:46:37 +02:00
if ( ! empty ( $action_application_2 )) {
2016-10-24 06:00:04 +02:00
$y ++ ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_uuid' ] = uuid ();
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_uuid' ] = $dialplan_uuid ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_tag' ] = 'action' ;
2020-02-07 20:27:44 +01:00
if ( $destination -> valid ( $action_application_2 . ':' . $action_data_2 )) {
2020-02-07 20:24:36 +01:00
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_type' ] = $action_application_2 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_data' ] = $action_data_2 ;
}
2016-10-24 06:00:04 +02:00
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_order' ] = $y * 10 ;
$array [ 'dialplans' ][ $x ][ 'dialplan_details' ][ $y ][ 'dialplan_detail_group' ] = '0' ;
2016-10-14 16:11:52 +02:00
}
//update the destination dialplan_uuid
2019-08-05 21:33:45 +02:00
if ( is_uuid ( $destination_uuid )) {
2024-11-29 21:57:01 +01:00
$p = permissions :: new ();
2019-08-05 21:33:45 +02:00
$p -> add ( 'destination_edit' , 'temp' );
$array [ 'destinations' ][ 0 ][ 'destination_uuid' ] = $destination_uuid ;
$array [ 'destinations' ][ 0 ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'destinations' ][ 0 ][ 'dialplan_uuid' ] = $dialplan_uuid ;
2016-10-14 16:11:52 +02:00
}
2013-05-09 21:56:16 +02:00
2016-10-24 06:00:04 +02:00
//save the data
$database = new database ;
$database -> app_name = 'inbound_routes' ;
$database -> app_uuid = $app_uuid ;
$database -> save ( $array );
$message = $database -> message ;
2019-08-05 21:33:45 +02:00
unset ( $array );
//remove temp permission, if exists
if ( is_uuid ( $destination_uuid )) {
$p -> delete ( 'destination_edit' , 'temp' );
}
2012-06-04 16:58:40 +02:00
2016-10-14 16:11:52 +02:00
//update the dialplan xml
$dialplans = new dialplan ;
$dialplans -> source = " details " ;
$dialplans -> destination = " database " ;
$dialplans -> uuid = $dialplan_uuid ;
$dialplans -> xml ();
2016-10-14 16:09:05 +02:00
2016-10-14 16:11:52 +02:00
//clear the cache
$cache = new cache ;
$cache -> delete ( " dialplan:public " );
2013-01-16 01:26:48 +01:00
2016-10-14 16:11:52 +02:00
//redirect message
2018-08-31 05:09:01 +02:00
message :: add ( $text [ 'confirm-update-complete' ]);
2017-09-24 18:09:19 +02:00
header ( " Location: " . PROJECT_PATH . " /app/dialplans/dialplans.php?app_uuid=c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4 " );
2019-08-05 21:33:45 +02:00
exit ;
}
2012-06-04 16:58:40 +02:00
2020-01-11 22:32:19 +01:00
//create token
$object = new token ;
$token = $object -> create ( $_SERVER [ 'PHP_SELF' ]);
//include the header
$document [ 'title' ] = $text [ 'title-dialplan-inbound-add' ];
require_once " resources/header.php " ;
2012-06-04 16:58:40 +02:00
?>
< script type = " text/javascript " >
function type_onchange ( dialplan_detail_type ) {
2016-04-13 21:23:07 +02:00
var field_value = document . getElementById ( dialplan_detail_type ) . value ;
if ( dialplan_detail_type == " condition_field_1 " ) {
if ( field_value == " destination_number " ) {
document . getElementById ( " desc_condition_expression_1 " ) . innerHTML = " expression: 5551231234 " ;
}
else if ( field_value == " zzz " ) {
document . getElementById ( " desc_condition_expression_1 " ) . innerHTML = " " ;
}
else {
document . getElementById ( " desc_condition_expression_1 " ) . innerHTML = " " ;
}
2012-06-04 16:58:40 +02:00
}
2016-04-13 21:23:07 +02:00
if ( dialplan_detail_type == " condition_field_2 " ) {
if ( field_value == " destination_number " ) {
document . getElementById ( " desc_condition_expression_2 " ) . innerHTML = " expression: 5551231234 " ;
}
else if ( field_value == " zzz " ) {
document . getElementById ( " desc_condition_expression_2 " ) . innerHTML = " " ;
}
else {
document . getElementById ( " desc_condition_expression_2 " ) . innerHTML = " " ;
}
2012-06-04 16:58:40 +02:00
}
}
</ script >
< ? php
2020-01-11 22:32:19 +01:00
2012-06-04 16:58:40 +02:00
//show the content
2020-03-05 18:02:25 +01:00
echo " <form method='post' name='frm' id='frm'> \n " ;
2020-01-11 22:32:19 +01:00
echo " <div class='action_bar' id='action_bar'> \n " ;
echo " <div class='heading'><b> " . $text [ 'title-dialplan-inbound-add' ] . " </b></div> \n " ;
echo " <div class='actions'> \n " ;
2020-03-05 08:05:45 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-back' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_back' ], 'id' => 'btn_back' , 'link' => PROJECT_PATH . '/app/dialplans/dialplans.php?app_uuid=c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ]);
2013-08-27 01:28:11 +02:00
if ( permission_exists ( " inbound_route_advanced " )) {
if ( permission_exists ( " inbound_route_edit " ) && $action == " advanced " ) {
2020-01-11 22:39:11 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-basic' ], 'icon' => 'hammer' , 'style' => 'margin-left: 15px;' , 'link' => 'dialplan_inbound_add.php?action=basic' ]);
2013-08-27 01:28:11 +02:00
}
else {
2020-01-11 22:32:19 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-advanced' ], 'icon' => 'tools' , 'style' => 'margin-left: 15px;' , 'link' => 'dialplan_inbound_add.php?action=advanced' ]);
2013-08-27 01:28:11 +02:00
}
2012-06-04 16:58:40 +02:00
}
2020-03-05 08:05:45 +01:00
echo button :: create ([ 'type' => 'submit' , 'label' => $text [ 'button-save' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_save' ], 'id' => 'btn_save' , 'style' => 'margin-left: 15px;' ]);
2020-01-11 22:32:19 +01:00
echo " </div> \n " ;
echo " <div style='clear: both;'></div> \n " ;
echo " </div> \n " ;
echo $text [ 'description-dialplan-inbound-add' ] . " \n " ;
echo " <br /><br /> \n " ;
2012-06-04 16:58:40 +02:00
2024-09-06 07:37:34 +02:00
echo " <div class='card'> \n " ;
2015-02-15 08:59:02 +01:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2016-02-26 02:45:27 +01:00
echo " <td width='30%' class='vncellreq' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-name' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
2016-02-26 02:45:27 +01:00
echo " <td width='70%' class='vtable' align='left'> \n " ;
2018-08-28 04:34:56 +02:00
echo " <input class='formfld' type='text' name='dialplan_name' maxlength='255' value= \" " . escape ( $dialplan_name ) . " \" > \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
2012-11-24 23:59:08 +01:00
echo " " . $text [ 'description-name' ] . " <br /> \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
2013-08-27 01:28:11 +02:00
if ( permission_exists ( " inbound_route_edit " ) && $action == " advanced " && permission_exists ( " inbound_route_advanced " )) {
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-condition_1' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
?>
< script >
var Objs ;
function changeToInput_condition_field_1 ( obj ){
tb = document . createElement ( 'INPUT' );
tb . type = 'text' ;
tb . name = obj . name ;
tb . className = 'formfld' ;
tb . setAttribute ( 'id' , 'condition_field_1' );
tb . setAttribute ( 'style' , 'width: 85%;' );
tb . value = obj . options [ obj . selectedIndex ] . value ;
document . getElementById ( 'btn_select_to_input_condition_field_1' ) . style . visibility = 'hidden' ;
tbb = document . createElement ( 'INPUT' );
tbb . setAttribute ( 'class' , 'btn' );
2014-08-03 08:12:10 +02:00
tbb . setAttribute ( 'style' , 'margin-left: 4px;' );
2012-06-04 16:58:40 +02:00
tbb . type = 'button' ;
2014-08-03 09:02:12 +02:00
tbb . value = $ ( " <div /> " ) . html ( '◁' ) . text ();
2012-06-04 16:58:40 +02:00
tbb . objs = [ obj , tb , tbb ];
tbb . onclick = function (){ Replace_condition_field_1 ( this . objs ); }
obj . parentNode . insertBefore ( tb , obj );
obj . parentNode . insertBefore ( tbb , obj );
obj . parentNode . removeChild ( obj );
Replace_condition_field_1 ( this . objs );
}
2013-05-29 06:34:28 +02:00
2012-06-04 16:58:40 +02:00
function Replace_condition_field_1 ( obj ){
obj [ 2 ] . parentNode . insertBefore ( obj [ 0 ], obj [ 2 ]);
obj [ 0 ] . parentNode . removeChild ( obj [ 1 ]);
obj [ 0 ] . parentNode . removeChild ( obj [ 2 ]);
document . getElementById ( 'btn_select_to_input_condition_field_1' ) . style . visibility = 'visible' ;
}
</ script >
< ? php
2016-09-01 05:57:31 +02:00
echo " <table border='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2016-09-01 05:57:31 +02:00
//echo " <td>".$text['label-field']."</td>\n";
echo " <td nowrap='nowrap'> \n " ;
2012-06-04 16:58:40 +02:00
2016-09-01 05:57:31 +02:00
echo " <select class='formfld' name='condition_field_1' id='condition_field_1' onchange='changeToInput_condition_field_1(this);this.style.visibility = \" hidden \" ;'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <option value=''></option> \n " ;
2023-05-05 18:46:37 +02:00
if ( ! empty ( $condition_field_1 )) {
2018-08-28 04:34:56 +02:00
echo " <option value=' " . escape ( $condition_field_1 ) . " ' selected> " . escape ( $condition_field_1 ) . " </option> \n " ;
2012-06-04 16:58:40 +02:00
}
2013-05-29 06:34:28 +02:00
echo " <option value='context'> " . $text [ 'option-context' ] . " </option> \n " ;
echo " <option value='username'> " . $text [ 'option-username' ] . " </option> \n " ;
echo " <option value='rdnis'> " . $text [ 'option-rdnis' ] . " </option> \n " ;
echo " <option value='destination_number'> " . $text [ 'option-destination_number' ] . " </option> \n " ;
echo " <option value='public'> " . $text [ 'option-public' ] . " </option> \n " ;
echo " <option value='caller_id_name'> " . $text [ 'option-caller_id_name' ] . " </option> \n " ;
echo " <option value='caller_id_number'> " . $text [ 'option-caller_id_number' ] . " </option> \n " ;
echo " <option value='ani'> " . $text [ 'option-ani' ] . " </option> \n " ;
echo " <option value='ani2'> " . $text [ 'option-ani2' ] . " </option> \n " ;
echo " <option value='uuid'> " . $text [ 'option-uuid' ] . " </option> \n " ;
echo " <option value='source'> " . $text [ 'option-source' ] . " </option> \n " ;
echo " <option value='chan_name'> " . $text [ 'option-chan_name' ] . " </option> \n " ;
echo " <option value='network_addr'> " . $text [ 'option-network_addr' ] . " </option> \n " ;
2012-06-04 16:58:40 +02:00
echo " </select> \n " ;
2014-08-03 09:02:12 +02:00
echo " <input type='button' id='btn_select_to_input_condition_field_1' class='btn' name='' alt=' " . $text [ 'button-back' ] . " ' onclick='changeToInput_condition_field_1(document.getElementById( \" condition_field_1 \" ));this.style.visibility = \" hidden \" ;' value='◁'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
echo " </td> \n " ;
2016-09-01 05:57:31 +02:00
echo " <td> \n " ;
2018-08-28 04:34:56 +02:00
echo " <input class='formfld' type='text' name='condition_expression_1' maxlength='255' value= \" " . escape ( $condition_expression_1 ) . " \" > \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </table> \n " ;
echo " <div id='desc_condition_expression_1'></div> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-condition_2' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2016-09-01 05:57:31 +02:00
echo " <table border='0'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
2016-09-01 05:57:31 +02:00
//echo " <td align='left'>".$text['label-field']."</td>\n";
echo " <td align='left' nowrap='nowrap'> \n " ;
2012-06-04 16:58:40 +02:00
?>
< script >
var Objs ;
function changeToInput_condition_field_2 ( obj ){
tb = document . createElement ( 'INPUT' );
tb . type = 'text' ;
tb . name = obj . name ;
tb . className = 'formfld' ;
tb . setAttribute ( 'id' , 'condition_field_2' );
tb . setAttribute ( 'style' , 'width: 85%;' );
tb . value = obj . options [ obj . selectedIndex ] . value ;
document . getElementById ( 'btn_select_to_input_condition_field_2' ) . style . visibility = 'hidden' ;
tbb = document . createElement ( 'INPUT' );
tbb . setAttribute ( 'class' , 'btn' );
2014-08-03 08:12:10 +02:00
tbb . setAttribute ( 'style' , 'margin-left: 4px;' );
2012-06-04 16:58:40 +02:00
tbb . type = 'button' ;
2014-08-03 09:02:12 +02:00
tbb . value = $ ( " <div /> " ) . html ( '◁' ) . text ();
2012-06-04 16:58:40 +02:00
tbb . objs = [ obj , tb , tbb ];
tbb . onclick = function (){ Replace_condition_field_2 ( this . objs ); }
obj . parentNode . insertBefore ( tb , obj );
obj . parentNode . insertBefore ( tbb , obj );
obj . parentNode . removeChild ( obj );
Replace_condition_field_2 ( this . objs );
}
2013-05-29 06:34:28 +02:00
2012-06-04 16:58:40 +02:00
function Replace_condition_field_2 ( obj ){
obj [ 2 ] . parentNode . insertBefore ( obj [ 0 ], obj [ 2 ]);
obj [ 0 ] . parentNode . removeChild ( obj [ 1 ]);
obj [ 0 ] . parentNode . removeChild ( obj [ 2 ]);
document . getElementById ( 'btn_select_to_input_condition_field_2' ) . style . visibility = 'visible' ;
}
</ script >
< ? php
2016-09-01 05:57:31 +02:00
echo " <select class='formfld' name='condition_field_2' id='condition_field_2' onchange='changeToInput_condition_field_2(this);this.style.visibility = \" hidden \" ;'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <option value=''></option> \n " ;
2023-05-05 18:46:37 +02:00
if ( ! empty ( $condition_field_2 )) {
2018-08-28 04:34:56 +02:00
echo " <option value=' " . escape ( $condition_field_2 ) . " ' selected> " . escape ( $condition_field_2 ) . " </option> \n " ;
2012-06-04 16:58:40 +02:00
}
2013-05-29 06:34:28 +02:00
echo " <option value='context'> " . $text [ 'option-context' ] . " </option> \n " ;
echo " <option value='username'> " . $text [ 'option-username' ] . " </option> \n " ;
echo " <option value='rdnis'> " . $text [ 'option-rdnis' ] . " </option> \n " ;
echo " <option value='destination_number'> " . $text [ 'option-destination_number' ] . " </option> \n " ;
echo " <option value='public'> " . $text [ 'option-public' ] . " </option> \n " ;
echo " <option value='caller_id_name'> " . $text [ 'option-caller_id_name' ] . " </option> \n " ;
echo " <option value='caller_id_number'> " . $text [ 'option-caller_id_number' ] . " </option> \n " ;
echo " <option value='ani'> " . $text [ 'option-ani' ] . " </option> \n " ;
echo " <option value='ani2'> " . $text [ 'option-ani2' ] . " </option> \n " ;
echo " <option value='uuid'> " . $text [ 'option-uuid' ] . " </option> \n " ;
echo " <option value='source'> " . $text [ 'option-source' ] . " </option> \n " ;
echo " <option value='chan_name'> " . $text [ 'option-chan_name' ] . " </option> \n " ;
echo " <option value='network_addr'> " . $text [ 'option-network_addr' ] . " </option> \n " ;
2012-06-04 16:58:40 +02:00
echo " </select> \n " ;
2014-08-03 09:02:12 +02:00
echo " <input type='button' id='btn_select_to_input_condition_field_2' class='btn' name='' alt=' " . $text [ 'button-back' ] . " ' onclick='changeToInput_condition_field_2(document.getElementById( \" condition_field_2 \" ));this.style.visibility = \" hidden \" ;' value='◁'> \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
2016-09-01 05:57:31 +02:00
//echo " </td>\n";
//echo " <td align='left'> ".$text['label-expression']."\n";
//echo " </td>\n";
echo " <td> \n " ;
2018-08-28 04:34:56 +02:00
echo " <input class='formfld' type='text' name='condition_expression_2' maxlength='255' value= \" " . escape ( $condition_expression_2 ) . " \" > \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </table> \n " ;
echo " <div id='desc_condition_expression_2'></div> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
else {
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-destination-number' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2012-10-25 07:54:23 +02:00
$sql = " select * from v_destinations " ;
2019-08-05 21:33:45 +02:00
$sql .= " where domain_uuid = :domain_uuid " ;
2012-10-25 07:54:23 +02:00
$sql .= " and destination_type = 'inbound' " ;
$sql .= " order by destination_number asc " ;
2019-08-05 21:33:45 +02:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$database = new database ;
$result = $database -> select ( $sql , $parameters , 'all' );
if ( is_array ( $result ) && @ sizeof ( $result ) != 0 ) {
2014-04-15 03:31:49 +02:00
echo " <select name='destination_uuid' id='destination_uuid' class='formfld' > \n " ;
2012-10-25 07:54:23 +02:00
echo " <option></option> \n " ;
2024-08-22 20:41:10 +02:00
foreach ( $result as $row ) {
2023-05-05 18:46:37 +02:00
if ( empty ( $row [ " dialplan_uuid " ])) {
2018-08-28 04:34:56 +02:00
echo " <option value=' " . escape ( $row [ " destination_uuid " ]) . " ' style= \" font-weight:bold; \" > " . escape ( $row [ " destination_number " ]) . " " . escape ( $row [ " destination_description " ]) . " </option> \n " ;
2013-05-09 23:00:15 +02:00
}
else {
2018-08-28 04:34:56 +02:00
echo " <option value=' " . escape ( $row [ " destination_uuid " ]) . " '> " . escape ( $row [ " destination_number " ]) . " " . escape ( $row [ " destination_description " ]) . " </option> \n " ;
2013-05-09 23:00:15 +02:00
}
2012-10-25 07:54:23 +02:00
}
echo " </select> \n " ;
echo " <br /> \n " ;
2012-11-24 23:59:08 +01:00
echo " " . $text [ 'label-select-inbound-destination-number' ] . " \n " ;
2012-10-25 07:54:23 +02:00
}
else {
2013-05-29 06:34:28 +02:00
echo " <input type= \" button \" class= \" btn \" name= \" \" alt= \" " . $text [ 'button-add' ] . " \" onclick= \" window.location=' " . PROJECT_PATH . " /app/destinations/destinations.php' \" value=' " . $text [ 'button-add' ] . " '> \n " ;
2012-10-25 07:54:23 +02:00
}
2019-08-05 21:33:45 +02:00
unset ( $sql , $parameters , $result , $row );
2012-10-25 07:54:23 +02:00
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap> \n " ;
if ( permission_exists ( " inbound_route_edit " ) && $action == " advanced " ) {
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-action_1' ] . " \n " ;
2012-06-04 16:58:40 +02:00
}
else {
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-action' ] . " \n " ;
2012-06-04 16:58:40 +02:00
}
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-06-03 01:01:15 +02:00
echo $destination -> select ( 'dialplan' , 'action_1' , $action_1 ? ? null );
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
if ( permission_exists ( " inbound_route_edit " ) && $action == " advanced " ) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-action_2' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2015-08-07 22:06:07 +02:00
echo $destination -> select ( 'dialplan' , 'action_2' , $action_2 );
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-limit' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td colspan='4' class='vtable' align='left'> \n " ;
2018-08-29 23:14:56 +02:00
echo " <input class='formfld' type='text' name='limit' maxlength='255' value= \" " . escape ( $limit ) . " \" > \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2014-11-05 10:05:35 +01:00
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap> \n " ;
2016-09-01 06:07:44 +02:00
echo " " . $text [ 'label-caller-id-number-prefix' ] . " \n " ;
2014-11-05 10:05:35 +01:00
echo " </td> \n " ;
echo " <td colspan='4' class='vtable' align='left'> \n " ;
2018-08-28 04:34:56 +02:00
echo " <input class='formfld' type='text' name='caller_id_outbound_prefix' maxlength='255' value= \" " . escape ( $limit ) . " \" > \n " ;
2014-11-05 10:05:35 +01:00
echo " <br /> \n " ;
2016-09-01 06:07:44 +02:00
echo " " . $text [ 'description-caller-id-number-prefix' ] . " <br /> \n " ;
2014-11-05 10:05:35 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-order' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2014-04-15 03:31:49 +02:00
echo " <select name='public_order' class='formfld'> \n " ;
2023-06-13 01:06:56 +02:00
if ( ! empty ( $public_order ) && strlen ( htmlspecialchars ( $public_order )) > 0 ) {
2014-01-16 20:20:48 +01:00
echo " <option selected='yes' value=' " . htmlspecialchars ( $public_order ) . " '> " . htmlspecialchars ( $public_order ) . " </option> \n " ;
2012-06-04 16:58:40 +02:00
}
2014-01-16 20:20:48 +01:00
$i = 100 ;
while ( $i <= 999 ) {
if ( strlen ( $i ) == 1 ) { echo " <option value='00 $i '>00 $i </option> \n " ; }
if ( strlen ( $i ) == 2 ) { echo " <option value='0 $i '>0 $i </option> \n " ; }
if ( strlen ( $i ) == 3 ) { echo " <option value=' $i '> $i </option> \n " ; }
$i = $i + 10 ;
2012-06-04 16:58:40 +02:00
}
2014-01-16 20:20:48 +01:00
echo " </select> \n " ;
echo " <br /> \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
echo " <tr> \n " ;
echo " <td class='vncellreq' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-enabled' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
2023-06-16 01:44:40 +02:00
echo " <td class='vtable' style='position: relative;' align='left'> \n " ;
if ( substr ( $_SESSION [ 'theme' ][ 'input_toggle_style' ][ 'text' ], 0 , 6 ) == 'switch' ) {
echo " <label class='switch'> \n " ;
echo " <input type='checkbox' id='dialplan_enabled' name='dialplan_enabled' value='true' " . ( ! empty ( $dialplan_enabled ) && $dialplan_enabled == 'true' ? " checked='checked' " : null ) . " > \n " ;
echo " <span class='slider'></span> \n " ;
echo " </label> \n " ;
2012-06-04 16:58:40 +02:00
}
else {
2023-06-16 01:44:40 +02:00
echo " <select class='formfld' id='dialplan_enabled' name='dialplan_enabled'> \n " ;
echo " <option value='true' " . ( $dialplan_enabled == 'true' ? " selected='selected' " : null ) . " > " . $text [ 'option-true' ] . " </option> \n " ;
echo " <option value='false' " . ( $dialplan_enabled == 'false' ? " selected='selected' " : null ) . " > " . $text [ 'option-false' ] . " </option> \n " ;
echo " </select> \n " ;
2012-06-04 16:58:40 +02:00
}
echo " <br /> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap> \n " ;
2015-02-15 07:50:00 +01:00
echo " " . $text [ 'label-description' ] . " \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " <td colspan='4' class='vtable' align='left'> \n " ;
2018-08-28 04:34:56 +02:00
echo " <input class='formfld' type='text' name='dialplan_description' maxlength='255' value= \" " . escape ( $dialplan_description ) . " \" > \n " ;
2012-06-04 16:58:40 +02:00
echo " <br /> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2020-01-11 22:32:19 +01:00
echo " </table> " ;
2024-09-06 07:37:34 +02:00
echo " </div> \n " ;
2020-01-11 22:32:19 +01:00
echo " <br><br> " ;
2013-08-28 08:00:28 +02:00
if ( $action == " update " && permission_exists ( " inbound_route_edit " )) {
2018-08-28 04:34:56 +02:00
echo " <input type='hidden' name='dialplan_uuid' value=' " . escape ( $dialplan_uuid ) . " '> \n " ;
2012-06-04 16:58:40 +02:00
}
2020-01-11 22:32:19 +01:00
echo " <input type='hidden' name=' " . $token [ 'name' ] . " ' value=' " . $token [ 'hash' ] . " '> \n " ;
2012-06-04 16:58:40 +02:00
2015-02-15 08:59:02 +01:00
echo " </form> " ;
2012-06-04 16:58:40 +02:00
//include the footer
2013-07-06 08:29:50 +02:00
require_once " resources/footer.php " ;
2016-10-24 06:00:04 +02:00
2024-09-06 07:37:34 +02:00
?>