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('destination_add') || permission_exists('destination_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"; $destination_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (count($_POST)>0) { $dialplan_uuid = check_str($_POST["dialplan_uuid"]); $destination_type = check_str($_POST["destination_type"]); $destination_number = check_str($_POST["destination_number"]); $destination_caller_id_name = check_str($_POST["destination_caller_id_name"]); $destination_caller_id_number = check_str($_POST["destination_caller_id_number"]); $destination_context = check_str($_POST["destination_context"]); $fax_uuid = check_str($_POST["fax_uuid"]); $destination_enabled = check_str($_POST["destination_enabled"]); $destination_description = check_str($_POST["destination_description"]); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $destination_uuid = check_str($_POST["destination_uuid"]); } //check for all required data //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } //if (strlen($destination_type) == 0) { $msg .= "Please provide: Name
\n"; } //if (strlen($destination_number) == 0) { $msg .= "Please provide: Extension
\n"; } //if (strlen($destination_caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name
\n"; } //if (strlen($destination_caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number
\n"; } //if (strlen($destination_context) == 0) { $msg .= "Please provide: Context
\n"; } //if (strlen($destination_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } //if (strlen($destination_description) == 0) { $msg .= "Please provide: 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") { if ($action == "add") { $sql = "insert into v_destinations "; $sql .= "("; $sql .= "domain_uuid, "; if (strlen($dialplan_uuid) > 0) { $sql .= "dialplan_uuid, "; } $sql .= "destination_uuid, "; $sql .= "destination_type, "; $sql .= "destination_number, "; if (permission_exists('outbound_caller_id_select')) { $sql .= "destination_caller_id_name, "; $sql .= "destination_caller_id_number, "; } $sql .= "destination_context, "; if (strlen($fax_uuid) > 0) { $sql .= "fax_uuid, "; } $sql .= "destination_enabled, "; $sql .= "destination_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; if (strlen($dialplan_uuid) > 0) { $sql .= "'$dialplan_uuid', "; } $sql .= "'".uuid()."', "; $sql .= "'$destination_type', "; $sql .= "'$destination_number', "; if (permission_exists('outbound_caller_id_select')) { $sql .= "'$destination_caller_id_name', "; $sql .= "'$destination_caller_id_number', "; } $sql .= "'$destination_context', "; if (strlen($fax_uuid) > 0) { $sql .= "'$fax_uuid', "; } $sql .= "'$destination_enabled', "; $sql .= "'$destination_description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-add']; header("Location: destinations.php"); return; } //if ($action == "add") if ($action == "update") { $sql = "update v_destinations set "; if (strlen($dialplan_uuid) > 0) { $sql .= "dialplan_uuid = '$dialplan_uuid', "; } $sql .= "destination_type = '$destination_type', "; $sql .= "destination_number = '$destination_number', "; if (permission_exists('outbound_caller_id_select')) { $sql .= "destination_caller_id_name = '$destination_caller_id_name', "; $sql .= "destination_caller_id_number = '$destination_caller_id_number', "; } $sql .= "destination_context = '$destination_context', "; if (strlen($fax_uuid) > 0) { $sql .= "fax_uuid = '$fax_uuid', "; } $sql .= "destination_enabled = '$destination_enabled', "; $sql .= "destination_description = '$destination_description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and destination_uuid = '$destination_uuid'"; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-update']; header("Location: destinations.php"); 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") { $destination_uuid = $_GET["id"]; $sql = "select * from v_destinations "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and destination_uuid = '$destination_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); foreach ($result as &$row) { $dialplan_uuid = $row["dialplan_uuid"]; $destination_type = $row["destination_type"]; $destination_number = $row["destination_number"]; $destination_caller_id_name = $row["destination_caller_id_name"]; $destination_caller_id_number = $row["destination_caller_id_number"]; $destination_context = $row["destination_context"]; $fax_uuid = $row["fax_uuid"]; $destination_enabled = $row["destination_enabled"]; $destination_description = $row["destination_description"]; break; //limit to 1 row } unset ($prep_statement); } //set the defaults if (strlen($destination_type) == 0) { $destination_type = 'inbound'; } if (strlen($destination_context) == 0) { $destination_context = 'public'; } //show the header require_once "resources/header.php"; if ($action == "update") { $page["title"] = $text['title-destination-edit']; } else if ($action == "add") { $page["title"] = $text['title-destination-add']; } //show the content echo "
"; echo "\n"; echo "\n"; echo " "; echo " "; 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"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('outbound_caller_id_select')) { 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 " "; echo "
".$text['header-destination-add']."".$text['header-destination-edit']."
\n"; echo $text['description-destinations']."

\n"; echo "
\n"; echo " ".$text['label-destination_type'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_type']."\n"; echo "
\n"; echo " ".$text['label-destination_number'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_number']."\n"; echo "
\n"; echo " ".$text['label-destination_caller_id_name'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_caller_id_name']."\n"; echo "
\n"; echo " ".$text['label-destination_caller_id_number'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_caller_id_number']."\n"; echo "
\n"; echo " ".$text['label-destination_context'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_context']."\n"; echo "
\n"; echo " ".$text['label-fax_uuid'].":\n"; echo "\n"; $sql = "select * from v_fax "; $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; $sql .= "order by fax_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); echo " \n"; unset ($prep_statement, $extension); echo "
\n"; echo " ".$text['description-fax_uuid']."\n"; echo "
\n"; echo " ".$text['label-destination_enabled'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_enabled']."\n"; echo "
\n"; echo " ".$text['label-destination_description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_description']."\n"; echo "
\n"; if ($action == "update") { echo " \n"; echo " \n"; } echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //include the footer require_once "resources/footer.php"; ?>