Update ivr_menu_edit.php

Improve the indentation and some progress to separate getting the data from displaying it.
This commit is contained in:
FusionPBX 2016-07-11 17:06:32 -06:00 committed by GitHub
parent 120b37361e
commit bec130b265
1 changed files with 158 additions and 153 deletions

View File

@ -112,14 +112,16 @@ else {
}
}
//process the http data
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
//get the id
if ($action == "update") {
$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']."<br>\n"; }
if (strlen($ivr_menu_extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."<br>\n"; }
if (strlen($ivr_menu_greet_long) == 0) { $msg .= $text['message-required'].$text['label-greet_long']."<br>\n"; }
@ -271,9 +273,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$ivr = new ivr_menu;
$ivr->domain_uuid = $_SESSION["domain_uuid"];
$ivr->ivr_menu_uuid = $ivr_menu_uuid;
$result = $ivr->find();
$result_count = count($result);
foreach ($result as &$row) {
$ivr_menus = $ivr->find();
if (is_array($ivr_menus)) foreach ($ivr_menus as &$row) {
$ivr_menu_name = $row["ivr_menu_name"];
$ivr_menu_extension = $row["ivr_menu_extension"];
$ivr_menu_greet_long = $row["ivr_menu_greet_long"];
@ -308,6 +309,15 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
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);
//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'; }
@ -332,6 +342,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$prep_statement->execute();
$recordings = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
//get the phrases
$sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$phrases = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//content
require_once "resources/header.php";
$document['title'] = $text['title-ivr_menu'];
@ -438,7 +454,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
}
//recordings
$tmp_selected = false;
if (count($recordings) > 0) {
if (is_array($recordings)) {
echo "<optgroup label='Recordings'>\n";
foreach ($recordings as &$row) {
$recording_name = $row["recording_name"];
@ -458,11 +474,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo "</optgroup>\n";
}
//phrases
$sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) > 0) {
if (is_array($phrases)) {
echo "<optgroup label='Phrases'>\n";
foreach ($result as &$row) {
if ($ivr_menu_greet_long == "phrase:".$row["phrase_uuid"]) {
@ -635,15 +647,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " <td></td>\n";
echo " </tr>\n";
if (strlen($ivr_menu_uuid) > 0) {
$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();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
foreach($result as $field) {
if (is_array($ivr_menu_options)) foreach($ivr_menu_options as $field) {
$ivr_menu_option_param = $field['ivr_menu_option_param'];
if (strlen(trim($ivr_menu_option_param)) == 0) {
$ivr_menu_option_param = $field['ivr_menu_option_action'];