Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15461 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Controller;
6
 
7
use Laminas\Db\Adapter\AdapterInterface;
16766 efrain 8
use LeadersLinked\Cache\CacheInterface;
15461 efrain 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\Library\Functions;
14
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
15
use LeadersLinked\Model\RecruitmentSelectionCandidate;
16
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
17
use LeadersLinked\Mapper\UserMapper;
18
use Laminas\Hydrator\ArraySerializableHydrator;
19
use Laminas\Db\ResultSet\HydratingResultSet;
20
use LeadersLinked\Mapper\QueryMapper;
21
use Laminas\Paginator\Adapter\DbSelect;
22
use Laminas\Paginator\Paginator;
23
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationVacancyForm;
24
use LeadersLinked\Mapper\RecruitmentSelectionApplicationMapper;
25
use LeadersLinked\Model\RecruitmentSelectionApplication;
26
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationCandidateForm;
27
use LeadersLinked\Mapper\LocationMapper;
28
use LeadersLinked\Mapper\JobCategoryMapper;
29
use LeadersLinked\Mapper\IndustryMapper;
30
use LeadersLinked\Mapper\JobDescriptionMapper;
31
use LeadersLinked\Mapper\RecruitmentSelectionFileMapper;
32
use LeadersLinked\Mapper\RecruitmentSelectionInterviewMapper;
33
use LeadersLinked\Model\RecruitmentSelectionInterview;
34
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationFileForm;
35
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationPointsAndCommentForm;
36
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationLevelForm;
37
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationStatusForm;
38
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationInterviewForm;
39
 
40
class RecruitmentSelectionApplicationController extends AbstractActionController{
41
 
42
    /**
43
     *
44
     * @var AdapterInterface
45
     */
46
    private $adapter;
47
 
48
    /**
49
     *
16766 efrain 50
     * @var CacheInterface
15461 efrain 51
     */
52
    private $cache;
53
 
54
    /**
55
     *
56
     * @var  LoggerInterface
57
     */
58
    private $logger;
59
 
60
    /**
61
     *
62
     * @var array
63
     */
64
    private $config;
65
 
66
    /**
67
     *
68
     * @param AdapterInterface $adapter
16766 efrain 69
     *@param CacheInterface $cache
15461 efrain 70
     * @param LoggerInterface $logger
71
     * @param array $config
72
     */
73
    public function __construct($adapter, $cache, $logger, $config) {
74
        $this->adapter = $adapter;
75
        $this->cache = $cache;
76
        $this->logger = $logger;
77
        $this->config = $config;
78
    }
79
 
80
    public function indexAction() {
81
        $currentUserPlugin = $this->plugin('currentUserPlugin');
82
        $currentUser = $currentUserPlugin->getUser();
83
        $currentCompany = $currentUserPlugin->getCompany();
84
 
85
        $request = $this->getRequest();
86
 
87
        if ($request->isGet()) {
88
 
89
            $headers = $request->getHeaders();
90
 
91
            $isJson = false;
92
            if ($headers->has('Accept')) {
93
                $accept = $headers->get('Accept');
94
 
95
                $prioritized = $accept->getPrioritized();
96
 
97
                foreach ($prioritized as $key => $value) {
98
                    $raw = trim($value->getRaw());
99
 
100
                    if (!$isJson) {
101
                        $isJson = strpos($raw, 'json');
102
                    }
103
                }
104
            }
105
 
106
           // $isJson = true;
107
            if ($isJson) {
108
 
109
                $vacancy_uuid = $this->params()->fromQuery('vacancy_id');
110
 
111
                $data = [
112
                    'items' => [],
113
                    'total' => 0,
114
                    'link_add' => '',
115
                ];
116
 
117
 
118
                if (!$vacancy_uuid) {
119
                    return new JsonModel([
120
                        'success' => true,
121
                        'data' => $data
122
                    ]);
123
                }
124
 
125
 
126
                $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
127
                $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
128
                if (! $vacancy) {
129
                    return new JsonModel([
130
                        'success' => true,
131
                        'data' => 'ERROR_VACANCY_NOT_FOUND'
132
                    ]);
133
                }
134
 
135
                if ( $vacancy->company_id != $currentCompany->id) {
136
                    return new JsonModel([
137
                        'success' => true,
138
                        'data' => 'ERROR_UNAUTHORIZED'
139
                    ]);
140
                }
141
 
142
 
143
                $search = $this->params()->fromQuery('search');
16766 efrain 144
                $search = empty($search) ? '' : Functions::sanitizeFilterString($search);
15461 efrain 145
 
146
                $start = intval($this->params()->fromQuery('start', 0), 10);
147
                $records_x_page = intval($this->params()->fromQuery('length', 10), 10);
148
                $page =  intval($start / $records_x_page);
149
                $page++;
150
 
151
                $order = $this->params()->fromQuery('order', []);
152
                $order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
16766 efrain 153
                $order_direction = empty($order[0]['dir']) ? 'ASC' : Functions::sanitizeFilterString(filter_var($order[0]['dir']));
15461 efrain 154
 
155
                $fields = ['first_name', 'last_name', 'email'];
156
                $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
157
 
158
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
159
                    $order_direction = 'ASC';
160
                }
161
 
162
 
163
 
164
 
165
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
166
                $allowAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/add');
167
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/delete');
168
                $allowView = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/view');
169
 
170
 
171
 
172
                $queryMapper = QueryMapper::getInstance($this->adapter);
173
                $sql = $queryMapper->getSql();
174
                $select = $sql->select();
175
                $select->columns(['uuid', 'level', 'status']);
176
                $select->from(['tb1' => RecruitmentSelectionApplicationMapper::_TABLE]);
177
                $select->join(['tb2' => RecruitmentSelectionCandidateMapper::_TABLE], 'tb1.candidate_id  = tb2.id', ['first_name', 'last_name', 'email']);
178
                $select->where->equalTo('tb1.vacancy_id', $vacancy->id);
179
 
180
 
181
                if($search) {
182
                    $select->where->nest()
183
                    ->like('first_name', '%' . $search . '%')
184
                    ->or->like('last_name', '%' . $search . '%')
185
                    ->or->like('email', '%' . $search . '%')
186
                    ->unnest();
187
                }
188
 
189
                $select->order($order_field . ' ' . $order_direction);
190
 
191
               // echo $select->getSqlString($this->adapter->platform); exit;
192
 
193
                $hydrator = new ArraySerializableHydrator();
194
                $resultset = new HydratingResultSet($hydrator);
195
 
196
                $adapter = new DbSelect($select, $sql, $resultset);
197
                $paginator = new Paginator($adapter);
198
                $paginator->setItemCountPerPage($records_x_page);
199
                $paginator->setCurrentPageNumber($page);
200
 
201
 
202
                $items = [];
203
                $records = $paginator->getCurrentItems();
204
 
205
 
206
                foreach ($records as $record) {
207
 
208
                    switch($record['status'])
209
                    {
210
                        case RecruitmentSelectionApplication::STATUS_ACTIVE :
211
                            $status = 'LABEL_ACTIVE';
212
                            break;
213
 
214
 
215
                        case RecruitmentSelectionApplication::STATUS_INACTIVE :
216
                            $status = 'LABEL_INACTIVE';
217
                            break;
218
 
219
                        case RecruitmentSelectionApplication::STATUS_SELECTED :
220
                            $status = 'LABEL_SELECTED';
221
                            break;
222
 
223
                        case RecruitmentSelectionApplication::STATUS_REJECTED :
224
                            $status = 'LABEL_REJECTED';
225
                            break;
226
 
227
                    }
228
 
229
                    switch($record['level'])
230
                    {
231
                        case RecruitmentSelectionApplication::LEVEL_CAPTURE :
232
                            $level = 'LABEL_CAPTURE';
233
                            break;
234
 
235
                        case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
236
                            $level =  'LABEL_PRE_SELECTION';
237
                            break;
238
 
239
                        case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
240
                            $level =  'LABEL_HUMAN_RESOURCE';
241
                            break;
242
 
243
                        case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
244
                            $level =  'LABEL_BOSS_INTERVIEW';
245
                            break;
246
 
247
                        case RecruitmentSelectionApplication::LEVEL_FINISHED :
248
                            $level =  'LABEL_FINISHED';
249
                            break;
250
 
251
                        default :
252
                            $level =  'LABEL_UNKNOWN';
253
                            break;
254
 
255
                    }
256
 
257
                    $item = [
258
                        'first_name' => $record['first_name'],
259
                        'last_name' => $record['last_name'],
260
                        'email' => $record['email'],
261
                        'status' => $status,
262
                        'level' => $level,
263
                        'actions' => [
264
                            'link_delete' => $allowDelete ? $this->url()->fromRoute('recruitment-and-selection/applications/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $record['uuid']] ) : '',
265
                            'link_view' => $allowView ? $this->url()->fromRoute('recruitment-and-selection/applications/view', ['vacancy_id' => $vacancy->uuid, 'application_id' => $record['uuid']] ) : '',
266
                        ]
267
                    ];
268
 
269
                    array_push($items, $item);
270
                }
271
 
272
                $data['items'] = $items;
273
                $data['total'] = $paginator->getTotalItemCount();
274
                $data['link_add'] =  $allowAdd ? $this->url()->fromRoute( 'recruitment-and-selection/applications/add', ['vacancy_id' => $vacancy->uuid ]) : '';
275
 
276
 
277
                return new JsonModel([
278
                    'success' => true,
279
                    'data' => $data
280
                ]);
281
            } else {
282
                $formFile = new RecruitmentSelectionApplicationFileForm();
283
                $formAdd = new RecruitmentSelectionApplicationCandidateForm($this->adapter);
284
                $formFilter = new RecruitmentSelectionApplicationVacancyForm($this->adapter, $currentCompany->id);
285
                $formComment = new RecruitmentSelectionApplicationPointsAndCommentForm();
286
                $formLevel = new RecruitmentSelectionApplicationLevelForm();
287
                $formStatus = new RecruitmentSelectionApplicationStatusForm();
288
                $formInterview = new RecruitmentSelectionApplicationInterviewForm($this->adapter, $currentCompany->id);
289
 
290
 
291
                $this->layout()->setTemplate('layout/layout-backend');
292
                $viewModel = new ViewModel();
293
                $viewModel->setTemplate('leaders-linked/recruitment-and-selection-applications/index.phtml');
294
                $viewModel->setVariables([
295
                    'formFilter' => $formFilter,
296
                    'formAdd' => $formAdd,
297
                    'formFile' => $formFile,
298
                    'formComment' => $formComment,
299
                    'formLevel' => $formLevel,
300
                    'formStatus' => $formStatus,
301
                    'formInterview' => $formInterview,
302
                ]);
303
 
304
                return $viewModel;
305
            }
306
        } else {
307
            return new JsonModel([
308
                'success' => false,
309
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
310
            ]);
311
            ;
312
        }
313
    }
314
 
315
    public function userByEmailAction()
316
    {
317
        $currentUserPlugin = $this->plugin('currentUserPlugin');
318
        $currentUser = $currentUserPlugin->getUser();
319
        $currentCompany     = $currentUserPlugin->getCompany();
320
 
321
 
322
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
323
        $currentNetwork = $currentNetworkPlugin->getNetwork();
324
 
325
        $request = $this->getRequest();
326
 
327
        if ($request->isGet()) {
328
 
329
 
330
 
331
            $email = trim(filter_var($this->params()->fromQuery('email'), FILTER_SANITIZE_EMAIL));
332
            if($email) {
333
 
334
                $userMapper = UserMapper::getInstance($this->adapter);
335
                $user = $userMapper->fetchOneActiveByEmailAndNetworkId($email, $currentNetwork->id);
336
                if($user) {
337
                    $data = [
338
                        'success' => true,
339
                        'data' => [
340
                            'uuid' => $user->uuid,
341
                            'first_name' => $user->first_name,
342
                            'last_name' => $user->last_name,
343
                            'email' => $user->email
344
                        ]
345
                    ];
346
                } else {
15463 efrain 347
                    $recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
348
                    $candidate = $recruitmentSelectionCandidateMapper->fetchOneActiveByEmailAndCompanyId($email, $currentCompany->id);
349
                    if($candidate) {
350
                        $data = [
351
                            'success' => true,
352
                            'data' => [
353
                                'uuid' => '',
354
                                'first_name' => $candidate->first_name,
355
                                'last_name' => $candidate->last_name,
356
                                'email' => $candidate->email
357
                            ]
358
                        ];
359
                    } else {
360
 
361
                        $data = [
362
                            'success' => false,
363
                            'data' => 'ERROR_EMAIL_NOT_FOUND'
364
                        ];
365
                    }
15461 efrain 366
                }
367
            } else {
368
                $data = [
369
                    'success' => false,
370
                    'data' => 'ERROR_EMAIL_NOT_FOUND'
371
                ];
372
            }
373
        } else {
374
            $data = [
375
                'success' => false,
376
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
377
            ];
378
        }
379
 
380
 
381
        return new JsonModel($data);
382
 
383
    }
384
 
385
 
386
    public function addAction()
387
    {
388
        $currentUserPlugin  = $this->plugin('currentUserPlugin');
389
        $currentCompany     = $currentUserPlugin->getCompany();
390
        $currentUser        = $currentUserPlugin->getUser();
391
 
392
        $request    = $this->getRequest();
393
 
394
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
395
 
396
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
397
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
398
 
399
        if(!$vacancy) {
400
            $data = [
401
                'success' => false,
402
                'data' => 'ERROR_VACANCY_NOT_FOUND'
403
            ];
404
 
405
            return new JsonModel($data);
406
        }
407
 
408
 
409
        if($vacancy->company_id != $currentCompany->id) {
410
            $data = [
411
                'success' => false,
412
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
413
            ];
414
 
415
            return new JsonModel($data);
416
        }
417
 
418
 
419
 
420
 
421
 
422
        if($request->isPost()) {
423
            $dataPost = $request->getPost()->toArray();
424
 
425
            $form = new  RecruitmentSelectionApplicationCandidateForm($this->adapter);
426
            $form->setData($dataPost);
427
 
428
            if($form->isValid()) {
429
                $dataPost = (array) $form->getData();
430
 
431
                $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
432
                $candidate = $candidateMapper->fetchOneByEmail($dataPost['email']);
433
                if($candidate) {
434
 
435
 
436
                    $candidate->first_name = $dataPost['first_name'];
437
                    $candidate->last_name = $dataPost['last_name'];
438
 
439
                    $result = $candidateMapper->update($candidate);
440
 
441
                } else {
442
 
443
                    $candidate = new RecruitmentSelectionCandidate();
444
                    $candidate->company_id = $currentCompany->id;
445
                    $candidate->email = strtolower($dataPost['email']);
446
                    $candidate->first_name = $dataPost['first_name'];
447
                    $candidate->last_name = $dataPost['last_name'];
448
 
449
                    $result = $candidateMapper->insert($candidate);
450
                }
451
 
452
 
453
                if(!$result) {
454
                    $data = [
455
                        'success'   => false,
456
                        'data'      => $candidateMapper->getError()
457
                    ];
458
 
459
                    return new JsonModel($data);
460
                }
461
 
462
                $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
463
                $application = $applicationMapper->fetchOneByVancancyIdAndCandidateId($vacancy->id, $candidate->id);
464
 
465
 
466
                if($application) {
467
                    $data = [
468
                        'success'   => false,
469
                        'data'      => 'ERROR_VACANCY_CANDIDATE_HAS_BEEN_PREVIOUSLY_ADDED',
470
                    ];
471
 
472
                    return new JsonModel($data);
473
 
474
                }
475
 
476
 
477
                $application = new RecruitmentSelectionApplication();
478
                $application->candidate_id = $candidate->id;
479
                $application->company_id = $currentCompany->id;
480
                $application->level = RecruitmentSelectionApplication::LEVEL_CAPTURE;
481
                $application->status = RecruitmentSelectionApplication::STATUS_ACTIVE;
482
                $application->vacancy_id = $vacancy->id;
483
 
484
 
485
 
486
                if($applicationMapper->insert($application)) {
487
 
488
                    $this->logger->info('Se agrego la aplicación del candidato : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
489
 
490
                    $data = [
491
                        'success'   => true,
492
                        'data'   => 'LABEL_RECORD_ADDED'
493
                    ];
494
                } else {
495
                    $data = [
496
                        'success'   => false,
497
                        'data'      => $applicationMapper->getError()
498
                    ];
499
 
500
                }
501
 
502
                return new JsonModel($data);
503
 
504
            } else {
505
                $messages = [];
506
                $form_messages = (array) $form->getMessages();
507
                foreach ($form_messages as $fieldname => $field_messages) {
508
 
509
                    $messages[$fieldname] = array_values($field_messages);
510
                }
511
 
512
                return new JsonModel([
513
                    'success' => false,
514
                    'data' => $messages
515
                ]);
516
 
517
            }
518
 
519
        } else {
520
            $data = [
521
                'success' => false,
522
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
523
            ];
524
 
525
            return new JsonModel($data);
526
        }
527
 
528
        return new JsonModel($data);
529
    }
530
 
531
 
532
    public function commentAction()
533
    {
534
        $request = $this->getRequest();
535
        $currentUserPlugin = $this->plugin('currentUserPlugin');
536
        $currentCompany = $currentUserPlugin->getCompany();
537
        $currentUser = $currentUserPlugin->getUser();
538
 
539
        $request = $this->getRequest();
540
        $application_id = $this->params()->fromRoute('application_id');
541
 
542
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
543
 
544
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
545
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
546
 
547
        if(!$vacancy) {
548
            $data = [
549
                'success' => false,
550
                'data' => 'ERROR_VACANCY_NOT_FOUND'
551
            ];
552
 
553
            return new JsonModel($data);
554
        }
555
 
556
 
557
        if($vacancy->company_id != $currentCompany->id) {
558
            $data = [
559
                'success' => false,
560
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
561
            ];
562
 
563
            return new JsonModel($data);
564
        }
565
 
566
 
567
 
568
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
569
        $application = $applicationMapper->fetchOneByUuid($application_id);
570
 
571
 
572
        if (!$application) {
573
            $data = [
574
                'success' => false,
575
                'data' => 'ERROR_RECORD_NOT_FOUND'
576
            ];
577
 
578
            return new JsonModel($data);
579
        }
580
 
581
 
582
        if ($application->vacancy_id != $vacancy->id) {
583
            return new JsonModel([
584
                'success' => false,
585
                'data' => 'ERROR_UNAUTHORIZED'
586
            ]);
587
        }
588
 
589
 
590
        if ($request->isGet()) {
591
 
592
            $data = [
593
                'success' => true,
594
                'data' => [
595
                    'points' => $application->points ? intval($application->points, 10) : 0,
596
                    'comment' => $application->comment ? trim($application->comment) : '',
597
                ]
598
            ];
599
 
600
            return new JsonModel($data);
601
 
602
 
603
 
604
        } else if ($request->isPost()) {
605
 
606
 
607
            $dataPost = $request->getPost()->toArray();
608
 
609
            $form = new RecruitmentSelectionApplicationPointsAndCommentForm();
610
            $form->setData($dataPost);
611
 
612
            if($form->isValid()) {
613
                $dataPost = (array) $form->getData();
614
 
615
                $application->points    = $dataPost['points'];
616
                $application->comment   = $dataPost['comment'];
617
 
618
                $result =  $applicationMapper->update($application);
619
                if ($result) {
620
                    $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
621
                    $candidate = $candidateMapper->fetchOne($application->candidate_id);
622
 
623
 
624
                    $this->logger->info('Se actualizo los puntos y comentario de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
625
 
626
                    $data = [
627
                        'success' => true,
628
                        'data' => [
629
                            'message' => 'LABEL_RECORD_UPDATED',
630
                            'points' => $application->points ? intval($application->points, 10) : 0,
631
                            'comment' => $application->comment ? trim($application->comment) : '',
632
                        ]
633
                    ];
634
 
635
 
636
                } else {
637
 
638
                    $data = [
639
                        'success' => false,
640
                        'data' => $applicationMapper->getError()
641
                    ];
642
 
643
                    return new JsonModel($data);
644
                }
645
 
646
 
647
            } else {
648
                $messages = [];
649
                $form_messages = (array) $form->getMessages();
650
                foreach ($form_messages as $fieldname => $field_messages) {
651
 
652
                    $messages[$fieldname] = array_values($field_messages);
653
                }
654
 
655
                return new JsonModel([
656
                    'success' => false,
657
                    'data' => $messages
658
                ]);
659
            }
660
 
661
 
662
        } else {
663
            $data = [
664
                'success' => false,
665
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
666
            ];
667
 
668
            return new JsonModel($data);
669
        }
670
 
671
        return new JsonModel($data);
672
    }
673
 
674
 
675
    public function statusAction()
676
    {
677
        $request = $this->getRequest();
678
        $currentUserPlugin = $this->plugin('currentUserPlugin');
679
        $currentCompany = $currentUserPlugin->getCompany();
680
        $currentUser = $currentUserPlugin->getUser();
681
 
682
        $request = $this->getRequest();
683
        $application_id = $this->params()->fromRoute('application_id');
684
 
685
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
686
 
687
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
688
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
689
 
690
        if(!$vacancy) {
691
            $data = [
692
                'success' => false,
693
                'data' => 'ERROR_VACANCY_NOT_FOUND'
694
            ];
695
 
696
            return new JsonModel($data);
697
        }
698
 
699
 
700
        if($vacancy->company_id != $currentCompany->id) {
701
            $data = [
702
                'success' => false,
703
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
704
            ];
705
 
706
            return new JsonModel($data);
707
        }
708
 
709
 
710
 
711
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
712
        $application = $applicationMapper->fetchOneByUuid($application_id);
713
 
714
 
715
        if (!$application) {
716
            $data = [
717
                'success' => false,
718
                'data' => 'ERROR_RECORD_NOT_FOUND'
719
            ];
720
 
721
            return new JsonModel($data);
722
        }
723
 
724
 
725
        if ($application->vacancy_id != $vacancy->id) {
726
            return new JsonModel([
727
                'success' => false,
728
                'data' => 'ERROR_UNAUTHORIZED'
729
            ]);
730
        }
731
 
732
 
733
        if ($request->isGet()) {
734
 
735
            $data = [
736
                'success' => true,
737
                'data' => [
738
                    'status' => $application->status
739
                ]
740
            ];
741
 
742
            return new JsonModel($data);
743
 
744
 
745
 
746
        } else if ($request->isPost()) {
747
 
748
 
749
            $dataPost = $request->getPost()->toArray();
750
 
751
            $form = new RecruitmentSelectionApplicationStatusForm();
752
            $form->setData($dataPost);
753
 
754
            if($form->isValid()) {
755
                $dataPost = (array) $form->getData();
756
 
757
                $application->status    = $dataPost['status'];
758
 
759
                $result =  $applicationMapper->update($application);
760
                if ($result) {
761
                    $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
762
                    $candidate = $candidateMapper->fetchOne($application->candidate_id);
763
 
764
 
765
                    $this->logger->info('Se actualizo el estado de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
766
 
767
                    switch($application->status)
768
                    {
769
                        case RecruitmentSelectionApplication::STATUS_ACTIVE :
770
                            $status = 'LABEL_ACTIVE';
771
                            break;
772
 
773
 
774
                        case RecruitmentSelectionApplication::STATUS_INACTIVE :
775
                            $status = 'LABEL_INACTIVE';
776
                            break;
777
 
778
                        case RecruitmentSelectionApplication::STATUS_SELECTED :
779
                            $status = 'LABEL_SELECTED';
780
                            break;
781
 
782
                        case RecruitmentSelectionApplication::STATUS_REJECTED :
783
                            $status = 'LABEL_REJECTED';
784
                            break;
785
 
786
                    }
787
 
788
 
789
                    $data = [
790
                        'success' => true,
791
                        'data' => [
792
                            'message' => 'LABEL_RECORD_UPDATED',
793
                            'status' => $status
794
                        ]
795
                    ];
796
 
797
 
798
 
799
                } else {
800
 
801
                    $data = [
802
                        'success' => false,
803
                        'data' => $applicationMapper->getError()
804
                    ];
805
 
806
                    return new JsonModel($data);
807
                }
808
 
809
 
810
            } else {
811
                $messages = [];
812
                $form_messages = (array) $form->getMessages();
813
                foreach ($form_messages as $fieldname => $field_messages) {
814
 
815
                    $messages[$fieldname] = array_values($field_messages);
816
                }
817
 
818
                return new JsonModel([
819
                    'success' => false,
820
                    'data' => $messages
821
                ]);
822
            }
823
 
824
 
825
        } else {
826
            $data = [
827
                'success' => false,
828
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
829
            ];
830
 
831
            return new JsonModel($data);
832
        }
833
 
834
        return new JsonModel($data);
835
    }
836
 
837
 
838
    public function levelAction()
839
    {
840
        $request = $this->getRequest();
841
        $currentUserPlugin = $this->plugin('currentUserPlugin');
842
        $currentCompany = $currentUserPlugin->getCompany();
843
        $currentUser = $currentUserPlugin->getUser();
844
 
845
        $request = $this->getRequest();
846
        $application_id = $this->params()->fromRoute('application_id');
847
 
848
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
849
 
850
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
851
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
852
 
853
        if(!$vacancy) {
854
            $data = [
855
                'success' => false,
856
                'data' => 'ERROR_VACANCY_NOT_FOUND'
857
            ];
858
 
859
            return new JsonModel($data);
860
        }
861
 
862
 
863
        if($vacancy->company_id != $currentCompany->id) {
864
            $data = [
865
                'success' => false,
866
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
867
            ];
868
 
869
            return new JsonModel($data);
870
        }
871
 
872
 
873
 
874
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
875
        $application = $applicationMapper->fetchOneByUuid($application_id);
876
 
877
 
878
        if (!$application) {
879
            $data = [
880
                'success' => false,
881
                'data' => 'ERROR_RECORD_NOT_FOUND'
882
            ];
883
 
884
            return new JsonModel($data);
885
        }
886
 
887
 
888
        if ($application->vacancy_id != $vacancy->id) {
889
            return new JsonModel([
890
                'success' => false,
891
                'data' => 'ERROR_UNAUTHORIZED'
892
            ]);
893
        }
894
 
895
 
896
        if ($request->isGet()) {
897
 
898
            $data = [
899
                'success' => true,
900
                'data' => [
901
                    'level' => $application->level
902
                ]
903
            ];
904
 
905
            return new JsonModel($data);
906
 
907
 
908
 
909
        } else if ($request->isPost()) {
910
 
911
 
912
            $dataPost = $request->getPost()->toArray();
913
 
914
            $form = new RecruitmentSelectionApplicationLevelForm();
915
            $form->setData($dataPost);
916
 
917
            if($form->isValid()) {
918
                $dataPost = (array) $form->getData();
919
 
920
                $application->level = $dataPost['level'];
921
 
922
                $result =  $applicationMapper->update($application);
923
                if ($result) {
924
                    $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
925
                    $candidate = $candidateMapper->fetchOne($application->candidate_id);
926
 
927
 
928
                    $this->logger->info('Se actualizo el nivel de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
929
 
930
 
931
                    switch($application->level)
932
                    {
933
                        case RecruitmentSelectionApplication::LEVEL_CAPTURE :
934
                            $level = 'LABEL_CAPTURE';
935
                            break;
936
 
937
                        case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
938
                            $level =  'LABEL_PRE_SELECTION';
939
                            break;
940
 
941
                        case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
942
                            $level =  'LABEL_HUMAN_RESOURCE';
943
                            break;
944
 
945
                        case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
946
                            $level =  'LABEL_BOSS_INTERVIEW';
947
                            break;
948
 
949
                        case RecruitmentSelectionApplication::LEVEL_FINISHED :
950
                            $level =  'LABEL_FINISHED';
951
                            break;
952
 
953
                        default :
954
                            $level =  'LABEL_UNKNOWN';
955
                            break;
956
 
957
                    }
958
 
959
                    $data = [
960
                        'success' => true,
961
                        'data' => [
962
                            'message' => 'LABEL_RECORD_UPDATED',
963
                            'level' => $level
964
                        ]
965
                    ];
966
 
967
                } else {
968
 
969
                    $data = [
970
                        'success' => false,
971
                        'data' => $applicationMapper->getError()
972
                    ];
973
 
974
                    return new JsonModel($data);
975
                }
976
 
977
 
978
            } else {
979
                $messages = [];
980
                $form_messages = (array) $form->getMessages();
981
                foreach ($form_messages as $fieldname => $field_messages) {
982
 
983
                    $messages[$fieldname] = array_values($field_messages);
984
                }
985
 
986
                return new JsonModel([
987
                    'success' => false,
988
                    'data' => $messages
989
                ]);
990
            }
991
 
992
 
993
        } else {
994
            $data = [
995
                'success' => false,
996
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
997
            ];
998
 
999
            return new JsonModel($data);
1000
        }
1001
 
1002
        return new JsonModel($data);
1003
    }
1004
 
1005
 
1006
    public function deleteAction()
1007
    {
1008
        $request = $this->getRequest();
1009
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1010
        $currentCompany = $currentUserPlugin->getCompany();
1011
        $currentUser = $currentUserPlugin->getUser();
1012
 
1013
        $request = $this->getRequest();
1014
        $application_id = $this->params()->fromRoute('application_id');
1015
 
1016
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
1017
 
1018
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
1019
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
1020
 
1021
        if(!$vacancy) {
1022
            $data = [
1023
                'success' => false,
1024
                'data' => 'ERROR_VACANCY_NOT_FOUND'
1025
            ];
1026
 
1027
            return new JsonModel($data);
1028
        }
1029
 
1030
 
1031
        if($vacancy->company_id != $currentCompany->id) {
1032
            $data = [
1033
                'success' => false,
1034
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
1035
            ];
1036
 
1037
            return new JsonModel($data);
1038
        }
1039
 
1040
 
1041
 
1042
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
1043
        $application = $applicationMapper->fetchOneByUuid($application_id);
1044
 
1045
 
1046
        if (!$application) {
1047
            $data = [
1048
                'success' => false,
1049
                'data' => 'ERROR_RECORD_NOT_FOUND'
1050
            ];
1051
 
1052
            return new JsonModel($data);
1053
        }
1054
 
1055
 
1056
        if ($application->vacancy_id != $vacancy->id) {
1057
            return new JsonModel([
1058
                'success' => false,
1059
                'data' => 'ERROR_UNAUTHORIZED'
1060
            ]);
1061
        }
1062
 
1063
 
1064
 
1065
        if ($request->isPost()) {
1066
 
1067
            $result = $applicationMapper->delete($application->id);
1068
            if ($result) {
1069
                $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1070
                $candidate = $candidateMapper->fetchOne($application->candidate_id);
1071
 
1072
 
1073
 
1074
                $this->logger->info('Se borro la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1075
 
1076
                $data = [
1077
                    'success' => true,
1078
                    'data' => 'LABEL_RECORD_DELETED'
1079
                ];
1080
            } else {
1081
 
1082
                $data = [
1083
                    'success' => false,
1084
                    'data' => $candidateMapper->getError()
1085
                ];
1086
 
1087
                return new JsonModel($data);
1088
            }
1089
        } else {
1090
            $data = [
1091
                'success' => false,
1092
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1093
            ];
1094
 
1095
            return new JsonModel($data);
1096
        }
1097
 
1098
        return new JsonModel($data);
1099
    }
1100
 
1101
    public function viewAction()
1102
    {
1103
        $request = $this->getRequest();
1104
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1105
        $currentCompany = $currentUserPlugin->getCompany();
1106
        $currentUser = $currentUserPlugin->getUser();
1107
 
1108
        $request = $this->getRequest();
1109
        $application_id = $this->params()->fromRoute('application_id');
1110
 
1111
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
1112
 
1113
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
1114
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
1115
 
1116
        if(!$vacancy) {
1117
            $data = [
1118
                'success' => false,
1119
                'data' => 'ERROR_VACANCY_NOT_FOUND'
1120
            ];
1121
 
1122
            return new JsonModel($data);
1123
        }
1124
 
1125
 
1126
        if($vacancy->company_id != $currentCompany->id) {
1127
            $data = [
1128
                'success' => false,
1129
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
1130
            ];
1131
 
1132
            return new JsonModel($data);
1133
        }
1134
 
1135
 
1136
 
1137
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
1138
        $application = $applicationMapper->fetchOneByUuid($application_id);
1139
 
1140
 
1141
        if (!$application) {
1142
            $data = [
1143
                'success' => false,
1144
                'data' => 'ERROR_RECORD_NOT_FOUND'
1145
            ];
1146
 
1147
            return new JsonModel($data);
1148
        }
1149
 
1150
 
1151
        if ($application->vacancy_id != $vacancy->id) {
1152
            return new JsonModel([
1153
                'success' => false,
1154
                'data' => 'ERROR_UNAUTHORIZED'
1155
            ]);
1156
        }
1157
 
1158
 
1159
 
1160
        if ($request->isGet()) {
1161
 
1162
            $acl = $this->getEvent()->getViewModel()->getVariable('acl');
1163
            $allowFile = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files');
1164
            $allowFileAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/add');
1165
            $allowFileDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/delete');
1166
            $allowFileView = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/view');
1167
            $allowInterview = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/interviews');
1168
            $allowInterviewAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/interviews/add');
1169
            $allowComment = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/comment');
1170
            $allowLevel = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/level');
1171
            $allowStatus = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/status');
1172
 
1173
 
1174
            $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1175
            $candidate = $candidateMapper->fetchOne($application->candidate_id);
1176
 
1177
 
1178
            switch($application->status)
1179
            {
1180
                case RecruitmentSelectionApplication::STATUS_ACTIVE :
1181
                    $status = 'LABEL_ACTIVE';
1182
                    break;
1183
 
1184
 
1185
                case RecruitmentSelectionApplication::STATUS_INACTIVE :
1186
                    $status = 'LABEL_INACTIVE';
1187
                    break;
1188
 
1189
                case RecruitmentSelectionApplication::STATUS_SELECTED :
1190
                    $status = 'LABEL_SELECTED';
1191
                    break;
1192
 
1193
                case RecruitmentSelectionApplication::STATUS_REJECT :
1194
                    $status = 'LABEL_REJECTED';
1195
                    break;
1196
 
1197
            }
1198
 
1199
            switch($application->level)
1200
            {
1201
                case RecruitmentSelectionApplication::LEVEL_CAPTURE :
1202
                    $level = 'LABEL_CAPTURE';
1203
                    break;
1204
 
1205
                case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
1206
                    $level =  'LABEL_PRE_SELECTION';
1207
                    break;
1208
 
1209
                case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
1210
                    $level =  'LABEL_HUMAN_RESOURCE';
1211
                    break;
1212
 
1213
                case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
1214
                    $level =  'LABEL_BOSS_INTERVIEW';
1215
                    break;
1216
 
1217
                case RecruitmentSelectionApplication::LEVEL_FINISHED :
1218
                    $level =  'LABEL_FINISHED';
1219
                    break;
1220
 
1221
                default :
1222
                    $level =  'LABEL_UNKNOWN';
1223
                    break;
1224
 
1225
            }
1226
 
1227
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
1228
            $jobCategory = $jobCategoryMapper->fetchOne($vacancy->job_category_id);
1229
 
1230
            $industryMapper = IndustryMapper::getInstance($this->adapter);
1231
            $industry = $industryMapper->fetchOne($vacancy->industry_id);
1232
 
1233
 
1234
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
1235
            $jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
1236
 
1237
 
1238
            $locationMapper = LocationMapper::getInstance($this->adapter);
1239
            $location = $locationMapper->fetchOne($vacancy->location_id);
1240
 
1241
 
1242
            $dt = \DateTime::createFromFormat('Y-m-d', $vacancy->last_date);
1243
            $last_date = $dt->format('d/m/Y');
1244
 
1245
 
1246
            $recruitmentSelectionFileMapper = RecruitmentSelectionFileMapper::getInstance($this->adapter);
1247
 
1248
 
1249
            $files = [];
1250
            $records = $recruitmentSelectionFileMapper->fetchAllByVacancyId($vacancy->id);
1251
            foreach($records as $record)
1252
            {
1253
                array_push($files, [
1254
                    'name' => $record->name,
1255
                    'filename' => basename($record->file),
1256
                    'link_view' => $allowFileView ? $this->url()->fromRoute('recruitment-and-selection/applications/files/view', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]) : '',
1257
                    'link_delete' => $allowFileDelete ? $this->url()->fromRoute('recruitment-and-selection/applications/files/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]) : '',
1258
                ]);
1259
            }
1260
 
1261
            $userMapper = UserMapper::getInstance($this->adapter);
1262
            $interviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
1263
 
1264
 
1265
 
1266
 
1267
            $interviews = [];
1268
            $records = $interviewMapper->fetchAllByVacancyId($vacancy->id);
1269
            foreach($records as $record)
1270
            {
1271
                $status = '';
1272
                switch($record->status)
1273
                {
1274
                    case RecruitmentSelectionInterview::STATUS_ACCEPTED :
1275
                        $status = 'LABEL_ACCEPTED';
1276
                        $link_report = $this->url()->fromRoute('recruitment-and-selection/applications/interviews/report', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]);
1277
 
1278
                        break;
1279
 
1280
                    case RecruitmentSelectionInterview::STATUS_PENDING :
1281
                        $status = 'LABEL_PENDING';
1282
                        $link_report = '';
1283
                        break;
1284
 
1285
                    case RecruitmentSelectionInterview::STATUS_REJECTED :
1286
                        $status = 'LABEL_REJECTED';
1287
 
1288
                        $link_report = $this->url()->fromRoute('recruitment-and-selection/applications/interviews/report', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]);
1289
 
1290
                        break;
1291
 
1292
                    default :
1293
                        $status = 'LABEL_UNKNOWN';
1294
                        $link_report = '';
1295
                        break;
1296
 
1297
                }
1298
 
1299
                $type = '';
1300
                switch($record->type)
1301
                {
1302
                    case RecruitmentSelectionInterview::TYPE_BOSS :
1303
                        $type = 'LABEL_BOSS_INTERVIEW';
1304
                        break;
1305
 
1306
                    case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
1307
                        $type = 'LABEL_HUMAN_RESOURCE';
1308
                        break;
1309
 
1310
                    default :
1311
                        $type = 'LABEL_UNKNOWN';
1312
                        break;
1313
 
1314
                }
1315
 
1316
                $dt = \DateTime::createFromFormat('Y-m-d',  $record->last_date);
1317
                $last_date = $dt->format('d/m/Y');
1318
 
1319
 
1320
                if($record->actual_date) {
1321
 
1322
                    $dt = \DateTime::createFromFormat('Y-m-d',  $record->actual_date);
1323
                    $actual_date = $dt->format('d/m/Y');
1324
                } else {
1325
                    $actual_date = '';
1326
                }
1327
 
1328
                $user = $userMapper->fetchOne($record->interviewer_id);
1329
                $interviewer = $user->first_name . ' ' . $user->last_name  . '(' . $user->email . ')';
1330
 
1331
 
1332
 
1333
 
1334
                array_push($interviews, [
1335
                    'type' => $type,
1336
                    'status' => $status,
1337
                    'last_date' => $last_date,
1338
                    'actual_date' => $actual_date,
1339
                    'interviewer' => $interviewer,
1340
                    'points' => $record->points,
1341
                    'link_edit' => $this->url()->fromRoute('recruitment-and-selection/applications/interviews/edit', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]),
1342
                    'link_report' => $link_report,
1343
                    'link_delete' => $this->url()->fromRoute('recruitment-and-selection/applications/interviews/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]),
1344
 
1345
                ]);
1346
            }
1347
 
1348
            $data = [
1349
                'success' => true,
1350
                'data' => [
1351
                    'application' => [
1352
                        'first_name' => $candidate->first_name,
1353
                        'last_name' => $candidate->last_name,
1354
                        'email' => $candidate->email,
1355
                        'level' => $level,
1356
                        'status' => $status,
1357
                        'points' => $application->points,
1358
                        'comment' => $application->comment,
1359
                    ],
1360
                    'vacancy' => [
1361
                        'name' => $vacancy->name,
1362
                        'last_date' => $last_date,
1363
                        'address' => $location->formatted_address,
1364
                        'industry' => $industry->name,
1365
                        'job_category' => $jobCategory->name,
1366
                        'job_description' => $jobDescription->name
1367
                    ],
1368
                    'files' => $files,
1369
                    'interviews' => $interviews,
1370
                    'link_files' => $allowFile ? $this->url()->fromRoute('recruitment-and-selection/applications/files', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1371
                    'link_files_add' =>  $allowFileAdd ?  $this->url()->fromRoute('recruitment-and-selection/applications/files/add', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1372
                    'interviews' =>  $interviews,
1373
                    'link_interviews' => $allowInterview ? $this->url()->fromRoute('recruitment-and-selection/applications/interviews', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1374
                    'link_interviews_add' => $allowInterviewAdd ? $this->url()->fromRoute('recruitment-and-selection/applications/interviews/add', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1375
                    'link_comment' => $allowComment ? $this->url()->fromRoute('recruitment-and-selection/applications/comment', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1376
                    'link_level' => $allowLevel ? $this->url()->fromRoute('recruitment-and-selection/applications/level', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1377
                    'link_status' => $allowStatus ? $this->url()->fromRoute('recruitment-and-selection/applications/status', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1378
 
1379
 
1380
 
1381
                ]
1382
            ];
1383
 
1384
            return new JsonModel($data);
1385
        } else {
1386
            $data = [
1387
                'success' => false,
1388
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1389
            ];
1390
 
1391
            return new JsonModel($data);
1392
        }
1393
 
1394
        return new JsonModel($data);
1395
    }
1396
 
1397
 
1398
 
1399
 
1400
 
1401
 
1402
 
1403
}