ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBookingProcessGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilBookingProcessGUI:

Public Member Functions

 executeCommand ()
 
 book ()
 First step in booking process. More...
 
 assignParticipants ()
 
 bookMultipleParticipants ()
 Create reservations for a bunch of booking pool participants. More...
 
 redirectToList ()
 
 saveMultipleBookings ()
 Save multiple users reservations for one booking pool object. More...
 
 confirmedBooking ()
 
 processBooking (int $a_object_id, int $a_from=null, int $a_to=null, int $a_group_id=null)
 Book object for date. More...
 
 confirmBookingNumbers (array $a_objects_counter, int $a_group_id, ilPropertyFormGUI $a_form=null)
 
 confirmedBookingNumbers ()
 
 displayPostInfo ()
 Display post booking informations. More...
 
 deliverPostFile ()
 Deliver post booking file. More...
 

Protected Member Functions

 back ()
 
 setHelpId (string $a_id)
 
 checkPermissionBool (string $a_perm)
 
 checkPermission (string $a_perm)
 
 saveParticipant ()
 save booking participant More...
 
 initBookingNumbersForm (array $a_objects_counter, int $a_group_id, bool $a_reload=false, ?array $new_values=null)
 
 addDaysDate (string $a_date, int $a_days)
 
 addDaysStamp (int $a_stamp, int $a_days)
 
 handleBookingSuccess (int $a_obj_id, array $a_rsv_ids=null)
 

Protected Attributes

array $raw_post_data
 
ILIAS BookingManager StandardGUIRequest $book_request
 
ilObjBookingPool $pool
 
int $booking_object_id
 
int $user_id_to_book
 
int $user_id_assigner
 
string $seed
 
string $sseed
 
ilBookingHelpAdapter $help
 
int $context_obj_id
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilAccessHandler $access
 
ilTabsGUI $tabs_gui
 
ilObjUser $user
 
int $book_obj_id
 
array $rsv_ids = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Booking process ui class

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilBookingProcessGUI.php.

Member Function Documentation

◆ addDaysDate()

ilBookingProcessGUI::addDaysDate ( string  $a_date,
int  $a_days 
)
protected

Definition at line 961 of file class.ilBookingProcessGUI.php.

Referenced by confirmedBookingNumbers().

964  : string {
965  $date = date_parse($a_date);
966  $stamp = mktime(0, 0, 1, $date["month"], $date["day"] + $a_days, $date["year"]);
967  return date("Y-m-d", $stamp);
968  }
+ Here is the caller graph for this function:

◆ addDaysStamp()

ilBookingProcessGUI::addDaysStamp ( int  $a_stamp,
int  $a_days 
)
protected

Definition at line 970 of file class.ilBookingProcessGUI.php.

Referenced by confirmedBookingNumbers().

973  : int {
974  $date = getdate($a_stamp);
975  return mktime(
976  $date["hours"],
977  $date["minutes"],
978  $date["seconds"],
979  $date["mon"],
980  $date["mday"] + $a_days,
981  $date["year"]
982  );
983  }
+ Here is the caller graph for this function:

◆ assignParticipants()

ilBookingProcessGUI::assignParticipants ( )

Definition at line 487 of file class.ilBookingProcessGUI.php.

References $book_obj_id, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

487  : void
488  {
489  $this->tabs_gui->clearTargets();
490  $this->tabs_gui->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'back'));
491 
492  $table = new ilBookingAssignParticipantsTableGUI($this, 'assignParticipants', $this->pool->getRefId(), $this->pool->getId(), $this->book_obj_id);
493 
494  $this->tpl->setContent($table->getHTML());
495  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ back()

ilBookingProcessGUI::back ( )
protected

Definition at line 113 of file class.ilBookingProcessGUI.php.

References ILIAS\Repository\ctrl().

Referenced by bookMultipleParticipants(), checkPermission(), confirmedBookingNumbers(), handleBookingSuccess(), and saveMultipleBookings().

113  : void
114  {
115  $this->ctrl->returnToParent($this);
116  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ book()

ilBookingProcessGUI::book ( )

First step in booking process.

Definition at line 149 of file class.ilBookingProcessGUI.php.

References $i, $id, $ilUser, $tpl, $user, ilCalendarUtil\_buildWeekDayList(), ilCalendarAppointmentColors\_getColorsByType(), ilCalendarUserSettings\_getInstanceByUserId(), ilCalendarUtil\_numericDayToString(), ilCalendarUtil\_numericMonthToString(), ilCalendarUtil\calculateFontColor(), ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ilBookingSchedule\getAvailabilityFrom(), ilBookingSchedule\getAvailabilityTo(), ilBookingReservation\getAvailableObject(), ilBookingSchedule\getDeadline(), ilBookingSchedule\getDefinition(), ilBookingSchedule\getRaster(), IL_CAL_DATE, IL_CAL_FKT_GETDATE, IL_CAL_UNIX, ILIAS\Repository\int(), ILIAS\Repository\lng(), ilGlobalTemplateInterface\setContent(), setHelpId(), ilCalendarSettings\TIME_FORMAT_12, ilCalendarSettings\TIME_FORMAT_24, ilObjBookingPool\TYPE_FIX_SCHEDULE, ilDateTime\WEEK, and ilDateTime\YEAR.

Referenced by confirmedBooking().

149  : void // ok
150  {
151  $tpl = $this->tpl;
152 
153  $this->tabs_gui->clearTargets();
154  $this->tabs_gui->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'back'));
155 
156  $this->setHelpId("book");
157 
158  $obj = new ilBookingObject($this->book_obj_id);
159 
160  $this->lng->loadLanguageModule("dateplaner");
161  $this->ctrl->setParameter($this, 'object_id', $obj->getId());
162 
163  if ($this->user_id_to_book !== $this->user_id_assigner) {
164  $this->ctrl->setParameter($this, 'bkusr', $this->user_id_to_book);
165  }
166 
167  if ($this->pool->getScheduleType() === ilObjBookingPool::TYPE_FIX_SCHEDULE) {
168  $schedule = new ilBookingSchedule($obj->getScheduleId());
169 
170  $tpl->setContent($this->renderSlots($schedule, array($obj->getId()), $obj->getTitle()));
171  } else {
172  $cgui = new ilConfirmationGUI();
173  $cgui->setHeaderText($this->lng->txt("book_confirm_booking_no_schedule"));
174 
175  $cgui->setFormAction($this->ctrl->getFormAction($this));
176  $cgui->setCancel($this->lng->txt("cancel"), "back");
177  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedBooking");
178 
179  $cgui->addItem("object_id", $obj->getId(), $obj->getTitle());
180 
181  $tpl->setContent($cgui->getHTML());
182  }
183  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bookMultipleParticipants()

ilBookingProcessGUI::bookMultipleParticipants ( )

Create reservations for a bunch of booking pool participants.

Definition at line 500 of file class.ilBookingProcessGUI.php.

References $id, $name, ilObjUser\_lookupFullname(), back(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilBookingReservation\numAvailableFromObjectNoSchedule().

500  : void
501  {
502  $participants = $this->book_request->getParticipants();
503  if (count($participants) === 0) {
504  $this->back();
505  return;
506  }
507 
508  $this->tabs_gui->clearTargets();
509  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, 'assignparticipants'));
510 
511  $conf = new ilConfirmationGUI();
512  $conf->setFormAction($this->ctrl->getFormAction($this));
513 
514  //add user list as items.
515  foreach ($participants as $id) {
517  $conf->addItem("participants[]", $id, $name);
518  }
519 
520  $available = ilBookingReservation::numAvailableFromObjectNoSchedule($this->book_obj_id);
521  if (count($participants) > $available) {
522  $obj = new ilBookingObject($this->book_obj_id);
523  $conf->setHeaderText(
524  sprintf(
525  $this->lng->txt('book_limit_objects_available'),
526  count($participants),
527  $obj->getTitle(),
528  $available
529  )
530  );
531  } else {
532  $conf->setHeaderText($this->lng->txt('book_confirm_booking_no_schedule'));
533  $conf->addHiddenItem("object_id", $this->book_obj_id);
534  $conf->setConfirm($this->lng->txt("assign"), "saveMultipleBookings");
535  }
536 
537  $conf->setCancel($this->lng->txt("cancel"), 'redirectToList');
538  $this->tpl->setContent($conf->getHTML());
539  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupFullname(int $a_user_id)
if($format !==null) $name
Definition: metadata.php:247
static numAvailableFromObjectNoSchedule(int $a_obj_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ checkPermission()

ilBookingProcessGUI::checkPermission ( string  $a_perm)
protected

Definition at line 133 of file class.ilBookingProcessGUI.php.

References back(), checkPermissionBool(), and ILIAS\Repository\lng().

Referenced by processBooking().

133  : void
134  {
135  if (!$this->checkPermissionBool($a_perm)) {
136  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_permission"), true);
137  $this->back();
138  }
139  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPermissionBool()

ilBookingProcessGUI::checkPermissionBool ( string  $a_perm)
protected

Definition at line 123 of file class.ilBookingProcessGUI.php.

References $access.

Referenced by checkPermission().

123  : bool
124  {
125  $ilAccess = $this->access;
126 
127  if (!$ilAccess->checkAccess($a_perm, "", $this->pool->getRefId())) {
128  return false;
129  }
130  return true;
131  }
+ Here is the caller graph for this function:

◆ confirmBookingNumbers()

ilBookingProcessGUI::confirmBookingNumbers ( array  $a_objects_counter,
int  $a_group_id,
ilPropertyFormGUI  $a_form = null 
)

Definition at line 708 of file class.ilBookingProcessGUI.php.

References $tpl, ILIAS\Repository\ctrl(), initBookingNumbersForm(), ILIAS\Repository\lng(), and ilGlobalTemplateInterface\setContent().

Referenced by confirmedBooking(), and confirmedBookingNumbers().

712  : void {
713  $tpl = $this->tpl;
714 
715  $this->tabs_gui->clearTargets();
716  $this->tabs_gui->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'back'));
717 
718  if (!$a_form) {
719  $a_form = $this->initBookingNumbersForm($a_objects_counter, $a_group_id);
720  }
721 
722  $tpl->setContent($a_form->getHTML());
723  }
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
initBookingNumbersForm(array $a_objects_counter, int $a_group_id, bool $a_reload=false, ?array $new_values=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmedBooking()

ilBookingProcessGUI::confirmedBooking ( )

Definition at line 579 of file class.ilBookingProcessGUI.php.

References $book_obj_id, Vendor\Package\$f, book(), confirmBookingNumbers(), ILIAS\Repository\ctrl(), ilBookingReservation\getAvailableObject(), ilBookingObject\getNrOfItemsForObjects(), ilBookingReservation\getObjectReservationForUser(), handleBookingSuccess(), ILIAS\Repository\int(), ilBookingReservation\isObjectAvailableNoSchedule(), ILIAS\Repository\lng(), processBooking(), saveParticipant(), and ilObjBookingPool\TYPE_FIX_SCHEDULE.

579  : bool
580  {
581  $success = false;
582  $rsv_ids = array();
583 
584  if ($this->pool->getScheduleType() !== ilObjBookingPool::TYPE_FIX_SCHEDULE) {
585  if ($this->book_obj_id > 0) {
586  $object_id = $this->book_obj_id;
587  if ($object_id) {
589  count(ilBookingReservation::getObjectReservationForUser($object_id, $this->user_id_to_book)) === 0) { // #18304
590  $rsv_ids[] = $this->processBooking($object_id);
591  $success = $object_id;
592  } else {
593  // #11852
594  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('book_reservation_failed_overbooked'), true);
595  $this->ctrl->redirect($this, 'back');
596  }
597  }
598  }
599  } else {
600  $dates = $this->book_request->getDates();
601  if (count($dates) === 0) {
602  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
603  $this->book();
604  return false;
605  }
606 
607  // single object reservation(s)
608  if ($this->book_obj_id > 0) {
609  $confirm = array();
610 
611  $object_id = $this->book_obj_id;
612  $group_id = null;
613  if ($object_id) {
614  $nr = ilBookingObject::getNrOfItemsForObjects(array($object_id));
615  // needed for recurrence
617  $repo = $f->getRepo();
618  $group_id = $repo->getNewGroupId();
619  foreach ($dates as $date) {
620  $fromto = explode('_', $date);
621  $from = (int) $fromto[0];
622  $to = (int) $fromto[1] - 1;
623 
624  $counter = ilBookingReservation::getAvailableObject(array($object_id), $from, $to, false, true);
625  $counter = $counter[$object_id];
626  if ($counter) {
627  // needed for recurrence
628  $confirm[$object_id . "_" . $from . "_" . ($to + 1)] = $counter;
629  }
630  }
631  }
632 
633  if (count($confirm)) {
634  $this->confirmBookingNumbers($confirm, $group_id);
635  return false;
636  }
637  }
638  }
639 
640  if ($success) {
641  $this->saveParticipant();
642  $this->handleBookingSuccess($success, $rsv_ids);
643  } else {
644  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('book_reservation_failed'), true);
645  $this->ctrl->redirect($this, 'book');
646  }
647  return true;
648  }
processBooking(int $a_object_id, int $a_from=null, int $a_to=null, int $a_group_id=null)
Book object for date.
handleBookingSuccess(int $a_obj_id, array $a_rsv_ids=null)
confirmBookingNumbers(array $a_objects_counter, int $a_group_id, ilPropertyFormGUI $a_form=null)
static getObjectReservationForUser(int $a_object_id, int $a_user_id)
book()
First step in booking process.
saveParticipant()
save booking participant
static getAvailableObject(array $a_ids, int $a_from, int $a_to, bool $a_return_single=true, bool $a_return_counter=false)
Check if any of given objects are bookable.
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items for a set of object ids.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isObjectAvailableNoSchedule(int $a_obj_id)
+ Here is the call graph for this function:

◆ confirmedBookingNumbers()

ilBookingProcessGUI::confirmedBookingNumbers ( )

Definition at line 828 of file class.ilBookingProcessGUI.php.

References $id, $parts, addDaysDate(), addDaysStamp(), back(), confirmBookingNumbers(), ilBookingReservation\getAvailableObject(), handleBookingSuccess(), IL_CAL_DATE, initBookingNumbersForm(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilCalendarUtil\parseIncomingDate(), processBooking(), and saveParticipant().

828  : void
829  {
830 
831  //get the user who will get the booking.
832  if ($this->book_request->getBookedUser() > 0) {
833  $this->user_id_to_book = $this->book_request->getBookedUser();
834  }
835 
836  // convert post data to initial form config
837  $counter = array();
838  $current_first = $obj_id = null;
839  foreach (array_keys($this->raw_post_data) as $id) {
840  if (str_starts_with($id, "conf_nr__")) {
841  $id = explode("_", substr($id, 9));
842  $counter[$id[0] . "_" . $id[1] . "_" . $id[2]] = (int) $id[3];
843  if (!$current_first) {
844  $current_first = date("Y-m-d", $id[1]);
845  }
846  }
847  }
848 
849  // recurrence
850 
851  // checkInput() has not been called yet, so we have to improvise
852  $rece = $this->book_request->getRece();
853  $recm = $this->book_request->getRecm();
854  $end = ilCalendarUtil::parseIncomingDate($rece, false);
855 
856  $new_values = [];
857 
858  if ((int) $recm > 0 && $end && $current_first) {
859  ksort($counter);
860  $end = $end->get(IL_CAL_DATE);
861  $cycle = (int) $recm * 7;
862  $cut = 0;
863  $org = $counter;
864  while ($cut < 1000 && $this->addDaysDate($current_first, $cycle) <= $end) {
865  $cut++;
866  $current_first = null;
867  foreach ($org as $item_id => $max) {
868  $parts = explode("_", $item_id);
869  $obj_id = $parts[0];
870 
871  $from = $this->addDaysStamp($parts[1], $cycle * $cut);
872  $to = $this->addDaysStamp($parts[2], $cycle * $cut);
873 
874  $new_item_id = $obj_id . "_" . $from . "_" . $to;
875 
876  // form reload because of validation errors
877  if (!isset($counter[$new_item_id]) && date("Y-m-d", $to) <= $end) {
878  // get max available for added dates
879  $new_max = ilBookingReservation::getAvailableObject(array($obj_id), $from, $to - 1, false, true);
880  $new_max = (int) $new_max[$obj_id];
881 
882  $counter[$new_item_id] = $new_max;
883 
884  if (!$current_first) {
885  $current_first = date("Y-m-d", $from);
886  }
887 
888  // clone input
889  $new_values["conf_nr__" . $new_item_id . "_" . $new_max] =
890  $_POST["conf_nr__" . $item_id . "_" . $max];
891  }
892  }
893  }
894  }
895 
896  $group_id = $this->book_request->getGroupId();
897 
898  $form = $this->initBookingNumbersForm($counter, $group_id, true, $new_values);
899  if ($form->checkInput()) {
900  $success = false;
901  $rsv_ids = array();
902  foreach ($counter as $id => $all_nr) {
903  $book_nr = $form->getInput("conf_nr__" . $id . "_" . $all_nr);
904  $parts = explode("_", $id);
905  $obj_id = $parts[0];
906  $from = $parts[1];
907  $to = $parts[2] - 1;
908 
909  // get currently available slots
910  $counter = ilBookingReservation::getAvailableObject(array($obj_id), $from, $to, false, true);
911  $counter = $counter[$obj_id];
912  if ($counter) {
913  // we can only book what is left
914  $book_nr = min($book_nr, $counter);
915  for ($loop = 0; $loop < $book_nr; $loop++) {
916  $rsv_ids[] = $this->processBooking($obj_id, $from, $to, $group_id);
917  $success = $obj_id;
918  }
919  }
920  }
921  if ($success) {
922  $this->saveParticipant();
923  $this->handleBookingSuccess($success, $rsv_ids);
924  } else {
925  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('book_reservation_failed'), true);
926  $this->back();
927  }
928  } else {
929  // ilDateTimeInputGUI does NOT add hidden values on disabled!
930 
931  $rece_array = explode(".", $rece);
932 
933  $rece_day = str_pad($rece_array[0], 2, "0", STR_PAD_LEFT);
934  $rece_month = str_pad($rece_array[1], 2, "0", STR_PAD_LEFT);
935  $rece_year = $rece_array[2];
936 
937  // ilDateTimeInputGUI will choke on POST array format
938  //$_POST["rece"] = null;
939 
940  $form->setValuesByPost();
941 
942  $rece_date = new ilDate($rece_year . "-" . $rece_month . "-" . $rece_day, IL_CAL_DATE);
943 
944  $rece = $form->getItemByPostVar("rece");
945  if ($rece !== null) {
946  $rece->setDate($rece_date);
947  }
948  $recm = $form->getItemByPostVar("recm");
949  if ($recm !== null) {
950  $recm->setHideSubForm((int) $form->getInput("recm") < 1);
951  }
952 
953  $hidden_date = new ilHiddenInputGUI("rece");
954  $hidden_date->setValue($rece_date);
955  $form->addItem($hidden_date);
956 
957  $this->confirmBookingNumbers($counter, $group_id, $form);
958  }
959  }
processBooking(int $a_object_id, int $a_from=null, int $a_to=null, int $a_group_id=null)
Book object for date.
handleBookingSuccess(int $a_obj_id, array $a_rsv_ids=null)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
confirmBookingNumbers(array $a_objects_counter, int $a_group_id, ilPropertyFormGUI $a_form=null)
saveParticipant()
save booking participant
static getAvailableObject(array $a_ids, int $a_from, int $a_to, bool $a_return_single=true, bool $a_return_counter=false)
Check if any of given objects are bookable.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addDaysDate(string $a_date, int $a_days)
const IL_CAL_DATE
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
initBookingNumbersForm(array $a_objects_counter, int $a_group_id, bool $a_reload=false, ?array $new_values=null)
static parseIncomingDate($a_value, bool $a_add_time=false)
Try to parse incoming value to date object.
addDaysStamp(int $a_stamp, int $a_days)
+ Here is the call graph for this function:

◆ deliverPostFile()

ilBookingProcessGUI::deliverPostFile ( )

Deliver post booking file.

Definition at line 1105 of file class.ilBookingProcessGUI.php.

References $book_obj_id, $id, $user_id_assigner, ilFileDelivery\deliverFileLegacy(), and ilBookingReservation\getObjectReservationForUser().

1105  : void
1106  {
1108  if (!$id) {
1109  return;
1110  }
1111 
1112  $book_ids = ilBookingReservation::getObjectReservationForUser($id, $this->user_id_assigner);
1113  $book_id = current($book_ids);
1114  $obj = new ilBookingReservation($book_id);
1115  if ($obj->getUserId() !== $this->user_id_assigner) {
1116  return;
1117  }
1118 
1119  $obj = new ilBookingObject($id);
1120  $file = $obj->getPostFileFullPath();
1121  if ($file) {
1122  ilFileDelivery::deliverFileLegacy($file, $obj->getPostFile());
1123  }
1124  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getObjectReservationForUser(int $a_object_id, int $a_user_id)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ displayPostInfo()

ilBookingProcessGUI::displayPostInfo ( )

Display post booking informations.

Definition at line 1013 of file class.ilBookingProcessGUI.php.

References $book_obj_id, $ctrl, $id, ILIAS\LTI\ToolProvider\$key, $lng, $tpl, $url, ilDatePresentation\formatPeriod(), ilBookingReservation\getObjectReservationForUser(), IL_CAL_UNIX, ilGlobalTemplateInterface\setContent(), ilDatePresentation\setUseRelativeDates(), ilLanguage\txt(), and ilDatePresentation\useRelativeDates().

1013  : void
1014  {
1015  $tpl = $this->tpl;
1016  $lng = $this->lng;
1017  $ilCtrl = $this->ctrl;
1019  if (!$id) {
1020  return;
1021  }
1022  // placeholder
1023  $book_ids = ilBookingReservation::getObjectReservationForUser($id, $this->user_id_assigner);
1024  $tmp = array();
1025  foreach ($book_ids as $book_id) {
1026  if (in_array($book_id, $this->rsv_ids) || count($this->rsv_ids) === 0) {
1027  $obj = new ilBookingReservation($book_id);
1028  $from = $obj->getFrom();
1029  $to = $obj->getTo();
1030  if ($from > time()) {
1031  $key = $from . "-" . $to;
1032  if (!isset($tmp[$key])) {
1033  $tmp[$key] = 0;
1034  }
1035  $tmp[$key]++;
1036  }
1037  }
1038  }
1039 
1042 
1043  $period = array();
1044  ksort($tmp);
1045  foreach ($tmp as $time => $counter) {
1046  $time = explode("-", $time);
1048  new ilDateTime($time[0], IL_CAL_UNIX),
1049  new ilDateTime($time[1], IL_CAL_UNIX)
1050  );
1051  if ($counter > 1) {
1052  $time .= " (" . $counter . ")";
1053  }
1054  $period[] = $time;
1055  }
1056  $book_id = array_shift($book_ids);
1057 
1059 
1060 
1061  /*
1062  #23578 since Booking pool participants.
1063  $obj = new ilBookingReservation($book_id);
1064  if ($obj->getUserId() != $ilUser->getId())
1065  {
1066  return;
1067  }
1068  */
1069 
1070  $obj = new ilBookingObject($id);
1071  $pfile = $obj->getPostFile();
1072  $ptext = $obj->getPostText();
1073 
1074  $mytpl = new ilTemplate('tpl.booking_reservation_post.html', true, true, 'Modules/BookingManager/BookingProcess');
1075  $mytpl->setVariable("TITLE", $lng->txt('book_post_booking_information'));
1076 
1077  if ($ptext) {
1078  // placeholder
1079  $ptext = str_replace(
1080  ["[OBJECT]", "[PERIOD]"],
1081  [$obj->getTitle(), implode("<br />", $period)],
1082  $ptext
1083  );
1084 
1085  $mytpl->setVariable("POST_TEXT", nl2br($ptext));
1086  }
1087 
1088  if ($pfile) {
1089  $url = $ilCtrl->getLinkTarget($this, 'deliverPostFile');
1090 
1091  $mytpl->setVariable("DOWNLOAD", $lng->txt('download'));
1092  $mytpl->setVariable("URL_FILE", $url);
1093  $mytpl->setVariable("TXT_FILE", $pfile);
1094  }
1095 
1096  $mytpl->setVariable("TXT_SUBMIT", $lng->txt('ok'));
1097  $mytpl->setVariable("URL_SUBMIT", $ilCtrl->getLinkTarget($this, "back"));
1098 
1099  $tpl->setContent($mytpl->get());
1100  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getObjectReservationForUser(int $a_object_id, int $a_user_id)
const IL_CAL_UNIX
setContent(string $a_html)
Sets content for standard template.
string $key
Consumer key/client ID value.
Definition: System.php:193
ilGlobalTemplateInterface $tpl
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$url
static setUseRelativeDates(bool $a_status)
set use relative dates
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ executeCommand()

ilBookingProcessGUI::executeCommand ( )

Definition at line 89 of file class.ilBookingProcessGUI.php.

References $ctrl, ilCtrl\getCmd(), and ilCtrl\getNextClass().

89  : void
90  {
92 
93  $next_class = $ctrl->getNextClass($this);
94  $cmd = $ctrl->getCmd("show");
95  switch ($next_class) {
96  default:
97  if (in_array($cmd, array("book", "back",
98  "assignParticipants",
99  "bookMultipleParticipants",
100  "saveMultipleBookings",
101  "confirmedBooking",
102  "confirmBookingNumbers",
103  "confirmedBookingNumbers",
104  "displayPostInfo",
105  "deliverPostFile"
106  ))) {
107  $this->$cmd();
108  }
109  }
110  }
getCmd(string $fallback_command=null)
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ handleBookingSuccess()

ilBookingProcessGUI::handleBookingSuccess ( int  $a_obj_id,
array  $a_rsv_ids = null 
)
protected

Definition at line 989 of file class.ilBookingProcessGUI.php.

References back(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by confirmedBooking(), and confirmedBookingNumbers().

992  : void {
993  $this->tpl->setOnScreenMessage('success', $this->lng->txt('book_reservation_confirmed'), true);
994 
995  // show post booking information?
996  $obj = new ilBookingObject($a_obj_id);
997  $pfile = $obj->getPostFile();
998  $ptext = $obj->getPostText();
999 
1000  if (trim($ptext) || $pfile) {
1001  if (count($a_rsv_ids)) {
1002  $this->ctrl->setParameter($this, 'rsv_ids', implode(";", $a_rsv_ids));
1003  }
1004  $this->ctrl->redirect($this, 'displayPostInfo');
1005  } else {
1006  $this->back();
1007  }
1008  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initBookingNumbersForm()

ilBookingProcessGUI::initBookingNumbersForm ( array  $a_objects_counter,
int  $a_group_id,
bool  $a_reload = false,
?array  $new_values = null 
)
protected
Exceptions
ilCtrlException
ilDateTimeException

Definition at line 729 of file class.ilBookingProcessGUI.php.

References $id, ILIAS\Repository\ctrl(), ilDatePresentation\formatPeriod(), IL_CAL_UNIX, ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by confirmBookingNumbers(), and confirmedBookingNumbers().

735  $form = new ilPropertyFormGUI();
736  $form->setFormAction($this->ctrl->getFormAction($this, "confirmedBooking"));
737  $form->setTitle($this->lng->txt("book_confirm_booking_schedule_number_of_objects"));
738  $form->setDescription($this->lng->txt("book_confirm_booking_schedule_number_of_objects_info"));
739 
740  $section = false;
741  $min_date = null;
742  foreach ($a_objects_counter as $id => $counter) {
743  $id = explode("_", $id);
744  $book_id = $id[0] . "_" . $id[1] . "_" . $id[2] . "_" . $counter;
745 
746  $obj = new ilBookingObject($id[0]);
747 
748  if (!$section) {
749  $section = new ilFormSectionHeaderGUI();
750  $section->setTitle($obj->getTitle());
751  $form->addItem($section);
752 
753  $section = true;
754  }
755 
756  $period = /* $this->lng->txt("book_period").": ". */
758  new ilDateTime($id[1], IL_CAL_UNIX),
759  new ilDateTime($id[2], IL_CAL_UNIX)
760  );
761 
762  $nr_field = new ilNumberInputGUI($period, "conf_nr__" . $book_id);
763  $nr_field->setValue(1);
764  $nr_field->setSize(3);
765  $nr_field->setMaxValue($counter);
766  $nr_field->setMinValue($counter ? 1 : 0);
767  $nr_field->setRequired(true);
768  if (!is_null($new_values) && isset($new_values["conf_nr__" . $book_id])) {
769  $nr_field->setRequestParam(
770  "conf_nr__" . $book_id,
771  $new_values["conf_nr__" . $book_id]
772  );
773  }
774  $form->addItem($nr_field);
775 
776  if (!$min_date || $id[1] < $min_date) {
777  $min_date = $id[1];
778  }
779  }
780 
781  // recurrence
782  $this->lng->loadLanguageModule("dateplaner");
783  $rec_mode = new ilSelectInputGUI($this->lng->txt("cal_recurrences"), "recm");
784  $rec_mode->setRequired(true);
785  $rec_mode->setOptions(array(
786  "-1" => $this->lng->txt("cal_no_recurrence"),
787  1 => $this->lng->txt("cal_weekly"),
788  2 => $this->lng->txt("r_14"),
789  4 => $this->lng->txt("r_4_weeks")
790  ));
791  $form->addItem($rec_mode);
792 
793  $rec_end = new ilDateTimeInputGUI($this->lng->txt("cal_repeat_until"), "rece");
794  $rec_end->setRequired(true);
795  $rec_mode->addSubItem($rec_end);
796 
797  if (!$a_reload) {
798  // show date only if active recurrence
799  $rec_mode->setHideSubForm(true, '>= 1');
800 
801  if ($min_date) {
802  $rec_end->setDate(new ilDateTime($min_date, IL_CAL_UNIX));
803  }
804  } else {
805  // recurrence may not be changed on reload
806  $rec_mode->setDisabled(true);
807  $rec_end->setDisabled(true);
808  }
809 
810  if ($a_group_id) {
811  $grp = new ilHiddenInputGUI("grp_id");
812  $grp->setValue($a_group_id);
813  $form->addItem($grp);
814  }
815 
816  if ($this->user_id_assigner !== $this->user_id_to_book) {
817  $usr = new ilHiddenInputGUI("bkusr");
818  $usr->setValue($this->user_id_to_book);
819  $form->addItem($usr);
820  }
821 
822  $form->addCommandButton("confirmedBookingNumbers", $this->lng->txt("confirm"));
823  $form->addCommandButton("back", $this->lng->txt("cancel"));
824 
825  return $form;
826  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a number property in a property form.
setRequired(bool $a_required)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processBooking()

ilBookingProcessGUI::processBooking ( int  $a_object_id,
int  $a_from = null,
int  $a_to = null,
int  $a_group_id = null 
)

Book object for date.

Returns
int reservation id
Exceptions
ilDateTimeException

Definition at line 663 of file class.ilBookingProcessGUI.php.

References ilCalendarCategoryAssignments\addAssignment(), checkPermission(), IL_CAL_UNIX, ilCalendarUtil\initDefaultCalendarByType(), ILIAS\Repository\lng(), and ilCalendarCategory\TYPE_BOOK.

Referenced by confirmedBooking(), confirmedBookingNumbers(), and saveMultipleBookings().

668  : int {
669  // #11995
670  $this->checkPermission('read');
671 
672  $reservation = new ilBookingReservation();
673  $reservation->setObjectId($a_object_id);
674  $reservation->setUserId($this->user_id_to_book);
675  $reservation->setAssignerId($this->user_id_assigner);
676  $reservation->setFrom((int) $a_from);
677  $reservation->setTo((int) $a_to);
678  $reservation->setGroupId((int) $a_group_id);
679  $reservation->setContextObjId($this->context_obj_id);
680  $reservation->save();
681 
682  if ($a_from) {
683  $this->lng->loadLanguageModule('dateplaner');
684  $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $this->user_id_to_book, $this->lng->txt('cal_ch_personal_book'), true);
685 
686  $object = new ilBookingObject($a_object_id);
687 
688  $entry = new ilCalendarEntry();
689  $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX));
690  $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX));
691  $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle());
692  $entry->setContextId($reservation->getId());
693  $entry->save();
694 
695  $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
696  if ($def_cat !== null) {
697  $assignment->addAssignment($def_cat->getCategoryID());
698  }
699  }
700 
701  return $reservation->getId();
702  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
static initDefaultCalendarByType(int $a_type_id, int $a_usr_id, string $a_title, bool $a_create=false)
Init the default calendar for given type and user.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectToList()

ilBookingProcessGUI::redirectToList ( )

Definition at line 541 of file class.ilBookingProcessGUI.php.

References ILIAS\Repository\ctrl().

541  : void
542  {
543  $this->ctrl->redirect($this, 'assignParticipants');
544  }
+ Here is the call graph for this function:

◆ saveMultipleBookings()

ilBookingProcessGUI::saveMultipleBookings ( )

Save multiple users reservations for one booking pool object.

Todo:
check if object/user exist in the DB,

Definition at line 550 of file class.ilBookingProcessGUI.php.

References $id, back(), ILIAS\Repository\lng(), and processBooking().

550  : void
551  {
552  $participants = $this->book_request->getParticipants();
553  $object_id = $this->book_request->getObjectId();
554  if (count($participants) > 0 && $object_id > 0) {
555  $this->book_obj_id = $object_id;
556  } else {
557  $this->back();
558  }
559  $rsv_ids = array();
560  foreach ($participants as $id) {
561  $this->user_id_to_book = $id;
562  $rsv_ids[] = $this->processBooking($this->book_obj_id);
563  }
564 
565  if (count($rsv_ids)) {
566  $this->tpl->setOnScreenMessage('success', "booking_multiple_succesfully");
567  } else {
568  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('book_reservation_failed_overbooked'), true);
569  }
570  $this->back();
571  }
processBooking(int $a_object_id, int $a_from=null, int $a_to=null, int $a_group_id=null)
Book object for date.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ saveParticipant()

ilBookingProcessGUI::saveParticipant ( )
protected

save booking participant

Definition at line 653 of file class.ilBookingProcessGUI.php.

Referenced by confirmedBooking(), and confirmedBookingNumbers().

653  : void
654  {
655  $participant = new ilBookingParticipant($this->user_id_to_book, $this->pool->getId());
656  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ setHelpId()

ilBookingProcessGUI::setHelpId ( string  $a_id)
protected

Definition at line 118 of file class.ilBookingProcessGUI.php.

References ILIAS\Repository\help().

Referenced by book().

118  : void
119  {
120  $this->help->setHelpId($a_id);
121  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilBookingProcessGUI::$access
protected

Definition at line 38 of file class.ilBookingProcessGUI.php.

Referenced by checkPermissionBool().

◆ $book_obj_id

int ilBookingProcessGUI::$book_obj_id
protected

◆ $book_request

ILIAS BookingManager StandardGUIRequest ilBookingProcessGUI::$book_request
protected

Definition at line 26 of file class.ilBookingProcessGUI.php.

◆ $booking_object_id

int ilBookingProcessGUI::$booking_object_id
protected

Definition at line 28 of file class.ilBookingProcessGUI.php.

◆ $context_obj_id

int ilBookingProcessGUI::$context_obj_id
protected

Definition at line 34 of file class.ilBookingProcessGUI.php.

◆ $ctrl

ilCtrl ilBookingProcessGUI::$ctrl
protected

Definition at line 35 of file class.ilBookingProcessGUI.php.

Referenced by displayPostInfo(), and executeCommand().

◆ $help

ilBookingHelpAdapter ilBookingProcessGUI::$help
protected

Definition at line 33 of file class.ilBookingProcessGUI.php.

◆ $lng

ilLanguage ilBookingProcessGUI::$lng
protected

Definition at line 37 of file class.ilBookingProcessGUI.php.

Referenced by displayPostInfo().

◆ $pool

ilObjBookingPool ilBookingProcessGUI::$pool
protected

Definition at line 27 of file class.ilBookingProcessGUI.php.

◆ $raw_post_data

array ilBookingProcessGUI::$raw_post_data
protected

Definition at line 25 of file class.ilBookingProcessGUI.php.

◆ $rsv_ids

array ilBookingProcessGUI::$rsv_ids = []
protected

Definition at line 42 of file class.ilBookingProcessGUI.php.

◆ $seed

string ilBookingProcessGUI::$seed
protected

Definition at line 31 of file class.ilBookingProcessGUI.php.

◆ $sseed

string ilBookingProcessGUI::$sseed
protected

Definition at line 32 of file class.ilBookingProcessGUI.php.

◆ $tabs_gui

ilTabsGUI ilBookingProcessGUI::$tabs_gui
protected

Definition at line 39 of file class.ilBookingProcessGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilBookingProcessGUI::$tpl
protected

Definition at line 36 of file class.ilBookingProcessGUI.php.

Referenced by book(), confirmBookingNumbers(), and displayPostInfo().

◆ $user

ilObjUser ilBookingProcessGUI::$user
protected

Definition at line 40 of file class.ilBookingProcessGUI.php.

Referenced by book().

◆ $user_id_assigner

int ilBookingProcessGUI::$user_id_assigner
protected

Definition at line 30 of file class.ilBookingProcessGUI.php.

Referenced by deliverPostFile().

◆ $user_id_to_book

int ilBookingProcessGUI::$user_id_to_book
protected

Definition at line 29 of file class.ilBookingProcessGUI.php.


The documentation for this class was generated from the following file: