Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $ivr_menu_option_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get the menu id if (strlen($_GET["ivr_menu_uuid"]) > 0) { $ivr_menu_uuid = check_str($_GET["ivr_menu_uuid"]); } //get the http post variables and set them to php variables if (count($_POST)>0) { //$domain_uuid = check_str($_POST["domain_uuid"]); $ivr_menu_uuid = check_str($_POST["ivr_menu_uuid"]); $ivr_menu_option_digits = check_str($_POST["ivr_menu_option_digits"]); $ivr_menu_option_action = check_str($_POST["ivr_menu_option_action"]); $ivr_menu_option_param = check_str($_POST["ivr_menu_option_param"]); $ivr_menu_option_order = check_str($_POST["ivr_menu_option_order"]); $ivr_menu_option_description = check_str($_POST["ivr_menu_option_description"]); //set the default ivr_menu_option_action if (strlen($ivr_menu_option_action) == 0) { $ivr_menu_option_action = "menu-exec-app"; } //seperate the action and the param $options_array = explode(":", $ivr_menu_option_param); $ivr_menu_option_action = array_shift($options_array); $ivr_menu_option_param = join(':', $options_array); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $ivr_menu_option_uuid = check_str($_POST["ivr_menu_option_uuid"]); } //check for all required data if (strlen($ivr_menu_option_digits) == 0) { $msg .= $text['message-required'].$text['label-option']."
\n"; } //if (strlen($ivr_menu_option_param) == 0) { $msg .= $text['message-required'].$text['label-destination']."
\n"; } if (strlen($ivr_menu_option_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } //if (strlen($ivr_menu_option_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; } //add or update the database if ($_POST["persistformvar"] != "true") { //create the object require_once "resources/classes/database.php"; require_once "resources/classes/ivr_menu.php"; $ivr = new ivr_menu; $ivr->domain_uuid = $_SESSION["domain_uuid"]; $ivr->ivr_menu_uuid = $ivr_menu_uuid; $ivr->ivr_menu_option_uuid = $ivr_menu_option_uuid; $ivr->ivr_menu_option_digits = trim($ivr_menu_option_digits); $ivr->ivr_menu_option_action = $ivr_menu_option_action; $ivr->ivr_menu_option_param = $ivr_menu_option_param; $ivr->ivr_menu_option_order = $ivr_menu_option_order; $ivr->ivr_menu_option_description = $ivr_menu_option_description; if ($action == "add" && permission_exists('ivr_menu_add')) { //run the add method in the ivr menu class $ivr_menu_option_uuid = uuid(); $ivr->ivr_menu_option_uuid = $ivr_menu_option_uuid; $ivr->add(); //redirect the user $_SESSION['message'] = $text['message-add']; header('Location: ivr_menu_edit.php?id='.$ivr_menu_uuid); return; } //if ($action == "add") if ($action == "update" && permission_exists('ivr_menu_edit')) { //run the update method in the ivr menu class $ivr->ivr_menu_option_uuid = $ivr_menu_option_uuid; $ivr->update(); //redirect the user $_SESSION['message'] = $text['message-update']; header('Location: ivr_menu_edit.php?id='.$ivr_menu_uuid); return; } //if ($action == "update") } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { $ivr_menu_option_uuid = $_GET["id"]; $sql = "select * from v_ivr_menu_options "; $sql .= "where ivr_menu_option_uuid = '$ivr_menu_option_uuid' "; $sql .= "and domain_uuid = '$domain_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $domain_uuid = $row["domain_uuid"]; $ivr_menu_uuid = $row["ivr_menu_uuid"]; $ivr_menu_option_digits = trim($row["ivr_menu_option_digits"]); $ivr_menu_option_action = $row["ivr_menu_option_action"]; $ivr_menu_option_param = $row["ivr_menu_option_param"]; //if admin show only the param if (if_group("admin")) { $ivr_menu_options_label = $ivr_menu_option_param; } //if superadmin show both the action and param if (if_group("superadmin")) { $ivr_menu_options_label = $ivr_menu_option_action.':'.$ivr_menu_option_param; } $ivr_menu_option_order = $row["ivr_menu_option_order"]; $ivr_menu_option_description = $row["ivr_menu_option_description"]; break; //limit to 1 row } unset ($prep_statement); } //send the content to the browser require_once "resources/header.php"; if ($action == "add") { $page["title"] = $text['title-option_add']; } if ($action == "update") { $page["title"] = $text['title-option_edit']; } echo "
"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "
\n"; echo "
"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; if ($action == "add") { echo "\n"; } if ($action == "update") { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; /* if (if_group("superadmin")) { 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 " "; echo "
".$text['header-option_add']."".$text['header-option_edit']."
\n"; echo $text['description-option_add_edit']."

\n"; echo "
\n"; echo " ".$text['label-option'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-option']."\n"; echo "
\n"; echo " Type:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "The type is required when a custom destination is defined. \n"; echo "
\n"; echo " ".$text['label-destination'].":\n"; echo "\n"; //switch_select_destination($select_type, $select_label, $select_name, $select_value, $select_style, $action='') $tmp_select_value = ''; if (strlen($ivr_menu_option_action.$ivr_menu_option_param) > 0) { $tmp_select_value = $ivr_menu_option_action.':'.$ivr_menu_option_param; } switch_select_destination("ivr", $ivr_menu_options_label, "ivr_menu_option_param", $tmp_select_value, "", $ivr_menu_option_action); unset($tmp_select_value); echo "
\n"; echo $text['description-destination']."\n"; echo "
\n"; echo " ".$text['label-order'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-order']."\n"; echo "
\n"; echo " ".$text['label-description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-description']."\n"; echo "
\n"; echo " \n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; require_once "resources/footer.php"; ?>