ILIAS  release_8 Revision v8.23
class.ilAppointmentPresentationConsultationHoursGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
11 {
12  public function collectPropertiesAndActions(): void
13  {
14  $a_app = $this->appointment;
15 
16  $cat_id = $this->getCatId($a_app['event']->getEntryId());
17  $cat_info = $this->getCatInfo();
18  $context_id = $a_app['event']->getContextId();
19 
20  $this->addCommonSection($a_app, $cat_info['obj_id']);
21 
22  //objects
23  $booking = new ilBookingEntry($context_id);
24 
25  if ($manager = ilConsultationHourAppointments::getManager(true, true, $booking->getObjId())) {
26  $this->addInfoProperty($this->lng->txt("cal_ch_manager"), $manager);
27  }
28 
29  if ($booking->isOwner()) {
30  $buttons = array();
31  foreach ($booking->getTargetObjIds() as $obj_id) {
32  //$this->addObjectLinks($obj_id, $this->appointment);
33 
35  $refs = $this->getReadableRefIds($obj_id);
36  reset($refs);
37 
38  foreach ($refs as $ref_id) {
39  $link_title = $title;
40  if (count($refs) > 1) {
41  $par_ref = $this->tree->getParentId($ref_id);
42  $link_title .= " (" . ilObject::_lookupTitle(ilObject::_lookupObjId($par_ref)) . ")";
43  }
44  $buttons[] = $this->ui->renderer()->render(
45  $this->ui->factory()->button()->shy($link_title, ilLink::_getStaticLink($ref_id))
46  );
47  }
48  }
49  if (count($buttons) > 0) {
50  $this->addInfoProperty($this->lng->txt("cal_repo_obj"), implode("<br>", $buttons));
51  }
52  }
53 
54  // owner
55  $this->addInfoProperty(
56  $this->lng->txt('cal_ch_booking_owner'),
57  ilObjUser::_lookupFullname($booking->getObjId())
58  );
59 
60  if ($deadline = $booking->getDeadlineHours()) {
61  $limit = $a_app['dstart'] - ($deadline * 60 * 60);
62 
63  if (time() > $limit) {
64  $this->addInfoProperty($this->lng->txt("cal_ch_deadline"), $this->lng->txt("exc_time_over_short"));
65  //$this->addListItemProperty($this->lng->txt("cal_ch_deadline"),$this->lng->txt("exc_time_over_short"));
66  } else {
67  //appointment starts at -> $a_app['dstart']
68  //limit registration -> $a_app['dstart'] - $deadline
69 
70  //$string = ilUtil::period2String(new ilDateTime($limit, IL_CAL_UNIX));
72 
73  $this->addInfoProperty($this->lng->txt("cal_ch_deadline"), $string);
74  $this->addListItemProperty($this->lng->txt("cal_ch_deadline"), $string);
75  }
76  }
77 
78  // max nr of bookings
79  $this->addInfoProperty($this->lng->txt('cal_ch_num_bookings'), (string) $booking->getNumberOfBookings());
80  $this->addListItemProperty($this->lng->txt('cal_ch_num_bookings'), (string) $booking->getNumberOfBookings());
81 
82  // for the following code
83  // see ilCalendarAppointmentPanelGUI in ILIAS 5.2 (getHTML())
84  $is_owner = $booking->isOwner();
85  $user_entry = ($cat_info['obj_id'] == $this->user->getId());
86 
87  if ($user_entry && !$is_owner) {
88  // find source calendar entry in owner calendar
90  $booking->getObjId(),
91  $a_app['event']->getContextId(),
92  $a_app['event']->getStart()
93  );
94  $ref_event = $apps[0];
95  } else {
96  $ref_event = $a_app['event']->getEntryId();
97  }
98 
99  $cb = $booking->getCurrentNumberOfBookings($ref_event);
100  if (!$is_owner) {
101  $this->addInfoProperty($this->lng->txt('cal_ch_current_bookings'), (string) $cb);
102  }
103  $this->addListItemProperty($this->lng->txt('cal_ch_current_bookings'), (string) $cb);
104 
105  if (!$is_owner) {
106  if ($booking->hasBooked($ref_event)) {
107  if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) {
108  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
109  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
110  $this->addAction(
111  $this->lng->txt('cal_ch_cancel_booking'),
112  $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')
113  );
114  }
115  } elseif ($booking->isAppointmentBookableForUser($ref_event, $GLOBALS['DIC']['ilUser']->getId())) {
116  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
117  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
118  $this->addAction(
119  $this->lng->txt('cal_ch_book'),
120  $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'book')
121  );
122  }
123  } else {
124  // list booking users
125  $link_users = true;
127  $link_users = false;
128  }
129  $users = array();
130  foreach ($booking->getCurrentBookings($a_app['event']->getEntryId()) as $user_id) {
131  if ($link_users) {
132  $users[] = $this->getUserName($user_id);
133  } else {
134  $users[] = ilObjUser::_lookupFullname($user_id);
135  }
136  }
137  if ($users) {
138  $this->addInfoProperty($this->lng->txt('cal_ch_current_bookings'), implode('<br>', $users));
139  }
140  }
141 
142  // last edited
143  $this->addLastUpdate($a_app);
144  }
145 }
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.
addListItemProperty(string $a_txt, string $a_val)
Add list item property.
static _lookupFullname(int $a_user_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
addInfoProperty(string $a_txt, string $a_val)
Add info property.
static _lookupObjId(int $ref_id)
addLastUpdate(array $a_app)
Add last update.
static getAppointmentIds(int $a_user_id, int $a_context_id=null, ?ilDateTime $a_start=null, ?int $a_type=null, bool $a_check_owner=true)
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
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.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
getUserName(int $a_user_id, bool $a_force_name=false)
Get (linked if possible) user name.
static _getInstance($a_usr_id=0)
get singleton instance
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.