diff --git a/app/ivr_menus/ivr_menus.php b/app/ivr_menus/ivr_menus.php index 989c07d261..6665d4ae9d 100644 --- a/app/ivr_menus/ivr_menus.php +++ b/app/ivr_menus/ivr_menus.php @@ -3,11 +3,6 @@ FusionPBX Version: MPL 1.1 - The contents of this file are subject to the Mozilla Public License Version - Luis Daniel Lucio Quiroz + Mark J. Crane */ //includes require_once "root.php"; require_once "resources/require.php"; - require_once "resources/check_auth.php"; - require_once "resources/classes/logging.php"; - require_once "resources/classes/ringbacks.php"; //check permissions - if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//function to show the list of sound files - // moved to functions.php - -//action add or update - if (strlen($_REQUEST["id"]) > 0) { - $action = "update"; - $ivr_menu_uuid = check_str($_REQUEST["id"]); - } - else { - $action = "add"; - $ivr_menu_uuid = uuid(); - } - -//get total ivr menu count from the database, check limit, if defined - if ($action == 'add') { - if ($_SESSION['limit']['ivr_menus']['numeric'] != '') { - $sql = "select count(ivr_menu_uuid) as num_rows from v_ivr_menus where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - $total_ivr_menus = $row['num_rows']; - } - unset($prep_statement, $row); - if ($total_ivr_menus >= $_SESSION['limit']['ivr_menus']['numeric']) { - $_SESSION['message_mood'] = 'negative'; - $_SESSION['message'] = $text['message-maximum_ivr_menus'].' '.$_SESSION['limit']['ivr_menus']['numeric']; - header('Location: ivr_menus.php'); - return; - } - } - } - -//get http post values and set them to php variables - if (count($_POST) > 0) { - - //get ivr menu - $ivr_menu_name = check_str($_POST["ivr_menu_name"]); - $ivr_menu_extension = check_str($_POST["ivr_menu_extension"]); - $ivr_menu_greet_long = check_str($_POST["ivr_menu_greet_long"]); - $ivr_menu_greet_short = check_str($_POST["ivr_menu_greet_short"]); - $ivr_menu_options = $_POST["ivr_menu_options"]; - $ivr_menu_invalid_sound = check_str($_POST["ivr_menu_invalid_sound"]); - $ivr_menu_exit_sound = check_str($_POST["ivr_menu_exit_sound"]); - $ivr_menu_confirm_macro = check_str($_POST["ivr_menu_confirm_macro"]); - $ivr_menu_confirm_key = check_str($_POST["ivr_menu_confirm_key"]); - $ivr_menu_tts_engine = check_str($_POST["ivr_menu_tts_engine"]); - $ivr_menu_tts_voice = check_str($_POST["ivr_menu_tts_voice"]); - $ivr_menu_confirm_attempts = check_str($_POST["ivr_menu_confirm_attempts"]); - $ivr_menu_timeout = check_str($_POST["ivr_menu_timeout"]); - $ivr_menu_inter_digit_timeout = check_str($_POST["ivr_menu_inter_digit_timeout"]); - $ivr_menu_max_failures = check_str($_POST["ivr_menu_max_failures"]); - $ivr_menu_max_timeouts = check_str($_POST["ivr_menu_max_timeouts"]); - $ivr_menu_digit_len = check_str($_POST["ivr_menu_digit_len"]); - $ivr_menu_direct_dial = check_str($_POST["ivr_menu_direct_dial"]); - $ivr_menu_ringback = check_str($_POST["ivr_menu_ringback"]); - $ivr_menu_cid_prefix = check_str($_POST["ivr_menu_cid_prefix"]); - $ivr_menu_enabled = check_str($_POST["ivr_menu_enabled"]); - $ivr_menu_description = check_str($_POST["ivr_menu_description"]); - $dialplan_uuid = check_str($_POST["dialplan_uuid"]); - - //process the values - $ivr_menu_exit_action = check_str($_POST["ivr_menu_exit_action"]); - //$ivr_menu_exit_action = "transfer:1001 XML default"; - $timeout_action_array = explode(":", $ivr_menu_exit_action); - $ivr_menu_exit_app = array_shift($timeout_action_array); - $ivr_menu_exit_data = join(':', $timeout_action_array); - - //set the default ivr_menu_option_action - if (strlen($ivr_menu_option_action) == 0) { - $ivr_menu_option_action = "menu-exec-app"; - } - - } - -//process the http data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - - //get the id - if ($action == "update" && strlen($ivr_menu_uuid) == 0) { - $ivr_menu_uuid = check_str($_POST["ivr_menu_uuid"]); - } - - //check for all required data - $msg = ''; - if (strlen($ivr_menu_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } - if (strlen($ivr_menu_extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } - if (strlen($ivr_menu_greet_long) == 0) { $msg .= $text['message-required'].$text['label-greet_long']."
\n"; } - //if (strlen($ivr_menu_greet_short) == 0) { $msg .= $text['message-required'].$text['label-greet_short']."
\n"; } - //if (strlen($ivr_menu_invalid_sound) == 0) { $msg .= $text['message-required'].$text['label-invalid_sound']."
\n"; } - //if (strlen($ivr_menu_exit_sound) == 0) { $msg .= $text['message-required'].$text['label-exit_sound']."
\n"; } - //if (strlen($ivr_menu_confirm_macro) == 0) { $msg .= $text['message-required'].$text['label-comfirm_macro']."
\n"; } - //if (strlen($ivr_menu_confirm_key) == 0) { $msg .= $text['message-required'].$text['label-comfirm_key']."
\n"; } - //if (strlen($ivr_menu_tts_engine) == 0) { $msg .= $text['message-required'].$text['label-tts_engine']."
\n"; } - //if (strlen($ivr_menu_tts_voice) == 0) { $msg .= $text['message-required'].$text['label-tts_voice']."
\n"; } - if (strlen($ivr_menu_confirm_attempts) == 0) { $msg .= $text['message-required'].$text['label-comfirm_attempts']."
\n"; } - if (strlen($ivr_menu_timeout) == 0) { $msg .= $text['message-required'].$text['label-timeout']."
\n"; } - //if (strlen($ivr_menu_exit_app) == 0) { $msg .= $text['message-required'].$text['label-exit_action']."
\n"; } - if (strlen($ivr_menu_inter_digit_timeout) == 0) { $msg .= $text['message-required'].$text['label-inter_digit_timeout']."
\n"; } - if (strlen($ivr_menu_max_failures) == 0) { $msg .= $text['message-required'].$text['label-max_failures']."
\n"; } - if (strlen($ivr_menu_max_timeouts) == 0) { $msg .= $text['message-required'].$text['label-max_timeouts']."
\n"; } - if (strlen($ivr_menu_digit_len) == 0) { $msg .= $text['message-required'].$text['label-digit_length']."
\n"; } - if (strlen($ivr_menu_direct_dial) == 0) { $msg .= $text['message-required'].$text['label-direct_dial']."
\n"; } - //if (strlen($ivr_menu_ringback) == 0) { $msg .= $text['message-required'].$text['label-ring_back']."
\n"; } - if (strlen($ivr_menu_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - //if (strlen($ivr_menu_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //array cleanup - //remove the save - unset($_POST["submit"]); - - //add the domain_uuid - if (strlen($_POST["domain_uuid"] ) == 0) { - $_POST["domain_uuid"] = $_SESSION['domain_uuid']; - } - - //seperate the action and the param - $exit_array = explode(":", $_POST["ivr_menu_exit_action"]); - $_POST["ivr_menu_exit_app"] = array_shift($exit_array); - $_POST["ivr_menu_exit_data"] = join(':', $exit_array); - unset($_POST["ivr_menu_exit_action"]); - - //unset empty options, and seperate the option action from the param - $x = 0; - foreach ($_POST["ivr_menu_options"] as $row) { - if (strlen($row["ivr_menu_option_param"]) == 0) { - //remove the empty row - unset($_POST["ivr_menu_options"][$x]); - } - else { - //check if the option param is numeric - if (is_numeric($row["ivr_menu_option_param"])) { - //add the ivr menu syntax - $_POST["ivr_menu_options"][$x]["ivr_menu_option_action"] = "menu-exec-app"; - $_POST["ivr_menu_options"][$x]["ivr_menu_option_param"] = "transfer ".$row["ivr_menu_option_param"]." XML ".$_SESSION['domain_name']; - } - else { - //seperate the action and the param - $options_array = explode(":", $row["ivr_menu_option_param"]); - $_POST["ivr_menu_options"][$x]["ivr_menu_option_action"] = array_shift($options_array); - $_POST["ivr_menu_options"][$x]["ivr_menu_option_param"] = join(':', $options_array); - } - - //add the domain_uuid - if (strlen($row["domain_uuid"]) == 0) { - $_POST["ivr_menu_options"][$x]["domain_uuid"] = $_POST["domain_uuid"]; - } - } - $x++; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - - //used for debugging - if ($_POST["debug"] == "true") { - unset($_POST["debug"]); - echo "
\n";
-						print_r($_POST);
-						echo "
\n"; - exit; - } - - //build the xml dialplan - $dialplan_xml = "\n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= "\n"; - - //build the dialplan array - $dialplan["domain_uuid"] = $_SESSION['domain_uuid']; - $dialplan["dialplan_uuid"] = $dialplan_uuid; - $dialplan["dialplan_name"] = $ivr_menu_name; - $dialplan["dialplan_number"] = $ivr_menu_extension; - $dialplan["dialplan_context"] = $_SESSION["context"]; - $dialplan["dialplan_continue"] = "false"; - $dialplan["dialplan_xml"] = $dialplan_xml; - $dialplan["dialplan_order"] = "101"; - $dialplan["dialplan_enabled"] = "true"; - $dialplan["dialplan_description"] = $ivr_menu_description; - $dialplan["app_uuid"] = "a5788e9b-58bc-bd1b-df59-fff5d51253ab"; - - //prepare the array - $array['ivr_menus'][] = $_POST; - $array['dialplans'][] = $dialplan; - - //add the dialplan permission - $p = new permissions; - $p->add("dialplan_add", "temp"); - $p->add("dialplan_edit", "temp"); - - //save to the data - $orm = new orm; - //$orm->name('ivr_menus'); - $orm->app_name = 'ivr_menus'; - $orm->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab'; - if (strlen($ivr_menu_uuid) > 0) { - $orm->uuid($ivr_menu_uuid); - } - $orm->save($array); - $message = $orm->message; - - //remove the temporary permission - $p->delete("dialplan_add", "temp"); - $p->delete("dialplan_edit", "temp"); - - //save the ivr menu - //$ivr = new ivr_menu; - //$ivr->domain_uuid = $_SESSION["domain_uuid"]; - //if (strlen($ivr_menu_uuid ) > 0) { - // $ivr->ivr_menu_uuid = $ivr_menu_uuid; - //} - //$response = $ivr->save($_POST); - //if (strlen($response['uuid']) > 0) { - // $ivr_menu_uuid = $response['uuid']; - //} - - //clear the cache - $cache = new cache; - $cache->delete("dialplan:".$_SESSION["context"]); - $cache->delete("configuration:ivr.conf:".$ivr_menu_uuid); - - //set the add message - if ($action == "add" && permission_exists('ivr_menu_add')) { - $_SESSION['message'] = $text['message-add']; - } - - //set the update message - if ($action == "update" && permission_exists('ivr_menu_edit')) { - $_SESSION['message'] = $text['message-update']; - } - - //redirect the user - header("Location: ivr_menu_edit.php?id=".$ivr_menu_uuid); - return; - - } //if ($_POST["persistformvar"] != "true") - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - -//initialize the destinations object - $destination = new destinations; - -//pre-populate the form - if (strlen($ivr_menu_uuid) == 0) { $ivr_menu_uuid = check_str($_REQUEST["id"]); } - if (strlen($ivr_menu_uuid) > 0 && $_POST["persistformvar"] != "true") { - $ivr = new ivr_menu; - $ivr->domain_uuid = $_SESSION["domain_uuid"]; - $ivr->ivr_menu_uuid = $ivr_menu_uuid; - $ivr_menus = $ivr->find(); - if (is_array($ivr_menus)) foreach ($ivr_menus as &$row) { - $dialplan_uuid = $row["dialplan_uuid"]; - $ivr_menu_name = $row["ivr_menu_name"]; - $ivr_menu_extension = $row["ivr_menu_extension"]; - $ivr_menu_greet_long = $row["ivr_menu_greet_long"]; - $ivr_menu_greet_short = $row["ivr_menu_greet_short"]; - $ivr_menu_invalid_sound = $row["ivr_menu_invalid_sound"]; - $ivr_menu_exit_sound = $row["ivr_menu_exit_sound"]; - $ivr_menu_confirm_macro = $row["ivr_menu_confirm_macro"]; - $ivr_menu_confirm_key = $row["ivr_menu_confirm_key"]; - $ivr_menu_tts_engine = $row["ivr_menu_tts_engine"]; - $ivr_menu_tts_voice = $row["ivr_menu_tts_voice"]; - $ivr_menu_confirm_attempts = $row["ivr_menu_confirm_attempts"]; - $ivr_menu_timeout = $row["ivr_menu_timeout"]; - $ivr_menu_exit_app = $row["ivr_menu_exit_app"]; - $ivr_menu_exit_data = $row["ivr_menu_exit_data"]; - $ivr_menu_inter_digit_timeout = $row["ivr_menu_inter_digit_timeout"]; - $ivr_menu_max_failures = $row["ivr_menu_max_failures"]; - $ivr_menu_max_timeouts = $row["ivr_menu_max_timeouts"]; - $ivr_menu_digit_len = $row["ivr_menu_digit_len"]; - $ivr_menu_direct_dial = $row["ivr_menu_direct_dial"]; - $ivr_menu_ringback = $row["ivr_menu_ringback"]; - $ivr_menu_cid_prefix = $row["ivr_menu_cid_prefix"]; - $ivr_menu_enabled = $row["ivr_menu_enabled"]; - $ivr_menu_description = $row["ivr_menu_description"]; - - //replace the dash with a space - $ivr_menu_name = str_replace("-", " ", $ivr_menu_name); - - if (strlen($ivr_menu_exit_app) > 0) { - $ivr_menu_exit_action = $ivr_menu_exit_app.":".$ivr_menu_exit_data; - } - } - unset ($prep_statement); - } - -//get the ivr menu options - $sql = "select * from v_ivr_menu_options "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and ivr_menu_uuid = '$ivr_menu_uuid' "; - $sql .= "order by ivr_menu_option_digits, ivr_menu_option_order asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $ivr_menu_options = $prep_statement->fetchAll(PDO::FETCH_NAMED); - -//add an empty row to the options array - if (count($ivr_menu_options) == 0) { - $count = 5; - $x = 0; - } - if (count($ivr_menu_options) > 0) { - $count = 1; - $x = ''; - } - while ($x < $count) { - $ivr_menu_options[$x]['ivr_menu_option_digits'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_action'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_param'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_order'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_description'] = ''; - $x++; - } - -//set the defaults - if (strlen($ivr_menu_timeout) == 0) { $ivr_menu_timeout = '3000'; } - if (strlen($ivr_menu_ringback) == 0) { $ivr_menu_ringback = 'local_stream://default'; } - if (strlen($ivr_menu_invalid_sound) == 0) { $ivr_menu_invalid_sound = 'ivr/ivr-that_was_an_invalid_entry.wav'; } - //if (strlen($ivr_menu_confirm_key) == 0) { $ivr_menu_confirm_key = '#'; } - if (strlen($ivr_menu_tts_engine) == 0) { $ivr_menu_tts_engine = 'flite'; } - if (strlen($ivr_menu_tts_voice) == 0) { $ivr_menu_tts_voice = 'rms'; } - if (strlen($ivr_menu_confirm_attempts) == 0) { $ivr_menu_confirm_attempts = '1'; } - if (strlen($ivr_menu_inter_digit_timeout) == 0) { $ivr_menu_inter_digit_timeout = '2000'; } - if (strlen($ivr_menu_max_failures) == 0) { $ivr_menu_max_failures = '1'; } - if (strlen($ivr_menu_max_timeouts) == 0) { $ivr_menu_max_timeouts = '1'; } - if (strlen($ivr_menu_digit_len) == 0) { $ivr_menu_digit_len = '5'; } - if (strlen($ivr_menu_direct_dial) == 0) { $ivr_menu_direct_dial = 'false'; } - if (strlen($ivr_menu_enabled) == 0) { $ivr_menu_enabled = 'true'; } - if (!isset($ivr_menu_exit_action)) { $ivr_menu_exit_action = ''; } - -//get the recordings - $sql = "select recording_name, recording_filename from v_recordings "; - $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; - $sql .= "order by recording_name asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $recordings = $prep_statement->fetchAll(PDO::FETCH_ASSOC); - -//get the phrases - $sql = "select * from v_phrases "; - $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $phrases = $prep_statement->fetchAll(PDO::FETCH_NAMED); - -//get the sound files - $file = new file; - $sound_files = $file->sounds(); - -//content - require_once "resources/header.php"; - $document['title'] = $text['title-ivr_menu']; - - echo ""; - - echo "
\n"; - - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "
"; - echo " ".$text['header-ivr_menu'].""; - echo "

"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
"; - echo " ".$text['description-ivr_menu']; - echo "

"; - echo "
"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo " "; - echo " "; - echo " "; - echo " "; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo " ".$text['label-name']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-name']."\n"; - echo "
\n"; - echo " ".$text['label-extension']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-extension']."\n"; - echo "
\n"; - echo " ".$text['label-greet_long']."\n"; - echo "\n"; - if (if_group("superadmin")) { - $destination_id = "ivr_menu_greet_long"; - $script = "\n"; - $script .= "\n"; - echo $script; - } - echo "\n"; - if (if_group("superadmin")) { - echo ""; - unset($destination_id); - } - echo "
\n"; - echo $text['description-greet_long']."\n"; - echo "
\n"; - echo " ".$text['label-greet_short']."\n"; - echo "\n"; - if (if_group("superadmin")) { - $destination_id = "ivr_menu_greet_short"; - $script = "\n"; - $script .= "\n"; - echo $script; - } - echo "\n"; - if (if_group("superadmin")) { - echo ""; - unset($destination_id); - } - echo "
\n"; - echo $text['description-greet_short']."\n"; - echo "
".$text['label-options'].""; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (is_array($ivr_menu_options)) { - $c = 0; - foreach($ivr_menu_options as $field) { - - //add the primary key uuid - if (strlen($field['ivr_menu_option_uuid']) > 0) { - echo " \n"; - } - - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo " \n"; - echo " \n"; - - $c++; - } - } - unset($sql, $result); -/* - for ($c = 0; $c < 1; $c++) { - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo " \n"; - echo " \n"; - } -*/ - echo "
".$text['label-option']."".$text['label-destination']."".$text['label-order']."".$text['label-description']."
\n"; - echo " \n"; - echo "\n"; - $destination_action = ''; - if (strlen($field['ivr_menu_option_action'].$field['ivr_menu_option_param']) > 0) { - $destination_action = $field['ivr_menu_option_action'].':'.$field['ivr_menu_option_param']; - } else { $destination_action = ''; } - echo $destination->select('ivr', 'ivr_menu_options['.$c.'][ivr_menu_option_param]', $destination_action); - unset($destination_action); - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo ""; - if (strlen($field['ivr_menu_option_uuid']) > 0) { - //echo " $v_link_label_edit"; - echo " $v_link_label_delete"; - } - else { - echo "  \n"; - } - echo "
\n"; - echo " \n"; - echo "\n"; - echo $destination->select('ivr', 'ivr_menu_options['.$c.'][ivr_menu_option_param]', $destination_action); - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "
\n"; - - echo " ".$text['description-options']."\n"; - echo "
\n"; - echo "
\n"; - echo " ".$text['label-timeout']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-timeout']."\n"; - echo "
\n"; - echo " ".$text['label-exit_action']."\n"; - echo "\n"; - echo $destination->select('dialplan', 'ivr_menu_exit_action', $ivr_menu_exit_action); - echo "
\n"; - echo " ".$text['description-exit_action']."\n"; - echo "
\n"; - echo " ".$text['label-direct_dial']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-direct_dial']."\n"; - echo "
\n"; - echo " ".$text['label-ring_back']."\n"; - echo "\n"; - - $ringbacks = new ringbacks; - echo $ringbacks->select('ivr_menu_ringback', $ivr_menu_ringback); - - echo "
\n"; - echo $text['description-ring_back']."\n"; - echo "
\n"; - echo " ".$text['label-caller_id_name_prefix']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-caller_id_name_prefix']."\n"; - echo "
\n"; - - //--- begin: show_advanced ----------------------- - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - - echo "
\n"; - echo " \n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "
\n"; - echo " ".$text['label-invalid_sound']."\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo $text['description-invalid_sound']."\n"; - echo "
\n"; - echo " ".$text['label-exit_sound']."\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo $text['description-exit_sound']."\n"; - echo "
\n"; - echo " ".$text['label-comfirm_macro']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-comfirm_macro']."\n"; - echo "
\n"; - echo " ".$text['label-comfirm_key']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-comfirm_key']."\n"; - echo "
\n"; - echo " ".$text['label-tts_engine']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-tts_engine']."\n"; - echo "
\n"; - echo " ".$text['label-tts_voice']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-tts_voice']."\n"; - echo "
\n"; - echo " ".$text['label-comfirm_attempts']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-comfirm_attempts']."\n"; - echo "
\n"; - echo " ".$text['label-inter-digit_timeout']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-inter-digit_timeout']."\n"; - echo "
\n"; - echo " ".$text['label-max_failures']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-max_failures']."\n"; - echo "
\n"; - echo " ".$text['label-max_timeouts']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-max_timeouts']."\n"; - echo "
\n"; - echo " ".$text['label-digit_length']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-digit_length']."\n"; - echo "
\n"; - echo "
"; - - //--- end: show_advanced ----------------------- - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " "; - echo "
\n"; - echo " ".$text['label-enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-enabled']."\n"; - echo "
\n"; - echo " ".$text['label-description']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-description']."\n"; - echo "
\n"; - if (strlen($ivr_menu_uuid) > 0) { - echo " \n"; - echo " \n"; - } - echo "
"; - echo " \n"; - echo "
"; - echo "

"; - - echo "
"; - -//include the footer - require_once "resources/footer.php"; - -?> - - 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 - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; require_once "resources/check_auth.php"; - -//check permissions if (permission_exists('ivr_menu_view')) { //access granted } @@ -1340,1401 +37,178 @@ echo "access denied"; exit; } - - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane - Luis Daniel Lucio Quiroz -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - require_once "resources/check_auth.php"; - require_once "resources/classes/logging.php"; - require_once "resources/classes/ringbacks.php"; - -//check permissions - if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } //add multi-lingual support $language = new text; $text = $language->get(); -//function to show the list of sound files - // moved to functions.php +//get variables used to control the order + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); -//action add or update - if (strlen($_REQUEST["id"]) > 0) { - $action = "update"; - $ivr_menu_uuid = check_str($_REQUEST["id"]); +//add the search term + $search = strtolower(check_str($_GET["search"])); + if (strlen($search) > 0) { + $sql_search = "and ("; + $sql_search .= "lower(ivr_menu_name) like '%".$search."%' "; + $sql_search .= "or lower(ivr_menu_extension) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_greet_long) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_greet_short) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_invalid_sound) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_exit_sound) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_confirm_macro) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_confirm_key) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_tts_engine) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_tts_voice) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_confirm_attempts) like '%".$search."%'" ; + //$sql_search .= "or lower(ivr_menu_timeout) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_exit_app) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_exit_data) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_inter_digit_timeout) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_max_failures) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_max_timeouts) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_digit_len) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_direct_dial) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_ringback) like '%".$search."%' "; + //$sql_search .= "or lower(ivr_menu_cid_prefix) like '%".$search."%' "; + $sql_search .= "or lower(ivr_menu_enabled) like '%".$search."%' "; + $sql_search .= "or lower(ivr_menu_description) like '%".$search."%' "; + $sql_search .= ")"; } - else { - $action = "add"; - $ivr_menu_uuid = uuid(); - } - -//get total ivr menu count from the database, check limit, if defined - if ($action == 'add') { - if ($_SESSION['limit']['ivr_menus']['numeric'] != '') { - $sql = "select count(ivr_menu_uuid) as num_rows from v_ivr_menus where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - $total_ivr_menus = $row['num_rows']; - } - unset($prep_statement, $row); - if ($total_ivr_menus >= $_SESSION['limit']['ivr_menus']['numeric']) { - $_SESSION['message_mood'] = 'negative'; - $_SESSION['message'] = $text['message-maximum_ivr_menus'].' '.$_SESSION['limit']['ivr_menus']['numeric']; - header('Location: ivr_menus.php'); - return; - } - } - } - -//get http post values and set them to php variables - if (count($_POST) > 0) { - - //get ivr menu - $ivr_menu_name = check_str($_POST["ivr_menu_name"]); - $ivr_menu_extension = check_str($_POST["ivr_menu_extension"]); - $ivr_menu_greet_long = check_str($_POST["ivr_menu_greet_long"]); - $ivr_menu_greet_short = check_str($_POST["ivr_menu_greet_short"]); - $ivr_menu_options = $_POST["ivr_menu_options"]; - $ivr_menu_invalid_sound = check_str($_POST["ivr_menu_invalid_sound"]); - $ivr_menu_exit_sound = check_str($_POST["ivr_menu_exit_sound"]); - $ivr_menu_confirm_macro = check_str($_POST["ivr_menu_confirm_macro"]); - $ivr_menu_confirm_key = check_str($_POST["ivr_menu_confirm_key"]); - $ivr_menu_tts_engine = check_str($_POST["ivr_menu_tts_engine"]); - $ivr_menu_tts_voice = check_str($_POST["ivr_menu_tts_voice"]); - $ivr_menu_confirm_attempts = check_str($_POST["ivr_menu_confirm_attempts"]); - $ivr_menu_timeout = check_str($_POST["ivr_menu_timeout"]); - $ivr_menu_inter_digit_timeout = check_str($_POST["ivr_menu_inter_digit_timeout"]); - $ivr_menu_max_failures = check_str($_POST["ivr_menu_max_failures"]); - $ivr_menu_max_timeouts = check_str($_POST["ivr_menu_max_timeouts"]); - $ivr_menu_digit_len = check_str($_POST["ivr_menu_digit_len"]); - $ivr_menu_direct_dial = check_str($_POST["ivr_menu_direct_dial"]); - $ivr_menu_ringback = check_str($_POST["ivr_menu_ringback"]); - $ivr_menu_cid_prefix = check_str($_POST["ivr_menu_cid_prefix"]); - $ivr_menu_enabled = check_str($_POST["ivr_menu_enabled"]); - $ivr_menu_description = check_str($_POST["ivr_menu_description"]); - $dialplan_uuid = check_str($_POST["dialplan_uuid"]); - - //process the values - $ivr_menu_exit_action = check_str($_POST["ivr_menu_exit_action"]); - //$ivr_menu_exit_action = "transfer:1001 XML default"; - $timeout_action_array = explode(":", $ivr_menu_exit_action); - $ivr_menu_exit_app = array_shift($timeout_action_array); - $ivr_menu_exit_data = join(':', $timeout_action_array); - - //set the default ivr_menu_option_action - if (strlen($ivr_menu_option_action) == 0) { - $ivr_menu_option_action = "menu-exec-app"; - } - - } - -//process the http data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - - //get the id - if ($action == "update" && strlen($ivr_menu_uuid) == 0) { - $ivr_menu_uuid = check_str($_POST["ivr_menu_uuid"]); - } - - //check for all required data - $msg = ''; - if (strlen($ivr_menu_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } - if (strlen($ivr_menu_extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } - if (strlen($ivr_menu_greet_long) == 0) { $msg .= $text['message-required'].$text['label-greet_long']."
\n"; } - //if (strlen($ivr_menu_greet_short) == 0) { $msg .= $text['message-required'].$text['label-greet_short']."
\n"; } - //if (strlen($ivr_menu_invalid_sound) == 0) { $msg .= $text['message-required'].$text['label-invalid_sound']."
\n"; } - //if (strlen($ivr_menu_exit_sound) == 0) { $msg .= $text['message-required'].$text['label-exit_sound']."
\n"; } - //if (strlen($ivr_menu_confirm_macro) == 0) { $msg .= $text['message-required'].$text['label-comfirm_macro']."
\n"; } - //if (strlen($ivr_menu_confirm_key) == 0) { $msg .= $text['message-required'].$text['label-comfirm_key']."
\n"; } - //if (strlen($ivr_menu_tts_engine) == 0) { $msg .= $text['message-required'].$text['label-tts_engine']."
\n"; } - //if (strlen($ivr_menu_tts_voice) == 0) { $msg .= $text['message-required'].$text['label-tts_voice']."
\n"; } - if (strlen($ivr_menu_confirm_attempts) == 0) { $msg .= $text['message-required'].$text['label-comfirm_attempts']."
\n"; } - if (strlen($ivr_menu_timeout) == 0) { $msg .= $text['message-required'].$text['label-timeout']."
\n"; } - //if (strlen($ivr_menu_exit_app) == 0) { $msg .= $text['message-required'].$text['label-exit_action']."
\n"; } - if (strlen($ivr_menu_inter_digit_timeout) == 0) { $msg .= $text['message-required'].$text['label-inter_digit_timeout']."
\n"; } - if (strlen($ivr_menu_max_failures) == 0) { $msg .= $text['message-required'].$text['label-max_failures']."
\n"; } - if (strlen($ivr_menu_max_timeouts) == 0) { $msg .= $text['message-required'].$text['label-max_timeouts']."
\n"; } - if (strlen($ivr_menu_digit_len) == 0) { $msg .= $text['message-required'].$text['label-digit_length']."
\n"; } - if (strlen($ivr_menu_direct_dial) == 0) { $msg .= $text['message-required'].$text['label-direct_dial']."
\n"; } - //if (strlen($ivr_menu_ringback) == 0) { $msg .= $text['message-required'].$text['label-ring_back']."
\n"; } - if (strlen($ivr_menu_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - //if (strlen($ivr_menu_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //array cleanup - //remove the save - unset($_POST["submit"]); - - //add the domain_uuid - if (strlen($_POST["domain_uuid"] ) == 0) { - $_POST["domain_uuid"] = $_SESSION['domain_uuid']; - } - - //seperate the action and the param - $exit_array = explode(":", $_POST["ivr_menu_exit_action"]); - $_POST["ivr_menu_exit_app"] = array_shift($exit_array); - $_POST["ivr_menu_exit_data"] = join(':', $exit_array); - unset($_POST["ivr_menu_exit_action"]); - - //unset empty options, and seperate the option action from the param - $x = 0; - foreach ($_POST["ivr_menu_options"] as $row) { - if (strlen($row["ivr_menu_option_param"]) == 0) { - //remove the empty row - unset($_POST["ivr_menu_options"][$x]); - } - else { - //check if the option param is numeric - if (is_numeric($row["ivr_menu_option_param"])) { - //add the ivr menu syntax - $_POST["ivr_menu_options"][$x]["ivr_menu_option_action"] = "menu-exec-app"; - $_POST["ivr_menu_options"][$x]["ivr_menu_option_param"] = "transfer ".$row["ivr_menu_option_param"]." XML ".$_SESSION['domain_name']; - } - else { - //seperate the action and the param - $options_array = explode(":", $row["ivr_menu_option_param"]); - $_POST["ivr_menu_options"][$x]["ivr_menu_option_action"] = array_shift($options_array); - $_POST["ivr_menu_options"][$x]["ivr_menu_option_param"] = join(':', $options_array); - } - - //add the domain_uuid - if (strlen($row["domain_uuid"]) == 0) { - $_POST["ivr_menu_options"][$x]["domain_uuid"] = $_POST["domain_uuid"]; - } - } - $x++; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - - //used for debugging - if ($_POST["debug"] == "true") { - unset($_POST["debug"]); - echo "
\n";
-						print_r($_POST);
-						echo "
\n"; - exit; - } - - //build the xml dialplan - $dialplan_xml = "\n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= " \n"; - $dialplan_xml .= "\n"; - - //build the dialplan array - $dialplan["domain_uuid"] = $_SESSION['domain_uuid']; - $dialplan["dialplan_uuid"] = $dialplan_uuid; - $dialplan["dialplan_name"] = $ivr_menu_name; - $dialplan["dialplan_number"] = $ivr_menu_extension; - $dialplan["dialplan_context"] = $_SESSION["context"]; - $dialplan["dialplan_continue"] = "false"; - $dialplan["dialplan_xml"] = $dialplan_xml; - $dialplan["dialplan_order"] = "101"; - $dialplan["dialplan_enabled"] = "true"; - $dialplan["dialplan_description"] = $ivr_menu_description; - $dialplan["app_uuid"] = "a5788e9b-58bc-bd1b-df59-fff5d51253ab"; - - //prepare the array - $array['ivr_menus'][] = $_POST; - $array['dialplans'][] = $dialplan; - - //add the dialplan permission - $p = new permissions; - $p->add("dialplan_add", "temp"); - $p->add("dialplan_edit", "temp"); - - //save to the data - $orm = new orm; - //$orm->name('ivr_menus'); - $orm->app_name = 'ivr_menus'; - $orm->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab'; - if (strlen($ivr_menu_uuid) > 0) { - $orm->uuid($ivr_menu_uuid); - } - $orm->save($array); - $message = $orm->message; - - //remove the temporary permission - $p->delete("dialplan_add", "temp"); - $p->delete("dialplan_edit", "temp"); - - //save the ivr menu - //$ivr = new ivr_menu; - //$ivr->domain_uuid = $_SESSION["domain_uuid"]; - //if (strlen($ivr_menu_uuid ) > 0) { - // $ivr->ivr_menu_uuid = $ivr_menu_uuid; - //} - //$response = $ivr->save($_POST); - //if (strlen($response['uuid']) > 0) { - // $ivr_menu_uuid = $response['uuid']; - //} - - //clear the cache - $cache = new cache; - $cache->delete("dialplan:".$_SESSION["context"]); - $cache->delete("configuration:ivr.conf:".$ivr_menu_uuid); - - //set the add message - if ($action == "add" && permission_exists('ivr_menu_add')) { - $_SESSION['message'] = $text['message-add']; - } - - //set the update message - if ($action == "update" && permission_exists('ivr_menu_edit')) { - $_SESSION['message'] = $text['message-update']; - } - - //redirect the user - header("Location: ivr_menu_edit.php?id=".$ivr_menu_uuid); - return; - - } //if ($_POST["persistformvar"] != "true") - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - -//initialize the destinations object - $destination = new destinations; - -//pre-populate the form - if (strlen($ivr_menu_uuid) == 0) { $ivr_menu_uuid = check_str($_REQUEST["id"]); } - if (strlen($ivr_menu_uuid) > 0 && $_POST["persistformvar"] != "true") { - $ivr = new ivr_menu; - $ivr->domain_uuid = $_SESSION["domain_uuid"]; - $ivr->ivr_menu_uuid = $ivr_menu_uuid; - $ivr_menus = $ivr->find(); - if (is_array($ivr_menus)) foreach ($ivr_menus as &$row) { - $dialplan_uuid = $row["dialplan_uuid"]; - $ivr_menu_name = $row["ivr_menu_name"]; - $ivr_menu_extension = $row["ivr_menu_extension"]; - $ivr_menu_greet_long = $row["ivr_menu_greet_long"]; - $ivr_menu_greet_short = $row["ivr_menu_greet_short"]; - $ivr_menu_invalid_sound = $row["ivr_menu_invalid_sound"]; - $ivr_menu_exit_sound = $row["ivr_menu_exit_sound"]; - $ivr_menu_confirm_macro = $row["ivr_menu_confirm_macro"]; - $ivr_menu_confirm_key = $row["ivr_menu_confirm_key"]; - $ivr_menu_tts_engine = $row["ivr_menu_tts_engine"]; - $ivr_menu_tts_voice = $row["ivr_menu_tts_voice"]; - $ivr_menu_confirm_attempts = $row["ivr_menu_confirm_attempts"]; - $ivr_menu_timeout = $row["ivr_menu_timeout"]; - $ivr_menu_exit_app = $row["ivr_menu_exit_app"]; - $ivr_menu_exit_data = $row["ivr_menu_exit_data"]; - $ivr_menu_inter_digit_timeout = $row["ivr_menu_inter_digit_timeout"]; - $ivr_menu_max_failures = $row["ivr_menu_max_failures"]; - $ivr_menu_max_timeouts = $row["ivr_menu_max_timeouts"]; - $ivr_menu_digit_len = $row["ivr_menu_digit_len"]; - $ivr_menu_direct_dial = $row["ivr_menu_direct_dial"]; - $ivr_menu_ringback = $row["ivr_menu_ringback"]; - $ivr_menu_cid_prefix = $row["ivr_menu_cid_prefix"]; - $ivr_menu_enabled = $row["ivr_menu_enabled"]; - $ivr_menu_description = $row["ivr_menu_description"]; - - //replace the dash with a space - $ivr_menu_name = str_replace("-", " ", $ivr_menu_name); - - if (strlen($ivr_menu_exit_app) > 0) { - $ivr_menu_exit_action = $ivr_menu_exit_app.":".$ivr_menu_exit_data; - } - } - unset ($prep_statement); - } - -//get the ivr menu options - $sql = "select * from v_ivr_menu_options "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and ivr_menu_uuid = '$ivr_menu_uuid' "; - $sql .= "order by ivr_menu_option_digits, ivr_menu_option_order asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $ivr_menu_options = $prep_statement->fetchAll(PDO::FETCH_NAMED); - -//add an empty row to the options array - if (count($ivr_menu_options) == 0) { - $count = 5; - $x = 0; - } - if (count($ivr_menu_options) > 0) { - $count = 1; - $x = ''; - } - while ($x < $count) { - $ivr_menu_options[$x]['ivr_menu_option_digits'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_action'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_param'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_order'] = ''; - $ivr_menu_options[$x]['ivr_menu_option_description'] = ''; - $x++; - } - -//set the defaults - if (strlen($ivr_menu_timeout) == 0) { $ivr_menu_timeout = '3000'; } - if (strlen($ivr_menu_ringback) == 0) { $ivr_menu_ringback = 'local_stream://default'; } - if (strlen($ivr_menu_invalid_sound) == 0) { $ivr_menu_invalid_sound = 'ivr/ivr-that_was_an_invalid_entry.wav'; } - //if (strlen($ivr_menu_confirm_key) == 0) { $ivr_menu_confirm_key = '#'; } - if (strlen($ivr_menu_tts_engine) == 0) { $ivr_menu_tts_engine = 'flite'; } - if (strlen($ivr_menu_tts_voice) == 0) { $ivr_menu_tts_voice = 'rms'; } - if (strlen($ivr_menu_confirm_attempts) == 0) { $ivr_menu_confirm_attempts = '1'; } - if (strlen($ivr_menu_inter_digit_timeout) == 0) { $ivr_menu_inter_digit_timeout = '2000'; } - if (strlen($ivr_menu_max_failures) == 0) { $ivr_menu_max_failures = '1'; } - if (strlen($ivr_menu_max_timeouts) == 0) { $ivr_menu_max_timeouts = '1'; } - if (strlen($ivr_menu_digit_len) == 0) { $ivr_menu_digit_len = '5'; } - if (strlen($ivr_menu_direct_dial) == 0) { $ivr_menu_direct_dial = 'false'; } - if (strlen($ivr_menu_enabled) == 0) { $ivr_menu_enabled = 'true'; } - if (!isset($ivr_menu_exit_action)) { $ivr_menu_exit_action = ''; } - -//get the recordings - $sql = "select recording_name, recording_filename from v_recordings "; - $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; - $sql .= "order by recording_name asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $recordings = $prep_statement->fetchAll(PDO::FETCH_ASSOC); - -//get the phrases - $sql = "select * from v_phrases "; - $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $phrases = $prep_statement->fetchAll(PDO::FETCH_NAMED); - -//get the sound files - $file = new file; - $sound_files = $file->sounds(); - -//content - require_once "resources/header.php"; - $document['title'] = $text['title-ivr_menu']; - - echo ""; - - echo "
\n"; - - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "
"; - echo " ".$text['header-ivr_menu'].""; - echo "

"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
"; - echo " ".$text['description-ivr_menu']; - echo "

"; - echo "
"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo " "; - echo " "; - echo " "; - echo " "; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo " ".$text['label-name']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-name']."\n"; - echo "
\n"; - echo " ".$text['label-extension']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-extension']."\n"; - echo "
\n"; - echo " ".$text['label-greet_long']."\n"; - echo "\n"; - if (if_group("superadmin")) { - $destination_id = "ivr_menu_greet_long"; - $script = "\n"; - $script .= "\n"; - echo $script; - } - echo "\n"; - if (if_group("superadmin")) { - echo ""; - unset($destination_id); - } - echo "
\n"; - echo $text['description-greet_long']."\n"; - echo "
\n"; - echo " ".$text['label-greet_short']."\n"; - echo "\n"; - if (if_group("superadmin")) { - $destination_id = "ivr_menu_greet_short"; - $script = "\n"; - $script .= "\n"; - echo $script; - } - echo "\n"; - if (if_group("superadmin")) { - echo ""; - unset($destination_id); - } - echo "
\n"; - echo $text['description-greet_short']."\n"; - echo "
".$text['label-options'].""; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (is_array($ivr_menu_options)) { - $c = 0; - foreach($ivr_menu_options as $field) { - - //add the primary key uuid - if (strlen($field['ivr_menu_option_uuid']) > 0) { - echo " \n"; - } - - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo " \n"; - echo " \n"; - - $c++; - } - } - unset($sql, $result); -/* - for ($c = 0; $c < 1; $c++) { - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo " \n"; - echo " \n"; - } -*/ - echo "
".$text['label-option']."".$text['label-destination']."".$text['label-order']."".$text['label-description']."
\n"; - echo " \n"; - echo "\n"; - $destination_action = ''; - if (strlen($field['ivr_menu_option_action'].$field['ivr_menu_option_param']) > 0) { - $destination_action = $field['ivr_menu_option_action'].':'.$field['ivr_menu_option_param']; - } else { $destination_action = ''; } - echo $destination->select('ivr', 'ivr_menu_options['.$c.'][ivr_menu_option_param]', $destination_action); - unset($destination_action); - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo ""; - if (strlen($field['ivr_menu_option_uuid']) > 0) { - //echo " $v_link_label_edit"; - echo " $v_link_label_delete"; - } - else { - echo "  \n"; - } - echo "
\n"; - echo " \n"; - echo "\n"; - echo $destination->select('ivr', 'ivr_menu_options['.$c.'][ivr_menu_option_param]', $destination_action); - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "
\n"; - - echo " ".$text['description-options']."\n"; - echo "
\n"; - echo "
\n"; - echo " ".$text['label-timeout']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-timeout']."\n"; - echo "
\n"; - echo " ".$text['label-exit_action']."\n"; - echo "\n"; - echo $destination->select('dialplan', 'ivr_menu_exit_action', $ivr_menu_exit_action); - echo "
\n"; - echo " ".$text['description-exit_action']."\n"; - echo "
\n"; - echo " ".$text['label-direct_dial']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-direct_dial']."\n"; - echo "
\n"; - echo " ".$text['label-ring_back']."\n"; - echo "\n"; - - $ringbacks = new ringbacks; - echo $ringbacks->select('ivr_menu_ringback', $ivr_menu_ringback); - - echo "
\n"; - echo $text['description-ring_back']."\n"; - echo "
\n"; - echo " ".$text['label-caller_id_name_prefix']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-caller_id_name_prefix']."\n"; - echo "
\n"; - - //--- begin: show_advanced ----------------------- - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - - echo "
\n"; - echo " \n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "
\n"; - echo " ".$text['label-invalid_sound']."\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo $text['description-invalid_sound']."\n"; - echo "
\n"; - echo " ".$text['label-exit_sound']."\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo $text['description-exit_sound']."\n"; - echo "
\n"; - echo " ".$text['label-comfirm_macro']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-comfirm_macro']."\n"; - echo "
\n"; - echo " ".$text['label-comfirm_key']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-comfirm_key']."\n"; - echo "
\n"; - echo " ".$text['label-tts_engine']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-tts_engine']."\n"; - echo "
\n"; - echo " ".$text['label-tts_voice']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-tts_voice']."\n"; - echo "
\n"; - echo " ".$text['label-comfirm_attempts']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-comfirm_attempts']."\n"; - echo "
\n"; - echo " ".$text['label-inter-digit_timeout']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-inter-digit_timeout']."\n"; - echo "
\n"; - echo " ".$text['label-max_failures']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-max_failures']."\n"; - echo "
\n"; - echo " ".$text['label-max_timeouts']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-max_timeouts']."\n"; - echo "
\n"; - echo " ".$text['label-digit_length']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-digit_length']."\n"; - echo "
\n"; - echo "
"; - - //--- end: show_advanced ----------------------- - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " "; - echo "
\n"; - echo " ".$text['label-enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-enabled']."\n"; - echo "
\n"; - echo " ".$text['label-description']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-description']."\n"; - echo "
\n"; - if (strlen($ivr_menu_uuid) > 0) { - echo " \n"; - echo " \n"; - } - echo "
"; - echo " \n"; - echo "
"; - echo "

"; - - echo "
"; - -//include the footer - require_once "resources/footer.php"; - -?> - -//add multi-lingual support - $language = new text; - $text = $language->get(); //additional includes require_once "resources/header.php"; - $document['title'] = $text['title-ivr_menus']; require_once "resources/paging.php"; -//get the http values and set them as variables - if (isset($_GET["order_by"])) { - $order_by['0']['name'] = check_str($_GET["order_by"]); - $order_by['0']['order'] = check_str($_GET["order"]); +//prepare to page the results + $sql = "select count(ivr_menu_uuid) as num_rows from v_ivr_menus "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } } - else { - $order_by['0']['name'] = 'ivr_menu_name'; - $order_by['0']['order'] = 'asc'; - } - -//show the content - echo "".$text['header-ivr_menus']."\n"; - echo "

\n"; - echo $text['description-ivr_menus']."\n"; - echo "

\n"; - -//get the count - $ivr = new ivr_menu; - $ivr->domain_uuid = $_SESSION["domain_uuid"]; - $ivr->table = "v_ivr_menus"; - $where[0]['name'] = 'domain_uuid'; - $where[0]['value'] = $_SESSION["domain_uuid"]; - $where[0]['operator'] = '='; - $ivr->where = $where; - $num_rows = $ivr->count(); - -//use total ivr menu count from the database - $total_ivr_menus = $num_rows; //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = ""; - if (!isset($_GET['page'])) { $_GET['page'] = 0; } - $_GET['page'] = check_str($_GET['page']); - list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $_GET['page']; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; -//get the list from the db - if (isset($order_by)) { - if (count($order_by) > 0) { - $ivr->order_by = $order_by; - } - } - $ivr_menus = $ivr->find(); +//get the list + $sql = "select * from v_ivr_menus "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); +//alternate the row style $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['title-ivr_menus']."
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['description-ivr_menu']."

\n"; + echo "
\n"; + echo "\n"; echo "\n"; - echo th_order_by('ivr_menu_name', $text['label-name'], $order_by[0]['name'], $order_by[0]['order']); - echo th_order_by('ivr_menu_extension', $text['label-extension'], $order_by[0]['name'], $order_by[0]['order']); - echo th_order_by('ivr_menu_direct_dial', $text['label-direct_dial'], $order_by[0]['name'], $order_by[0]['order']); - echo th_order_by('ivr_menu_enabled', $text['label-enabled'], $order_by[0]['name'], $order_by[0]['order']); - echo th_order_by('ivr_menu_description', $text['label-description'], $order_by[0]['name'], $order_by[0]['order']); + //echo th_order_by('ivr_menu_uuid', $text['label-ivr_menu_uuid'], $order_by, $order); + //echo th_order_by('dialplan_uuid', $text['label-dialplan_uuid'], $order_by, $order); + echo th_order_by('ivr_menu_name', $text['label-name'], $order_by, $order); + echo th_order_by('ivr_menu_extension', $text['label-extension'], $order_by, $order); + //echo th_order_by('ivr_menu_greet_long', $text['label-ivr_menu_greet_long'], $order_by, $order); + //echo th_order_by('ivr_menu_greet_short', $text['label-ivr_menu_greet_short'], $order_by, $order); + //echo th_order_by('ivr_menu_invalid_sound', $text['label-ivr_menu_invalid_sound'], $order_by, $order); + //echo th_order_by('ivr_menu_exit_sound', $text['label-ivr_menu_exit_sound'], $order_by, $order); + //echo th_order_by('ivr_menu_confirm_macro', $text['label-ivr_menu_confirm_macro'], $order_by, $order); + //echo th_order_by('ivr_menu_confirm_key', $text['label-ivr_menu_confirm_key'], $order_by, $order); + //echo th_order_by('ivr_menu_tts_engine', $text['label-ivr_menu_tts_engine'], $order_by, $order); + //echo th_order_by('ivr_menu_tts_voice', $text['label-ivr_menu_tts_voice'], $order_by, $order); + //echo th_order_by('ivr_menu_confirm_attempts', $text['label-ivr_menu_confirm_attempts'], $order_by, $order); + //echo th_order_by('ivr_menu_timeout', $text['label-ivr_menu_timeout'], $order_by, $order); + //echo th_order_by('ivr_menu_exit_app', $text['label-ivr_menu_exit_app'], $order_by, $order); + //echo th_order_by('ivr_menu_exit_data', $text['label-ivr_menu_exit_data'], $order_by, $order); + //echo th_order_by('ivr_menu_inter_digit_timeout', $text['label-ivr_menu_inter_digit_timeout'], $order_by, $order); + //echo th_order_by('ivr_menu_max_failures', $text['label-ivr_menu_max_failures'], $order_by, $order); + //echo th_order_by('ivr_menu_max_timeouts', $text['label-ivr_menu_max_timeouts'], $order_by, $order); + //echo th_order_by('ivr_menu_digit_len', $text['label-ivr_menu_digit_len'], $order_by, $order); + //echo th_order_by('ivr_menu_direct_dial', $text['label-ivr_menu_direct_dial'], $order_by, $order); + //echo th_order_by('ivr_menu_ringback', $text['label-ivr_menu_ringback'], $order_by, $order); + //echo th_order_by('ivr_menu_cid_prefix', $text['label-ivr_menu_cid_prefix'], $order_by, $order); + echo th_order_by('ivr_menu_enabled', $text['label-enabled'], $order_by, $order); + echo th_order_by('ivr_menu_description', $text['label-description'], $order_by, $order); echo "\n"; - echo "\n"; + echo "\n"; - if (is_array($ivr_menus)) { - foreach($ivr_menus as $row) { - $ivr_menu_name = str_replace("-", " ", $row['ivr_menu_name']); - $tr_link = (permission_exists('ivr_menu_edit')) ? "href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."'" : null; - echo "\n"; - echo " \n"; + echo "\n"; + //echo " \n"; + //echo " \n"; + echo " \n"; echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; + echo "\n"; + echo " \n"; + echo "
"; if (permission_exists('ivr_menu_add')) { if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) { - echo "".$v_link_label_add.""; + echo "$v_link_label_add"; } } + else { + echo " \n"; + } echo "
"; + if (is_array($result)) { + foreach($result as $row) { if (permission_exists('ivr_menu_edit')) { - echo "".$ivr_menu_name.""; + $tr_link = "href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."'"; } - else { - echo $ivr_menu_name; - } - echo "
".$row['ivr_menu_uuid']." ".$row['dialplan_uuid']." ".$row['ivr_menu_name']." ".$row['ivr_menu_extension']." ".ucwords($row['ivr_menu_direct_dial'])."".$text['label-'.$row['ivr_menu_enabled']]."".$row['ivr_menu_description']." ".$row['ivr_menu_greet_long']." ".$row['ivr_menu_greet_short']." ".$row['ivr_menu_invalid_sound']." ".$row['ivr_menu_exit_sound']." ".$row['ivr_menu_confirm_macro']." ".$row['ivr_menu_confirm_key']." ".$row['ivr_menu_tts_engine']." ".$row['ivr_menu_tts_voice']." ".$row['ivr_menu_confirm_attempts']." ".$row['ivr_menu_timeout']." ".$row['ivr_menu_exit_app']." ".$row['ivr_menu_exit_data']." ".$row['ivr_menu_inter_digit_timeout']." ".$row['ivr_menu_max_failures']." ".$row['ivr_menu_max_timeouts']." ".$row['ivr_menu_digit_len']." ".$row['ivr_menu_direct_dial']." ".$row['ivr_menu_ringback']." ".$row['ivr_menu_cid_prefix']." ".$row['ivr_menu_enabled']." ".$row['ivr_menu_description']." "; if (permission_exists('ivr_menu_edit')) { echo "$v_link_label_edit"; @@ -2749,22 +223,30 @@ unset($sql, $result, $row_count); } //end if results + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; + echo "$v_link_label_add"; } } - echo "
 $paging_controls"; if (permission_exists('ivr_menu_add')) { if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) { - echo "
 "; - echo "".$v_link_label_add.""; - echo "
\n"; - echo "
"; + else { + echo " "; + } + echo "
\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "

"; - echo "
".$paging_controls."
\n"; - echo "

"; - -//show the footer +//include the footer require_once "resources/footer.php"; + ?>