1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
8 |
|
|
|
9 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
10 |
use Laminas\Log\LoggerInterface;
|
|
|
11 |
use Laminas\View\Model\ViewModel;
|
|
|
12 |
use Laminas\View\Model\JsonModel;
|
|
|
13 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
14 |
use LeadersLinked\Mapper\CalendarEventMapper;
|
|
|
15 |
use LeadersLinked\Mapper\ZoomMeetingMapper;
|
|
|
16 |
use LeadersLinked\Model\CalendarEvent;
|
|
|
17 |
use LeadersLinked\Library\Functions;
|
|
|
18 |
use LeadersLinked\Mapper\PerformanceEvaluationTestMapper;
|
|
|
19 |
use LeadersLinked\Mapper\PerformanceEvaluationFormMapper;
|
|
|
20 |
use LeadersLinked\Model\PerformanceEvaluationTest;
|
|
|
21 |
use LeadersLinked\Mapper\JobDescriptionMapper;
|
|
|
22 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
|
|
23 |
use LeadersLinked\Model\CompanyUser;
|
|
|
24 |
use LeadersLinked\Mapper\CompanyMapper;
|
|
|
25 |
use LeadersLinked\Mapper\RecruitmentSelectionInterviewMapper;
|
|
|
26 |
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
|
|
|
27 |
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
|
|
|
28 |
use LeadersLinked\Model\RecruitmentSelectionInterview;
|
|
|
29 |
use Laminas\Mvc\I18n\Translator;
|
|
|
30 |
use LeadersLinked\Cache\CacheInterface;
|
|
|
31 |
use LeadersLinked\Mapper\SurveyTestMapper;
|
|
|
32 |
use LeadersLinked\Mapper\SurveyCampaignMapper;
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
class CalendarController extends AbstractActionController
|
|
|
36 |
{
|
|
|
37 |
/**
|
|
|
38 |
*
|
|
|
39 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
|
|
40 |
*/
|
|
|
41 |
private $adapter;
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
*
|
|
|
45 |
* @var \LeadersLinked\Cache\CacheInterface
|
|
|
46 |
*/
|
|
|
47 |
private $cache;
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
*
|
|
|
52 |
* @var \Laminas\Log\LoggerInterface
|
|
|
53 |
*/
|
|
|
54 |
private $logger;
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
*
|
|
|
58 |
* @var array
|
|
|
59 |
*/
|
|
|
60 |
private $config;
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
*
|
|
|
65 |
* @var \Laminas\Mvc\I18n\Translator
|
|
|
66 |
*/
|
|
|
67 |
private $translator;
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
*
|
|
|
72 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
73 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
74 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
|
|
75 |
* @param array $config
|
|
|
76 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
|
|
77 |
*/
|
|
|
78 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
|
|
79 |
{
|
|
|
80 |
$this->adapter = $adapter;
|
|
|
81 |
$this->cache = $cache;
|
|
|
82 |
$this->logger = $logger;
|
|
|
83 |
$this->config = $config;
|
|
|
84 |
$this->translator = $translator;
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
public function indexAction()
|
|
|
90 |
{
|
|
|
91 |
return new JsonModel([
|
|
|
92 |
'success' => false,
|
|
|
93 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
94 |
]);
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
public function eventsAction()
|
|
|
101 |
{
|
|
|
102 |
|
|
|
103 |
$request = $this->getRequest();
|
|
|
104 |
if($request->isGet()) {
|
|
|
105 |
|
|
|
106 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
107 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
108 |
|
|
|
109 |
$currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
|
|
|
110 |
$currentNetwork = $currentNetworkPlugin->getNetwork();
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
$start = $this->params()->fromQuery('start');
|
|
|
115 |
$end = $this->params()->fromQuery('end');
|
|
|
116 |
|
|
|
117 |
if(!empty($start) && !empty($end)) {
|
|
|
118 |
|
|
|
119 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $start);
|
|
|
120 |
$dtEnd = \DateTime::createFromFormat('Y-m-d', $end);
|
|
|
121 |
} else {
|
|
|
122 |
$dtStart = null;
|
|
|
123 |
$dtEnd = null;
|
|
|
124 |
}
|
|
|
125 |
|
128 |
efrain |
126 |
|
|
|
127 |
|
1 |
efrain |
128 |
if(!$dtStart || !$dtEnd) {
|
|
|
129 |
$t = time();
|
|
|
130 |
$year = intval(date('Y', $t), 10);
|
|
|
131 |
$month = intval(date('m', $t), 10);
|
|
|
132 |
$last_day = intval(date('t', $t), 10);
|
|
|
133 |
|
132 |
efrain |
134 |
$dt = new \DateTime();
|
|
|
135 |
$dt->setDate($year, $month, 1);
|
|
|
136 |
$dt->setTime(0, 0, 0);
|
1 |
efrain |
137 |
|
132 |
efrain |
138 |
$start = $dt->format('Y-m-d H:i:s');
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
$dt = new \DateTime();
|
|
|
142 |
$dt->setDate($year, $month, $last_day);
|
|
|
143 |
$dt->setTime(0, 0, 0);
|
|
|
144 |
|
|
|
145 |
$end = $dt->format('Y-m-d H:i:s');
|
1 |
efrain |
146 |
|
|
|
147 |
} else {
|
129 |
efrain |
148 |
|
1 |
efrain |
149 |
$dtStart->setTime(0, 0, 0);
|
|
|
150 |
$start = $dtStart->format('Y-m-d H:i:s');
|
|
|
151 |
|
|
|
152 |
$dtEnd->setTime(23, 59, 59);
|
|
|
153 |
$end = $dtEnd->format('Y-m-d H:i:s');
|
|
|
154 |
}
|
133 |
efrain |
155 |
|
1 |
efrain |
156 |
|
|
|
157 |
$events = [];
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
//3 días
|
|
|
162 |
$expirePeriod = 86400 * 3;
|
|
|
163 |
$t1 = time();
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
$companies = [];
|
|
|
167 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
168 |
|
|
|
169 |
$companyUsers = [];
|
|
|
170 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
171 |
$records = $companyUserMapper->fetchAllByUserId($currentUser->id);
|
|
|
172 |
|
135 |
efrain |
173 |
foreach($records as $record) {
|
1 |
efrain |
174 |
$companyUsers[$record->company_id] = $record->backend == CompanyUser::BACKEND_YES;
|
134 |
efrain |
175 |
}
|
1 |
efrain |
176 |
|
|
|
177 |
|
|
|
178 |
$zoomMeetingMapper = ZoomMeetingMapper::getInstance($this->adapter);
|
|
|
179 |
$recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
180 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
181 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
182 |
$performanceEvaluationTestMapper = PerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
183 |
$performanceEvaluationFormMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
184 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
185 |
$userMapper = UserMapper::getInstance($this->adapter);
|
128 |
efrain |
186 |
|
127 |
efrain |
187 |
$calendarEventMapper = CalendarEventMapper::getInstance($this->adapter);
|
|
|
188 |
$records = $calendarEventMapper->fetchAllByUserIdAndStartTimeAndEndTime($currentUser->id, $start, $end);
|
134 |
efrain |
189 |
|
127 |
efrain |
190 |
|
1 |
efrain |
191 |
foreach($records as $record)
|
|
|
192 |
{
|
|
|
193 |
switch($record->type)
|
|
|
194 |
{
|
|
|
195 |
case CalendarEvent::TYPE_SURVEY_NORMAL:
|
|
|
196 |
$backgroundColor = $currentNetwork->css_calendar_survey_bg_color;
|
|
|
197 |
$textColor = $currentNetwork->css_calendar_survey_text_color;
|
|
|
198 |
|
|
|
199 |
$surveyTestMapper = SurveyTestMapper::getInstance($this->adapter);
|
|
|
200 |
$surveyTest = $surveyTestMapper->fetchOne($record->relational_id);
|
|
|
201 |
|
|
|
202 |
if($surveyTest && $surveyTest->user_id == $currentUser->id) {
|
|
|
203 |
|
|
|
204 |
$surveyCampaingMapper = SurveyCampaignMapper::getInstance($this->adapter);
|
|
|
205 |
$surveyCampaing = $surveyCampaingMapper->fetchOne($surveyTest->campaign_id);
|
|
|
206 |
|
|
|
207 |
$url = '';
|
|
|
208 |
$hasLink = !empty($companyUsers[$surveyTest->company_id]);
|
|
|
209 |
|
|
|
210 |
if ($hasLink) {
|
|
|
211 |
|
|
|
212 |
if (!isset($companies[$surveyTest->company_id])) {
|
|
|
213 |
$company = $companyMapper->fetchOne($surveyTest->company_id);
|
|
|
214 |
|
|
|
215 |
$companies[$company->id] = $company;
|
|
|
216 |
} else {
|
|
|
217 |
$company = $companies[$surveyTest->company_id];
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
222 |
'id' => $company->uuid,
|
|
|
223 |
'relational' => $surveyTest->uuid,
|
|
|
224 |
'type' => CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE,
|
136 |
efrain |
225 |
], ['force_canonical' => true] );
|
1 |
efrain |
226 |
}
|
|
|
227 |
|
|
|
228 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $surveyCampaing->end_date);
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
array_push($events, [
|
|
|
232 |
'id' => $surveyTest->uuid,
|
|
|
233 |
'title' => $surveyCampaing->name,
|
146 |
efrain |
234 |
'start' => $dtStart->format('Y-m-d'),
|
1 |
efrain |
235 |
'url' => $url,
|
|
|
236 |
'backgroundColor' => $backgroundColor,
|
|
|
237 |
'textColor' => $textColor,
|
|
|
238 |
'allDay' => true,
|
|
|
239 |
'type' => 'task',
|
135 |
efrain |
240 |
'source' => 'internal',
|
1 |
efrain |
241 |
]);
|
|
|
242 |
}
|
|
|
243 |
|
|
|
244 |
break;
|
|
|
245 |
|
|
|
246 |
case CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE:
|
|
|
247 |
$backgroundColor = $currentNetwork->css_calendar_organizational_climate_bg_color;
|
|
|
248 |
$textColor = $currentNetwork->css_calendar_organizational_climate_text_color;
|
|
|
249 |
|
|
|
250 |
$surveyTestMapper = SurveyTestMapper::getInstance($this->adapter);
|
|
|
251 |
$surveyTest = $surveyTestMapper->fetchOne($record->relational_id);
|
|
|
252 |
|
|
|
253 |
if($surveyTest && $surveyTest->user_id == $currentUser->id) {
|
|
|
254 |
|
|
|
255 |
$surveyCampaingMapper = SurveyCampaignMapper::getInstance($this->adapter);
|
|
|
256 |
$surveyCampaing = $surveyCampaingMapper->fetchOne($surveyTest->campaign_id);
|
|
|
257 |
|
|
|
258 |
$url = '';
|
|
|
259 |
$hasLink = !empty($companyUsers[$surveyTest->company_id]);
|
|
|
260 |
|
|
|
261 |
if ($hasLink) {
|
|
|
262 |
|
|
|
263 |
if (!isset($companies[$surveyTest->company_id])) {
|
|
|
264 |
$company = $companyMapper->fetchOne($surveyTest->company_id);
|
|
|
265 |
|
|
|
266 |
$companies[$company->id] = $company;
|
|
|
267 |
} else {
|
|
|
268 |
$company = $companies[$surveyTest->company_id];
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
273 |
'id' => $company->uuid,
|
|
|
274 |
'relational' => $surveyTest->uuid,
|
|
|
275 |
'type' => CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE,
|
136 |
efrain |
276 |
], ['force_canonical' => true]);
|
1 |
efrain |
277 |
}
|
|
|
278 |
|
|
|
279 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $surveyCampaing->end_date);
|
|
|
280 |
|
|
|
281 |
|
|
|
282 |
array_push($events, [
|
|
|
283 |
'id' => $surveyTest->uuid,
|
|
|
284 |
'title' => $surveyCampaing->name,
|
146 |
efrain |
285 |
'start' => $dtStart->format('Y-m-d'),
|
1 |
efrain |
286 |
'url' => $url,
|
|
|
287 |
'backgroundColor' => $backgroundColor,
|
|
|
288 |
'textColor' => $textColor,
|
|
|
289 |
'allDay' => true,
|
|
|
290 |
'type' => 'task',
|
135 |
efrain |
291 |
'source' => 'internal',
|
1 |
efrain |
292 |
]);
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
break;
|
|
|
296 |
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
case CalendarEvent::TYPE_RECRUITMENT_SELECTION_INTERVIEW :
|
|
|
302 |
$backgroundColor = $currentNetwork->css_calendar_recruitment_and_selection_bg_color ;
|
|
|
303 |
$textColor = $currentNetwork->css_calendar_recruitment_and_selection_text_color;
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
$recruitmentSelectionInterview = $recruitmentSelectionInterviewMapper->fetchOne($record->relational_id);
|
|
|
307 |
if($recruitmentSelectionInterview) {
|
|
|
308 |
|
|
|
309 |
$recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
$recruitmentSelectionCandidate = $recruitmentSelectionCandidateMapper->fetchOne($recruitmentSelectionInterview->candidate_id);
|
|
|
314 |
if($recruitmentSelectionVacancy && $recruitmentSelectionCandidate) {
|
|
|
315 |
$jobDescription = $jobDescriptionMapper->fetchOne($recruitmentSelectionVacancy->job_description_id);
|
|
|
316 |
if($jobDescription) {
|
|
|
317 |
$url = '';
|
|
|
318 |
$hasLink = !empty($companyUsers[$recruitmentSelectionInterview->company_id]);
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
if($hasLink) {
|
|
|
323 |
|
|
|
324 |
if(!isset($companies[$recruitmentSelectionInterview->company_id])) {
|
|
|
325 |
$company = $companyMapper->fetchOne($recruitmentSelectionInterview->company_id);
|
|
|
326 |
|
|
|
327 |
$companies[ $company->id ] = $company;
|
|
|
328 |
} else {
|
|
|
329 |
$company = $companies[ $recruitmentSelectionInterview->company_id ];
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
334 |
'id' => $company->uuid,
|
|
|
335 |
'relational' => $recruitmentSelectionInterview->uuid,
|
|
|
336 |
'type' => CalendarEvent::TYPE_RECRUITMENT_SELECTION_INTERVIEW
|
136 |
efrain |
337 |
], ['force_canonical' => true]);
|
1 |
efrain |
338 |
}
|
|
|
339 |
|
|
|
340 |
$agenda = " LABEL_RECRUITMENT_SELECTION_JOB_DESCRIPTION : " . $jobDescription->name . "<br>";
|
|
|
341 |
switch($recruitmentSelectionInterview->type)
|
|
|
342 |
{
|
|
|
343 |
case RecruitmentSelectionInterview::TYPE_BOSS :
|
|
|
344 |
$agenda .= " LABEL_RECRUITMENT_SELECTION_TYPE : LABEL_RECRUITMENT_SELECTION_TYPE_BOSS_INTERVIEW <br>";
|
|
|
345 |
break;
|
|
|
346 |
|
|
|
347 |
case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
|
|
|
348 |
$agenda .= " LABEL_RECRUITMENT_SELECTION_TYPE : LABEL_RECRUITMENT_SELECTION_TYPE_HUMAN_RESOURCE <br>";
|
|
|
349 |
break;
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
$agenda .= " LABEL_RECRUITMENT_SELECTION_CANDIDATE : " . trim($recruitmentSelectionCandidate->first_name . ' ' . $recruitmentSelectionCandidate->last_name) . " <br>";
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
|
356 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $recruitmentSelectionInterview->last_date);
|
|
|
357 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_LAST_DATE : " . $dtStart->format('Y-m-d') . "<br>" ;
|
|
|
358 |
|
|
|
359 |
|
|
|
360 |
array_push($events, [
|
|
|
361 |
'id' => $recruitmentSelectionInterview->uuid,
|
|
|
362 |
'title' => $recruitmentSelectionVacancy->name,
|
|
|
363 |
'agenda' => $agenda,
|
|
|
364 |
'url' => $url,
|
|
|
365 |
'start' => $dtStart->format('Y-m-d'),
|
|
|
366 |
'url' => '',
|
|
|
367 |
'backgroundColor' => $backgroundColor,
|
|
|
368 |
'textColor' => $textColor,
|
|
|
369 |
'allDay' => true,
|
|
|
370 |
'type' => 'task',
|
135 |
efrain |
371 |
'source' => 'internal',
|
1 |
efrain |
372 |
]);
|
|
|
373 |
}
|
|
|
374 |
}
|
|
|
375 |
}
|
|
|
376 |
|
|
|
377 |
|
|
|
378 |
break;
|
|
|
379 |
|
|
|
380 |
case CalendarEvent::TYPE_PERFORMANCE_EVALUATION :
|
|
|
381 |
|
|
|
382 |
|
|
|
383 |
$backgroundColor = $currentNetwork->css_calendar_performance_evaluation_bg_color ;
|
|
|
384 |
$textColor = $currentNetwork->css_calendar_performance_evaluation_text_color;
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
$performanceEvaluationTest = $performanceEvaluationTestMapper->fetchOne($record->relational_id);
|
|
|
388 |
if($performanceEvaluationTest) {
|
|
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
|
392 |
$performanceEvaluationForm = $performanceEvaluationFormMapper->fetchOne($performanceEvaluationTest->form_id);
|
|
|
393 |
if($performanceEvaluationForm) {
|
|
|
394 |
$jobDescription = $jobDescriptionMapper->fetchOne($performanceEvaluationForm->job_description_id);
|
|
|
395 |
if($jobDescription) {
|
|
|
396 |
$url = '';
|
|
|
397 |
if($performanceEvaluationTest->supervisor_id) {
|
|
|
398 |
$supervisor = $userMapper->fetchOne($performanceEvaluationTest->supervisor_id);
|
|
|
399 |
} else {
|
|
|
400 |
$supervisor = '';
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
if($performanceEvaluationTest->employee_id) {
|
|
|
404 |
$employee = $userMapper->fetchOne($performanceEvaluationTest->employee_id);
|
|
|
405 |
} else {
|
|
|
406 |
$employee = '';
|
|
|
407 |
}
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
$hasLink = !empty($companyUsers[$performanceEvaluationTest->company_id]);
|
|
|
411 |
|
|
|
412 |
switch ($performanceEvaluationTest->type)
|
|
|
413 |
{
|
|
|
414 |
case PerformanceEvaluationTest::TYPE_SUPERVISOR :
|
|
|
415 |
case PerformanceEvaluationTest::TYPE_BOTH :
|
|
|
416 |
if($performanceEvaluationTest->supervisor_id != $currentUser->id) {
|
|
|
417 |
$hasLink = false;
|
|
|
418 |
}
|
|
|
419 |
break;
|
|
|
420 |
|
|
|
421 |
case PerformanceEvaluationTest::TYPE_EMPLOYEE :
|
|
|
422 |
if($performanceEvaluationTest->employee_id != $currentUser->id) {
|
|
|
423 |
$hasLink = false;
|
|
|
424 |
}
|
|
|
425 |
break;
|
|
|
426 |
|
|
|
427 |
default :
|
|
|
428 |
$hasLink = false;
|
|
|
429 |
break;
|
|
|
430 |
}
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
|
434 |
if($hasLink) {
|
|
|
435 |
|
|
|
436 |
if(!isset($companies[$performanceEvaluationTest->company_id])) {
|
|
|
437 |
$company = $companyMapper->fetchOne($performanceEvaluationTest->company_id);
|
|
|
438 |
|
|
|
439 |
$companies[ $company->id ] = $company;
|
|
|
440 |
} else {
|
|
|
441 |
$company = $companies[ $performanceEvaluationTest->company_id ];
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
|
|
|
445 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
446 |
'id' => $company->uuid,
|
|
|
447 |
'relational' => $performanceEvaluationTest->uuid,
|
|
|
448 |
'type' => CalendarEvent::TYPE_PERFORMANCE_EVALUATION
|
136 |
efrain |
449 |
], ['force_canonical' => true]);
|
1 |
efrain |
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
}
|
|
|
454 |
|
|
|
455 |
$agenda = " LABEL_PERFORMANCE_EVALUATION_FORM_NAME : " . $performanceEvaluationForm->name . "<br>";
|
|
|
456 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_JOB_DESCRIPTION : " . $jobDescription->name . "<br>";
|
|
|
457 |
|
|
|
458 |
switch($performanceEvaluationTest->type)
|
|
|
459 |
{
|
|
|
460 |
case PerformanceEvaluationTest::TYPE_BOTH :
|
|
|
461 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_TYPE : LABEL_PERFORMANCE_EVALUATION_TYPE_BOTH <br>";
|
|
|
462 |
break;
|
|
|
463 |
|
|
|
464 |
case PerformanceEvaluationTest::TYPE_SUPERVISOR :
|
|
|
465 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_TYPE : LABEL_PERFORMANCE_EVALUATION_TYPE_SUPERVISOR <br>";
|
|
|
466 |
break;
|
|
|
467 |
|
|
|
468 |
case PerformanceEvaluationTest::TYPE_EMPLOYEE :
|
|
|
469 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_TYPE : LABEL_PERFORMANCE_EVALUATION_TYPE_EMPLOYEE <br>";
|
|
|
470 |
break;
|
|
|
471 |
|
|
|
472 |
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
if($supervisor) {
|
|
|
476 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_SUPERVISOR : " . trim($supervisor->first_name . ' ' . $supervisor->last_name) . " <br>";
|
|
|
477 |
|
|
|
478 |
}
|
|
|
479 |
if($employee) {
|
|
|
480 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_EMPLOYEE : " . trim($employee->first_name . ' ' . $employee->last_name) . " <br>";
|
|
|
481 |
|
|
|
482 |
}
|
|
|
483 |
|
|
|
484 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $performanceEvaluationTest->last_date);
|
|
|
485 |
$agenda .= " LABEL_PERFORMANCE_EVALUATION_LAST_DATE : " . $dtStart->format('Y-m-d') . "<br>" ;
|
|
|
486 |
|
|
|
487 |
|
|
|
488 |
|
|
|
489 |
array_push($events, [
|
|
|
490 |
'id' => $performanceEvaluationTest->uuid,
|
|
|
491 |
'title' => $performanceEvaluationForm->name,
|
|
|
492 |
'agenda' => $agenda,
|
|
|
493 |
'start' => $dtStart->format('Y-m-d'),
|
|
|
494 |
'url' => $url,
|
|
|
495 |
'backgroundColor' => $backgroundColor,
|
|
|
496 |
'textColor' => $textColor,
|
|
|
497 |
'allDay' => true,
|
|
|
498 |
'type' => 'task',
|
135 |
efrain |
499 |
'source' => 'internal',
|
1 |
efrain |
500 |
]);
|
|
|
501 |
}
|
|
|
502 |
}
|
|
|
503 |
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
|
510 |
break;
|
|
|
511 |
|
|
|
512 |
case CalendarEvent::TYPE_ZOOM :
|
|
|
513 |
$zoomMeeting = $zoomMeetingMapper->fetchOne($record->relational_id);
|
|
|
514 |
if($zoomMeeting) {
|
|
|
515 |
|
|
|
516 |
$backgroundColor = $currentNetwork->css_calendar_zoom_bg_color ;
|
|
|
517 |
$textColor = $currentNetwork->css_calendar_zoom_text_color;
|
|
|
518 |
|
|
|
519 |
$dtStart = \DateTime::createFromFormat('Y-m-d H:i:s', $zoomMeeting->start_time);
|
|
|
520 |
$t2 = $dtStart->getTimestamp();
|
|
|
521 |
|
|
|
522 |
if($t2 > $t1) {
|
|
|
523 |
|
|
|
524 |
$t3 = $t1 + $expirePeriod;
|
|
|
525 |
if($t3 > $t2) {
|
|
|
526 |
$backgroundColor = $currentNetwork->css_calendar_expire_bg_color;
|
|
|
527 |
$textColor = $currentNetwork->css_calendar_expire_text_color;
|
|
|
528 |
}
|
|
|
529 |
|
|
|
530 |
}
|
|
|
531 |
|
|
|
532 |
|
|
|
533 |
|
|
|
534 |
if($currentUser->timezone && $currentUser->timezone != $zoomMeeting->timezone) {
|
|
|
535 |
|
|
|
536 |
$start = str_replace(' ', 'T', Functions::convertDateTimeBetweenTimeZones($zoomMeeting->start_time, $zoomMeeting->timezone, $currentUser->timezone));
|
|
|
537 |
$end = str_replace(' ', 'T', Functions::convertDateTimeBetweenTimeZones($zoomMeeting->end_time, $zoomMeeting->timezone, $currentUser->timezone));
|
|
|
538 |
|
|
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
|
542 |
|
|
|
543 |
} else {
|
|
|
544 |
$start = str_replace(' ', 'T', $zoomMeeting->start_time);
|
|
|
545 |
$end = str_replace(' ', 'T', $zoomMeeting->end_time);
|
|
|
546 |
}
|
|
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
|
550 |
|
|
|
551 |
|
|
|
552 |
|
|
|
553 |
$agenda = "<a href=\"{$zoomMeeting->join_url}\" target=\"_blank\">" . $zoomMeeting->agenda . "<br>" .
|
|
|
554 |
" LABEL_ZOOM_MEETING_START_DATE : " . $dtStart->format('Y-m-d') . "<br>" .
|
|
|
555 |
" LABEL_ZOOM_MEETING_START_TIME : " . $dtStart->format('H:i a') . "<br>" .
|
|
|
556 |
" LABEL_ZOOM_MEETING_TIMEZONE : " . $zoomMeeting->timezone . "<br>" .
|
|
|
557 |
" LABEL_ZOOM_MEETING_TITLE : " . $zoomMeeting->topic . "<br>" .
|
|
|
558 |
" LABEL_ZOOM_MEETING_URL : " . $zoomMeeting->join_url . "<br>" .
|
|
|
559 |
" LABEL_ZOOM_MEETING_PASSWORD : " . $zoomMeeting->password . "<br>" .
|
|
|
560 |
"</a>";
|
|
|
561 |
|
|
|
562 |
array_push($events, [
|
|
|
563 |
'id' => $zoomMeeting->id,
|
|
|
564 |
'title' => $zoomMeeting->topic,
|
|
|
565 |
'agenda' => $agenda,
|
|
|
566 |
'start' => $start,
|
|
|
567 |
'end' => $end,
|
|
|
568 |
'url' => $zoomMeeting->join_url,
|
|
|
569 |
'backgroundColor' => $backgroundColor,
|
|
|
570 |
'textColor' => $textColor,
|
|
|
571 |
'type' => 'event',
|
135 |
efrain |
572 |
'source' => 'external',
|
1 |
efrain |
573 |
]);
|
|
|
574 |
}
|
|
|
575 |
break;
|
|
|
576 |
|
|
|
577 |
|
|
|
578 |
}
|
|
|
579 |
|
|
|
580 |
|
|
|
581 |
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
|
|
|
585 |
|
|
|
586 |
|
121 |
efrain |
587 |
return new JsonModel([
|
|
|
588 |
'success' => true,
|
|
|
589 |
'data' => $events
|
|
|
590 |
]);
|
1 |
efrain |
591 |
|
|
|
592 |
} else {
|
|
|
593 |
$response = [
|
|
|
594 |
'success' => false,
|
|
|
595 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
596 |
];
|
|
|
597 |
}
|
|
|
598 |
|
|
|
599 |
return new JsonModel($response);
|
|
|
600 |
}
|
|
|
601 |
|
|
|
602 |
|
|
|
603 |
|
|
|
604 |
|
|
|
605 |
}
|