/** * Confirm delete */ function confirmDelete() { global $ilCtrl, $lng, $tpl, $ilTabs; $ilTabs->clearTargets(); $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render')); include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php'; $conf = new ilConfirmationGUI(); $conf->setFormAction($ilCtrl->getFormAction($this)); $conf->setHeaderText($lng->txt('book_confirm_delete')); include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $type = new ilBookingObject((int) $_GET['object_id']); $conf->addItem('object_id', (int) $_GET['object_id'], $type->getTitle()); $conf->setConfirm($lng->txt('delete'), 'delete'); $conf->setCancel($lng->txt('cancel'), 'render'); $tpl->setContent($conf->getHTML()); }
public function displayPostInfo() { global $tpl, $ilUser, $lng, $ilCtrl; $id = (int) $_GET["object_id"]; if (!$id) { return; } // placeholder include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $book_ids = ilBookingReservation::getObjectReservationForUser($id, $ilUser->getId(), true); $tmp = array(); $rsv_ids = explode(";", $_GET["rsv_ids"]); foreach ($book_ids as $book_id) { if (in_array($book_id, $rsv_ids)) { $obj = new ilBookingReservation($book_id); $from = $obj->getFrom(); $to = $obj->getTo(); if ($from > time()) { $tmp[$from . "-" . $to]++; } } } $olddt = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $period = array(); ksort($tmp); foreach ($tmp as $time => $counter) { $time = explode("-", $time); $time = ilDatePresentation::formatPeriod(new ilDateTime($time[0], IL_CAL_UNIX), new ilDateTime($time[1], IL_CAL_UNIX)); if ($counter > 1) { $time .= " (" . $counter . ")"; } $period[] = $time; } $book_id = array_shift($book_ids); ilDatePresentation::setUseRelativeDates($olddt); $obj = new ilBookingReservation($book_id); if ($obj->getUserId() != $ilUser->getId()) { return; } include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $obj = new ilBookingObject($id); $pfile = $obj->getPostFile(); $ptext = $obj->getPostText(); $mytpl = new ilTemplate('tpl.booking_reservation_post.html', true, true, 'Modules/BookingManager'); $mytpl->setVariable("TITLE", $lng->txt('book_post_booking_information')); if ($ptext) { // placeholder $ptext = str_replace("[OBJECT]", $obj->getTitle(), $ptext); $ptext = str_replace("[PERIOD]", implode("<br />", $period), $ptext); $mytpl->setVariable("POST_TEXT", nl2br($ptext)); } if ($pfile) { $ilCtrl->setParameter($this, "object_id", $obj->getId()); $url = $ilCtrl->getLinkTarget($this, 'deliverPostFile'); $ilCtrl->setParameter($this, "object_id", ""); $mytpl->setVariable("DOWNLOAD", $lng->txt('download')); $mytpl->setVariable("URL_FILE", $url); $mytpl->setVariable("TXT_FILE", $pfile); } $mytpl->setVariable("TXT_SUBMIT", $lng->txt('ok')); $mytpl->setVariable("URL_SUBMIT", $ilCtrl->getLinkTargetByClass('ilobjbookingpoolgui', 'render')); $tpl->setContent($mytpl->get()); }
/** * 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()); } }
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; }