ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAppointmentPresentationConsultationHoursGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 public function collectPropertiesAndActions(): void
29 {
30 $a_app = $this->appointment;
31
32 $cat_id = $this->getCatId($a_app['event']->getEntryId());
33 $cat_info = $this->getCatInfo();
34 $context_id = $a_app['event']->getContextId();
35
36 $this->addCommonSection($a_app, $cat_info['obj_id']);
37
38 //objects
39 $booking = new ilBookingEntry($context_id);
40
41 if ($manager = ilConsultationHourAppointments::getManager(true, true, $booking->getObjId())) {
42 $this->addInfoProperty($this->lng->txt("cal_ch_manager"), $manager);
43 }
44
45 if ($booking->isOwner($this->user->getId())) {
46 $buttons = array();
47 foreach ($booking->getTargetObjIds() as $obj_id) {
48 //$this->addObjectLinks($obj_id, $this->appointment);
49
51 $refs = $this->getReadableRefIds($obj_id);
52 reset($refs);
53
54 foreach ($refs as $ref_id) {
55 $link_title = $title;
56 if (count($refs) > 1) {
57 $par_ref = $this->tree->getParentId($ref_id);
58 $link_title .= " (" . ilObject::_lookupTitle(ilObject::_lookupObjId($par_ref)) . ")";
59 }
60 $buttons[] = $this->ui->renderer()->render(
61 $this->ui->factory()->button()->shy($link_title, ilLink::_getStaticLink($ref_id))
62 );
63 }
64 }
65 if (count($buttons) > 0) {
66 $this->addInfoProperty($this->lng->txt("cal_repo_obj"), implode("<br>", $buttons));
67 }
68 }
69
70 // owner
71 $this->addInfoProperty(
72 $this->lng->txt('cal_ch_booking_owner'),
73 ilObjUser::_lookupFullname($booking->getObjId())
74 );
75
76 if ($deadline = $booking->getDeadlineHours()) {
77 $limit = $a_app['dstart'] - ($deadline * 60 * 60);
78
79 if (time() > $limit) {
80 $this->addInfoProperty($this->lng->txt("cal_ch_deadline"), $this->lng->txt("exc_time_over_short"));
81 //$this->addListItemProperty($this->lng->txt("cal_ch_deadline"),$this->lng->txt("exc_time_over_short"));
82 } else {
83 //appointment starts at -> $a_app['dstart']
84 //limit registration -> $a_app['dstart'] - $deadline
85
86 //$string = ilUtil::period2String(new ilDateTime($limit, IL_CAL_UNIX));
88
89 $this->addInfoProperty($this->lng->txt("cal_ch_deadline"), $string);
90 $this->addListItemProperty($this->lng->txt("cal_ch_deadline"), $string);
91 }
92 }
93
94 $free = $booking->getNumberOfBookings() - $booking->getCurrentNumberOfBookings($a_app['event']->getEntryId());
95 $this->addInfoProperty(
96 $this->lng->txt('cal_ch_booking_num_available'),
97 sprintf($this->lng->txt('cal_ch_free_of_available'), $free, $booking->getNumberOfBookings())
98 );
100 $this->lng->txt('cal_ch_booking_num_available'),
101 sprintf($this->lng->txt('cal_ch_free_of_available'), $free, $booking->getNumberOfBookings())
102 );
103
104 // for the following code
105 // see ilCalendarAppointmentPanelGUI in ILIAS 5.2 (getHTML())
106 $is_owner = $booking->isOwner($this->user->getId());
107 $user_entry = ($cat_info['obj_id'] == $this->user->getId());
108
109 if ($user_entry && !$is_owner) {
110 // find source calendar entry in owner calendar
112 $booking->getObjId(),
113 $a_app['event']->getContextId(),
114 $a_app['event']->getStart()
115 );
116 $ref_event = $apps[0];
117 } else {
118 $ref_event = $a_app['event']->getEntryId();
119 }
120
121 $cb = $booking->getCurrentNumberOfBookings($ref_event);
122 if (!$is_owner) {
123 if ($booking->hasBooked($ref_event)) {
124 if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) {
125 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
126 //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
127 $this->addAction(
128 $this->lng->txt('cal_ch_cancel_booking'),
129 $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')
130 );
131 }
132 } elseif ($booking->isAppointmentBookableForUser($ref_event, $GLOBALS['DIC']['ilUser']->getId())) {
133 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
134 //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
135 $this->addAction(
136 $this->lng->txt('cal_ch_book'),
137 $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'book')
138 );
139 }
140 } else {
141 // current user is owner of booking
142 if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) {
143 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
144 $this->addAction(
145 $this->lng->txt('cal_ch_cancel_booking'),
146 $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')
147 );
148 $this->addAction(
149 $this->lng->txt('cal_ch_delete_booking'),
150 $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'deleteBooking')
151 );
152 }
153 $link_users = true;
155 $link_users = false;
156 }
157 $users = [];
158 $booking_comments = [];
159 foreach ($booking->getCurrentBookings($a_app['event']->getEntryId()) as $user_id) {
160
162 $a_app['event']->getEntryId(),
164 );
165 if ($link_users) {
166 $users[$user_id] = $this->getUserName($user_id);
167 } else {
169 }
170 }
171 if ($users) {
172 foreach ($booking_comments as $user_id => $comment) {
173 $this->addInfoProperty($this->lng->txt('cal_ch_current_bookings'), $users[$user_id]);
174 $this->addInfoProperty($this->lng->txt('cal_ch_current_booking_comment'), $comment);
175 }
176 $this->addListItemProperty($this->lng->txt('cal_ch_current_bookings'), implode(' ', $users));
177 }
178 }
179 }
180}
$comment
Definition: buildRTE.php:72
const IL_CAL_UNIX
addInfoProperty(string $a_txt, string $a_val)
Add info property.
addCommonSection(array $a_app, int $a_obj_id=0, ?array $cat_info=null, bool $a_container_info=false)
addAction(string $a_txt, string $a_link)
Add action.
getUserName(int $a_user_id, bool $a_force_name=false)
Get (linked if possible) user name.
addListItemProperty(string $a_txt, string $a_val)
Add list item property.
Booking definition.
static lookupBookingMessage(int $a_entry_id, int $a_usr_id)
static _getInstance($a_usr_id=0)
get singleton instance
static getManager(bool $a_as_name=false, bool $a_full_name=false, ?int $a_user_id=null)
Get consultation hour manager for current user or specific user.
static getAppointmentIds(int $a_user_id, ?int $a_context_id=null, ?ilDateTime $a_start=null, ?int $a_type=null, bool $a_check_owner=true)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _lookupFullname(int $a_user_id)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
$ref_id
Definition: ltiauth.php:66
$GLOBALS["DIC"]
Definition: wac.php:54