4 include_once
"Services/Form/classes/class.ilFormPropertyGUI.php";
35 $this->value = $a_value;
55 $this->validationFailureMessage = $a_msg;
60 return $this->validationFailureMessage;
86 foreach($data as $slot => $days)
90 $this->
setAlert($lng->txt(
"msg_input_does_not_match_regexp"));
94 $parts = explode(
"-", $slot);
95 $from = str_replace(
":",
"", $parts[0]);
96 $to = str_replace(
":",
"", $parts[1]);
98 foreach($data as $rslot => $rdays)
100 if($slot != $rslot && $rdays && array_intersect($days, $rdays))
102 $rparts = explode(
"-", $rslot);
103 $rfrom = str_replace(
":",
"", $rparts[0]);
104 $rto = str_replace(
":",
"", $rparts[1]);
106 if(($rfrom > $from && $rfrom < $to) ||
107 ($rto > $from && $rto < $to) ||
108 ($rfrom < $from && $rto > $to))
110 $this->
setAlert($lng->txt(
"msg_input_does_not_match_regexp"));
122 $this->
setAlert($lng->txt(
"msg_input_is_required"));
129 static function getPostData($a_post_var, $a_remove_invalid =
true)
132 for($loop = 0; $loop < 24; $loop++)
134 $days =
$_POST[$a_post_var.
"_days~".$loop];
136 $_POST[$a_post_var.
"_from_mm~".$loop]);
138 $_POST[$a_post_var.
"_to_mm~".$loop]);
141 if($days || $from !=
"00:00" || $to !=
"00:00")
143 $slot = $from.
"-".$to;
146 if(isset(
$res[$slot]))
148 $res[$slot] = array_unique(array_merge(
$res[$slot], $days));
157 $res[$slot] = array();
160 if($a_remove_invalid && !($days && $from && $to && $from != $to))
177 $tpl =
new ilTemplate(
"tpl.schedule_input.html",
true,
true,
"Modules/BookingManager");
179 $lng->loadLanguageModule(
"dateplaner");
184 $def = array(null=>null);
187 $days = array(
"Mo",
"Tu",
"We",
"Th",
"Fr",
"Sa",
"Su");
189 foreach($def as $slot => $days_select)
191 $tpl->setCurrentBlock(
"days");
192 foreach($days as $day)
194 $day_value = strtolower($day);
199 $tpl->setVariable(
"DAY", $day_value);
200 $tpl->setVariable(
"TXT_DAY", $lng->txt($day.
"_short"));
202 if($days_select && in_array($day_value, $days_select))
204 $tpl->setVariable(
"DAY_STATUS",
" checked=\"checked\"");
207 $tpl->parseCurrentBlock();
210 $tpl->setCurrentBlock(
"row");
214 $tpl->setVariable(
"TXT_FROM", $lng->txt(
"cal_from"));
215 $tpl->setVariable(
"TXT_TO", $lng->txt(
"cal_until"));
218 $tpl->setVariable(
"TXT_MULTI_ADD", $lng->txt(
"add"));
219 $tpl->setVariable(
"TXT_MULTI_REMOVE", $lng->txt(
"remove"));
223 $parts = explode(
"-", $slot);
224 $from = explode(
":", $parts[0]);
225 $to = explode(
":", $parts[1]);
227 $tpl->setVariable(
"FROM_HH_VALUE", $from[0]);
228 $tpl->setVariable(
"FROM_MM_VALUE", $from[1]);
229 $tpl->setVariable(
"TO_HH_VALUE", $to[0]);
230 $tpl->setVariable(
"TO_MM_VALUE", $to[1]);
237 $tpl->setVariable(
"ADD_STYLE",
" style=\"display:none\"");
243 $tpl->setVariable(
"RMV_STYLE",
" style=\"display:none\"");
247 $tpl->parseCurrentBlock();
264 $tpl->addJavascript(
"Modules/BookingManager/js/ScheduleInput.js");
268 $a_tpl->setCurrentBlock(
"prop_generic");
269 $a_tpl->setVariable(
"PROP_GENERIC", $html);
270 $a_tpl->parseCurrentBlock();
278 protected static function parseTime($a_hours, $a_minutes)
280 $hours = (int)$a_hours;
281 $min = (int)$a_minutes;
282 if($hours > 23 || $min > 59)
286 return str_pad($hours, 2,
"0", STR_PAD_LEFT).
":".
287 str_pad($min, 2,
"0", STR_PAD_LEFT);