ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAppointmentPresentationConsultationHoursGUI.php
Go to the documentation of this file.
1 <?php
2 include_once './Services/Calendar/interfaces/interface.ilCalendarAppointmentPresentation.php';
3 include_once './Services/Calendar/classes/AppointmentPresentation/class.ilAppointmentPresentationGUI.php';
4 
15 {
16  public function collectPropertiesAndActions()
17  {
18  include_once('./Services/Link/classes/class.ilLink.php');
19 
20  $a_app = $this->appointment;
21 
22  $cat_id = $this->getCatId($a_app['event']->getEntryId());
23  $cat_info = $this->getCatInfo($cat_id);
24  $context_id = $a_app['event']->getContextId();
25 
26  $this->addCommonSection($a_app, $cat_info['obj_id']);
27 
28  //objects
29  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
30  $booking = new ilBookingEntry($context_id);
31 
32  if ($manager = ilConsultationHourAppointments::getManager(true, true, $booking->getObjId())) {
33  $this->addInfoProperty($this->lng->txt("cal_ch_manager"), $manager);
34  }
35 
36  if ($booking->isOwner()) {
37  $buttons = array();
38  foreach ($booking->getTargetObjIds() as $obj_id) {
39  //$this->addObjectLinks($obj_id);
40 
42  $refs = $this->getReadableRefIds($obj_id);
43  reset($refs);
44 
45  foreach ($refs as $ref_id) {
46  $link_title = $title;
47  if (count($refs) > 1) {
48  $par_ref = $this->tree->getParentId($ref_id);
49  $link_title .= " (" . ilObject::_lookupTitle(ilObject::_lookupObjId($par_ref)) . ")";
50  }
51  $buttons[] = $this->ui->renderer()->render(
52  $this->ui->factory()->button()->shy($link_title, ilLink::_getStaticLink($ref_id))
53  );
54  }
55  }
56  if (count($buttons) > 0) {
57  $this->addInfoProperty($this->lng->txt("cal_repo_obj"), implode("<br>", $buttons));
58  }
59  }
60 
61  // owner
62  $this->addInfoProperty($this->lng->txt('cal_ch_booking_owner'), ilObjUser::_lookupFullname($booking->getObjId()));
63 
64  if ($deadline = $booking->getDeadlineHours()) {
65  $limit = $a_app['dstart'] - ($deadline * 60 * 60);
66 
67  if (time() > $limit) {
68  $this->addInfoProperty($this->lng->txt("cal_ch_deadline"), $this->lng->txt("exc_time_over_short"));
69  //$this->addListItemProperty($this->lng->txt("cal_ch_deadline"),$this->lng->txt("exc_time_over_short"));
70  } else {
71  //appointment starts at -> $a_app['dstart']
72  //limit registration -> $a_app['dstart'] - $deadline
73 
74  //$string = ilUtil::period2String(new ilDateTime($limit, IL_CAL_UNIX));
76 
77  $this->addInfoProperty($this->lng->txt("cal_ch_deadline"), $string);
78  $this->addListItemProperty($this->lng->txt("cal_ch_deadline"), $string);
79  }
80  }
81 
82  // max nr of bookings
83  $this->addInfoProperty($this->lng->txt('cal_ch_num_bookings'), $booking->getNumberOfBookings());
84  $this->addListItemProperty($this->lng->txt('cal_ch_num_bookings'), $booking->getNumberOfBookings());
85 
86  // for the following code
87  // see ilCalendarAppointmentPanelGUI in ILIAS 5.2 (getHTML())
88  $is_owner = $booking->isOwner();
89  $user_entry = ($cat_info['obj_id'] == $this->user->getId());
90 
91  if ($user_entry && !$is_owner) {
92  // find source calendar entry in owner calendar
93  include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
94  $apps = ilConsultationHourAppointments::getAppointmentIds($booking->getObjId(), $a_app['event']->getContextId(), $a_app['event']->getStart());
95  $ref_event = $apps[0];
96  } else {
97  $ref_event = $a_app['event']->getEntryId();
98  }
99 
100  $cb = $booking->getCurrentNumberOfBookings($ref_event);
101  if (!$is_owner) {
102  $this->addInfoProperty($this->lng->txt('cal_ch_current_bookings'), $cb);
103  }
104  $this->addListItemProperty($this->lng->txt('cal_ch_current_bookings'), $cb);
105 
106  if (!$is_owner) {
107  if ($booking->hasBooked($ref_event)) {
108  if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) {
109  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
110  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
111  $this->addAction(
112  $this->lng->txt('cal_ch_cancel_booking'),
113  $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')
114  );
115  }
116  } elseif ($booking->isAppointmentBookableForUser($ref_event, $GLOBALS['ilUser']->getId())) {
117  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
118  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
119  $this->addAction(
120  $this->lng->txt('cal_ch_book'),
121  $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'book')
122  );
123  }
124  } else {
125  // list booking users
126  $link_users = true;
128  $link_users = false;
129  }
130  include_once './Services/Link/classes/class.ilLink.php';
131  $users = array();
132  foreach ($booking->getCurrentBookings($a_app['event']->getEntryId()) as $user_id) {
133  if ($link_users) {
134  $users[] = $this->getUserName($user_id);
135  } else {
136  $users[] = ilObjUser::_lookupFullname($user_id);
137  }
138  }
139  if ($users) {
140  $this->addInfoProperty($this->lng->txt('cal_ch_current_bookings'), implode('<br>', $users));
141  }
142  }
143 
144  // last edited
145  $this->addLastUpdate($a_app);
146  }
147 }
addInfoProperty($a_txt, $a_val)
Add info property.
getUserName($a_user_id, $a_force_name=false)
Get (linked if possible) user name.
getReadableRefIds($a_obj_id)
Get readable ref ids.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static getAppointmentIds($a_user_id, $a_context_id=null, $a_start=null, $a_type=null, $a_check_owner=true)
Get all appointment ids.
Booking definition.
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
user()
Definition: user.php:4
addCommonSection($a_app, $a_obj_id=0, $cat_info=null, $a_container_info=false)
Add common section.
static _lookupObjId($a_id)
Date and time handling
static _getInstance($a_usr_id=0)
get singleton instance
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
addListItemProperty($a_txt, $a_val)
Add list item property.
static getManager($a_as_name=false, $a_full_name=false, $a_user_id=null)
Get consultation hour manager for current user or specific user.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.