ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilBookingProcessGUI Class Reference

Booking process ui class. More...

+ Collaboration diagram for ilBookingProcessGUI:

Public Member Functions

 __construct (ilObjBookingPool $pool, int $booking_object_id, ilBookingHelpAdapter $help, string $seed="", string $sseed="", int $context_obj_id=0)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 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 ()
 Book object - either of type or specific - for given dates. More...
 
 processBooking ($a_object_id, $a_from=null, $a_to=null, $a_group_id=null)
 Book object for date. More...
 
 confirmBookingNumbers (array $a_objects_counter, $a_group_id, ilPropertyFormGUI $a_form=null)
 
 confirmedBookingNumbers ()
 
 displayPostInfo ()
 Display post booking informatins. More...
 
 deliverPostFile ()
 Deliver post booking file. More...
 

Protected Member Functions

 back ()
 Back to parent. More...
 
 setHelpId (string $a_id)
 
 checkPermissionBool ($a_perm)
 Check permission. More...
 
 checkPermission ($a_perm)
 Check permission. More...
 
 saveParticipant ()
 save booking participant. More...
 
 initBookingNumbersForm (array $a_objects_counter, $a_group_id, $a_reload=false)
 
 addDaysDate ($a_date, $a_days)
 
 addDaysStamp ($a_stamp, $a_days)
 
 handleBookingSuccess ($a_obj_id, array $a_rsv_ids=null)
 

Protected Attributes

 $pool
 
 $booking_object_id
 
 $user_id_to_book
 
 $user_id_assigner
 
 $seed
 
 $help
 
 $context_obj_id
 

Detailed Description

Booking process ui class.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilBookingProcessGUI::__construct ( ilObjBookingPool  $pool,
int  $booking_object_id,
ilBookingHelpAdapter  $help,
string  $seed = "",
string  $sseed = "",
int  $context_obj_id = 0 
)

Constructor.

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

59 {
60 global $DIC;
61
62 $this->ctrl = $DIC->ctrl();
63 $this->tpl = $DIC["tpl"];
64 $this->lng = $DIC->language();
65 $this->access = $DIC->access();
66 $this->tabs_gui = $DIC->tabs();
67 $this->user = $DIC->user();
68 $this->help = $help;
69
70 $this->context_obj_id = $context_obj_id;
71
72 $this->book_obj_id = $booking_object_id;
73
74 $this->pool = $pool;
75
76 $this->seed = $seed;
77 $this->sseed = $sseed;
78
79 $this->rsv_ids = explode(";", $_REQUEST["rsv_ids"]);
80
81
82 $this->user_id_assigner = $this->user->getId();
83 if ($_GET['bkusr']) {
84 $this->user_id_to_book = (int) $_GET['bkusr'];
85 } else {
86 $this->user_id_to_book = $this->user_id_assigner; // by default user books his own booking objects.
87 }
88 $this->ctrl->saveParameter($this, ["bkusr"]);
89 }
user()
Definition: user.php:4
$_GET["client_id"]
help()
Definition: help.php:2
$DIC
Definition: xapitoken.php:46

References $_GET, $booking_object_id, $context_obj_id, $DIC, $help, $pool, $seed, $user_id_assigner, help(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addDaysDate()

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

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

967 {
968 $date = date_parse($a_date);
969 $stamp = mktime(0, 0, 1, $date["month"], $date["day"] + $a_days, $date["year"]);
970 return date("Y-m-d", $stamp);
971 }

Referenced by confirmedBookingNumbers().

+ Here is the caller graph for this function:

◆ addDaysStamp()

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

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

974 {
975 $date = getDate($a_stamp);
976 return mktime(
977 $date["hours"],
978 $date["minutes"],
979 $date["seconds"],
980 $date["mon"],
981 $date["mday"] + $a_days,
982 $date["year"]
983 );
984 }

Referenced by confirmedBookingNumbers().

+ Here is the caller graph for this function:

◆ assignParticipants()

ilBookingProcessGUI::assignParticipants ( )

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

521 {
522 $this->tabs_gui->clearTargets();
523 $this->tabs_gui->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'back'));
524
525 $table = new ilBookingAssignParticipantsTableGUI($this, 'assignParticipants', $this->pool->getRefId(), $this->pool->getId(), $this->book_obj_id);
526
527 $this->tpl->setContent($table->getHTML());
528 }

◆ back()

ilBookingProcessGUI::back ( )
protected

Back to parent.

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

121 {
122 $this->ctrl->returnToParent($this);
123 }

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

+ Here is the caller graph for this function:

◆ book()

ilBookingProcessGUI::book ( )

First step in booking process.

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

170 {
172
173 $this->tabs_gui->clearTargets();
174 $this->tabs_gui->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'back'));
175
176 $this->setHelpId("book");
177
178 $obj = new ilBookingObject($this->book_obj_id);
179
180 $this->lng->loadLanguageModule("dateplaner");
181 $this->ctrl->setParameter($this, 'object_id', $obj->getId());
182
183 if ($this->user_id_to_book != $this->user_id_assigner) {
184 $this->ctrl->setParameter($this, 'bkusr', $this->user_id_to_book);
185 }
186
187 if ($this->pool->getScheduleType() == ilObjBookingPool::TYPE_FIX_SCHEDULE) {
188 $schedule = new ilBookingSchedule($obj->getScheduleId());
189
190 $tpl->setContent($this->renderSlots($schedule, array($obj->getId()), $obj->getTitle()));
191 } else {
192 $cgui = new ilConfirmationGUI();
193 $cgui->setHeaderText($this->lng->txt("book_confirm_booking_no_schedule"));
194
195 $cgui->setFormAction($this->ctrl->getFormAction($this));
196 $cgui->setCancel($this->lng->txt("cancel"), "back");
197 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedBooking");
198
199 $cgui->addItem("object_id", $obj->getId(), $obj->getTitle());
200
201 $tpl->setContent($cgui->getHTML());
202 }
203 }
a bookable ressource
schedule for booking ressource
Confirmation screen class.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

References $tpl, setHelpId(), and ilObjBookingPool\TYPE_FIX_SCHEDULE.

Referenced by confirmedBooking().

+ 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 533 of file class.ilBookingProcessGUI.php.

534 {
535 if ($_POST["mass"]) {
536 $participants = $_POST["mass"];
537 } else {
538 $this->back();
539 }
540
541 $this->tabs_gui->clearTargets();
542 $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, 'assignparticipants'));
543
544 $conf = new ilConfirmationGUI();
545 $conf->setFormAction($this->ctrl->getFormAction($this));
546
547 //add user list as items.
548 foreach ($participants as $id) {
550 $conf->addItem("participants[]", $id, $name);
551 }
552
553 $available = ilBookingReservation::numAvailableFromObjectNoSchedule($this->book_obj_id);
554 if (sizeof($participants) > $available) {
555 $obj = new ilBookingObject($this->book_obj_id);
556 $conf->setHeaderText(
557 sprintf(
558 $this->lng->txt('book_limit_objects_available'),
559 sizeof($participants),
560 $obj->getTitle(),
561 $available
562 )
563 );
564 } else {
565 $conf->setHeaderText($this->lng->txt('book_confirm_booking_no_schedule'));
566 $conf->addHiddenItem("object_id", $this->book_obj_id);
567 $conf->setConfirm($this->lng->txt("assign"), "saveMultipleBookings");
568 }
569
570 $conf->setCancel($this->lng->txt("cancel"), 'redirectToList');
571 $this->tpl->setContent($conf->getHTML());
572 }
$_POST["username"]
static numAvailableFromObjectNoSchedule($a_obj_id)
static _lookupFullname($a_user_id)
Lookup Full Name.
if($format !==null) $name
Definition: metadata.php:230

References $_POST, $name, ilObjUser\_lookupFullname(), back(), and ilBookingReservation\numAvailableFromObjectNoSchedule().

+ Here is the call graph for this function:

◆ checkPermission()

ilBookingProcessGUI::checkPermission (   $a_perm)
protected

Check permission.

Parameters
$a_perm

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

154 {
155 if (!$this->checkPermissionBool($a_perm)) {
156 ilUtil::sendFailure($this->lng->txt("no_permission"), true);
157 $this->back();
158 }
159 }
checkPermissionBool($a_perm)
Check permission.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References back(), checkPermissionBool(), and ilUtil\sendFailure().

Referenced by processBooking().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPermissionBool()

ilBookingProcessGUI::checkPermissionBool (   $a_perm)
protected

Check permission.

Parameters
$a_perm

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

139 {
140 $ilAccess = $this->access;
141
142 if (!$ilAccess->checkAccess($a_perm, "", $this->pool->getRefId())) {
143 return false;
144 }
145 return true;
146 }

Referenced by checkPermission().

+ Here is the caller graph for this function:

◆ confirmBookingNumbers()

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

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

741 {
743
744 $this->tabs_gui->clearTargets();
745 $this->tabs_gui->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'back'));
746
747 if (!$a_form) {
748 $a_form = $this->initBookingNumbersForm($a_objects_counter, $a_group_id);
749 }
750
751 $tpl->setContent($a_form->getHTML());
752 }
initBookingNumbersForm(array $a_objects_counter, $a_group_id, $a_reload=false)

References $tpl, and initBookingNumbersForm().

Referenced by confirmedBooking(), and confirmedBookingNumbers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmedBooking()

ilBookingProcessGUI::confirmedBooking ( )

Book object - either of type or specific - for given dates.

Returns
bool

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

616 {
617 $success = false;
618 $rsv_ids = array();
619
620 if ($this->pool->getScheduleType() != ilObjBookingPool::TYPE_FIX_SCHEDULE) {
621 if ($this->book_obj_id > 0) {
622 $object_id = $this->book_obj_id;
623 if ($object_id) {
625 !ilBookingReservation::getObjectReservationForUser($object_id, $this->user_id_to_book)) { // #18304
626 $rsv_ids[] = $this->processBooking($object_id);
627 $success = $object_id;
628 } else {
629 // #11852
630 ilUtil::sendFailure($this->lng->txt('book_reservation_failed_overbooked'), true);
631 $this->ctrl->redirect($this, 'back');
632 }
633 }
634 }
635 } else {
636 if (!isset($_POST['date'])) {
637 ilUtil::sendFailure($this->lng->txt('select_one'));
638 $this->book();
639 return false;
640 }
641
642 // single object reservation(s)
643 if ($this->book_obj_id > 0) {
644 $confirm = array();
645
646 $object_id = $this->book_obj_id;
647 if ($object_id) {
648 $group_id = null;
649 $nr = ilBookingObject::getNrOfItemsForObjects(array($object_id));
650 // needed for recurrence
652 $repo = $f->getRepo();
653 $group_id = $repo->getNewGroupId();
654 foreach ($_POST['date'] as $date) {
655 $fromto = explode('_', $date);
656 $fromto[1]--;
657
658 $counter = ilBookingReservation::getAvailableObject(array($object_id), $fromto[0], $fromto[1], false, true);
659 $counter = $counter[$object_id];
660 if ($counter) {
661 // needed for recurrence
662 $confirm[$object_id . "_" . $fromto[0] . "_" . ($fromto[1] + 1)] = $counter;
663 }
664 }
665 }
666
667 if (sizeof($confirm)) {
668 $this->confirmBookingNumbers($confirm, $group_id);
669 return false;
670 }
671 }
672 }
673
674 if ($success) {
675 $this->saveParticipant();
676 $this->handleBookingSuccess($success, $rsv_ids);
677 } else {
678 ilUtil::sendFailure($this->lng->txt('book_reservation_failed'), true);
679 $this->ctrl->redirect($this, 'book');
680 }
681 return true;
682 }
$success
Definition: Utf8Test.php:86
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items.
processBooking($a_object_id, $a_from=null, $a_to=null, $a_group_id=null)
Book object for date.
book()
First step in booking process.
confirmBookingNumbers(array $a_objects_counter, $a_group_id, ilPropertyFormGUI $a_form=null)
saveParticipant()
save booking participant.
handleBookingSuccess($a_obj_id, array $a_rsv_ids=null)
static getObjectReservationForUser($a_object_id, $a_user_id, $a_multi=false)
static getAvailableObject(array $a_ids, $a_from, $a_to, $a_return_single=true, $a_return_counter=false)
Check if any of given objects are bookable.
static isObjectAvailableNoSchedule($a_obj_id)

References $_POST, Vendor\Package\$f, $success, book(), confirmBookingNumbers(), ilBookingReservation\getAvailableObject(), ilBookingObject\getNrOfItemsForObjects(), ilBookingReservation\getObjectReservationForUser(), handleBookingSuccess(), ilBookingReservation\isObjectAvailableNoSchedule(), processBooking(), saveParticipant(), ilUtil\sendFailure(), and ilObjBookingPool\TYPE_FIX_SCHEDULE.

+ Here is the call graph for this function:

◆ confirmedBookingNumbers()

ilBookingProcessGUI::confirmedBookingNumbers ( )

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

845 {
846
847 //get the user who will get the booking.
848 if ($_POST['bkusr']) {
849 $this->user_id_to_book = (int) $_POST['bkusr'];
850 }
851
852 // convert post data to initial form config
853 $counter = array();
854 $current_first = $obj_id = null;
855 foreach (array_keys($_POST) as $id) {
856 if (substr($id, 0, 9) == "conf_nr__") {
857 $id = explode("_", substr($id, 9));
858 $counter[$id[0] . "_" . $id[1] . "_" . $id[2]] = (int) $id[3];
859 if (!$current_first) {
860 $current_first = date("Y-m-d", $id[1]);
861 }
862 }
863 }
864
865 // recurrence
866
867 // checkInput() has not been called yet, so we have to improvise
868 $end = ilCalendarUtil::parseIncomingDate($_POST["rece"], null);
869
870 if ((int) $_POST["recm"] > 0 && $end && $current_first) {
871 ksort($counter);
872 $end = $end->get(IL_CAL_DATE);
873 $cycle = (int) $_POST["recm"] * 7;
874 $cut = 0;
875 $org = $counter;
876 while ($cut < 1000 && $this->addDaysDate($current_first, $cycle) <= $end) {
877 $cut++;
878 $current_first = null;
879 foreach ($org as $item_id => $max) {
880 $parts = explode("_", $item_id);
881 $obj_id = $parts[0];
882
883 $from = $this->addDaysStamp($parts[1], $cycle * $cut);
884 $to = $this->addDaysStamp($parts[2], $cycle * $cut);
885
886 $new_item_id = $obj_id . "_" . $from . "_" . $to;
887
888 // form reload because of validation errors
889 if (!isset($counter[$new_item_id]) && date("Y-m-d", $to) <= $end) {
890 // get max available for added dates
891 $new_max = ilBookingReservation::getAvailableObject(array($obj_id), $from, $to - 1, false, true);
892 $new_max = (int) $new_max[$obj_id];
893
894 $counter[$new_item_id] = $new_max;
895
896 if (!$current_first) {
897 $current_first = date("Y-m-d", $from);
898 }
899
900 // clone input
901 $_POST["conf_nr__" . $new_item_id . "_" . $new_max] = $_POST["conf_nr__" . $item_id . "_" . $max];
902 }
903 }
904 }
905 }
906
907 $group_id = $_POST["grp_id"];
908
909 $form = $this->initBookingNumbersForm($counter, $group_id, true);
910 if ($form->checkInput()) {
911 $success = false;
912 $rsv_ids = array();
913 foreach ($counter as $id => $all_nr) {
914 $book_nr = $form->getInput("conf_nr__" . $id . "_" . $all_nr);
915 $parts = explode("_", $id);
916 $obj_id = $parts[0];
917 $from = $parts[1];
918 $to = $parts[2] - 1;
919
920 // get currently available slots
921 $counter = ilBookingReservation::getAvailableObject(array($obj_id), $from, $to, false, true);
922 $counter = $counter[$obj_id];
923 if ($counter) {
924 // we can only book what is left
925 $book_nr = min($book_nr, $counter);
926 for ($loop = 0; $loop < $book_nr; $loop++) {
927 $rsv_ids[] = $this->processBooking($obj_id, $from, $to, $group_id);
928 $success = $obj_id;
929 }
930 }
931 }
932 if ($success) {
933 $this->saveParticipant();
934 $this->handleBookingSuccess($success, $rsv_ids);
935 } else {
936 ilUtil::sendFailure($this->lng->txt('book_reservation_failed'), true);
937 $this->back();
938 }
939 } else {
940 // ilDateTimeInputGUI does NOT add hidden values on disabled!
941
942 $rece_array = explode(".", $_POST['rece']);
943
944 $rece_day = str_pad($rece_array[0], 2, "0", STR_PAD_LEFT);
945 $rece_month = str_pad($rece_array[1], 2, "0", STR_PAD_LEFT);
946 $rece_year = $rece_array[2];
947
948 // ilDateTimeInputGUI will choke on POST array format
949 $_POST["rece"] = null;
950
951 $form->setValuesByPost();
952
953 $rece_date = new ilDate($rece_year . "-" . $rece_month . "-" . $rece_day, IL_CAL_DATE);
954
955 $form->getItemByPostVar("rece")->setDate($rece_date);
956 $form->getItemByPostVar("recm")->setHideSubForm($_POST["recm"] < 1);
957
958 $hidden_date = new ilHiddenInputGUI("rece");
959 $hidden_date->setValue($rece_date);
960 $form->addItem($hidden_date);
961
962 $this->confirmBookingNumbers($counter, $group_id, $form);
963 }
964 }
const IL_CAL_DATE
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.
Class for single dates.
This class represents a hidden form property in a property form.

References $_POST, $success, addDaysDate(), addDaysStamp(), back(), confirmBookingNumbers(), ilBookingReservation\getAvailableObject(), handleBookingSuccess(), IL_CAL_DATE, initBookingNumbersForm(), ilCalendarUtil\parseIncomingDate(), processBooking(), saveParticipant(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ deliverPostFile()

ilBookingProcessGUI::deliverPostFile ( )

Deliver post booking file.

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

1100 {
1101 $id = $this->book_obj_id;
1102 if (!$id) {
1103 return;
1104 }
1105
1106 $book_id = ilBookingReservation::getObjectReservationForUser($id, $this->user_id_assigner);
1107 $obj = new ilBookingReservation($book_id);
1108 if ($obj->getUserId() != $this->user_id_assigner) {
1109 return;
1110 }
1111
1112 $obj = new ilBookingObject($id);
1113 $file = $obj->getPostFileFullPath();
1114 if ($file) {
1115 ilUtil::deliverFile($file, $obj->getPostFile());
1116 }
1117 }
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

References ilUtil\deliverFile(), and ilBookingReservation\getObjectReservationForUser().

+ Here is the call graph for this function:

◆ displayPostInfo()

ilBookingProcessGUI::displayPostInfo ( )

Display post booking informatins.

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

1013 {
1014 $tpl = $this->tpl;
1015 $lng = $this->lng;
1016 $ilCtrl = $this->ctrl;
1017 $id = $this->book_obj_id;
1018 if (!$id) {
1019 return;
1020 }
1021
1022 // placeholder
1023
1024 $book_ids = ilBookingReservation::getObjectReservationForUser($id, $this->user_id_assigner, true);
1025 $tmp = array();
1026 foreach ($book_ids as $book_id) {
1027 if (in_array($book_id, $this->rsv_ids)) {
1028 $obj = new ilBookingReservation($book_id);
1029 $from = $obj->getFrom();
1030 $to = $obj->getTo();
1031 if ($from > time()) {
1032 $tmp[$from . "-" . $to]++;
1033 }
1034 }
1035 }
1036
1039
1040 $period = array();
1041 ksort($tmp);
1042 foreach ($tmp as $time => $counter) {
1043 $time = explode("-", $time);
1045 new ilDateTime($time[0], IL_CAL_UNIX),
1046 new ilDateTime($time[1], IL_CAL_UNIX)
1047 );
1048 if ($counter > 1) {
1049 $time .= " (" . $counter . ")";
1050 }
1051 $period[] = $time;
1052 }
1053 $book_id = array_shift($book_ids);
1054
1056
1057
1058 /*
1059 #23578 since Booking pool participants.
1060 $obj = new ilBookingReservation($book_id);
1061 if ($obj->getUserId() != $ilUser->getId())
1062 {
1063 return;
1064 }
1065 */
1066
1067 $obj = new ilBookingObject($id);
1068 $pfile = $obj->getPostFile();
1069 $ptext = $obj->getPostText();
1070
1071 $mytpl = new ilTemplate('tpl.booking_reservation_post.html', true, true, 'Modules/BookingManager/BookingProcess');
1072 $mytpl->setVariable("TITLE", $lng->txt('book_post_booking_information'));
1073
1074 if ($ptext) {
1075 // placeholder
1076 $ptext = str_replace("[OBJECT]", $obj->getTitle(), $ptext);
1077 $ptext = str_replace("[PERIOD]", implode("<br />", $period), $ptext);
1078
1079 $mytpl->setVariable("POST_TEXT", nl2br($ptext));
1080 }
1081
1082 if ($pfile) {
1083 $url = $ilCtrl->getLinkTarget($this, 'deliverPostFile');
1084
1085 $mytpl->setVariable("DOWNLOAD", $lng->txt('download'));
1086 $mytpl->setVariable("URL_FILE", $url);
1087 $mytpl->setVariable("TXT_FILE", $pfile);
1088 }
1089
1090 $mytpl->setVariable("TXT_SUBMIT", $lng->txt('ok'));
1091 $mytpl->setVariable("URL_SUBMIT", $ilCtrl->getLinkTarget($this, "back"));
1092
1093 $tpl->setContent($mytpl->get());
1094 }
const IL_CAL_UNIX
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
special template class to simplify handling of ITX/PEAR
global $ilCtrl
Definition: ilias.php:18
$url
$lng

References $ilCtrl, $lng, $tpl, $url, ilDatePresentation\formatPeriod(), ilBookingReservation\getObjectReservationForUser(), IL_CAL_UNIX, ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

+ Here is the call graph for this function:

◆ executeCommand()

ilBookingProcessGUI::executeCommand ( )

Execute command.

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

95 {
96 $ctrl = $this->ctrl;
97
98 $next_class = $ctrl->getNextClass($this);
99 $cmd = $ctrl->getCmd("show");
100 switch ($next_class) {
101 default:
102 if (in_array($cmd, array("book", "back",
103 "assignParticipants",
104 "bookMultipleParticipants",
105 "saveMultipleBookings",
106 "confirmedBooking",
107 "confirmBookingNumbers",
108 "confirmedBookingNumbers",
109 "displayPostInfo",
110 "deliverPostFile"
111 ))) {
112 $this->$cmd();
113 }
114 }
115 }

◆ handleBookingSuccess()

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

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

991 {
992 ilUtil::sendSuccess($this->lng->txt('book_reservation_confirmed'), true);
993
994 // show post booking information?
995 $obj = new ilBookingObject($a_obj_id);
996 $pfile = $obj->getPostFile();
997 $ptext = $obj->getPostText();
998
999 if (trim($ptext) || $pfile) {
1000 if (sizeof($a_rsv_ids)) {
1001 $this->ctrl->setParameter($this, 'rsv_ids', implode(";", $a_rsv_ids));
1002 }
1003 $this->ctrl->redirect($this, 'displayPostInfo');
1004 } else {
1005 $this->back();
1006 }
1007 }

References back().

Referenced by confirmedBooking(), and confirmedBookingNumbers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initBookingNumbersForm()

ilBookingProcessGUI::initBookingNumbersForm ( array  $a_objects_counter,
  $a_group_id,
  $a_reload = false 
)
protected

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

756 {
757 $form = new ilPropertyFormGUI();
758 $form->setFormAction($this->ctrl->getFormAction($this, "confirmedBooking"));
759 $form->setTitle($this->lng->txt("book_confirm_booking_schedule_number_of_objects"));
760 $form->setDescription($this->lng->txt("book_confirm_booking_schedule_number_of_objects_info"));
761
762 $section = false;
763 $min_date = null;
764 foreach ($a_objects_counter as $id => $counter) {
765 $id = explode("_", $id);
766 $book_id = $id[0] . "_" . $id[1] . "_" . $id[2] . "_" . $counter;
767
768 $obj = new ilBookingObject($id[0]);
769
770 if (!$section) {
772 $section->setTitle($obj->getTitle());
773 $form->addItem($section);
774
775 $section = true;
776 }
777
778 $period = /* $this->lng->txt("book_period").": ". */
780 new ilDateTime($id[1], IL_CAL_UNIX),
781 new ilDateTime($id[2], IL_CAL_UNIX)
782 );
783
784 $nr_field = new ilNumberInputGUI($period, "conf_nr__" . $book_id);
785 $nr_field->setValue(1);
786 $nr_field->setSize(3);
787 $nr_field->setMaxValue($counter);
788 $nr_field->setMinValue($counter ? 1 : 0);
789 $nr_field->setRequired(true);
790 $form->addItem($nr_field);
791
792 if (!$min_date || $id[1] < $min_date) {
793 $min_date = $id[1];
794 }
795 }
796
797 // recurrence
798 $this->lng->loadLanguageModule("dateplaner");
799 $rec_mode = new ilSelectInputGUI($this->lng->txt("cal_recurrences"), "recm");
800 $rec_mode->setRequired(true);
801 $rec_mode->setOptions(array(
802 "-1" => $this->lng->txt("cal_no_recurrence"),
803 1 => $this->lng->txt("cal_weekly"),
804 2 => $this->lng->txt("r_14"),
805 4 => $this->lng->txt("r_4_weeks")
806 ));
807 $form->addItem($rec_mode);
808
809 $rec_end = new ilDateTimeInputGUI($this->lng->txt("cal_repeat_until"), "rece");
810 $rec_end->setRequired(true);
811 $rec_mode->addSubItem($rec_end);
812
813 if (!$a_reload) {
814 // show date only if active recurrence
815 $rec_mode->setHideSubForm(true, '>= 1');
816
817 if ($min_date) {
818 $rec_end->setDate(new ilDateTime($min_date, IL_CAL_UNIX));
819 }
820 } else {
821 // recurrence may not be changed on reload
822 $rec_mode->setDisabled(true);
823 $rec_end->setDisabled(true);
824 }
825
826 if ($a_group_id) {
827 $grp = new ilHiddenInputGUI("grp_id");
828 $grp->setValue($a_group_id);
829 $form->addItem($grp);
830 }
831
832 if ($this->user_id_assigner != $this->user_id_to_book) {
833 $usr = new ilHiddenInputGUI("bkusr");
834 $usr->setValue($this->user_id_to_book);
835 $form->addItem($usr);
836 }
837
838 $form->addCommandButton("confirmedBookingNumbers", $this->lng->txt("confirm"));
839 $form->addCommandButton("back", $this->lng->txt("cancel"));
840
841 return $form;
842 }
$section
Definition: Utf8Test.php:83
This class represents a date/time property in a property form.
This class represents a section header in a property form.
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.

References $section, ilDatePresentation\formatPeriod(), and IL_CAL_UNIX.

Referenced by confirmBookingNumbers(), and confirmedBookingNumbers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processBooking()

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

Book object for date.

Parameters
int$a_object_id
int$a_fromtimestamp
int$a_totimestamp
int$a_group_id
Returns
int

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

702 {
703 // #11995
704 $this->checkPermission('read');
705
706 $reservation = new ilBookingReservation();
707 $reservation->setObjectId($a_object_id);
708 $reservation->setUserId($this->user_id_to_book);
709 $reservation->setAssignerId($this->user_id_assigner);
710 $reservation->setFrom($a_from);
711 $reservation->setTo($a_to);
712 $reservation->setGroupId($a_group_id);
713 $reservation->setContextObjId($this->context_obj_id);
714 $reservation->save();
715
716 if ($a_from) {
717 $this->lng->loadLanguageModule('dateplaner');
718 $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $this->user_id_to_book, $this->lng->txt('cal_ch_personal_book'), true);
719
720 $object = new ilBookingObject($a_object_id);
721
722 $entry = new ilCalendarEntry;
723 $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX));
724 $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX));
725 $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle());
726 $entry->setContextId($reservation->getId());
727 $entry->save();
728
729 $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
730 $assignment->addAssignment($def_cat->getCategoryId());
731 }
732
733 return $reservation->getId();
734 }
checkPermission($a_perm)
Check permission.
Model for a calendar entry.
setStart($a_start)
@access public
static initDefaultCalendarByType($a_type_id, $a_usr_id, $a_title, $a_create=false)
Init the default calendar for given type and user.

References checkPermission(), IL_CAL_UNIX, ilCalendarUtil\initDefaultCalendarByType(), ilCalendarEntry\setStart(), and ilCalendarCategory\TYPE_BOOK.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectToList()

ilBookingProcessGUI::redirectToList ( )

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

575 {
576 $this->ctrl->redirect($this, 'assignParticipants');
577 }

◆ saveMultipleBookings()

ilBookingProcessGUI::saveMultipleBookings ( )

Save multiple users reservations for one booking pool object.

//TODO check if object/user exist in the DB,

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

584 {
585 if ($_POST["participants"] && $_POST['object_id']) {
586 $participants = $_POST["participants"];
587 $this->book_obj_id = $_POST['object_id'];
588 } else {
589 $this->back();
590 }
591 $rsv_ids = array();
592 foreach ($participants as $id) {
593 $this->user_id_to_book = $id;
594 $rsv_ids[] = $this->processBooking($this->book_obj_id);
595 }
596
597 if (sizeof($rsv_ids)) {
598 ilUtil::sendSuccess("booking_multiple_succesfully");
599 $this->back();
600 } else {
601 ilUtil::sendFailure($this->lng->txt('book_reservation_failed_overbooked'), true);
602 $this->back();
603 }
604 }

References $_POST, back(), processBooking(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ saveParticipant()

ilBookingProcessGUI::saveParticipant ( )
protected

save booking participant.

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

688 {
689 $participant = new ilBookingParticipant($this->user_id_to_book, $this->pool->getId());
690 }
Class ilBookingParticipant.

Referenced by confirmedBooking(), and confirmedBookingNumbers().

+ Here is the caller graph for this function:

◆ setHelpId()

ilBookingProcessGUI::setHelpId ( string  $a_id)
protected
Parameters
string$a_id

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

129 {
130 $this->help->setHelpId($a_id);
131 }

References help().

Referenced by book().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $booking_object_id

ilBookingProcessGUI::$booking_object_id
protected

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

Referenced by __construct().

◆ $context_obj_id

ilBookingProcessGUI::$context_obj_id
protected

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

Referenced by __construct().

◆ $help

ilBookingProcessGUI::$help
protected

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

Referenced by __construct().

◆ $pool

ilBookingProcessGUI::$pool
protected

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

Referenced by __construct().

◆ $seed

ilBookingProcessGUI::$seed
protected

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

Referenced by __construct().

◆ $user_id_assigner

ilBookingProcessGUI::$user_id_assigner
protected

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

Referenced by __construct().

◆ $user_id_to_book

ilBookingProcessGUI::$user_id_to_book
protected

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


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