ILIAS  release_8 Revision v8.24
class.ilEmployeeTalkTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
23
25{
26 public const STATUS_ALL = 0;
27 public const STATUS_PENDING = 1;
28 public const STATUS_COMPLETED = 2;
29
31
32 public function __construct(ControlFlowCommandHandler $a_parent_obj, $a_parent_cmd = "")
33 {
37 $container = $GLOBALS['DIC'];
38
39 $this->language = $container->language();
40 $this->language->loadLanguageModule('etal');
41 $this->language->loadLanguageModule('orgu');
42
43 $this->setPrefix('myst_etal_list_');
44 $this->setFormName('myst_etal_list');
45 $this->setId('myst_etal_list');
46
47 parent::__construct($a_parent_obj, $a_parent_cmd, '');
48 $this->setRowTemplate('tpl.list_employee_talk_row.html', "Modules/EmployeeTalk");
49 $this->setFormAction($container->ctrl()->getFormAction($a_parent_obj));
50 ;
51 $this->setDefaultOrderDirection('desc');
52
53 $this->setShowRowsSelector(true);
54
55
56 $this->setEnableTitle(true);
57 $this->setDisableFilterHiding(true);
58 $this->setEnableNumInfo(true);
59 //$this->setExternalSorting(false);
60 //$this->setExternalSegmentation(false);
61 $this->setExternalSegmentation(true);
62
63 //$this->setExportFormats(array(self::EXPORT_EXCEL, self::EXPORT_CSV));
64 $this->addColumns();
65
66 $this->initFilter();
67 $this->determineLimit();
69 }
70
71 public function initFilter(): void
72 {
73 $this->setFilterCols(6);
74 $this->addFilterItemByMetaType('etal_title', self::FILTER_TEXT, false, $this->language->txt('title'));
75 $this->addFilterItemByMetaType('etal_template', self::FILTER_TEXT, false, $this->language->txt('type'));
76
80 $dateSelectInput = $this->addFilterItemByMetaType('etal_date', self::FILTER_DATE, false, $this->language->txt('date_of_talk'));
81
82 // Filter throws a null pointer error if not set
83 if ($dateSelectInput->getDate() === null) {
84 $dateSelectInput->setDate(new ilDateTime());
85 }
86 $this->addFilterItemByMetaType('etal_superior', self::FILTER_TEXT, false, $this->language->txt('superior'));
87 $this->addFilterItemByMetaType('etal_employee', self::FILTER_TEXT, false, $this->language->txt('employee'));
91 $ilSelectInput = $this->addFilterItemByMetaType('etal_status', self::FILTER_SELECT, false, $this->language->txt('status'));
92 $ilSelectInput->setOptions([
93 self::STATUS_ALL => $this->language->txt('etal_status_all'),
94 self::STATUS_PENDING => $this->language->txt('etal_status_pending'),
95 self::STATUS_COMPLETED => $this->language->txt('etal_status_completed')
96 ]);
97 }
98
99 private function addColumns(): void
100 {
101 $this->addColumn(
102 $this->language->txt('title'),
103 "etal_title",
104 "auto"
105 );
106 $this->addColumn(
107 $this->language->txt('type'),
108 "etal_template",
109 "auto"
110 );
111 $this->addColumn(
112 $this->language->txt('date_of_talk'),
113 "etal_date",
114 "auto"
115 );
116 $this->addColumn(
117 $this->language->txt('superior'),
118 "etal_superior",
119 "auto"
120 );
121 $this->addColumn(
122 $this->language->txt('employee'),
123 "etal_employee",
124 "auto"
125 );
126 $this->addColumn(
127 $this->language->txt('status'),
128 "etal_status",
129 "auto"
130 );
131 $this->addColumn(
132 $this->language->txt('action'),
133 "",
134 "auto"
135 );
136
137 $this->setDefaultFilterVisiblity(true);
138 $this->setDefaultOrderField("etal_date");
139 }
140
141 protected function fillRow($a_set): void
142 {
143 $class = strtolower(ilObjEmployeeTalkGUI::class);
144 $classPath = [
145 strtolower(ilDashboardGUI::class),
146 strtolower(ilMyStaffGUI::class),
147 strtolower(ilEmployeeTalkMyStaffListGUI::class),
148 $class
149 ];
150 $this->ctrl->setParameterByClass($class, "ref_id", $a_set["ref_id"]);
151 $url = $this->ctrl->getLinkTargetByClass($classPath, ControlFlowCommand::DEFAULT);
152
153 $actions = new ilAdvancedSelectionListGUI();
154 $actions->setListTitle($this->language->txt("actions"));
155 $actions->setAsynch(true);
156 $actions->setId((string) $a_set["ref_id"]);
157
158 $actions->setAsynchUrl(
159 str_replace("\\", "\\\\", $this->ctrl->getLinkTargetByClass(
160 [
161 strtolower(ilDashboardGUI::class),
162 strtolower(ilMyStaffGUI::class),
163 strtolower(ilEmployeeTalkMyStaffListGUI::class)
164 ],
165 ControlFlowCommand::TABLE_ACTIONS,
166 "",
167 true
168 )) . '&ref_id=' . $a_set["ref_id"]
169 );
170
171 $this->tpl->setVariable("HREF_ETAL_TITLE", $url);
172 $this->tpl->setVariable("VAL_ETAL_TITLE", $a_set['etal_title']);
173 $this->tpl->setVariable("VAL_ETAL_TEMPLATE", $a_set['etal_template']);
174 $this->tpl->setVariable("VAL_ETAL_DATE", ilDatePresentation::formatDate($a_set['etal_date']));
175 $this->tpl->setVariable("VAL_ETAL_SUPERIOR", $a_set['etal_superior']);
176 $this->tpl->setVariable("VAL_ETAL_EMPLOYEE", $a_set['etal_employee']);
177 $this->tpl->setVariable("VAL_ETAL_STATUS", $a_set['etal_status']);
178 $this->tpl->setVariable("ACTIONS", $actions->getHTML());
179 }
180
181 public function setTalkData(array $talks): void
182 {
183 $filter = $this->getCurrentState()['filter_values'];
184
185 $data = [];
186 foreach ($talks as $val) {
187 if (!ilObject::_hasUntrashedReference($val->getObjectId())) {
188 continue;
189 }
190
191 if (trim($filter['etal_employee']) !== "") {
192 $filterUser = ilObjUser::getUserIdByLogin(trim($filter['etal_employee']));
193 if ($val->getEmployee() !== $filterUser) {
194 continue;
195 }
196 }
197
198 $refIds = ilObjEmployeeTalk::_getAllReferences($val->getObjectId());
199 $talk = new ilObjEmployeeTalk(array_pop($refIds), true);
200 $talkData = $talk->getData();
201 $employeeName = $this->language->txt('etal_unknown_username');
202 $superiorName = $this->language->txt('etal_unknown_username');
203 $ownerId = $talk->getOwner();
204 if (ilObjUser::_exists($talk->getOwner())) {
205 $superiorName = ilObjUser::_lookupLogin($ownerId);
206 }
207 if (ilObjUser::_exists($talkData->getEmployee())) {
208 $employeeName = ilObjUser::_lookupLogin($talkData->getEmployee());
209 }
210
211 if (trim($filter['etal_superior']) !== "") {
212 $filterUser = ilObjUser::getUserIdByLogin(trim($filter['etal_superior']));
213 if (intval($talk->getOwner()) !== $filterUser) {
214 continue;
215 }
216 }
217
218 if (trim($filter['etal_title']) !== "") {
219 if (strpos(strtolower($talk->getTitle()), strtolower(trim($filter['etal_title']))) === false) {
220 continue;
221 }
222 }
223
224 if ($filter['etal_date'] !== false && $filter['etal_date'] !== null) {
225 $filterDate = new ilDateTime($filter['etal_date'], IL_CAL_DATE);
226 if (
227 !ilDateTime::_equals($filterDate, $val->getStartDate(), IL_CAL_DAY)
228 ) {
229 continue;
230 }
231 }
232 if ($filter['etal_status'] !== "" && intval($filter['etal_status'] !== 0)) {
233 $filterCompleted = intval($filter['etal_status']) === ilEmployeeTalkTableGUI::STATUS_COMPLETED;
234 if ($filterCompleted && !$val->isCompleted()) {
235 continue;
236 }
237
238 if (!$filterCompleted && $val->isCompleted()) {
239 continue;
240 }
241 }
242
243 $template_title = '';
244 if ($talkData->getTemplateId() > 0 && ilObject::_exists($talkData->getTemplateId())) {
245 $template = ilObjectFactory::getInstanceByObjId($talkData->getTemplateId());
246 $template_title = $template->getTitle();
247 }
248 if (trim($filter['etal_template']) !== "") {
249 if (strpos(strtolower($template_title), strtolower(trim($filter['etal_template']))) === false) {
250 continue;
251 }
252 }
253
254 $data[] = [
255 "ref_id" => $talk->getRefId(),
256 "etal_title" => $talk->getTitle(),
257 "etal_template" => $template_title,
258 "etal_date" => $talkData->getStartDate(),
259 "etal_superior" => $superiorName,
260 "etal_employee" => $employeeName,
261 "etal_status" => $talkData->isCompleted() ? $this->language->txt('etal_status_completed') : $this->language->txt('etal_status_pending'),
262 "permission_write" => false,
263 "permission_delete" => false
264 ];
265 }
266
267 $offset = intval($this->getOffset());
268 $limit = intval($this->getLimit());
269
270 $this->setMaxCount(count($data));
271
272 $dataSlice = array_slice($data, $offset, $limit, true);
273 $this->setData($dataSlice);
274 }
275}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const IL_CAL_DATE
const IL_CAL_DAY
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
language handling
static getUserIdByLogin(string $a_login)
static _lookupLogin(int $a_user_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _getAllReferences(int $id)
get all reference ids for object ID
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
determineOffsetAndOrder(bool $a_omit_offset=false)
setEnableNumInfo(bool $a_val)
setExternalSegmentation(bool $a_val)
setEnableTitle(bool $a_enabletitle)
setFormName(string $a_name="")
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
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)
getCurrentState()
get current settings for order, limit, columns and filter
setDisableFilterHiding(bool $a_val=true)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setFilterCols(int $a_val)
setDefaultFilterVisiblity(bool $a_status)
setData(array $a_data)
Set table data.
setMaxCount(int $a_max_count)
set max.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url
$container
@noRector
Definition: wac.php:14