Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "includes/require.php"; require_once "includes/checkauth.php"; if (permission_exists('time_conditions_add')) { //access granted } else { echo "access denied"; exit; } require_once "includes/header.php"; require_once "includes/paging.php"; $order_by = $_GET["order_by"]; $order = $_GET["order"]; //get the post form variables and se them to php variables if (count($_POST)>0) { $dialplan_name = check_str($_POST["dialplan_name"]); $dialplan_number = check_str($_POST["dialplan_number"]); $dialplan_order = check_str($_POST["dialplan_order"]); $condition_hour = check_str($_POST["condition_hour"]); $condition_minute = check_str($_POST["condition_minute"]); $condition_minute_of_day = check_str($_POST["condition_minute_of_day"]); $condition_mday = check_str($_POST["condition_mday"]); $condition_mweek = check_str($_POST["condition_mweek"]); $condition_mon = check_str($_POST["condition_mon"]); $condition_yday = check_str($_POST["condition_yday"]); $condition_year = check_str($_POST["condition_year"]); $condition_wday = check_str($_POST["condition_wday"]); $condition_week = check_str($_POST["condition_week"]); $action_1 = check_str($_POST["action_1"]); //$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); $anti_action_1 = check_str($_POST["anti_action_1"]); //$anti_action_1 = "transfer:1001 XML default"; $anti_action_1_array = explode(":", $anti_action_1); $anti_action_application_1 = array_shift($anti_action_1_array); $anti_action_data_1 = join(':', $anti_action_1_array); //$action_application_1 = check_str($_POST["action_application_1"]); //$action_data_1 = check_str($_POST["action_data_1"]); //$anti_action_application_1 = check_str($_POST["anti_action_application_1"]); //$anti_action_data_1 = check_str($_POST["anti_action_data_1"]); $dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_description = check_str($_POST["dialplan_description"]); if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } //if (strlen($condition_field_1) == 0) { $msg .= "Please provide: Condition Field
\n"; } //if (strlen($condition_expression_1) == 0) { $msg .= "Please provide: Condition Expression
\n"; } //if (strlen($action_application_1) == 0) { $msg .= "Please provide: Action Application
\n"; } //if (strlen($enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } //if (strlen($dialplan_description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "includes/header.php"; require_once "includes/persistformvar.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "includes/footer.php"; return; } //start the atomic transaction $count = $db->exec("BEGIN;"); //returns affected rows //add the main dialplan include entry $dialplan_uuid = uuid(); $sql = "insert into v_dialplans "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "app_uuid, "; $sql .= "dialplan_name, "; $sql .= "dialplan_order, "; $sql .= "dialplan_continue, "; $sql .= "dialplan_context, "; $sql .= "dialplan_enabled, "; $sql .= "dialplan_description "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'4b821450-926b-175a-af93-a03c441818b1', "; $sql .= "'$dialplan_name', "; $sql .= "'$dialplan_order', "; $sql .= "'false', "; $sql .= "'".$_SESSION['context']."', "; $sql .= "'$dialplan_enabled', "; $sql .= "'$dialplan_description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); //add a destination number if (strlen($dialplan_number) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'destination_number', "; $sql .= "'^$dialplan_number$', "; $sql .= "'1' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } //add time based conditions if (strlen($condition_wday) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'wday', "; $sql .= "'$condition_wday', "; $sql .= "'1' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_minute_of_day) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'minute-of-day', "; $sql .= "'$condition_minute_of_day', "; $sql .= "'2' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_mday) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'mday', "; $sql .= "'$condition_mday', "; $sql .= "'3' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_mweek) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'mweek', "; $sql .= "'$condition_mweek', "; $sql .= "'4' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_mon) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'mon', "; $sql .= "'$condition_mon', "; $sql .= "'5' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_hour) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'hour', "; $sql .= "'$condition_hour', "; $sql .= "'6' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_minute) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'minute', "; $sql .= "'$condition_minute', "; $sql .= "'7' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_week) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'week', "; $sql .= "'$condition_week', "; $sql .= "'8' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_yday) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'yday', "; $sql .= "'$condition_yday', "; $sql .= "'9' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } if (strlen($condition_year) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'condition', "; $sql .= "'year', "; $sql .= "'$condition_year', "; $sql .= "'10' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } //add action 1 $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'action', "; $sql .= "'$action_application_1', "; $sql .= "'$action_data_1', "; $sql .= "'3' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); //add anti-action 1 if (strlen($anti_action_application_1) > 0) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'anti-action', "; $sql .= "'$anti_action_application_1', "; $sql .= "'$anti_action_data_1', "; $sql .= "'4' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); } //commit the atomic transaction $count = $db->exec("COMMIT;"); //returns affected rows //synchronize the xml config save_dialplan_xml(); require_once "includes/header.php"; echo "\n"; echo "
\n"; echo "Update Complete\n"; echo "
\n"; require_once "includes/footer.php"; return; } //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) ?> "; echo "\n"; echo "\n"; echo " \n"; echo ""; echo "
\n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
Time Conditions\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " \n"; echo " Time conditions route calls based on time conditions. You can use time conditions to \n"; echo " send calls to gateways, auto attendants, external numbers, to scripts, or any destination.\n"; echo " \n"; 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 "\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"; //begin: show_advanced echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; //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 "\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 " Name:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the name for the time condition.\n"; echo "
\n"; echo "\n"; echo "
\n"; echo " Extension:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the extension number.
\n"; echo "
\n"; //echo " Continue:\n"; //echo "\n"; //echo " \n"; //echo "
\n"; //echo "Extension Continue in most cases this is false. default: false\n"; //echo "
\n"; echo " Template:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "The templates provides a list of preset time conditions.\n"; echo "
\n"; echo " Day of Month:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the day of the month. 1-31 mday
\n"; echo "
\n"; echo " Day of Week:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the day of the week. 1-7 (Sun=1, Mon=2, Tues=3) wday\n"; echo "
\n"; echo "
\n"; echo " Minute of Day:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the minute of the day. 1-1440 (midnight = 1, 8am=480, 9am=540, 6pm=1080) minute-of-day
\n"; echo "
\n"; echo " Month:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the month. 1-12 (Jan=1, Feb=2, Mar=3, April=4, May=5, Jun=6, July=7 etc.) mon
\n"; echo "
\n"; echo " Week of Month:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the week of the month. 1-6 mweek
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
Show Advanced:\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 " Day of Year:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the day of the year. 1-365 yday\n"; echo "
\n"; echo "
\n"; echo " Hour:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the hour. 0-23 hour\n"; echo "
\n"; echo "
\n"; echo " Minute:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the minute. 0-59 minute\n"; echo "
\n"; echo "
\n"; echo " Week:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the week. 1-52 week\n"; echo "
\n"; echo "
\n"; echo " Year:\n"; echo "\n"; echo " \n"; echo "
\n"; echo " Enter the year. 0-9999 year\n"; echo "
\n"; echo "
\n"; echo "
"; echo "
\n"; echo " Action when True:\n"; echo "\n"; //switch_select_destination(select_type, select_label, select_name, select_value, select_style, $action); switch_select_destination("dialplan", $action_1, "action_1", $action_1, "width: 60%;", ""); echo "
\n"; echo " Action when False:\n"; echo "\n"; //switch_select_destination(select_type, select_label, select_name, select_value, select_style, $action); switch_select_destination("dialplan", $anti_action_1, "anti_action_1", $anti_action_1, "width: 60%;", ""); echo "
\n"; echo "
\n"; echo " Order:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " Enabled:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " Description:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo "
"; echo "
"; echo "
"; echo ""; echo "

"; //include the footer require_once "includes/footer.php"; ?>