/** * Gather data and build rows */ function getItems() { global $ilUser; include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $data = ilBookingObject::getList($this->pool_id); include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; foreach ($data as $item) { $item_id = $item["booking_object_id"]; $item_rsv = ilBookingReservation::getList(array($item_id), 1000, 0, array()); $this->reservations[$item_id] = $item_rsv["data"]; } if (!$this->has_schedule && $this->overall_limit) { $this->current_bookings = 0; foreach ($this->reservations as $obj_rsv) { foreach ($obj_rsv as $item) { if ($item["status"] != ilBookingReservation::STATUS_CANCELLED) { if ($item["user_id"] == $ilUser->getId()) { $this->current_bookings++; } } } } if ($this->current_bookings >= $this->overall_limit) { ilUtil::sendInfo($this->lng->txt("book_overall_limit_warning")); } } $this->setMaxCount(sizeof($data)); $this->setData($data); }
/** * Gather data and build rows */ function getItems() { include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $data = ilBookingObject::getList($this->pool_id); $this->setMaxCount(sizeof($data)); $this->setData($data); }
/** * Render list of booking schedules * * uses ilBookingSchedulesTableGUI */ function render() { global $tpl, $lng, $ilCtrl, $ilAccess; include_once 'Modules/BookingManager/classes/class.ilBookingSchedulesTableGUI.php'; $table = new ilBookingSchedulesTableGUI($this, 'render', $this->ref_id); if ($ilAccess->checkAccess('write', '', $this->ref_id)) { // if we have schedules but no objects - show info if (sizeof($table->getData())) { include_once "Modules/BookingManager/classes/class.ilBookingObject.php"; if (!sizeof(ilBookingObject::getList(ilObject::_lookupObjId($this->ref_id)))) { ilUtil::sendInfo($lng->txt("book_type_warning")); } } include_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php'; $bar = new ilToolbarGUI(); $bar->addButton($lng->txt('book_add_schedule'), $ilCtrl->getLinkTarget($this, 'create')); $bar = $bar->getHTML(); } $tpl->setContent($bar . $table->getHTML()); }
public function deliverPostFile() { global $ilUser; $id = (int) $_GET["object_id"]; if (!$id) { return; } include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $book_id = ilBookingReservation::getObjectReservationForUser($id, $ilUser->getId()); $obj = new ilBookingReservation($book_id); if ($obj->getUserId() != $ilUser->getId()) { return; } include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $obj = new ilBookingObject($id); $file = $obj->getPostFileFullPath(); if ($file) { ilUtil::deliverFile($file, $obj->getPostFile()); } }
/** * 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->hasSchedule) { $valid_status = array(ilBookingReservation::STATUS_IN_USE, ilBookingReservation::STATUS_CANCELLED, -ilBookingReservation::STATUS_IN_USE, -ilBookingReservation::STATUS_CANCELLED); } else { $valid_status = array(ilBookingReservation::STATUS_CANCELLED, -ilBookingReservation::STATUS_CANCELLED); } $options = array("" => $this->lng->txt('book_all')); 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(); if ($this->has_schedule) { $item = $this->addFilterItemByMetaType("fromto", ilTable2GUI::FILTER_DATE_RANGE, false, $this->lng->txt('book_fromto')); $this->filter["fromto"] = $item->getDate(); } }
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; }
/** * Book object for date * * @param int $a_object_id * @param int $a_from timestamp * @param int $a_to timestamp */ function processBooking($a_object_id, $a_from = null, $a_to = null) { global $ilUser; include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $reservation = new ilBookingReservation(); $reservation->setObjectId($a_object_id); $reservation->setUserId($ilUser->getID()); $reservation->setFrom($a_from); $reservation->setTo($a_to); $reservation->save(); if ($a_from) { $this->lng->loadLanguageModule('dateplaner'); include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; include_once 'Services/Calendar/classes/class.ilCalendarCategory.php'; $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $ilUser->getId(), $this->lng->txt('cal_ch_personal_book'), true); include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $object = new ilBookingObject($a_object_id); include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry(); $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX)); $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX)); $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle()); $entry->setContextId($reservation->getId()); $entry->save(); include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $assignment = new ilCalendarCategoryAssignments($entry->getEntryId()); $assignment->addAssignment($def_cat->getCategoryId()); } }
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; }
/** * Check if any of given objects are bookable * @param array $a_ids * @param int $a_from * @param int $a_to * @param int $a_return_single * @return int */ static function getAvailableObject(array $a_ids, $a_from, $a_to, $a_return_single = true) { global $ilDB; $nr_map = ilBookingObject::getNrOfItemsForObjects($a_ids); $from = $ilDB->quote($a_from, 'integer'); $to = $ilDB->quote($a_to, 'integer'); $set = $ilDB->query('SELECT count(*) cnt, object_id' . ' FROM booking_reservation' . ' WHERE ' . $ilDB->in('object_id', $a_ids, '', 'integer') . ' AND (status IS NULL OR status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') . ')' . ' AND ((date_from <= ' . $from . ' AND date_to >= ' . $from . ')' . ' OR (date_from <= ' . $to . ' AND date_to >= ' . $to . ')' . ' OR (date_from >= ' . $from . ' AND date_to <= ' . $to . '))' . ' GROUP BY object_id'); $blocked = array(); while ($row = $ilDB->fetchAssoc($set)) { if ($row['cnt'] >= $nr_map[$row['object_id']]) { $blocked[] = $row['object_id']; } } $available = array_diff($a_ids, $blocked); if (sizeof($available)) { if ($a_return_single) { return array_shift($available); } else { return $available; } } }
static function isObjectAvailableNoSchedule($a_obj_id) { global $ilDB; $all = ilBookingObject::getNrOfItemsForObjects(array($a_obj_id)); $all = (int) $all[$a_obj_id]; $set = $ilDB->query('SELECT COUNT(*) cnt' . ' FROM booking_reservation r' . ' JOIN booking_object o ON (o.booking_object_id = r.object_id)' . ' WHERE (status IS NULL OR status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') . ')' . ' AND r.object_id = ' . $ilDB->quote($a_obj_id, 'integer')); $cnt = $ilDB->fetchAssoc($set); $cnt = (int) $cnt['cnt']; return (bool) ($all - $cnt); // #11864 }
function rsvConfirmCancelAggregationForm($a_ids) { include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this, "rsvCancel")); $form->setTitle($this->lng->txt("book_confirm_cancel_aggregation")); include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; ilDatePresentation::setUseRelativeDates(false); foreach ($a_ids as $idx => $ids) { if (is_array($ids)) { $first = $ids; $first = array_shift($first); } else { $first = $ids; } $rsv = new ilBookingReservation($first); $obj = new ilBookingObject($rsv->getObjectId()); $caption = $obj->getTitle() . ", " . ilDatePresentation::formatPeriod(new ilDateTime($rsv->getFrom(), IL_CAL_UNIX), new ilDateTime($rsv->getTo() + 1, IL_CAL_UNIX)); $item = new ilNumberInputGUI($caption, "rsv_id_" . $idx); $item->setRequired(true); $item->setMinValue(0); $item->setSize(4); $form->addItem($item); if (is_array($ids)) { $item->setMaxValue(sizeof($ids)); foreach ($ids as $id) { $hidden = new ilHiddenInputGUI("rsv_aggr[" . $idx . "][]"); $hidden->setValue($id); $form->addItem($hidden); } } else { $item->setMaxValue(1); $hidden = new ilHiddenInputGUI("rsv_aggr[" . $idx . "]"); $hidden->setValue($ids); $form->addItem($hidden); } if ($_POST["rsv_id_" . $idx]) { $item->setValue((int) $_POST["rsv_id_" . $idx]); } } $form->addCommandButton("rsvCancel", $this->lng->txt("confirm")); $form->addCommandButton("log", $this->lng->txt("cancel")); return $form; }
/** * Gather data and build rows * @param array $filter */ function getItems(array $filter) { $this->determineOffsetAndOrder(); $ids = array(); include_once "Modules/BookingManager/classes/class.ilBookingObject.php"; foreach (ilBookingObject::getList($this->pool_id) as $item) { $ids[] = $item["booking_object_id"]; } include_once "Modules/BookingManager/classes/class.ilBookingReservation.php"; $data = ilBookingReservation::getList($ids, $this->getLimit(), $this->getOffset(), $filter); $this->setMaxCount($data['counter']); $this->setData($data['data']); }
/** * 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(); } }