ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarAppointmentsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
25{
26 private int $cat_id = 0;
28 private bool $is_editable = false;
29
30 public function __construct(object $a_parent_obj, string $a_parent_cmd, int $a_category_id)
31 {
32 global $DIC;
33
34 $this->categories = ilCalendarCategories::_getInstance();
35 $this->cat_id = $a_category_id;
36 $this->is_editable = $this->categories->isEditable($this->cat_id);
37
38 $this->setId('calcalapps');
39 parent::__construct($a_parent_obj, $a_parent_cmd);
40
41 $this->lng->loadLanguageModule('dateplaner');
42
43 $this->setFormName('appointments');
44 $this->addColumn('', 'f', "1");
45 $this->addColumn($this->lng->txt('cal_start'), 'dt_sort', "30%");
46 $this->addColumn($this->lng->txt('title'), 'title', "60%");
47 $this->addColumn($this->lng->txt('cal_duration'), 'duration', "20%");
48 $this->addColumn($this->lng->txt('cal_recurrences'), 'frequence', "10%");
49
50 if ($this->is_editable) {
51 $this->addMultiCommand('askDeleteAppointments', $this->lng->txt('delete'));
52 $this->enable('select_all');
53 } else {
54 $this->disable('select_all');
55 }
56
57 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
58 $this->setRowTemplate("tpl.show_appointment_row.html", "components/ILIAS/Calendar");
59
60 $this->setShowRowsSelector(true);
61 $this->enable('sort');
62 $this->enable('header');
63 $this->enable('numinfo');
64
65 $this->setDefaultOrderField('dt_sort');
66 $this->setSelectAllCheckbox('appointments');
67 }
68
69 protected function fillRow(array $a_set): void
70 {
71 if ($a_set['deletable']) {
72 $this->tpl->setVariable('VAL_ID', $a_set['id']);
73 }
74
75 $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']);
76
77 $this->tpl->setVariable('VAL_TITLE_LINK', $a_set['title']);
78 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_set['id']);
79 $this->tpl->setVariable('VAL_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
80
81 switch ($a_set['frequence']) {
83 $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_daily'));
84 break;
85
87 $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_weekly'));
88 break;
89
91 $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_monthly'));
92 break;
93
95 $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_yearly'));
96 break;
97
98 default:
99 //$this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence'));
100 $this->tpl->setVariable('VAL_FREQUENCE', '');
101 break;
102 }
103 $this->tpl->setVariable('VAL_BEGIN', $a_set['dt']);
104 if ($a_set['duration']) {
105 $this->tpl->setVariable('VAL_DURATION', ilDatePresentation::secondsToString($a_set['duration']));
106 } else {
107 $this->tpl->setVariable('VAL_DURATION', '');
108 }
109 }
110
115 public function setAppointments(array $a_apps): void
116 {
117 $cat = new ilCalendarCategory($this->cat_id);
118
119 $appointments = [];
120 foreach ($a_apps as $cal_entry_id) {
121 $entry = new ilCalendarEntry($cal_entry_id);
122 $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
123
124 // booking
125 $title = '';
126 if ($cat->getType() == ilCalendarCategory::TYPE_CH) {
127 $book = new ilBookingEntry($entry->getContextId());
128 if ($book) {
129 $title = $entry->getTitle();
130 if ($book->isOwner()) {
131 $max = $book->getNumberOfBookings();
132 $current = $book->getCurrentNumberOfBookings($entry->getEntryId());
133 if ($max > 1) {
134 $title .= ' (' . $current . '/' . $max . ')';
135 } elseif ($current == $max) {
136 $title .= ' (' . $this->lng->txt('cal_booked_out') . ')';
137 } else {
138 $title .= ' (' . $this->lng->txt('cal_book_free') . ')';
139 }
140 } elseif ($book->hasBooked($entry->getEntryId())) {
141 $title .= ' (' . $this->lng->txt('cal_date_booked') . ')';
142 }
143 }
144 } else {
145 $title = $entry->getPresentationTitle();
146 }
147
148 $tmp_arr['id'] = $entry->getEntryId();
149 $tmp_arr['title'] = $title;
150 $tmp_arr['description'] = $entry->getDescription();
151 $tmp_arr['fullday'] = $entry->isFullday();
152 $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
153 $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
154
155 $tmp_arr['dt_sort'] = $entry->getStart()->get(IL_CAL_UNIX);
156 $tmp_arr['dt'] = ilDatePresentation::formatPeriod(
157 $entry->getStart(),
158 $entry->getEnd()
159 );
160
161 $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
162 if ($tmp_arr['fullday']) {
163 $tmp_arr['duration'] += (60 * 60 * 24);
164 }
165
166 if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) {
167 $tmp_arr['duration'] = '';
168 }
169 $tmp_arr['frequence'] = $rec->getFrequenceType();
170 $tmp_arr['deletable'] = (!$entry->isAutoGenerated() and $this->is_editable);
171
172 $appointments[] = $tmp_arr;
173 }
174 $this->setData($appointments);
175 }
176}
const IL_CAL_UNIX
Booking definition.
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_category_id)
class for calendar categories
static _getInstance($a_usr_id=0)
get singleton instance
Stores calendar categories.
Model for a calendar entry.
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
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.
setFormName(string $a_name="")
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)
disable(string $a_module_name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26