diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index b1eb3c02c6..343463b0b1 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -36,7 +36,6 @@ else { require_once "resources/header.php"; require_once "resources/paging.php"; - //add multi-lingual support $language = new text; $text = $language->get(); @@ -526,9 +525,6 @@ require_once "resources/paging.php"; unset($result); //get the last action and anti-action - //echo "
\n";
-			//print_r($details);
-			//$detail_anti_action = $row['dialplan_detail_type'].$divider.$row['dialplan_detail_data'];
 			foreach($details as $group) {
 				foreach ($group as $row) {
 					if ($row['dialplan_detail_tag'] == 'action') {
@@ -541,8 +537,6 @@ require_once "resources/paging.php";
 					}
 				}
 			}
-			//echo "
\n"; - //exit; //blank row foreach($details as $group => $row) { @@ -570,6 +564,102 @@ require_once "resources/paging.php"; } } +//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']; + } + } + +//create a is_preset function to determine if the time settings are a preset + 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"; + } + ?>