/** * Build summary item rows for given object and filter(s) * * @param int $a_pool_id (aka parent obj id) */ function getItems($a_pool_id) { include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php'; $data = ilBookingSchedule::getList($a_pool_id); $this->setMaxCount(sizeof($data)); $this->setData($data); }
/** * Delete schedule */ function delete() { global $ilCtrl, $lng; include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php'; $obj = new ilBookingSchedule((int) $_POST['schedule_id']); $obj->delete(); ilUtil::sendSuccess($lng->txt('book_schedule_deleted'), true); $ilCtrl->redirect($this, 'render'); }
/** * Build property form * @param string $a_mode * @param int $id * @return object */ function initForm($a_mode = "create", $id = NULL) { global $lng, $ilCtrl, $ilObjDataCache; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form_gui = new ilPropertyFormGUI(); $title = new ilTextInputGUI($lng->txt("title"), "title"); $title->setRequired(true); $title->setSize(40); $title->setMaxLength(120); $form_gui->addItem($title); $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc"); $desc->setCols(70); $desc->setRows(15); $form_gui->addItem($desc); $file = new ilFileInputGUI($lng->txt("book_additional_info_file"), "file"); $file->setALlowDeletion(true); $form_gui->addItem($file); $nr = new ilNumberInputGUI($lng->txt("booking_nr_of_items"), "items"); $nr->setRequired(true); $nr->setSize(3); $nr->setMaxLength(3); $form_gui->addItem($nr); if ($this->pool_has_schedule) { $options = array(); include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php'; foreach (ilBookingSchedule::getList($ilObjDataCache->lookupObjId($this->ref_id)) as $schedule) { $options[$schedule["booking_schedule_id"]] = $schedule["title"]; } $schedule = new ilSelectInputGUI($lng->txt("book_schedule"), "schedule"); $schedule->setRequired(true); $schedule->setOptions($options); $form_gui->addItem($schedule); } $post = new ilFormSectionHeaderGUI(); $post->setTitle($lng->txt("book_post_booking_information")); $form_gui->addItem($post); $pdesc = new ilTextAreaInputGUI($lng->txt("book_post_booking_text"), "post_text"); $pdesc->setCols(70); $pdesc->setRows(15); $form_gui->addItem($pdesc); $pfile = new ilFileInputGUI($lng->txt("book_post_booking_file"), "post_file"); $pfile->setALlowDeletion(true); $form_gui->addItem($pfile); if ($a_mode == "edit") { $form_gui->setTitle($lng->txt("book_edit_object")); $item = new ilHiddenInputGUI('object_id'); $item->setValue($id); $form_gui->addItem($item); include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $obj = new ilBookingObject($id); $title->setValue($obj->getTitle()); $desc->setValue($obj->getDescription()); $nr->setValue($obj->getNrOfItems()); $pdesc->setValue($obj->getPostText()); $file->setValue($obj->getFile()); $pfile->setValue($obj->getPostFile()); if (isset($schedule)) { $schedule->setValue($obj->getScheduleId()); } $form_gui->addCommandButton("update", $lng->txt("save")); } else { $form_gui->setTitle($lng->txt("book_add_object")); $form_gui->addCommandButton("save", $lng->txt("save")); $form_gui->addCommandButton("render", $lng->txt("cancel")); } $form_gui->setFormAction($ilCtrl->getFormAction($this)); return $form_gui; }
public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false) { $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree); //copy online status if object is not the root copy object $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id); if (!$cp_options->isRootNode($this->getRefId())) { $new_obj->setOffline($this->isOffline()); } $new_obj->setScheduleType($this->getScheduleType()); $new_obj->setPublicLog($this->hasPublicLog()); $new_obj->setOverallLimit($this->getOverallLimit()); $smap = null; if ($this->getScheduleType() == self::TYPE_FIX_SCHEDULE) { // schedules include_once "Modules/BookingManager/classes/class.ilBookingSchedule.php"; foreach (ilBookingSchedule::getList($this->getId()) as $item) { $schedule = new ilBookingSchedule($item["booking_schedule_id"]); $smap[$item["booking_schedule_id"]] = $schedule->doClone($new_obj->getId()); } } // objects include_once "Modules/BookingManager/classes/class.ilBookingObject.php"; foreach (ilBookingObject::getList($this->getId()) as $item) { $bobj = new ilBookingObject($item["booking_object_id"]); $bobj->doClone($new_obj->getId(), $smap); } $new_obj->update(); return $new_obj; }
protected function renderSlots(ilBookingSchedule $schedule, array $object_ids, $title) { global $ilUser; // fix if (!$schedule->getRaster()) { $mytpl = new ilTemplate('tpl.booking_reservation_fix.html', true, true, 'Modules/BookingManager'); $mytpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this)); $mytpl->setVariable('TXT_TITLE', $this->lng->txt('book_reservation_title')); $mytpl->setVariable('TXT_INFO', $this->lng->txt('book_reservation_fix_info')); $mytpl->setVariable('TXT_OBJECT', $title); $mytpl->setVariable('TXT_CMD_BOOK', $this->lng->txt('book_confirm_booking')); $mytpl->setVariable('TXT_CMD_CANCEL', $this->lng->txt('cancel')); include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $morning_aggr = $user_settings->getDayStart(); $evening_aggr = $user_settings->getDayEnd(); $hours = array(); for ($i = $morning_aggr; $i <= $evening_aggr; $i++) { switch ($user_settings->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_24: if ($morning_aggr > 0 && $i == $morning_aggr) { $hours[$i] = sprintf('%02d:00', 0) . "-"; } $hours[$i] .= sprintf('%02d:00', $i); if ($evening_aggr < 23 && $i == $evening_aggr) { $hours[$i] .= "-" . sprintf('%02d:00', 23); } break; case ilCalendarSettings::TIME_FORMAT_12: if ($morning_aggr > 0 && $i == $morning_aggr) { $hours[$i] = date('h a', mktime(0, 0, 0, 1, 1, 2000)) . "-"; } $hours[$i] .= date('h a', mktime($i, 0, 0, 1, 1, 2000)); if ($evening_aggr < 23 && $i == $evening_aggr) { $hours[$i] .= "-" . date('h a', mktime(23, 0, 0, 1, 1, 2000)); } break; } } if (isset($_GET['seed'])) { $find_first_open = false; $seed = new ilDate($_GET['seed'], IL_CAL_DATE); } else { $find_first_open = true; $seed = new ilDate(time(), IL_CAL_UNIX); } include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $week_start = $user_settings->getWeekStart(); if (!$find_first_open) { $dates = array(); $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); } else { $dates = array(); $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); // find first open slot if (!$has_open_slot) { // 1 year is limit for search $limit = clone $seed; $limit->increment(ilDate::YEAR, 1); $limit = $limit->get(IL_CAL_UNIX); while (!$has_open_slot && $seed->get(IL_CAL_UNIX) < $limit) { $seed->increment(ilDate::WEEK, 1); $dates = array(); $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); } } } include_once 'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php'; $navigation = new ilCalendarHeaderNavigationGUI($this, $seed, ilDateTime::WEEK, 'book'); $mytpl->setVariable('NAVIGATION', $navigation->getHTML()); foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $mytpl->setCurrentBlock('weekdays'); $mytpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($date_info['wday'])); $mytpl->setVariable('TXT_DATE', $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'])); $mytpl->parseCurrentBlock(); } include_once 'Services/Calendar/classes/class.ilCalendarAppointmentColors.php'; include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; $color = array(); $all = ilCalendarAppointmentColors::_getColorsByType('crs'); for ($loop = 0; $loop < 7; $loop++) { $col = $all[$loop]; $fnt = ilCalendarUtil::calculateFontColor($col); $color[$loop + 1] = 'border-bottom: 1px solid ' . $col . '; background-color: ' . $col . '; color: ' . $fnt; } $counter = 0; foreach ($dates as $hour => $days) { $caption = $days; $caption = array_shift($caption); for ($loop = 1; $loop < 8; $loop++) { if (!isset($days[$loop])) { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ' '); $mytpl->parseCurrentBlock(); } else { if (isset($days[$loop]['captions'])) { foreach ($days[$loop]['captions'] as $slot_id => $slot_caption) { $mytpl->setCurrentBlock('choice'); $mytpl->setVariable('TXT_DATE', $slot_caption); $mytpl->setVariable('VALUE_DATE', $slot_id); $mytpl->setVariable('DATE_COLOR', $color[$loop]); $mytpl->parseCurrentBlock(); } $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ''); $mytpl->parseCurrentBlock(); } else { if (isset($days[$loop]['in_slot'])) { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DATE_COLOR', $color[$loop]); $mytpl->parseCurrentBlock(); } else { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ' '); $mytpl->parseCurrentBlock(); } } } } $mytpl->setCurrentBlock('slots'); $mytpl->setVariable('TXT_HOUR', $caption); if ($counter % 2) { $mytpl->setVariable('CSS_ROW', 'tblrow1'); } else { $mytpl->setVariable('CSS_ROW', 'tblrow2'); } $mytpl->parseCurrentBlock(); $counter++; } } else { // :TODO: inactive for now } return $mytpl->get(); }
public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false) { $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree); $new_obj->setOffline($this->isOffline()); $new_obj->setScheduleType($this->getScheduleType()); $new_obj->setPublicLog($this->hasPublicLog()); $smap = null; if ($this->getScheduleType() == self::TYPE_FIX_SCHEDULE) { $new_obj->setNumberOfSlots($this->getNumberOfSlots()); // schedules include_once "Modules/BookingManager/classes/class.ilBookingSchedule.php"; foreach (ilBookingSchedule::getList($this->getId()) as $item) { $schedule = new ilBookingSchedule($item["booking_schedule_id"]); $smap[$item["booking_schedule_id"]] = $schedule->doClone($new_obj->getId()); } } // objects include_once "Modules/BookingManager/classes/class.ilBookingObject.php"; foreach (ilBookingObject::getList($this->getId()) as $item) { $bobj = new ilBookingObject($item["booking_object_id"]); $bobj->doClone($new_obj->getId(), $smap); } $new_obj->update(); return $new_obj; }
/** * Init filter */ function initFilter(array $a_filter_pre = null) { if (is_array($a_filter_pre) && isset($a_filter_pre["object"])) { $_SESSION["form_" . $this->getId()]["object"] = serialize($a_filter_pre["object"]); if ($this->has_schedule) { $_SESSION["form_" . $this->getId()]["fromto"] = serialize(array("from" => serialize(new ilDateTime(date("Y-m-d"), IL_CAL_DATE)), "to" => "")); } } $this->objects = array(); include_once "Modules/BookingManager/classes/class.ilBookingObject.php"; foreach (ilBookingObject::getList($this->pool_id) as $item) { $this->objects[$item["booking_object_id"]] = $item["title"]; } $item = $this->addFilterItemByMetaType("object", ilTable2GUI::FILTER_SELECT); $item->setOptions(array("" => $this->lng->txt('book_all')) + $this->objects); $this->filter["object"] = $item->getValue(); if ($this->has_schedule) { if (!$_SESSION["form_" . $this->getId()]["fromto"]) { // default: from today $_SESSION["form_" . $this->getId()]["fromto"] = serialize(array("from" => serialize(new ilDateTime(date("Y-m-d"), IL_CAL_DATE)), "to" => null)); } $item = $this->addFilterItemByMetaType("fromto", ilTable2GUI::FILTER_DATE_RANGE, false, $this->lng->txt('book_fromto')); $this->filter["fromto"] = $item->getDate(); // only needed for full log if ($this->show_all) { // see ilObjBookingPoolGUI::buildDatesBySchedule() $map = array_flip(array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa')); $options = array("" => $this->lng->txt('book_all')); // schedule to slot require_once "Modules/BookingManager/classes/class.ilBookingSchedule.php"; foreach (ilBookingSchedule::getList($this->pool_id) as $def) { $schedule = new ilBookingSchedule($def["booking_schedule_id"]); foreach ($schedule->getDefinition() as $day => $slots) { $day_caption = ilCalendarUtil::_numericDayToString($map[$day], false); foreach ($slots as $slot) { $idx = $map[$day] . "_" . $slot; $options[$idx] = $day_caption . ", " . $slot; } } } ksort($options); $item = $this->addFilterItemByMetaType("book_schedule_slot", ilTable2GUI::FILTER_SELECT); $item->setOptions($options); $this->filter["slot"] = $item->getValue(); } } // status $valid_status = array(-ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_CANCELLED); if (!$this->has_schedule) { $options = array("" => $this->lng->txt('book_all')); } else { $options = array(); } foreach ($valid_status as $loop) { if ($loop > 0) { $options[$loop] = $this->lng->txt('book_reservation_status_' . $loop); } else { $options[$loop] = $this->lng->txt('book_not') . ' ' . $this->lng->txt('book_reservation_status_' . -$loop); } } $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT); $item->setOptions($options); $this->filter["status"] = $item->getValue(); // only needed for full log if ($this->show_all) { $options = array("" => $this->lng->txt('book_all')) + ilBookingReservation::getUserFilter(array_keys($this->objects)); $item = $this->addFilterItemByMetaType("user", ilTable2GUI::FILTER_SELECT); $item->setOptions($options); $this->filter["user_id"] = $item->getValue(); } }