/** * 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); }
/** * 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; }
public function editObject() { // if we have no schedules yet - show info include_once "Modules/BookingManager/classes/class.ilBookingSchedule.php"; if ($this->object->getScheduleType() != ilObjBookingPool::TYPE_NO_SCHEDULE && !sizeof(ilBookingSchedule::getList($this->object->getId()))) { ilUtil::sendInfo($this->lng->txt("book_schedule_warning_edit")); } return parent::editObject(); }
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(); } }