public function displayPostInfo()
 {
     global $tpl, $ilUser, $lng, $ilCtrl;
     $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);
     $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) {
         $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());
 }
 protected function handleBookingSuccess($a_obj_id)
 {
     ilUtil::sendSuccess($this->lng->txt('book_reservation_confirmed'), true);
     // show post booking information?
     include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
     $obj = new ilBookingObject($a_obj_id);
     $pfile = $obj->getPostFile();
     $ptext = $obj->getPostText();
     if (trim($ptext) || $pfile) {
         $this->ctrl->setParameterByClass('ilbookingobjectgui', 'object_id', $obj->getId());
         $this->ctrl->redirectByClass('ilbookingobjectgui', 'displayPostInfo');
     } else {
         $this->ctrl->redirect($this, 'render');
     }
 }
 /**
  * Book object - either of type or specific - for given dates
  */
 function confirmedBookingObject()
 {
     global $tpl;
     $success = false;
     if ($this->object->getScheduleType() == ilObjBookingPool::TYPE_NO_SCHEDULE) {
         if ($_POST['object_id']) {
             $this->processBooking($_POST['object_id']);
             $success = $_POST['object_id'];
         }
     } else {
         if (!isset($_POST['date'])) {
             ilUtil::sendFailure($this->lng->txt('select_one'));
             return $this->bookObject();
         }
         // single object reservation(s)
         if (isset($_GET['object_id'])) {
             foreach ($_POST['date'] as $date) {
                 $fromto = explode('_', $date);
                 $fromto[1]--;
                 $object_id = (int) $_GET['object_id'];
                 if ($object_id) {
                     $this->processBooking($object_id, $fromto[0], $fromto[1]);
                     $success = $object_id;
                 }
             }
         }
         /*
         // group object reservation(s)
         else
         {				
         	include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
         	include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';											
         	$all_object_ids = array();
         	foreach(ilBookingObject::getList((int)$_GET['type_id']) as $item)
         	{
         		$all_object_ids[] = $item['booking_object_id'];
         	}
         
         	$possible_objects = $counter = array();	
         	sort($_POST['date']);			
         	foreach($_POST['date'] as $date)
         	{
         		$fromto = explode('_', $date);
         		$fromto[1]--;
         		$possible_objects[$date] = ilBookingReservation::getAvailableObject($all_object_ids, $fromto[0], $fromto[1], false);		
         		foreach($possible_objects[$date] as $obj_id)
         		{
         			$counter[$obj_id]++;
         		}
         	}
         
         	if(max($counter))
         	{			
         		// we prefer the objects which are available for most slots
         		arsort($counter);
         		$counter = array_keys($counter);
         
         		// book each slot
         		foreach($possible_objects as $date => $available_ids)
         		{
         			$fromto = explode('_', $date);
         			$fromto[1]--;
         
         			// find "best" object for slot
         			foreach($counter as $best_object_id)
         			{
         				if(in_array($best_object_id, $available_ids))
         				{
         					$object_id = $best_object_id;
         					break;
         				}
         			}				
         			$this->processBooking($object_id, $fromto[0], $fromto[1]);
         			$success = true;	
         		}
         	}
         }			 
         */
     }
     if ($success) {
         ilUtil::sendSuccess($this->lng->txt('book_reservation_confirmed'), true);
         // show post booking information?
         include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
         $obj = new ilBookingObject($success);
         $pfile = $obj->getPostFile();
         $ptext = $obj->getPostText();
         if (trim($ptext) || $pfile) {
             $this->ctrl->setParameterByClass('ilbookingobjectgui', 'object_id', $obj->getId());
             $this->ctrl->redirectByClass('ilbookingobjectgui', 'displayPostInfo');
         } else {
             $this->ctrl->redirect($this, 'render');
         }
     } else {
         ilUtil::sendFailure($this->lng->txt('book_reservation_failed'), true);
         $this->ctrl->redirect($this, 'book');
     }
 }
 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());
 }