Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('time_condition_add') || permission_exists('time_condition_edit')) { //access granted } else { echo "access denied"; exit; } require_once "resources/header.php"; require_once "resources/paging.php"; //add multi-lingual support $language = new text; $text = $language->get(); //set the action as an add or an update if (isset($_REQUEST["id"])) { $action = "update"; $dialplan_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get the app uuid $app_uuid = check_str($_REQUEST["app_uuid"]); //get the http post values and set them as 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"]); $dialplan_continue = check_str($_POST["dialplan_continue"]); $dialplan_details = $_POST["dialplan_details"]; if (strlen($dialplan_continue) == 0) { $dialplan_continue = "false"; } $dialplan_context = check_str($_POST["dialplan_context"]); $dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_description = check_str($_POST["dialplan_description"]); } //set the default_context $dialplan_context = $_SESSION['context']; //prcoess the HTTP POST if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if ($action == "update") { $dialplan_uuid = check_str($_POST["dialplan_uuid"]); } //check for all required data $msg = ''; if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']." ".__line__."
\n"; } if (strlen($dialplan_order) == 0) { $msg .= $text['message-required'].$text['label-order']." ".__line__."
\n"; } if (strlen($dialplan_continue) == 0) { $msg .= $text['message-required'].$text['label-continue']." ".__line__."
\n"; } if (strlen($dialplan_context) == 0) { $msg .= $text['message-required'].$text['label-context']." ".__line__."
\n"; } if (strlen($dialplan_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']." ".__line__."
\n"; } //if (strlen($dialplan_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; } //remove submit from the post array unset($_POST["submit"]); //get the detail_type and detail_data $x = 0; $action_exists = false; //foreach ($dialplan_details as $row) { $first_time = true; foreach ($_POST["dialplan_details"] as $row) { $time_array = explode(',', 'year,mon,mday,wday,yday,week,mweek,hour,minute,minute-of-day,time-of-day,date-time'); if (in_array($row["dialplan_detail_type"], $time_array)) { //$dialplan_times[$group][$type] = $data; //$dialplan_times[$group]['group'] = $group; if (strlen($row["dialplan_detail_data"]) == 0) { if ($first_time) { $_POST["dialplan_details"][$x]['dialplan_detail_tag'] = 'condition'; $_POST["dialplan_details"][$x]['dialplan_detail_type'] = 'destination_number'; $_POST["dialplan_details"][$x]['dialplan_detail_data'] = '^'.$_POST["dialplan_number"].'$'; $_POST["dialplan_details"][$x]['dialplan_detail_group'] = '0'; $_POST["dialplan_details"][$x]['dialplan_detail_order'] = '10'; $_POST["dialplan_details"][$x]['dialplan_detail_break'] = 'never'; $x++; $_POST["dialplan_details"][$x]['dialplan_detail_tag'] = 'action'; $_POST["dialplan_details"][$x]['dialplan_detail_type'] = 'set'; $_POST["dialplan_details"][$x]['dialplan_detail_data'] = 'time_condition=true'; $_POST["dialplan_details"][$x]['dialplan_detail_inline'] = 'true'; $_POST["dialplan_details"][$x]['dialplan_detail_group'] = '0'; $_POST["dialplan_details"][$x]['dialplan_detail_order'] = '30'; $x++; } $first_time = false; if ($row["scope"] == 'range') { $data = $row[$row["dialplan_detail_type"]][stop]; } else { $data = $row[$row["dialplan_detail_type"]][start]; } $_POST["dialplan_details"][$x]['dialplan_detail_type'] = $row["dialplan_detail_type"]; $_POST["dialplan_details"][$x]['dialplan_detail_data'] = $data; $_POST["dialplan_details"][$x]['dialplan_detail_tag'] = 'condition'; $_POST["dialplan_details"][$x]['dialplan_detail_group'] = '0'; $_POST["dialplan_details"][$x]['dialplan_detail_order'] = '20'; $_POST["dialplan_details"][$x]['dialplan_detail_break'] = 'never'; $x++; unset($data); //unset rows scope and the array with start and stop unset($_POST["dialplan_details"][$x]['scope']); unset($_POST["dialplan_details"][$x][$row["dialplan_detail_type"]]); } } if (strlen($row['action']) > 0) { //get the application and data $action_array = explode(":", $row['action']); $action_application = array_shift($action_array); $action_data = join(':', $action_array); //add the action $_POST["dialplan_details"][$x]['dialplan_detail_type'] = $action_application; $_POST["dialplan_details"][$x]['dialplan_detail_data'] = $action_data; $_POST["dialplan_details"][$x]['dialplan_detail_tag'] = 'action'; $_POST["dialplan_details"][$x]['dialplan_detail_group'] = '100'; $_POST["dialplan_details"][$x]['dialplan_detail_order'] = '30'; //unset the empty row if (strlen($row["dialplan_detail_data"]) == 0) { unset($_POST["dialplan_details"][100]); } //set to true if the action exists $action_exists = true; } if (strlen($row['anti_action']) > 0) { //get the application and data $anti_action_array = explode(":", $row['anti_action']); $anti_action_application = array_shift($anti_action_array); $anti_action_data = join(':', $anti_action_array); //add the action $_POST["dialplan_details"][$x]['dialplan_detail_type'] = $anti_action_application; $_POST["dialplan_details"][$x]['dialplan_detail_data'] = $anti_action_data; $_POST["dialplan_details"][$x]['dialplan_detail_tag'] = 'anti-action'; $_POST["dialplan_details"][$x]['dialplan_detail_group'] = '100'; $_POST["dialplan_details"][$x]['dialplan_detail_order'] = '40'; //unset the empty row if (strlen($row["dialplan_detail_data"]) == 0) { unset($_POST["dialplan_details"][110]); } //set to true if the action exists $action_exists = true; } //increment the row $x++; } //if the action exists then if ($action_exists) { $_POST["dialplan_details"][$x]['dialplan_detail_tag'] = 'condition'; $_POST["dialplan_details"][$x]['dialplan_detail_type'] = 'destination_number'; $_POST["dialplan_details"][$x]['dialplan_detail_data'] = '^'.$_POST["dialplan_number"].'$'; $_POST["dialplan_details"][$x]['dialplan_detail_group'] = '100'; $_POST["dialplan_details"][$x]['dialplan_detail_order'] = '10'; $x++; $_POST["dialplan_details"][$x]['dialplan_detail_tag'] = 'condition'; $_POST["dialplan_details"][$x]['dialplan_detail_type'] = '${time_condition}'; $_POST["dialplan_details"][$x]['dialplan_detail_data'] = '^true$'; $_POST["dialplan_details"][$x]['dialplan_detail_group'] = '100'; $_POST["dialplan_details"][$x]['dialplan_detail_order'] = '20'; } //echo "
\n";
//print_r($_POST);
//echo __line__."
\n"; //remove the invalid characters from the dialplan name $dialplan_name = $_POST["dialplan_name"]; $dialplan_name = str_replace(" ", "_", $dialplan_name); $dialplan_name = str_replace("/", "", $dialplan_name); //build the array if (strlen($row["dialplan_uuid"]) > 0) { $array['dialplan_uuid'] = $_POST["dialplan_uuid"]; } if (isset($_POST["domain_uuid"])) { $array['domain_uuid'] = $_POST['domain_uuid']; } else { $array['domain_uuid'] = $_SESSION['domain_uuid']; } $array['dialplan_name'] = $dialplan_name; $array['dialplan_number'] = $_POST["dialplan_number"]; $array['dialplan_context'] = $dialplan_context; $array['dialplan_continue'] = $_POST["dialplan_continue"]; $array['dialplan_order'] = $_POST["dialplan_order"]; $array['dialplan_enabled'] = $_POST["dialplan_enabled"]; $array['dialplan_description'] = $_POST["dialplan_description"]; $array['app_uuid'] = '4b821450-926b-175a-af93-a03c441818b1'; $x = 0; foreach ($_POST["dialplan_details"] as $row) { if (strlen($row["dialplan_detail_tag"]) > 0) { if (strlen($row["dialplan_detail_uuid"]) > 0) { $array['dialplan_details'][$x]['dialplan_detail_uuid'] = $row["dialplan_detail_uuid"]; } $array['dialplan_details'][$x]['domain_uuid'] = $array['domain_uuid']; $array['dialplan_details'][$x]['dialplan_detail_tag'] = $row["dialplan_detail_tag"]; $array['dialplan_details'][$x]['dialplan_detail_type'] = $row["dialplan_detail_type"]; $array['dialplan_details'][$x]['dialplan_detail_data'] = $row["dialplan_detail_data"]; $array['dialplan_details'][$x]['dialplan_detail_break'] = $row["dialplan_detail_break"]; $array['dialplan_details'][$x]['dialplan_detail_inline'] = $row["dialplan_detail_inline"]; $array['dialplan_details'][$x]['dialplan_detail_group'] = $row["dialplan_detail_group"]; $array['dialplan_details'][$x]['dialplan_detail_order'] = $row["dialplan_detail_order"]; } $x++; } echo "
\n";
print_r($array);
echo __line__."
\n"; //add or update the database if ($_POST["persistformvar"] != "true") { $orm = new orm; $orm->name('dialplans'); $orm->uuid($dialplan_uuid); $orm->save($array); $message = $orm->message; echo "
\n";
print_r($message);
echo "
\n"; } exit; //clear the cache $cache = new cache; //$cache->delete("dialplan:".$dialplan_context); $cache->delete("dialplan:".$_SESSION["context"]); //synchronize the xml config save_dialplan_xml(); //set the message if ($action == "add") { $_SESSION['message'] = $text['message-add']; } else if ($action == "update") { $_SESSION['message'] = $text['message-update']; } header("Location: time_condition_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)); return; } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //get the information to pre-populate the form if (strlen($_GET['id']) > 0) { //get the dialplan if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $dialplan_uuid = $_GET["id"]; $orm = new orm; $orm->name('dialplans'); $orm->uuid($dialplan_uuid); $result = $orm->find()->get(); //$message = $orm->message; foreach ($result as &$row) { $domain_uuid = $row["domain_uuid"]; //$app_uuid = $row["app_uuid"]; $dialplan_name = $row["dialplan_name"]; $dialplan_number = $row["dialplan_number"]; $dialplan_order = $row["dialplan_order"]; $dialplan_continue = $row["dialplan_continue"]; $dialplan_context = $row["dialplan_context"]; $dialplan_enabled = $row["dialplan_enabled"]; $dialplan_description = $row["dialplan_description"]; } unset ($prep_statement); } //get the dialplan details in an array $sql = "select * from v_dialplan_details "; $sql .= "where dialplan_uuid = '$dialplan_uuid' "; $sql .= "order by dialplan_detail_group asc, dialplan_detail_order asc"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset ($prep_statement, $sql); //create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions $x = 0; $details = ''; //conditions foreach($result as $row) { if ($row['dialplan_detail_tag'] == "condition") { $group = $row['dialplan_detail_group']; foreach ($row as $key => $val) { $details[$group][$x][$key] = $val; } } $x++; } //regex foreach($result as $row) { if ($row['dialplan_detail_tag'] == "regex") { $group = $row['dialplan_detail_group']; foreach ($row as $key => $val) { $details[$group][$x][$key] = $val; } } $x++; } //actions foreach($result as $row) { if ($row['dialplan_detail_tag'] == "action") { $group = $row['dialplan_detail_group']; foreach ($row as $key => $val) { $details[$group][$x][$key] = $val; } } $x++; } //anti-actions foreach($result as $row) { if ($row['dialplan_detail_tag'] == "anti-action") { $group = $row['dialplan_detail_group']; foreach ($row as $key => $val) { $details[$group][$x][$key] = $val; } } $x++; } unset($result); //get the last action and anti-action foreach($details as $group) { foreach ($group as $row) { if ($row['dialplan_detail_tag'] == 'action') { //echo $row['dialplan_detail_tag']." ".$row['dialplan_detail_type'].":".$row['dialplan_detail_data']."\n"; $detail_action = $row['dialplan_detail_type'].':'.$row['dialplan_detail_data']; } if ($row['dialplan_detail_tag'] == 'anti-action') { //echo $row['dialplan_detail_tag']." ".$row['dialplan_detail_type'].":".$row['dialplan_detail_data']."\n"; $detail_anti_action = $row['dialplan_detail_type'].':'.$row['dialplan_detail_data']; } } } //blank row foreach($details as $group => $row) { //set the array key for the empty row $x = "999"; //get the highest dialplan_detail_order foreach ($row as $key => $field) { $dialplan_detail_order = 0; if ($dialplan_detail_order < $field['dialplan_detail_order']) { $dialplan_detail_order = $field['dialplan_detail_order']; } } //increment the highest order by 5 $dialplan_detail_order = $dialplan_detail_order + 10; //set the rest of the empty array //$details[$group][$x]['domain_uuid'] = ''; //$details[$group][$x]['dialplan_uuid'] = ''; $details[$group][$x]['dialplan_detail_tag'] = ''; $details[$group][$x]['dialplan_detail_type'] = ''; $details[$group][$x]['dialplan_detail_data'] = ''; $details[$group][$x]['dialplan_detail_break'] = ''; $details[$group][$x]['dialplan_detail_inline'] = ''; $details[$group][$x]['dialplan_detail_group'] = $group; $details[$group][$x]['dialplan_detail_order'] = $dialplan_detail_order; $details[$group][$x]['preset'] = 'false'; } } //get the presets foreach ($_SESSION['time_conditions']['preset'] as $json) { $presets[] = json_decode($json, true); } //get the time array from the dialplan set it as array dialplan_times $x = 0; foreach($details as $detail_group) { foreach ($detail_group as $row) { if ($row['dialplan_detail_tag'] == 'condition') { $type = $row['dialplan_detail_type']; $data = $row['dialplan_detail_data']; $group = $row['dialplan_detail_group']; //echo "type: ".$type. " data: ".$data."
\n"; $array = explode(',', 'year,mon,mday,wday,yday,week,mweek,hour,minute,minute-of-day,time-of-day,date-time'); if (in_array($type, $array)) { $dialplan_times[$group][$type] = $data; $dialplan_times[$group]['group'] = $group; } } } $x++; } //get the preset_times $p = 0; foreach ($presets as $preset_number => $preset) { foreach ($preset as $preset_name => $preset_variables) { $preset_times[] = $preset_variables['variables']; } } //add a function to check the time to see if its is a preset time function is_preset($presets, $times) { if ($_GET['debug'] == 'true') { echo "

\n"; echo "
\n"; echo "
\n"; } $preset_keys = array(); foreach ($presets as $row) { if ($_GET['debug'] == 'true') { echo "\n"; } $match = true; foreach ($row as $k => $v) { if ($_GET['debug'] == 'true') { echo "\n"; echo ""; } if ($row[$k] == $times[$k]) { if ($_GET['debug'] == 'true') { echo ""; } } else { if ($_GET['debug'] == 'true') { echo ""; } $match = false; } if ($_GET['debug'] == 'true') { echo "\n"; } } if ($_GET['debug'] == 'true') { echo "
".$k."".$row[$k]."".$k."".$times[$k]."matchno match
\n"; echo "
\n"; } if ($match) { return true; } } return false; } //set preset to true or false on dialplan_times array $x = 0; foreach ($dialplan_times as $times) { if ($_GET['debug'] == 'true') { echo "

\n";
			print_r($times);
			echo "
\n"; echo "
\n"; } $g = $times['group']; if (is_preset($preset_times, $times)) { $dialplan_times[$g]['preset'] = 'true'; } else { $dialplan_times[$g]['preset'] = 'false'; } $x++; } //show the results if ($_GET['debug'] == 'true') { echo "
\n";
		print_r($dialplan_times);
		echo "
\n"; } //set default values when adding a time condition if (count($details) == 0) { //$details[0]['domain_uuid'] = $domain_uuid; $group = 0; $details[$group][0]['dialplan_detail_tag'] = 'condition'; $details[$group][0]['dialplan_detail_type'] = 'wday'; $details[$group][0]['wday']['start'] = '2'; $details[$group][0]['wday']['stop'] = '6'; $details[$group][0]['dialplan_detail_data'] = '2-6'; $details[$group][0]['dialplan_detail_group'] = '0'; $details[$group][0]['dialplan_detail_order'] = '10'; $dialplan_times[$group]['preset'] = 'false'; $group++; $details[$group][0]['dialplan_detail_tag'] = 'condition'; $details[$group][0]['dialplan_detail_type'] = 'hour'; $details[$group][0]['hour']['start'] = '8'; $details[$group][0]['hour']['stop'] = '17'; $details[$group][0]['dialplan_detail_data'] = '8-17'; $details[$group][0]['dialplan_detail_group'] = '1'; $details[$group][0]['dialplan_detail_order'] = '20'; $dialplan_times[$group]['preset'] = 'false'; unset($group); } ?> \n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['title-time-condition-add']."
\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; echo " \n"; echo " ".$text['description-time-condition-add']."\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"; //show the presets echo "\n"; echo "\n"; echo "\n"; echo "\n"; //add destinations if (strlen($_GET['id']) == 0) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } //edit destinations $action_exists = false; $x = 0; foreach($details as $group) { foreach ($group as $row) { if ($row['dialplan_detail_tag'] == 'action' && $row['dialplan_detail_type'] != 'set') { echo "\n"; echo "\n"; echo "\n"; echo "\n"; $action_exists = true; } if ($row['dialplan_detail_tag'] == 'anti-action' && $row['dialplan_detail_type'] != 'set') { echo "\n"; echo "\n"; echo "\n"; echo "\n"; $action_exists = true; } } $x++; } 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 "\n"; echo "
\n"; echo " ".$text['label-extension']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo " ".$text['description-extension']."
\n"; echo "
\n"; echo " ".$text['label-conditions']."\n"; echo "\n"; //define select box options for each time condition variable (where appropriate) for ($y = date('Y'); $y <= (date('Y') + 10); $y++) { $var_option_select['year'][$y] = $y; } //years for ($m = 1; $m <= 12; $m++) { $var_option_select['mon'][$m] = date('F', strtotime('2015-'.number_pad($m,2).'-01')); } //month names for ($d = 1; $d <= 366; $d++) { $var_option_select['yday'][$d] = $d; } //days of year for ($d = 1; $d <= 31; $d++) { $var_option_select['mday'][$d] = $d; } //days of month for ($d = 1; $d <= 7; $d++) { $var_option_select['wday'][$d] = date('l', strtotime('Sunday +'.($d-1).' days')); } //week days for ($w = 1; $w <= 53; $w++) { $var_option_select['week'][$w] = $w; } //weeks of year for ($w = 1; $w <= 5; $w++) { $var_option_select['mweek'][$w] = $w; } //weeks of month for ($h = 0; $h <= 23; $h++) { $var_option_select['hour'][$h] = (($h) ? (($h >= 12) ? (($h == 12) ? $h : ($h-12)).' PM' : $h.' AM') : '12 AM'); } //hours of day for ($m = 0; $m <= 59; $m++) { $var_option_select['minute'][$m] = number_pad($m,2); } //minutes of hour //output condition fields echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; //echo "
\n";
//print_r($details);
//echo "
\n"; $x = 0; foreach($details as $detail_group) { foreach ($detail_group as $row) { //echo "
\n";
//print_r($row);
//echo "
\n"; //echo __line__; exit; if ($row['dialplan_detail_tag'] == 'condition') { $type = $row['dialplan_detail_type']; $data = $row['dialplan_detail_data']; $group = $row['dialplan_detail_group']; $dialplan_times[$group]['preset'] =='false'; if ($dialplan_times[$group]['preset'] == 'false' && $type != "destination_number") { $dialplan_uuid = $row['dialplan_uuid']; $dialplan_detail_uuid = $row['dialplan_detail_uuid']; $dialplan_detail_tag = $row['dialplan_detail_tag']; $dialplan_detail_type = $row['dialplan_detail_type']; $dialplan_detail_data = $row['dialplan_detail_data']; $dialplan_detail_break = $row['dialplan_detail_break']; $dialplan_detail_inline = $row['dialplan_detail_inline']; $dialplan_detail_group = $row['dialplan_detail_group']; $dialplan_detail_order = $row['dialplan_detail_order']; //add the primary key uuid if (strlen($dialplan_detail_uuid) > 0) { echo " \n"; } //start a new row echo " \n"; //time condition echo " \n"; //single or range echo " \n"; //$dialplan_detail_data echo " \n"; echo " \n"; } // if (in_array($type, $array)) } // if ($row['dialplan_detail_tag'] == 'condition') } // foreach ($detail_group as $row) $x++; } // foreach($details as $detail_group) echo "
".$text['label-condition_parameter']."".$text['label-condition_scope']."".$text['label-condition_values']."
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; //switch ($var_name) { switch ($dialplan_detail_type) { case "minute-of-day" : echo "\n"; break; case "time-of-day" : echo "\n"; echo " \n"; echo " \n"; echo " \n"; if (strlen($detail_data[1]) > 0) { echo " \n"; echo "  ~ "; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo "\n"; break; case "date-time" : echo "\n"; break; default: $var_name = $dialplan_detail_type; echo "\n"; echo " \n"; if (strlen($detail_data[1]) > 0) { echo " \n"; echo "  ~ \n"; echo " \n"; } echo " \n"; echo "\n"; } echo "
\n"; if ($action == 'add') { echo "\n"; } echo " ".$text['description-conditions']."
\n"; echo "
\n"; echo " ".$text['label-presets']."\n"; echo "\n"; //echo "
"; print_r($presets); echo "


"; echo " \n"; echo " \n"; echo " "; echo " \n"; echo " \n"; echo "
\n"; $preset_count = sizeof($presets); $presets_per_column = ceil($preset_count / 3); $p = 0; foreach ($presets as $preset_number => $preset) { foreach ($preset as $preset_name => $preset_variables) { $preset_times = $preset_variables['variables']; foreach ($dialplan_times as $row) { $array = explode(',', 'year,mon,mday,wday,yday,week,mweek,hour,minute,minute-of-day,time-of-day,date-time'); if ($_GET['debug'] == 'true') { echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; } $y = 0; $match = true; foreach ($array as $k) { if (strlen($preset_times[$k]) > 0) { if ($_GET['debug'] == 'true') { echo "\n"; echo ""; } if ($row[$k] == $preset_times[$k]) { if ($_GET['debug'] == 'true') { echo "\n"; } } else { if ($_GET['debug'] == 'true') { echo "\n"; } $match = false; } if ($_GET['debug'] == 'true') { echo "\n"; } $y++; } } if ($_GET['debug'] == 'true') { echo "
databasevaluepresetsvaluematch
$k".$row[$k]." $k".$preset_times[$k]." truefalse

"; } if ($match) { break; } } if ($match) { $checked = "checked='checked'"; } else { $checked = ''; } echo "
\n"; $p++; if ($p == $presets_per_column) { echo "
\n"; $p = 0; } } } echo "
\n"; echo "
\n"; echo " ".$text['description-presets']."
\n"; echo "
\n"; echo " ".$text['label-action']."\n"; echo "\n"; //switch_select_destination(select_type, select_label, select_name, select_value, select_style, $action); switch_select_destination("dialplan", $action_1, "dialplan_details[100][action]", "$detail_action", "", ""); echo "
\n"; echo " ".$text['label-action-alternate']."\n"; echo "\n"; //switch_select_destination(select_type, select_label, select_name, select_value, select_style, $action); switch_select_destination("dialplan", $anti_action_1, "dialplan_details[110][anti_action]", "$detail_anti_action ", "", ""); echo "
\n"; echo " ".$text['label-action']."\n"; echo "\n"; //switch_select_destination(select_type, select_label, select_name, select_value, select_style, $action); $data = $row['dialplan_detail_data']; $label = explode("XML", $data); $divider = ($row['dialplan_detail_type'] != '') ? ":" : null; $detail_action = $row['dialplan_detail_type'].$divider.$row['dialplan_detail_data']; switch_select_destination("dialplan", $label[0], "dialplan_details[".$x."]['action']", $detail_action, "width: 60%;", 'action'); echo "
\n"; echo " ".$text['label-action-alternate']."\n"; echo "\n"; //switch_select_destination(select_type, select_label, select_name, select_value, select_style, $action); $label = explode("XML", $row['dialplan_detail_data']); $divider = ($row['dialplan_detail_type'] != '') ? ":" : null; $detail_action = $row['dialplan_detail_type'].$divider.$row['dialplan_detail_data']; switch_select_destination("dialplan", $label[0], "dialplan_details[".$x."]['anti_action']", $detail_anti_action, "width: 60%;", 'action'); echo "
\n"; echo " ".$text['label-order']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo "

"; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo ""; echo "

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