ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilConsultationHourBookingTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\UI\Factory as UIFactory;
22use ILIAS\UI\Renderer as UIRenderer;
23
28{
29 private int $user_id = 0;
30
32 private UIRenderer $renderer;
33 private UIFactory $uiFactory;
34
35 public function __construct(object $a_parent_obj, string $a_parent_cmd, int $a_user_id)
36 {
37 $this->user_id = $a_user_id;
38 $this->setId('chboo_' . $this->user_id);
39 parent::__construct($a_parent_obj, $a_parent_cmd);
40
41 global $DIC;
42 $this->renderer = $DIC->ui()->renderer();
43 $this->uiFactory = $DIC->ui()->factory();
44
45 $this->initTable();
46 $this->today = new ilDateTime(time(), IL_CAL_UNIX);
47 }
48
52 protected function initTable(): void
53 {
54 $this->setRowTemplate('tpl.ch_booking_row.html', 'components/ILIAS/Calendar');
55
56 $this->setTitle($this->lng->txt('cal_ch_bookings_tbl'));
57 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), $this->getParentCmd()));
58
59 $this->addColumn('', '', '1px');
60 $this->addColumn($this->lng->txt('cal_start'), 'start');
61 $this->addColumn($this->lng->txt('name'), 'name');
62 $this->addColumn($this->lng->txt('cal_ch_booking_message_tbl'), 'comment');
63 $this->addColumn($this->lng->txt('title'), 'title');
64 $this->addColumn($this->lng->txt('actions'), '');
65
66 $this->enable('sort');
67 $this->enable('header');
68 $this->enable('num_info');
69
70 $this->setDefaultOrderField('start');
71 $this->setSelectAllCheckbox('bookuser');
72 $this->setShowRowsSelector(true);
73 $this->addMultiCommand('confirmRejectBooking', $this->lng->txt('cal_ch_reject_booking'));
74 $this->addMultiCommand('confirmDeleteBooking', $this->lng->txt('cal_ch_delete_booking'));
75 }
76
80 protected function fillRow(array $a_set): void
81 {
82 $this->tpl->setVariable('START', $a_set['start_str']);
83 $this->tpl->setVariable('NAME', $a_set['name']);
84 $this->tpl->setVariable('COMMENT', $a_set['comment']);
85 $this->tpl->setVariable('TITLE', $a_set['title']);
86 $this->tpl->setVariable('VAL_ID', $a_set['id']);
87
88 $dropDownItems = array();
89
90 $this->ctrl->setParameter($this->getParentObject(), 'bookuser', $a_set['id']);
91
92 $start = new ilDateTime($a_set['start'], IL_CAL_UNIX);
93 if (ilDateTime::_after($start, $this->today, IL_CAL_DAY)) {
94 $dropDownItems[] = $this->uiFactory->button()->shy(
95 $this->lng->txt('cal_ch_reject_booking'),
96 $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmRejectBooking')
97 );
98 }
99
100 $dropDownItems[] = $this->uiFactory->button()->shy(
101 $this->lng->txt('cal_ch_delete_booking'),
102 $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmDeleteBooking')
103 );
104 $dropDown = $this->uiFactory->dropdown()->standard($dropDownItems)
105 ->withLabel($this->lng->txt('actions'));
106 $this->tpl->setVariable('ACTIONS', $this->renderer->render($dropDown));
107 }
108
113 public function parse(array $appointments): void
114 {
115 $rows = array();
116 $counter = 0;
117 foreach ($appointments as $app) {
118 $cal_entry = new ilCalendarEntry($app);
119
122 $user_id,
123 true,
124 true,
125 $this->ctrl->getLinkTarget($this->getParentObject(), $this->getParentCmd()),
126 true,
127 true
128 );
129
131 $rows[$counter]['comment'] = '';
132 if (strlen(trim($message))) {
133 $rows[$counter]['comment'] = ('"' . $message . '"');
134 }
135 $rows[$counter]['title'] = $cal_entry->getTitle();
136 $rows[$counter]['start'] = $cal_entry->getStart()->get(IL_CAL_UNIX);
137 $rows[$counter]['start_str'] = ilDatePresentation::formatDate($cal_entry->getStart());
138 $rows[$counter]['id'] = $app . '_' . $user_id;
139 ++$counter;
140 }
141 }
142 $this->setData($rows);
143 }
144}
renderer()
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
const IL_CAL_UNIX
const IL_CAL_DAY
static lookupBookingsForAppointment(int $a_app_id)
Lookup booked users for appointment.
static lookupBookingMessage(int $a_entry_id, int $a_usr_id)
Model for a calendar entry.
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_user_id)
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
enable(string $a_module_name)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
An entity that renders components to a string output.
Definition: Renderer.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$counter
$message
Definition: xapiexit.php:31