Proyectos de Subversion LeadersLinked - Services

Rev

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