Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15463 | Ir a la última revisión | | 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;
8
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
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
     *
50
     * @var AbstractAdapter
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
69
     * @param AbstractAdapter $cache
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');
144
                $search = empty($search) ? '' : filter_var($search, FILTER_SANITIZE_STRING);
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);
153
                $order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
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 {
347
                    $data = [
348
                        'success' => false,
349
                        'data' => 'ERROR_EMAIL_NOT_FOUND'
350
                    ];
351
                }
352
            } else {
353
                $data = [
354
                    'success' => false,
355
                    'data' => 'ERROR_EMAIL_NOT_FOUND'
356
                ];
357
            }
358
        } else {
359
            $data = [
360
                'success' => false,
361
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
362
            ];
363
        }
364
 
365
 
366
        return new JsonModel($data);
367
 
368
    }
369
 
370
 
371
    public function addAction()
372
    {
373
        $currentUserPlugin  = $this->plugin('currentUserPlugin');
374
        $currentCompany     = $currentUserPlugin->getCompany();
375
        $currentUser        = $currentUserPlugin->getUser();
376
 
377
        $request    = $this->getRequest();
378
 
379
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
380
 
381
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
382
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
383
 
384
        if(!$vacancy) {
385
            $data = [
386
                'success' => false,
387
                'data' => 'ERROR_VACANCY_NOT_FOUND'
388
            ];
389
 
390
            return new JsonModel($data);
391
        }
392
 
393
 
394
        if($vacancy->company_id != $currentCompany->id) {
395
            $data = [
396
                'success' => false,
397
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
398
            ];
399
 
400
            return new JsonModel($data);
401
        }
402
 
403
 
404
 
405
 
406
 
407
        if($request->isPost()) {
408
            $dataPost = $request->getPost()->toArray();
409
 
410
            $form = new  RecruitmentSelectionApplicationCandidateForm($this->adapter);
411
            $form->setData($dataPost);
412
 
413
            if($form->isValid()) {
414
                $dataPost = (array) $form->getData();
415
 
416
                $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
417
                $candidate = $candidateMapper->fetchOneByEmail($dataPost['email']);
418
                if($candidate) {
419
 
420
 
421
                    $candidate->first_name = $dataPost['first_name'];
422
                    $candidate->last_name = $dataPost['last_name'];
423
 
424
                    $result = $candidateMapper->update($candidate);
425
 
426
                } else {
427
 
428
                    $candidate = new RecruitmentSelectionCandidate();
429
                    $candidate->company_id = $currentCompany->id;
430
                    $candidate->email = strtolower($dataPost['email']);
431
                    $candidate->first_name = $dataPost['first_name'];
432
                    $candidate->last_name = $dataPost['last_name'];
433
 
434
                    $result = $candidateMapper->insert($candidate);
435
                }
436
 
437
 
438
                if(!$result) {
439
                    $data = [
440
                        'success'   => false,
441
                        'data'      => $candidateMapper->getError()
442
                    ];
443
 
444
                    return new JsonModel($data);
445
                }
446
 
447
                $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
448
                $application = $applicationMapper->fetchOneByVancancyIdAndCandidateId($vacancy->id, $candidate->id);
449
 
450
 
451
                if($application) {
452
                    $data = [
453
                        'success'   => false,
454
                        'data'      => 'ERROR_VACANCY_CANDIDATE_HAS_BEEN_PREVIOUSLY_ADDED',
455
                    ];
456
 
457
                    return new JsonModel($data);
458
 
459
                }
460
 
461
 
462
                $application = new RecruitmentSelectionApplication();
463
                $application->candidate_id = $candidate->id;
464
                $application->company_id = $currentCompany->id;
465
                $application->level = RecruitmentSelectionApplication::LEVEL_CAPTURE;
466
                $application->status = RecruitmentSelectionApplication::STATUS_ACTIVE;
467
                $application->vacancy_id = $vacancy->id;
468
 
469
 
470
 
471
                if($applicationMapper->insert($application)) {
472
 
473
                    $this->logger->info('Se agrego la aplicación del candidato : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
474
 
475
                    $data = [
476
                        'success'   => true,
477
                        'data'   => 'LABEL_RECORD_ADDED'
478
                    ];
479
                } else {
480
                    $data = [
481
                        'success'   => false,
482
                        'data'      => $applicationMapper->getError()
483
                    ];
484
 
485
                }
486
 
487
                return new JsonModel($data);
488
 
489
            } else {
490
                $messages = [];
491
                $form_messages = (array) $form->getMessages();
492
                foreach ($form_messages as $fieldname => $field_messages) {
493
 
494
                    $messages[$fieldname] = array_values($field_messages);
495
                }
496
 
497
                return new JsonModel([
498
                    'success' => false,
499
                    'data' => $messages
500
                ]);
501
 
502
            }
503
 
504
        } else {
505
            $data = [
506
                'success' => false,
507
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
508
            ];
509
 
510
            return new JsonModel($data);
511
        }
512
 
513
        return new JsonModel($data);
514
    }
515
 
516
 
517
    public function commentAction()
518
    {
519
        $request = $this->getRequest();
520
        $currentUserPlugin = $this->plugin('currentUserPlugin');
521
        $currentCompany = $currentUserPlugin->getCompany();
522
        $currentUser = $currentUserPlugin->getUser();
523
 
524
        $request = $this->getRequest();
525
        $application_id = $this->params()->fromRoute('application_id');
526
 
527
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
528
 
529
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
530
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
531
 
532
        if(!$vacancy) {
533
            $data = [
534
                'success' => false,
535
                'data' => 'ERROR_VACANCY_NOT_FOUND'
536
            ];
537
 
538
            return new JsonModel($data);
539
        }
540
 
541
 
542
        if($vacancy->company_id != $currentCompany->id) {
543
            $data = [
544
                'success' => false,
545
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
546
            ];
547
 
548
            return new JsonModel($data);
549
        }
550
 
551
 
552
 
553
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
554
        $application = $applicationMapper->fetchOneByUuid($application_id);
555
 
556
 
557
        if (!$application) {
558
            $data = [
559
                'success' => false,
560
                'data' => 'ERROR_RECORD_NOT_FOUND'
561
            ];
562
 
563
            return new JsonModel($data);
564
        }
565
 
566
 
567
        if ($application->vacancy_id != $vacancy->id) {
568
            return new JsonModel([
569
                'success' => false,
570
                'data' => 'ERROR_UNAUTHORIZED'
571
            ]);
572
        }
573
 
574
 
575
        if ($request->isGet()) {
576
 
577
            $data = [
578
                'success' => true,
579
                'data' => [
580
                    'points' => $application->points ? intval($application->points, 10) : 0,
581
                    'comment' => $application->comment ? trim($application->comment) : '',
582
                ]
583
            ];
584
 
585
            return new JsonModel($data);
586
 
587
 
588
 
589
        } else if ($request->isPost()) {
590
 
591
 
592
            $dataPost = $request->getPost()->toArray();
593
 
594
            $form = new RecruitmentSelectionApplicationPointsAndCommentForm();
595
            $form->setData($dataPost);
596
 
597
            if($form->isValid()) {
598
                $dataPost = (array) $form->getData();
599
 
600
                $application->points    = $dataPost['points'];
601
                $application->comment   = $dataPost['comment'];
602
 
603
                $result =  $applicationMapper->update($application);
604
                if ($result) {
605
                    $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
606
                    $candidate = $candidateMapper->fetchOne($application->candidate_id);
607
 
608
 
609
                    $this->logger->info('Se actualizo los puntos y comentario de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
610
 
611
                    $data = [
612
                        'success' => true,
613
                        'data' => [
614
                            'message' => 'LABEL_RECORD_UPDATED',
615
                            'points' => $application->points ? intval($application->points, 10) : 0,
616
                            'comment' => $application->comment ? trim($application->comment) : '',
617
                        ]
618
                    ];
619
 
620
 
621
                } else {
622
 
623
                    $data = [
624
                        'success' => false,
625
                        'data' => $applicationMapper->getError()
626
                    ];
627
 
628
                    return new JsonModel($data);
629
                }
630
 
631
 
632
            } else {
633
                $messages = [];
634
                $form_messages = (array) $form->getMessages();
635
                foreach ($form_messages as $fieldname => $field_messages) {
636
 
637
                    $messages[$fieldname] = array_values($field_messages);
638
                }
639
 
640
                return new JsonModel([
641
                    'success' => false,
642
                    'data' => $messages
643
                ]);
644
            }
645
 
646
 
647
        } else {
648
            $data = [
649
                'success' => false,
650
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
651
            ];
652
 
653
            return new JsonModel($data);
654
        }
655
 
656
        return new JsonModel($data);
657
    }
658
 
659
 
660
    public function statusAction()
661
    {
662
        $request = $this->getRequest();
663
        $currentUserPlugin = $this->plugin('currentUserPlugin');
664
        $currentCompany = $currentUserPlugin->getCompany();
665
        $currentUser = $currentUserPlugin->getUser();
666
 
667
        $request = $this->getRequest();
668
        $application_id = $this->params()->fromRoute('application_id');
669
 
670
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
671
 
672
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
673
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
674
 
675
        if(!$vacancy) {
676
            $data = [
677
                'success' => false,
678
                'data' => 'ERROR_VACANCY_NOT_FOUND'
679
            ];
680
 
681
            return new JsonModel($data);
682
        }
683
 
684
 
685
        if($vacancy->company_id != $currentCompany->id) {
686
            $data = [
687
                'success' => false,
688
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
689
            ];
690
 
691
            return new JsonModel($data);
692
        }
693
 
694
 
695
 
696
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
697
        $application = $applicationMapper->fetchOneByUuid($application_id);
698
 
699
 
700
        if (!$application) {
701
            $data = [
702
                'success' => false,
703
                'data' => 'ERROR_RECORD_NOT_FOUND'
704
            ];
705
 
706
            return new JsonModel($data);
707
        }
708
 
709
 
710
        if ($application->vacancy_id != $vacancy->id) {
711
            return new JsonModel([
712
                'success' => false,
713
                'data' => 'ERROR_UNAUTHORIZED'
714
            ]);
715
        }
716
 
717
 
718
        if ($request->isGet()) {
719
 
720
            $data = [
721
                'success' => true,
722
                'data' => [
723
                    'status' => $application->status
724
                ]
725
            ];
726
 
727
            return new JsonModel($data);
728
 
729
 
730
 
731
        } else if ($request->isPost()) {
732
 
733
 
734
            $dataPost = $request->getPost()->toArray();
735
 
736
            $form = new RecruitmentSelectionApplicationStatusForm();
737
            $form->setData($dataPost);
738
 
739
            if($form->isValid()) {
740
                $dataPost = (array) $form->getData();
741
 
742
                $application->status    = $dataPost['status'];
743
 
744
                $result =  $applicationMapper->update($application);
745
                if ($result) {
746
                    $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
747
                    $candidate = $candidateMapper->fetchOne($application->candidate_id);
748
 
749
 
750
                    $this->logger->info('Se actualizo el estado de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
751
 
752
                    switch($application->status)
753
                    {
754
                        case RecruitmentSelectionApplication::STATUS_ACTIVE :
755
                            $status = 'LABEL_ACTIVE';
756
                            break;
757
 
758
 
759
                        case RecruitmentSelectionApplication::STATUS_INACTIVE :
760
                            $status = 'LABEL_INACTIVE';
761
                            break;
762
 
763
                        case RecruitmentSelectionApplication::STATUS_SELECTED :
764
                            $status = 'LABEL_SELECTED';
765
                            break;
766
 
767
                        case RecruitmentSelectionApplication::STATUS_REJECTED :
768
                            $status = 'LABEL_REJECTED';
769
                            break;
770
 
771
                    }
772
 
773
 
774
                    $data = [
775
                        'success' => true,
776
                        'data' => [
777
                            'message' => 'LABEL_RECORD_UPDATED',
778
                            'status' => $status
779
                        ]
780
                    ];
781
 
782
 
783
 
784
                } else {
785
 
786
                    $data = [
787
                        'success' => false,
788
                        'data' => $applicationMapper->getError()
789
                    ];
790
 
791
                    return new JsonModel($data);
792
                }
793
 
794
 
795
            } else {
796
                $messages = [];
797
                $form_messages = (array) $form->getMessages();
798
                foreach ($form_messages as $fieldname => $field_messages) {
799
 
800
                    $messages[$fieldname] = array_values($field_messages);
801
                }
802
 
803
                return new JsonModel([
804
                    'success' => false,
805
                    'data' => $messages
806
                ]);
807
            }
808
 
809
 
810
        } else {
811
            $data = [
812
                'success' => false,
813
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
814
            ];
815
 
816
            return new JsonModel($data);
817
        }
818
 
819
        return new JsonModel($data);
820
    }
821
 
822
 
823
    public function levelAction()
824
    {
825
        $request = $this->getRequest();
826
        $currentUserPlugin = $this->plugin('currentUserPlugin');
827
        $currentCompany = $currentUserPlugin->getCompany();
828
        $currentUser = $currentUserPlugin->getUser();
829
 
830
        $request = $this->getRequest();
831
        $application_id = $this->params()->fromRoute('application_id');
832
 
833
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
834
 
835
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
836
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
837
 
838
        if(!$vacancy) {
839
            $data = [
840
                'success' => false,
841
                'data' => 'ERROR_VACANCY_NOT_FOUND'
842
            ];
843
 
844
            return new JsonModel($data);
845
        }
846
 
847
 
848
        if($vacancy->company_id != $currentCompany->id) {
849
            $data = [
850
                'success' => false,
851
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
852
            ];
853
 
854
            return new JsonModel($data);
855
        }
856
 
857
 
858
 
859
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
860
        $application = $applicationMapper->fetchOneByUuid($application_id);
861
 
862
 
863
        if (!$application) {
864
            $data = [
865
                'success' => false,
866
                'data' => 'ERROR_RECORD_NOT_FOUND'
867
            ];
868
 
869
            return new JsonModel($data);
870
        }
871
 
872
 
873
        if ($application->vacancy_id != $vacancy->id) {
874
            return new JsonModel([
875
                'success' => false,
876
                'data' => 'ERROR_UNAUTHORIZED'
877
            ]);
878
        }
879
 
880
 
881
        if ($request->isGet()) {
882
 
883
            $data = [
884
                'success' => true,
885
                'data' => [
886
                    'level' => $application->level
887
                ]
888
            ];
889
 
890
            return new JsonModel($data);
891
 
892
 
893
 
894
        } else if ($request->isPost()) {
895
 
896
 
897
            $dataPost = $request->getPost()->toArray();
898
 
899
            $form = new RecruitmentSelectionApplicationLevelForm();
900
            $form->setData($dataPost);
901
 
902
            if($form->isValid()) {
903
                $dataPost = (array) $form->getData();
904
 
905
                $application->level = $dataPost['level'];
906
 
907
                $result =  $applicationMapper->update($application);
908
                if ($result) {
909
                    $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
910
                    $candidate = $candidateMapper->fetchOne($application->candidate_id);
911
 
912
 
913
                    $this->logger->info('Se actualizo el nivel de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
914
 
915
 
916
                    switch($application->level)
917
                    {
918
                        case RecruitmentSelectionApplication::LEVEL_CAPTURE :
919
                            $level = 'LABEL_CAPTURE';
920
                            break;
921
 
922
                        case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
923
                            $level =  'LABEL_PRE_SELECTION';
924
                            break;
925
 
926
                        case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
927
                            $level =  'LABEL_HUMAN_RESOURCE';
928
                            break;
929
 
930
                        case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
931
                            $level =  'LABEL_BOSS_INTERVIEW';
932
                            break;
933
 
934
                        case RecruitmentSelectionApplication::LEVEL_FINISHED :
935
                            $level =  'LABEL_FINISHED';
936
                            break;
937
 
938
                        default :
939
                            $level =  'LABEL_UNKNOWN';
940
                            break;
941
 
942
                    }
943
 
944
                    $data = [
945
                        'success' => true,
946
                        'data' => [
947
                            'message' => 'LABEL_RECORD_UPDATED',
948
                            'level' => $level
949
                        ]
950
                    ];
951
 
952
                } else {
953
 
954
                    $data = [
955
                        'success' => false,
956
                        'data' => $applicationMapper->getError()
957
                    ];
958
 
959
                    return new JsonModel($data);
960
                }
961
 
962
 
963
            } else {
964
                $messages = [];
965
                $form_messages = (array) $form->getMessages();
966
                foreach ($form_messages as $fieldname => $field_messages) {
967
 
968
                    $messages[$fieldname] = array_values($field_messages);
969
                }
970
 
971
                return new JsonModel([
972
                    'success' => false,
973
                    'data' => $messages
974
                ]);
975
            }
976
 
977
 
978
        } else {
979
            $data = [
980
                'success' => false,
981
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
982
            ];
983
 
984
            return new JsonModel($data);
985
        }
986
 
987
        return new JsonModel($data);
988
    }
989
 
990
 
991
    public function deleteAction()
992
    {
993
        $request = $this->getRequest();
994
        $currentUserPlugin = $this->plugin('currentUserPlugin');
995
        $currentCompany = $currentUserPlugin->getCompany();
996
        $currentUser = $currentUserPlugin->getUser();
997
 
998
        $request = $this->getRequest();
999
        $application_id = $this->params()->fromRoute('application_id');
1000
 
1001
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
1002
 
1003
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
1004
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
1005
 
1006
        if(!$vacancy) {
1007
            $data = [
1008
                'success' => false,
1009
                'data' => 'ERROR_VACANCY_NOT_FOUND'
1010
            ];
1011
 
1012
            return new JsonModel($data);
1013
        }
1014
 
1015
 
1016
        if($vacancy->company_id != $currentCompany->id) {
1017
            $data = [
1018
                'success' => false,
1019
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
1020
            ];
1021
 
1022
            return new JsonModel($data);
1023
        }
1024
 
1025
 
1026
 
1027
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
1028
        $application = $applicationMapper->fetchOneByUuid($application_id);
1029
 
1030
 
1031
        if (!$application) {
1032
            $data = [
1033
                'success' => false,
1034
                'data' => 'ERROR_RECORD_NOT_FOUND'
1035
            ];
1036
 
1037
            return new JsonModel($data);
1038
        }
1039
 
1040
 
1041
        if ($application->vacancy_id != $vacancy->id) {
1042
            return new JsonModel([
1043
                'success' => false,
1044
                'data' => 'ERROR_UNAUTHORIZED'
1045
            ]);
1046
        }
1047
 
1048
 
1049
 
1050
        if ($request->isPost()) {
1051
 
1052
            $result = $applicationMapper->delete($application->id);
1053
            if ($result) {
1054
                $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1055
                $candidate = $candidateMapper->fetchOne($application->candidate_id);
1056
 
1057
 
1058
 
1059
                $this->logger->info('Se borro la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1060
 
1061
                $data = [
1062
                    'success' => true,
1063
                    'data' => 'LABEL_RECORD_DELETED'
1064
                ];
1065
            } else {
1066
 
1067
                $data = [
1068
                    'success' => false,
1069
                    'data' => $candidateMapper->getError()
1070
                ];
1071
 
1072
                return new JsonModel($data);
1073
            }
1074
        } else {
1075
            $data = [
1076
                'success' => false,
1077
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1078
            ];
1079
 
1080
            return new JsonModel($data);
1081
        }
1082
 
1083
        return new JsonModel($data);
1084
    }
1085
 
1086
    public function viewAction()
1087
    {
1088
        $request = $this->getRequest();
1089
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1090
        $currentCompany = $currentUserPlugin->getCompany();
1091
        $currentUser = $currentUserPlugin->getUser();
1092
 
1093
        $request = $this->getRequest();
1094
        $application_id = $this->params()->fromRoute('application_id');
1095
 
1096
        $vacancy_uuid = $this->params()->fromRoute('vacancy_id');
1097
 
1098
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
1099
        $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
1100
 
1101
        if(!$vacancy) {
1102
            $data = [
1103
                'success' => false,
1104
                'data' => 'ERROR_VACANCY_NOT_FOUND'
1105
            ];
1106
 
1107
            return new JsonModel($data);
1108
        }
1109
 
1110
 
1111
        if($vacancy->company_id != $currentCompany->id) {
1112
            $data = [
1113
                'success' => false,
1114
                'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
1115
            ];
1116
 
1117
            return new JsonModel($data);
1118
        }
1119
 
1120
 
1121
 
1122
        $applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
1123
        $application = $applicationMapper->fetchOneByUuid($application_id);
1124
 
1125
 
1126
        if (!$application) {
1127
            $data = [
1128
                'success' => false,
1129
                'data' => 'ERROR_RECORD_NOT_FOUND'
1130
            ];
1131
 
1132
            return new JsonModel($data);
1133
        }
1134
 
1135
 
1136
        if ($application->vacancy_id != $vacancy->id) {
1137
            return new JsonModel([
1138
                'success' => false,
1139
                'data' => 'ERROR_UNAUTHORIZED'
1140
            ]);
1141
        }
1142
 
1143
 
1144
 
1145
        if ($request->isGet()) {
1146
 
1147
            $acl = $this->getEvent()->getViewModel()->getVariable('acl');
1148
            $allowFile = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files');
1149
            $allowFileAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/add');
1150
            $allowFileDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/delete');
1151
            $allowFileView = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/view');
1152
            $allowInterview = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/interviews');
1153
            $allowInterviewAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/interviews/add');
1154
            $allowComment = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/comment');
1155
            $allowLevel = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/level');
1156
            $allowStatus = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/status');
1157
 
1158
 
1159
            $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1160
            $candidate = $candidateMapper->fetchOne($application->candidate_id);
1161
 
1162
 
1163
            switch($application->status)
1164
            {
1165
                case RecruitmentSelectionApplication::STATUS_ACTIVE :
1166
                    $status = 'LABEL_ACTIVE';
1167
                    break;
1168
 
1169
 
1170
                case RecruitmentSelectionApplication::STATUS_INACTIVE :
1171
                    $status = 'LABEL_INACTIVE';
1172
                    break;
1173
 
1174
                case RecruitmentSelectionApplication::STATUS_SELECTED :
1175
                    $status = 'LABEL_SELECTED';
1176
                    break;
1177
 
1178
                case RecruitmentSelectionApplication::STATUS_REJECT :
1179
                    $status = 'LABEL_REJECTED';
1180
                    break;
1181
 
1182
            }
1183
 
1184
            switch($application->level)
1185
            {
1186
                case RecruitmentSelectionApplication::LEVEL_CAPTURE :
1187
                    $level = 'LABEL_CAPTURE';
1188
                    break;
1189
 
1190
                case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
1191
                    $level =  'LABEL_PRE_SELECTION';
1192
                    break;
1193
 
1194
                case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
1195
                    $level =  'LABEL_HUMAN_RESOURCE';
1196
                    break;
1197
 
1198
                case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
1199
                    $level =  'LABEL_BOSS_INTERVIEW';
1200
                    break;
1201
 
1202
                case RecruitmentSelectionApplication::LEVEL_FINISHED :
1203
                    $level =  'LABEL_FINISHED';
1204
                    break;
1205
 
1206
                default :
1207
                    $level =  'LABEL_UNKNOWN';
1208
                    break;
1209
 
1210
            }
1211
 
1212
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
1213
            $jobCategory = $jobCategoryMapper->fetchOne($vacancy->job_category_id);
1214
 
1215
            $industryMapper = IndustryMapper::getInstance($this->adapter);
1216
            $industry = $industryMapper->fetchOne($vacancy->industry_id);
1217
 
1218
 
1219
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
1220
            $jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
1221
 
1222
 
1223
            $locationMapper = LocationMapper::getInstance($this->adapter);
1224
            $location = $locationMapper->fetchOne($vacancy->location_id);
1225
 
1226
 
1227
            $dt = \DateTime::createFromFormat('Y-m-d', $vacancy->last_date);
1228
            $last_date = $dt->format('d/m/Y');
1229
 
1230
 
1231
            $recruitmentSelectionFileMapper = RecruitmentSelectionFileMapper::getInstance($this->adapter);
1232
 
1233
 
1234
            $files = [];
1235
            $records = $recruitmentSelectionFileMapper->fetchAllByVacancyId($vacancy->id);
1236
            foreach($records as $record)
1237
            {
1238
                array_push($files, [
1239
                    'name' => $record->name,
1240
                    'filename' => basename($record->file),
1241
                    'link_view' => $allowFileView ? $this->url()->fromRoute('recruitment-and-selection/applications/files/view', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]) : '',
1242
                    'link_delete' => $allowFileDelete ? $this->url()->fromRoute('recruitment-and-selection/applications/files/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]) : '',
1243
                ]);
1244
            }
1245
 
1246
            $userMapper = UserMapper::getInstance($this->adapter);
1247
            $interviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
1248
 
1249
 
1250
 
1251
 
1252
            $interviews = [];
1253
            $records = $interviewMapper->fetchAllByVacancyId($vacancy->id);
1254
            foreach($records as $record)
1255
            {
1256
                $status = '';
1257
                switch($record->status)
1258
                {
1259
                    case RecruitmentSelectionInterview::STATUS_ACCEPTED :
1260
                        $status = 'LABEL_ACCEPTED';
1261
                        $link_report = $this->url()->fromRoute('recruitment-and-selection/applications/interviews/report', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]);
1262
 
1263
                        break;
1264
 
1265
                    case RecruitmentSelectionInterview::STATUS_PENDING :
1266
                        $status = 'LABEL_PENDING';
1267
                        $link_report = '';
1268
                        break;
1269
 
1270
                    case RecruitmentSelectionInterview::STATUS_REJECTED :
1271
                        $status = 'LABEL_REJECTED';
1272
 
1273
                        $link_report = $this->url()->fromRoute('recruitment-and-selection/applications/interviews/report', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]);
1274
 
1275
                        break;
1276
 
1277
                    default :
1278
                        $status = 'LABEL_UNKNOWN';
1279
                        $link_report = '';
1280
                        break;
1281
 
1282
                }
1283
 
1284
                $type = '';
1285
                switch($record->type)
1286
                {
1287
                    case RecruitmentSelectionInterview::TYPE_BOSS :
1288
                        $type = 'LABEL_BOSS_INTERVIEW';
1289
                        break;
1290
 
1291
                    case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
1292
                        $type = 'LABEL_HUMAN_RESOURCE';
1293
                        break;
1294
 
1295
                    default :
1296
                        $type = 'LABEL_UNKNOWN';
1297
                        break;
1298
 
1299
                }
1300
 
1301
                $dt = \DateTime::createFromFormat('Y-m-d',  $record->last_date);
1302
                $last_date = $dt->format('d/m/Y');
1303
 
1304
 
1305
                if($record->actual_date) {
1306
 
1307
                    $dt = \DateTime::createFromFormat('Y-m-d',  $record->actual_date);
1308
                    $actual_date = $dt->format('d/m/Y');
1309
                } else {
1310
                    $actual_date = '';
1311
                }
1312
 
1313
                $user = $userMapper->fetchOne($record->interviewer_id);
1314
                $interviewer = $user->first_name . ' ' . $user->last_name  . '(' . $user->email . ')';
1315
 
1316
 
1317
 
1318
 
1319
                array_push($interviews, [
1320
                    'type' => $type,
1321
                    'status' => $status,
1322
                    'last_date' => $last_date,
1323
                    'actual_date' => $actual_date,
1324
                    'interviewer' => $interviewer,
1325
                    'points' => $record->points,
1326
                    'link_edit' => $this->url()->fromRoute('recruitment-and-selection/applications/interviews/edit', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]),
1327
                    'link_report' => $link_report,
1328
                    'link_delete' => $this->url()->fromRoute('recruitment-and-selection/applications/interviews/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]),
1329
 
1330
                ]);
1331
            }
1332
 
1333
            $data = [
1334
                'success' => true,
1335
                'data' => [
1336
                    'application' => [
1337
                        'first_name' => $candidate->first_name,
1338
                        'last_name' => $candidate->last_name,
1339
                        'email' => $candidate->email,
1340
                        'level' => $level,
1341
                        'status' => $status,
1342
                        'points' => $application->points,
1343
                        'comment' => $application->comment,
1344
                    ],
1345
                    'vacancy' => [
1346
                        'name' => $vacancy->name,
1347
                        'last_date' => $last_date,
1348
                        'address' => $location->formatted_address,
1349
                        'industry' => $industry->name,
1350
                        'job_category' => $jobCategory->name,
1351
                        'job_description' => $jobDescription->name
1352
                    ],
1353
                    'files' => $files,
1354
                    'interviews' => $interviews,
1355
                    'link_files' => $allowFile ? $this->url()->fromRoute('recruitment-and-selection/applications/files', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1356
                    'link_files_add' =>  $allowFileAdd ?  $this->url()->fromRoute('recruitment-and-selection/applications/files/add', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1357
                    'interviews' =>  $interviews,
1358
                    'link_interviews' => $allowInterview ? $this->url()->fromRoute('recruitment-and-selection/applications/interviews', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1359
                    'link_interviews_add' => $allowInterviewAdd ? $this->url()->fromRoute('recruitment-and-selection/applications/interviews/add', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1360
                    'link_comment' => $allowComment ? $this->url()->fromRoute('recruitment-and-selection/applications/comment', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1361
                    'link_level' => $allowLevel ? $this->url()->fromRoute('recruitment-and-selection/applications/level', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1362
                    'link_status' => $allowStatus ? $this->url()->fromRoute('recruitment-and-selection/applications/status', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
1363
 
1364
 
1365
 
1366
                ]
1367
            ];
1368
 
1369
            return new JsonModel($data);
1370
        } else {
1371
            $data = [
1372
                'success' => false,
1373
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1374
            ];
1375
 
1376
            return new JsonModel($data);
1377
        }
1378
 
1379
        return new JsonModel($data);
1380
    }
1381
 
1382
 
1383
 
1384
 
1385
 
1386
 
1387
 
1388
}