Proyectos de Subversion LeadersLinked - Services

Rev

Rev 127 | Rev 129 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
            header('Access-Control-Allow-Origin: *');
128
            header('Access-Control-Allow-Headers: *');
129
            header('Access-Control-Allow-Method: POST, GET, HEAD, OPTIONS');
130
            header('Access-Control-Max-Age: 86400');
131
 
132
 
133
 
1 efrain 134
            if(!$dtStart || !$dtEnd) {
135
              $t = time();
136
              $year = intval(date('Y', $t), 10);
137
              $month = intval(date('m', $t), 10);
138
              $last_day = intval(date('t', $t), 10);
139
 
140
              $start = mktime(0, 0, 0, $month, 1, $year);
141
              $start = date('Y-m-d H:i:s');
142
 
143
              $end = mktime(23, 56, 59, $month, $last_day, $year);
144
              $end = date('Y-m-d H:i:s');
145
 
146
            } else {
147
                $dtStart->setTime(0, 0, 0);
148
                $start = $dtStart->format('Y-m-d H:i:s');
149
 
150
                $dtEnd->setTime(23, 59, 59);
151
                $end  = $dtEnd->format('Y-m-d H:i:s');
152
            }
153
 
154
 
128 efrain 155
            echo 'start = ' . $start . ' end = ' . $end;
156
 
157
 
1 efrain 158
            $events = [];
159
 
160
 
161
 
162
            //3 días
163
            $expirePeriod = 86400 * 3;
164
            $t1 = time();
165
 
166
 
167
            $companies = [];
168
            $companyMapper = CompanyMapper::getInstance($this->adapter);
169
 
170
            $companyUsers = [];
171
            $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
172
            $records = $companyUserMapper->fetchAllByUserId($currentUser->id);
173
 
174
            foreach($records as $record) {
175
                $companyUsers[$record->company_id] = $record->backend == CompanyUser::BACKEND_YES;
176
             }
177
 
178
 
179
 
180
 
181
 
182
 
183
            $zoomMeetingMapper = ZoomMeetingMapper::getInstance($this->adapter);
184
            $recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
185
            $recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
186
            $recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
187
            $performanceEvaluationTestMapper = PerformanceEvaluationTestMapper::getInstance($this->adapter);
188
            $performanceEvaluationFormMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
189
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
190
            $userMapper = UserMapper::getInstance($this->adapter);
191
 
127 efrain 192
 
1 efrain 193
 
123 efrain 194
 
128 efrain 195
 
125 efrain 196
 
127 efrain 197
            $calendarEventMapper = CalendarEventMapper::getInstance($this->adapter);
198
            $records = $calendarEventMapper->fetchAllByUserIdAndStartTimeAndEndTime($currentUser->id, $start, $end);
199
 
123 efrain 200
            print_r($records); exit;
201
 
1 efrain 202
            foreach($records as $record)
203
            {
204
                switch($record->type)
205
                {
206
                    case CalendarEvent::TYPE_SURVEY_NORMAL:
207
                        $backgroundColor = $currentNetwork->css_calendar_survey_bg_color;
208
                        $textColor = $currentNetwork->css_calendar_survey_text_color;
209
 
210
                        $surveyTestMapper = SurveyTestMapper::getInstance($this->adapter);
211
                        $surveyTest = $surveyTestMapper->fetchOne($record->relational_id);
212
 
213
                        if($surveyTest && $surveyTest->user_id == $currentUser->id) {
214
 
215
                            $surveyCampaingMapper = SurveyCampaignMapper::getInstance($this->adapter);
216
                            $surveyCampaing = $surveyCampaingMapper->fetchOne($surveyTest->campaign_id);
217
 
218
                            $url = '';
219
                            $hasLink = !empty($companyUsers[$surveyTest->company_id]);
220
 
221
                            if ($hasLink) {
222
 
223
                                if (!isset($companies[$surveyTest->company_id])) {
224
                                    $company  = $companyMapper->fetchOne($surveyTest->company_id);
225
 
226
                                    $companies[$company->id]  = $company;
227
                                } else {
228
                                    $company = $companies[$surveyTest->company_id];
229
                                }
230
 
231
 
232
                                $url = $this->url()->fromRoute('backend/signin-company', [
233
                                    'id' => $company->uuid,
234
                                    'relational' => $surveyTest->uuid,
235
                                    'type' => CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE,
236
                                ]);
237
                            }
238
 
239
                            $dtStart = \DateTime::createFromFormat('Y-m-d', $surveyCampaing->end_date);
240
 
241
 
242
                            array_push($events, [
243
                                'id'                => $surveyTest->uuid,
244
                                'title'             => $surveyCampaing->name,
245
                                'start'             => $dtStart->format('d/m/Y'),
246
                                'url'               => $url,
247
                                'backgroundColor'   => $backgroundColor,
248
                                'textColor'         => $textColor,
249
                                'allDay'            => true,
250
                                'type'              => 'task',
251
                            ]);
252
                        }
253
 
254
                        break;
255
 
256
                    case CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE:
257
                        $backgroundColor = $currentNetwork->css_calendar_organizational_climate_bg_color;
258
                        $textColor = $currentNetwork->css_calendar_organizational_climate_text_color;
259
 
260
                        $surveyTestMapper = SurveyTestMapper::getInstance($this->adapter);
261
                        $surveyTest = $surveyTestMapper->fetchOne($record->relational_id);
262
 
263
                        if($surveyTest && $surveyTest->user_id == $currentUser->id) {
264
 
265
                            $surveyCampaingMapper = SurveyCampaignMapper::getInstance($this->adapter);
266
                            $surveyCampaing = $surveyCampaingMapper->fetchOne($surveyTest->campaign_id);
267
 
268
                            $url = '';
269
                            $hasLink = !empty($companyUsers[$surveyTest->company_id]);
270
 
271
                            if ($hasLink) {
272
 
273
                                if (!isset($companies[$surveyTest->company_id])) {
274
                                    $company  = $companyMapper->fetchOne($surveyTest->company_id);
275
 
276
                                    $companies[$company->id]  = $company;
277
                                } else {
278
                                    $company = $companies[$surveyTest->company_id];
279
                                }
280
 
281
 
282
                                $url = $this->url()->fromRoute('backend/signin-company', [
283
                                    'id' => $company->uuid,
284
                                    'relational' => $surveyTest->uuid,
285
                                    'type' => CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE,
286
                                ]);
287
                            }
288
 
289
                            $dtStart = \DateTime::createFromFormat('Y-m-d', $surveyCampaing->end_date);
290
 
291
 
292
                            array_push($events, [
293
                                'id'                => $surveyTest->uuid,
294
                                'title'             => $surveyCampaing->name,
295
                                'start'             => $dtStart->format('d/m/Y'),
296
                                'url'               => $url,
297
                                'backgroundColor'   => $backgroundColor,
298
                                'textColor'         => $textColor,
299
                                'allDay'            => true,
300
                                'type'              => 'task',
301
                            ]);
302
                        }
303
 
304
                        break;
305
 
306
 
307
 
308
 
309
 
310
                    case CalendarEvent::TYPE_RECRUITMENT_SELECTION_INTERVIEW  :
311
                        $backgroundColor = $currentNetwork->css_calendar_recruitment_and_selection_bg_color ;
312
                        $textColor = $currentNetwork->css_calendar_recruitment_and_selection_text_color;
313
 
314
 
315
                        $recruitmentSelectionInterview = $recruitmentSelectionInterviewMapper->fetchOne($record->relational_id);
316
                        if($recruitmentSelectionInterview) {
317
 
318
                            $recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
319
 
320
 
321
 
322
                            $recruitmentSelectionCandidate = $recruitmentSelectionCandidateMapper->fetchOne($recruitmentSelectionInterview->candidate_id);
323
                            if($recruitmentSelectionVacancy && $recruitmentSelectionCandidate) {
324
                                $jobDescription = $jobDescriptionMapper->fetchOne($recruitmentSelectionVacancy->job_description_id);
325
                                if($jobDescription) {
326
                                    $url = '';
327
                                    $hasLink = !empty($companyUsers[$recruitmentSelectionInterview->company_id]);
328
 
329
 
330
 
331
                                    if($hasLink) {
332
 
333
                                        if(!isset($companies[$recruitmentSelectionInterview->company_id])) {
334
                                            $company  = $companyMapper->fetchOne($recruitmentSelectionInterview->company_id);
335
 
336
                                            $companies[ $company->id ]  = $company;
337
                                        } else {
338
                                            $company = $companies[ $recruitmentSelectionInterview->company_id ];
339
                                        }
340
 
341
 
342
                                        $url = $this->url()->fromRoute('backend/signin-company', [
343
                                            'id' => $company->uuid,
344
                                            'relational' => $recruitmentSelectionInterview->uuid,
345
                                            'type' => CalendarEvent::TYPE_RECRUITMENT_SELECTION_INTERVIEW
346
                                        ]);
347
                                    }
348
 
349
                                    $agenda = " LABEL_RECRUITMENT_SELECTION_JOB_DESCRIPTION : " . $jobDescription->name . "<br>";
350
                                    switch($recruitmentSelectionInterview->type)
351
                                    {
352
                                        case RecruitmentSelectionInterview::TYPE_BOSS :
353
                                            $agenda .= " LABEL_RECRUITMENT_SELECTION_TYPE : LABEL_RECRUITMENT_SELECTION_TYPE_BOSS_INTERVIEW <br>";
354
                                            break;
355
 
356
                                        case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
357
                                            $agenda .= " LABEL_RECRUITMENT_SELECTION_TYPE : LABEL_RECRUITMENT_SELECTION_TYPE_HUMAN_RESOURCE <br>";
358
                                            break;
359
                                    }
360
 
361
                                    $agenda .= " LABEL_RECRUITMENT_SELECTION_CANDIDATE : " . trim($recruitmentSelectionCandidate->first_name . ' ' . $recruitmentSelectionCandidate->last_name) . " <br>";
362
 
363
 
364
 
365
                                    $dtStart = \DateTime::createFromFormat('Y-m-d', $recruitmentSelectionInterview->last_date);
366
                                    $agenda .= " LABEL_PERFORMANCE_EVALUATION_LAST_DATE : " . $dtStart->format('Y-m-d') . "<br>" ;
367
 
368
 
369
                                    array_push($events, [
370
                                        'id'                => $recruitmentSelectionInterview->uuid,
371
                                        'title'             => $recruitmentSelectionVacancy->name,
372
                                        'agenda'            => $agenda,
373
                                        'url'               => $url,
374
                                        'start'             => $dtStart->format('Y-m-d'),
375
                                        'url'               => '',
376
                                        'backgroundColor'   => $backgroundColor,
377
                                        'textColor'         => $textColor,
378
                                        'allDay'            => true,
379
                                        'type'              => 'task',
380
                                    ]);
381
                                }
382
                            }
383
                        }
384
 
385
 
386
                        break;
387
 
388
                    case CalendarEvent::TYPE_PERFORMANCE_EVALUATION :
389
 
390
 
391
                        $backgroundColor = $currentNetwork->css_calendar_performance_evaluation_bg_color ;
392
                        $textColor = $currentNetwork->css_calendar_performance_evaluation_text_color;
393
 
394
 
395
                        $performanceEvaluationTest = $performanceEvaluationTestMapper->fetchOne($record->relational_id);
396
                        if($performanceEvaluationTest) {
397
 
398
 
399
 
400
                            $performanceEvaluationForm = $performanceEvaluationFormMapper->fetchOne($performanceEvaluationTest->form_id);
401
                            if($performanceEvaluationForm) {
402
                                $jobDescription = $jobDescriptionMapper->fetchOne($performanceEvaluationForm->job_description_id);
403
                                if($jobDescription) {
404
                                    $url = '';
405
                                    if($performanceEvaluationTest->supervisor_id) {
406
                                        $supervisor = $userMapper->fetchOne($performanceEvaluationTest->supervisor_id);
407
                                    } else {
408
                                        $supervisor = '';
409
                                    }
410
 
411
                                    if($performanceEvaluationTest->employee_id) {
412
                                        $employee = $userMapper->fetchOne($performanceEvaluationTest->employee_id);
413
                                    } else {
414
                                        $employee = '';
415
                                    }
416
 
417
 
418
                                    $hasLink = !empty($companyUsers[$performanceEvaluationTest->company_id]);
419
 
420
                                    switch ($performanceEvaluationTest->type)
421
                                    {
422
                                        case PerformanceEvaluationTest::TYPE_SUPERVISOR :
423
                                        case PerformanceEvaluationTest::TYPE_BOTH  :
424
                                            if($performanceEvaluationTest->supervisor_id != $currentUser->id) {
425
                                                $hasLink = false;
426
                                            }
427
                                            break;
428
 
429
                                        case  PerformanceEvaluationTest::TYPE_EMPLOYEE  :
430
                                            if($performanceEvaluationTest->employee_id != $currentUser->id) {
431
                                                $hasLink = false;
432
                                            }
433
                                            break;
434
 
435
                                        default :
436
                                            $hasLink = false;
437
                                            break;
438
                                    }
439
 
440
 
441
 
442
                                    if($hasLink) {
443
 
444
                                        if(!isset($companies[$performanceEvaluationTest->company_id])) {
445
                                            $company  = $companyMapper->fetchOne($performanceEvaluationTest->company_id);
446
 
447
                                            $companies[ $company->id ]  = $company;
448
                                        } else {
449
                                            $company = $companies[ $performanceEvaluationTest->company_id ];
450
                                        }
451
 
452
 
453
                                        $url = $this->url()->fromRoute('backend/signin-company', [
454
                                            'id' => $company->uuid,
455
                                            'relational' => $performanceEvaluationTest->uuid,
456
                                            'type' => CalendarEvent::TYPE_PERFORMANCE_EVALUATION
457
                                        ]);
458
 
459
 
460
 
461
                                    }
462
 
463
                                    $agenda = " LABEL_PERFORMANCE_EVALUATION_FORM_NAME : " . $performanceEvaluationForm->name . "<br>";
464
                                    $agenda .= " LABEL_PERFORMANCE_EVALUATION_JOB_DESCRIPTION : " . $jobDescription->name . "<br>";
465
 
466
                                    switch($performanceEvaluationTest->type)
467
                                    {
468
                                        case PerformanceEvaluationTest::TYPE_BOTH :
469
                                            $agenda .= " LABEL_PERFORMANCE_EVALUATION_TYPE : LABEL_PERFORMANCE_EVALUATION_TYPE_BOTH <br>";
470
                                            break;
471
 
472
                                        case PerformanceEvaluationTest::TYPE_SUPERVISOR :
473
                                            $agenda .= " LABEL_PERFORMANCE_EVALUATION_TYPE : LABEL_PERFORMANCE_EVALUATION_TYPE_SUPERVISOR <br>";
474
                                            break;
475
 
476
                                        case PerformanceEvaluationTest::TYPE_EMPLOYEE :
477
                                            $agenda .= " LABEL_PERFORMANCE_EVALUATION_TYPE : LABEL_PERFORMANCE_EVALUATION_TYPE_EMPLOYEE <br>";
478
                                            break;
479
 
480
 
481
                                    }
482
 
483
                                    if($supervisor) {
484
                                        $agenda .= " LABEL_PERFORMANCE_EVALUATION_SUPERVISOR : " . trim($supervisor->first_name . ' ' . $supervisor->last_name) . " <br>";
485
 
486
                                    }
487
                                    if($employee) {
488
                                        $agenda .= " LABEL_PERFORMANCE_EVALUATION_EMPLOYEE : " . trim($employee->first_name . ' ' . $employee->last_name) . " <br>";
489
 
490
                                    }
491
 
492
                                    $dtStart = \DateTime::createFromFormat('Y-m-d', $performanceEvaluationTest->last_date);
493
                                    $agenda .= " LABEL_PERFORMANCE_EVALUATION_LAST_DATE : " . $dtStart->format('Y-m-d') . "<br>" ;
494
 
495
 
496
 
497
                                    array_push($events, [
498
                                        'id'                => $performanceEvaluationTest->uuid,
499
                                        'title'             =>  $performanceEvaluationForm->name,
500
                                        'agenda'            => $agenda,
501
                                        'start'             => $dtStart->format('Y-m-d'),
502
                                        'url'               => $url,
503
                                        'backgroundColor'   => $backgroundColor,
504
                                        'textColor'         => $textColor,
505
                                        'allDay'            => true,
506
                                        'type'              => 'task',
507
                                    ]);
508
                                }
509
                            }
510
 
511
                        }
512
 
513
 
514
 
515
 
516
 
517
                        break;
518
 
519
                    case CalendarEvent::TYPE_ZOOM :
520
                        $zoomMeeting = $zoomMeetingMapper->fetchOne($record->relational_id);
521
                        if($zoomMeeting) {
522
 
523
                            $backgroundColor = $currentNetwork->css_calendar_zoom_bg_color ;
524
                            $textColor = $currentNetwork->css_calendar_zoom_text_color;
525
 
526
                            $dtStart = \DateTime::createFromFormat('Y-m-d H:i:s', $zoomMeeting->start_time);
527
                            $t2 = $dtStart->getTimestamp();
528
 
529
                            if($t2 > $t1) {
530
 
531
                                $t3 = $t1 + $expirePeriod;
532
                                if($t3 > $t2) {
533
                                    $backgroundColor = $currentNetwork->css_calendar_expire_bg_color;
534
                                    $textColor = $currentNetwork->css_calendar_expire_text_color;
535
                                }
536
 
537
                            }
538
 
539
 
540
 
541
                            if($currentUser->timezone && $currentUser->timezone != $zoomMeeting->timezone) {
542
 
543
                                $start =  str_replace(' ', 'T', Functions::convertDateTimeBetweenTimeZones($zoomMeeting->start_time, $zoomMeeting->timezone, $currentUser->timezone));
544
                                $end =  str_replace(' ', 'T', Functions::convertDateTimeBetweenTimeZones($zoomMeeting->end_time, $zoomMeeting->timezone, $currentUser->timezone));
545
 
546
 
547
 
548
 
549
 
550
                            } else {
551
                                $start = str_replace(' ', 'T', $zoomMeeting->start_time);
552
                                $end = str_replace(' ', 'T', $zoomMeeting->end_time);
553
                            }
554
 
555
 
556
 
557
 
558
 
559
 
560
                            $agenda = "<a href=\"{$zoomMeeting->join_url}\" target=\"_blank\">" .  $zoomMeeting->agenda . "<br>" .
561
                                " LABEL_ZOOM_MEETING_START_DATE : " . $dtStart->format('Y-m-d') . "<br>" .
562
                                " LABEL_ZOOM_MEETING_START_TIME : " . $dtStart->format('H:i a') . "<br>" .
563
                                " LABEL_ZOOM_MEETING_TIMEZONE : " . $zoomMeeting->timezone . "<br>" .
564
                                " LABEL_ZOOM_MEETING_TITLE :  " . $zoomMeeting->topic  . "<br>" .
565
                                " LABEL_ZOOM_MEETING_URL : " . $zoomMeeting->join_url . "<br>" .
566
                                " LABEL_ZOOM_MEETING_PASSWORD : " . $zoomMeeting->password . "<br>" .
567
                                "</a>";
568
 
569
                            array_push($events, [
570
                                'id'                => $zoomMeeting->id,
571
                                'title'             => $zoomMeeting->topic,
572
                                'agenda'            => $agenda,
573
                                'start'             => $start,
574
                                'end'               => $end,
575
                                'url'               => $zoomMeeting->join_url,
576
                                'backgroundColor'   => $backgroundColor,
577
                                'textColor'         => $textColor,
578
                                'type'              => 'event',
579
                            ]);
580
                        }
581
                        break;
582
 
583
 
584
                }
585
 
586
 
587
 
588
            }
589
 
590
 
591
 
592
 
121 efrain 593
            return new JsonModel([
594
                'success' => true,
595
                'data' => $events
596
            ]);
1 efrain 597
 
598
        } else {
599
            $response = [
600
                'success' => false,
601
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
602
            ];
603
        }
604
 
605
        return new JsonModel($response);
606
    }
607
 
608
 
609
 
610
 
611
}