21 $this->ref_id = $a_parent_obj->ref_id;
22 $this->slots_no = $a_parent_obj->object->getNumberOfSlots();
32 $next_class = $ilCtrl->getNextClass($this);
37 $cmd = $ilCtrl->getCmd(
"render");
53 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id))
55 include_once
'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
57 $bar->
addButton($lng->txt(
'book_add_schedule'), $ilCtrl->getLinkTarget($this,
'create'));
58 $bar = $bar->getHTML();
61 include_once
'Modules/BookingManager/classes/class.ilBookingSchedulesTableGUI.php';
63 $tpl->setContent($bar.$table->getHTML());
73 $ilTabs->clearTargets();
74 $ilTabs->setBackTarget($lng->txt(
'book_back_to_list'), $ilCtrl->getLinkTarget($this,
'render'));
77 $tpl->setContent($form->getHTML());
87 $ilTabs->clearTargets();
88 $ilTabs->setBackTarget($lng->txt(
'book_back_to_list'), $ilCtrl->getLinkTarget($this,
'render'));
91 $tpl->setContent($form->getHTML());
104 $lng->loadLanguageModule(
"dateplaner");
106 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
111 $title->setRequired(
true);
113 $title->setMaxLength(120);
114 $form_gui->addItem(
$title);
159 $definition->
setInfo($lng->txt(
"book_schedule_days_info"));
160 $definition->setRequired(
true);
161 $form_gui->addItem($definition);
163 $days = array(
'mo',
'tu',
'we',
'th',
'fr',
'sa',
'su');
164 foreach($days as $day_id)
167 $definition->addOption($day);
169 for($loop = 1; $loop <= $this->slots_no; $loop++)
171 $hours[$day_id][$loop] =
new ilTextInputGUI($lng->txt(
"book_schedule_slot").
" ".$loop, $day_id.
"_slot[]");
172 $hours[$day_id][$loop]->setSize(14);
173 $hours[$day_id][$loop]->setMaxLength(14);
174 $day->addSubItem($hours[$day_id][$loop]);
179 $deadline->
setInfo($lng->txt(
"book_deadline_info"));
180 $deadline->setSuffix($lng->txt(
"book_hours"));
181 $deadline->setMinValue(0);
182 $deadline->setSize(3);
183 $deadline->setMaxLength(3);
184 $form_gui->addItem($deadline);
186 if ($a_mode ==
"edit")
188 $form_gui->setTitle($lng->txt(
"book_edit_schedule"));
191 $item->setValue($id);
192 $form_gui->addItem($item);
194 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
196 $title->setValue($schedule->getTitle());
197 $deadline->setValue($schedule->getDeadline());
214 $def = $schedule->getDefinition();
215 $definition->setValue(array_keys($def));
216 foreach($def as $day_id => $slots)
218 foreach($slots as $idx => $slot)
220 if(isset($hours[$day_id][$idx+1]))
222 $hours[$day_id][$idx+1]->setValue($slot);
227 $form_gui->addCommandButton(
"update", $lng->txt(
"save"));
231 $form_gui->setTitle($lng->txt(
"book_add_schedule"));
232 $form_gui->addCommandButton(
"save", $lng->txt(
"save"));
233 $form_gui->addCommandButton(
"render", $lng->txt(
"cancel"));
235 $form_gui->setFormAction($ilCtrl->getFormAction($this));
248 if($form->checkInput())
250 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
260 $form->setValuesByPost();
262 $tpl->setContent($form->getHTML());
274 if($form->checkInput())
276 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
286 $form->setValuesByPost();
288 $tpl->setContent($form->getHTML());
303 foreach($days_group->getOptions() as $option)
305 $days_fields[$option->getValue()] = $option;
308 foreach($days as $day)
310 $slot = $form->
getInput($day.
"_slot");
311 $subs = $days_fields[$day]->getSubItems();
314 $subs[0]->setValue($slot[0]);
318 $subs[1]->setValue($slot[1]);
331 global $ilObjDataCache;
333 $schedule->setTitle($form->getInput(
"title"));
334 $schedule->setPoolId($ilObjDataCache->lookupObjId($this->ref_id));
335 $schedule->setDeadline($form->getInput(
"deadline"));
354 $definition = array();
355 foreach($form->getInput(
"days") as $day_id)
357 $day_slots = array();
358 foreach($form->getInput($day_id.
"_slot") as $slot)
362 $fromto = explode(
"-", $slot);
363 if(
sizeof($fromto) == 2)
369 $definition[$day_id][] = $from.
"-".$to;
374 if(!
sizeof($definition[$day_id]))
376 $definition[$day_id] = array(
"00:00-23:59");
381 foreach($definition as $day_id => $slots)
385 foreach($slots as $idx => $slot)
387 $slot = explode(
'-', $slot);
393 $slots[$idx] = $from.
'-'.$to;
401 $definition[$day_id] = $slots;
404 $schedule->setDefinition($definition);
413 $raw = strtolower(trim($raw));
416 if(substr($raw, -2) ==
'pm')
419 $raw = substr($raw, 0, -2);
421 else if(substr($raw, -2) ==
'am')
424 $raw = substr($raw, 0, -2);
426 if($colon = strpos($raw,
':'))
428 $min = (int)substr($raw, $colon+1);
429 $raw = substr($raw, 0, $colon);
436 if($pm && $hours < 12)
440 else if($am && $hours == 12)
444 if($hours > 23 || $min > 59)
448 return str_pad($hours, 2,
"0", STR_PAD_LEFT).
":".
449 str_pad($min, 2,
"0", STR_PAD_LEFT);
459 include_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
461 $conf->setFormAction($ilCtrl->getFormAction($this));
462 $conf->setHeaderText($lng->txt(
'book_confirm_delete'));
464 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
466 $conf->addItem(
'schedule_id', (
int)$_GET[
'schedule_id'], $type->getTitle());
467 $conf->setConfirm($lng->txt(
'delete'),
'delete');
468 $conf->setCancel($lng->txt(
'cancel'),
'render');
470 $tpl->setContent($conf->getHTML());
480 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
485 $ilCtrl->redirect($this,
'render');