Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 12264 | Rev 12314 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 12264 Rev 12304
Línea 23... Línea 23...
23
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
23
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
24
use LeadersLinked\Mapper\CompanyMapper;
24
use LeadersLinked\Mapper\CompanyMapper;
25
use LeadersLinked\Model\Company;
25
use LeadersLinked\Model\Company;
26
use LeadersLinked\Mapper\JobCategoryMapper;
26
use LeadersLinked\Mapper\JobCategoryMapper;
Línea 27... Línea 27...
27
 
27
 
28
class RecruitmentSelectionVacancyController extends AbstractActionController
-
 
Línea 29... Línea 28...
29
{
28
class RecruitmentSelectionVacancyController extends AbstractActionController {
30
 
29
 
31
    /**
30
    /**
32
     *
31
     *
Línea 57... Línea 56...
57
     * @param AdapterInterface $adapter
56
     * @param AdapterInterface $adapter
58
     * @param AbstractAdapter $cache
57
     * @param AbstractAdapter $cache
59
     * @param LoggerInterface $logger
58
     * @param LoggerInterface $logger
60
     * @param array $config
59
     * @param array $config
61
     */
60
     */
62
    public function __construct($adapter, $cache, $logger, $config)
61
    public function __construct($adapter, $cache, $logger, $config) {
63
    {
-
 
64
        $this->adapter = $adapter;
62
        $this->adapter = $adapter;
65
        $this->cache = $cache;
63
        $this->cache = $cache;
66
        $this->logger = $logger;
64
        $this->logger = $logger;
67
        $this->config = $config;
65
        $this->config = $config;
68
    }
66
    }
Línea 69... Línea 67...
69
 
67
 
70
    public function indexAction()
-
 
71
    {
68
    public function indexAction() {
72
        $request = $this->getRequest();
69
        $request = $this->getRequest();
73
        $currentUserPlugin = $this->plugin('currentUserPlugin');
70
        $currentUserPlugin = $this->plugin('currentUserPlugin');
74
        $currentCompany = $currentUserPlugin->getCompany();
71
        $currentCompany = $currentUserPlugin->getCompany();
Línea 75... Línea 72...
75
        $currentUser = $currentUserPlugin->getUser();
72
        $currentUser = $currentUserPlugin->getUser();
76
 
73
 
77
 
74
 
78
        $request = $this->getRequest();
75
        $request = $this->getRequest();
79
        if ($request->isGet()) {
76
        if ($request->isGet()) {
80
            $sandbox = $this->config['leaderslinked.runmode.sandbox'];
77
            $sandbox = $this->config['leaderslinked.runmode.sandbox'];
81
            if ($sandbox) {
78
            if($sandbox) {
82
                $google_map_key  = $this->config['leaderslinked.google_map.sandbox_api_key'];
79
                $google_map_key  = $this->config['leaderslinked.google_map.sandbox_api_key'];
83
            } else {
80
            } else {
Línea 84... Línea 81...
84
                $google_map_key  = $this->config['leaderslinked.google_map.production_api_key'];
81
                $google_map_key  = $this->config['leaderslinked.google_map.production_api_key'];
Línea 85... Línea 82...
85
            }
82
            }
86
 
83
            
Línea 120... Línea 117...
120
                    $order_direction = 'ASC';
117
                    $order_direction = 'ASC';
121
                }
118
                }
Línea 122... Línea 119...
122
 
119
 
123
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
120
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
124
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/vacancies/delete');
121
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/vacancies/delete');
125
 
122
               
126
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/vacancies/edit');
123
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/vacancies/edit');
Línea 127... Línea 124...
127
 
124
                
128
 
125
 
Línea 129... Línea 126...
129
                $recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
126
                $recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
130
                $paginator = $recruitmentSelectionVacancyMapper->fetchAllDataTableByCompanyId($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
127
                $paginator = $recruitmentSelectionVacancyMapper->fetchAllDataTableByCompanyId($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
131
 
128
 
Línea 132... Línea -...
132
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
-
 
133
                $industryMapper = IndustryMapper::getInstance($this->adapter);
-
 
134
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
-
 
135
 
-
 
136
                $jobDescritions = [];
-
 
137
                $industries = [];
-
 
138
                $jobCategories = [];
-
 
139
 
-
 
140
                $records = $jobCategoryMapper->fetchAllActives();
-
 
141
 
-
 
142
                foreach ($records as $record) {
-
 
143
                    $jobCategories[$record->uuid] = $record->name;
-
 
144
                }
-
 
145
 
-
 
146
                $records = $industryMapper->fetchAllActives();
-
 
147
 
-
 
148
                foreach ($records as $record) {
-
 
149
                    $industries[$record->uuid] = $record->name;
-
 
150
                }
-
 
151
 
-
 
152
                $records = $currentCompany ?
-
 
153
                    $jobDescriptionMapper->fetchAllActiveByCompanyId($currentCompany->id) :
-
 
154
                    $jobDescriptionMapper->fetchAllByDefault();
-
 
155
 
-
 
156
                foreach ($records as $record) {
129
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
157
                    $jobDescritions[$record->uuid] = $record->name;
130
                $industryMapper = IndustryMapper::getInstance($this->adapter);
158
                }
131
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
159
 
132
 
160
                $items = [];
133
                $items = [];
161
                $records = $paginator->getCurrentItems();
134
                $records = $paginator->getCurrentItems();
Línea 162... Línea 135...
162
 
135
                
Línea 190... Línea 163...
190
 
163
 
Línea 191... Línea 164...
191
                $form = new RecruitmentSelectionVacancyForm($this->adapter, $currentCompany->id);
164
                $form = new RecruitmentSelectionVacancyForm($this->adapter, $currentCompany->id);
192
 
165
 
193
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
166
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
194
                $industryMapper = industryMapper::getInstance($this->adapter);
167
                $industryMapper = industryMapper::getInstance($this->adapter);
195
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
168
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);              
196
 
169
                
197
                $this->layout()->setTemplate('layout/layout-backend');
170
                $this->layout()->setTemplate('layout/layout-backend');
198
                $viewModel = new ViewModel();
171
                $viewModel = new ViewModel();
199
                $viewModel->setTemplate('leaders-linked/recruitment-and-selection-vacancies/index.phtml');
172
                $viewModel->setTemplate('leaders-linked/recruitment-and-selection-vacancies/index.phtml');
200
                $viewModel->setVariable('form', $form);
-
 
201
                $viewModel->setVariable('google_map_key', $google_map_key);
-
 
202
                $viewModel->setVariable('jobCategories', $jobCategories);
-
 
203
                $viewModel->setVariable('industries', $industries);
-
 
Línea -... Línea 173...
-
 
173
                $viewModel->setVariable('form', $form);
204
                $viewModel->setVariable('jobDescriptions', $jobDescritions);
174
                $viewModel->setVariable('google_map_key', $google_map_key);
205
 
175
 
206
 
176
                
207
                return $viewModel;
177
                return $viewModel;
208
            }
178
            }
209
        } else {
179
        } else {
210
            return new JsonModel([
180
            return new JsonModel([
-
 
181
                'success' => false,
211
                'success' => false,
182
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
212
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
183
            ]);
Línea 213... Línea 184...
213
            ]);;
184
            ;
214
        }
-
 
215
    }
185
        }
216
 
186
    }
217
    public function addAction()
187
 
218
    {
188
    public function addAction() {
Línea 236... Línea 206...
236
            //    'last' =>  $last_dt,
206
            //    'last' =>  $last_dt,
237
            //    'actual' => $actual_dt,
207
            //    'actual' => $actual_dt,
238
            //    'todb' => $dataPost['last_date']
208
            //    'todb' => $dataPost['last_date']
239
            //   ]                     
209
            //   ]                     
240
            //]);
210
            //]);
241
            if ($actual_dt > $last_dt) {
211
            if($actual_dt > $last_dt){
242
                return new JsonModel([
212
                 return new JsonModel([
243
                    'success' => false,
213
                     'success' => false,
244
                    'data' => 'ERROR_UNAUTHORIZED'
214
                     'data' => 'ERROR_UNAUTHORIZED'
245
                ]);
215
                ]);   
246
            }
216
            }
247
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionVacancy::STATUS_INACTIVE;
217
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionVacancy::STATUS_INACTIVE;
Línea 248... Línea 218...
248
 
218
 
Línea 253... Línea 223...
253
 
223
 
Línea 254... Línea 224...
254
                $hydrator = new ObjectPropertyHydrator();
224
                $hydrator = new ObjectPropertyHydrator();
255
 
225
 
256
                $location = new Location();
226
                $location = new Location();
257
                $hydrator->hydrate($dataPost, $location);
227
                $hydrator->hydrate($dataPost, $location);
258
 
228
                
Línea 259... Línea 229...
259
                $locationMapper = LocationMapper::getInstance($this->adapter);
229
                $locationMapper= LocationMapper::getInstance($this->adapter);
260
                $result = $locationMapper->insert($location);
230
                $result = $locationMapper->insert($location);
261
 
231
 
262
 
232
 
263
                if (!$result) {
233
                if (!$result) {
264
                    return new JsonModel([
234
                    return new JsonModel([
Línea 265... Línea 235...
265
                        'success'   => false,
235
                        'success'   => false,
266
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
236
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'                       
Línea 276... Línea 246...
276
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
246
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
277
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
247
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
278
                $vacancy->job_description_id = $jobDescription->id;
248
                $vacancy->job_description_id = $jobDescription->id;
Línea 279... Línea 249...
279
 
249
 
280
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
250
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
281
                $jobCategory = $jobCategoryMapper->fetchOneByUuid($dataPost['job_category_id']);
251
                $jobCategory = $jobCategoryMapper->fetchOneByUuid( $dataPost['job_category_id']);
Línea 282... Línea 252...
282
                $vacancy->job_category_id = $jobCategory->id;
252
                $vacancy->job_category_id = $jobCategory->id;
283
 
253
 
284
                $industryMapper = IndustryMapper::getInstance($this->adapter);
254
                $industryMapper = IndustryMapper::getInstance($this->adapter);
Línea 285... Línea 255...
285
                $industry = $industryMapper->fetchOneByUuid($dataPost['industry_id']);
255
                $industry = $industryMapper->fetchOneByUuid($dataPost['industry_id']);
286
                $vacancy->industry_id = $industry->id;
256
                $vacancy->industry_id = $industry->id;
287
 
257
 
288
                $vacancy->description = $dataPost['description'];
258
                $vacancy->description = $dataPost['description'];
289
                $vacancy->last_date = $dataPost['last_date'];
259
                $vacancy->last_date = $dataPost['last_date'];
290
 
260
                    
291
                $dt = \DateTime::createFromFormat('d/m/Y', $vacancy->last_date);
261
                $dt = \DateTime::createFromFormat('d/m/Y', $vacancy->last_date);
Línea 292... Línea 262...
292
                if ($dt) {
262
                if($dt) {
Línea 302... Línea 272...
302
 
272
 
303
                    $data = [
273
                    $data = [
304
                        'success' => true,
274
                        'success' => true,
305
                        'data' => 'LABEL_RECORD_ADDED'
275
                        'data' => 'LABEL_RECORD_ADDED'
-
 
276
                    ];
306
                    ];
277
 
307
                } else {
278
                } else {
308
                    $data = [
279
                    $data = [
309
                        'success' => false,
280
                        'success' => false,
310
                        'data' => $recruitmentSelectionVacancyMapper->getError()
281
                        'data' => $recruitmentSelectionVacancyMapper->getError()
Línea 335... Línea 306...
335
        }
306
        }
Línea 336... Línea 307...
336
 
307
 
337
        return new JsonModel($data);
308
        return new JsonModel($data);
Línea 338... Línea 309...
338
    }
309
    }
339
 
-
 
340
    public function editAction()
310
 
341
    {
311
    public function editAction() {
342
        $request = $this->getRequest();
312
        $request = $this->getRequest();
343
        $currentUserPlugin = $this->plugin('currentUserPlugin');
313
        $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 401... Línea 371...
401
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
371
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
402
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
372
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
403
                $vacancy->job_description_id = $jobDescription->id;
373
                $vacancy->job_description_id = $jobDescription->id;
Línea 404... Línea 374...
404
 
374
 
405
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
375
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
406
                $jobCategory = $jobCategoryMapper->fetchOneByUuid($dataPost['job_category_id']);
376
                $jobCategory = $jobCategoryMapper->fetchOneByUuid( $dataPost['job_category_id']);
Línea 407... Línea 377...
407
                $vacancy->job_category_id = $jobCategory->id;
377
                $vacancy->job_category_id = $jobCategory->id;
408
 
378
 
409
                $industryMapper = IndustryMapper::getInstance($this->adapter);
379
                $industryMapper = IndustryMapper::getInstance($this->adapter);
Línea 413... Línea 383...
413
                $vacancy->job_description_id = $jobDescription->id;
383
                $vacancy->job_description_id = $jobDescription->id;
414
                $vacancy->job_category_id = $jobCategory->id;
384
                $vacancy->job_category_id = $jobCategory->id;
415
                $vacancy->industry_id = $industry->id;
385
                $vacancy->industry_id = $industry->id;
Línea 416... Línea 386...
416
 
386
 
417
                $result = $recruitmentSelectionVacancyMapper->update($vacancy);
387
                $result = $recruitmentSelectionVacancyMapper->update($vacancy);
Línea 418... Línea 388...
418
 
388
               
419
 
389
 
420
                if ($result) {
390
                if ($result) {
421
                    $this->logger->info('Se agrego el proceso de reclutamiento' . $vacancy->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
391
                    $this->logger->info('Se agrego el proceso de reclutamiento' . $vacancy->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
Línea 452... Línea 422...
452
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
422
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
453
            $jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
423
            $jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
454
            $jobDescritions = [];
424
            $jobDescritions = [];
Línea 455... Línea 425...
455
 
425
 
456
            $records = $currentCompany ?
426
            $records = $currentCompany ?
457
                $jobDescriptionMapper->fetchAllActiveByCompanyId($currentCompany->id) :
427
                    $jobDescriptionMapper->fetchAllActiveByCompanyId($currentCompany->id) :
458
                $jobDescriptionMapper->fetchAllByDefault();
428
                    $jobDescriptionMapper->fetchAllByDefault();
459
 
429
            
-
 
430
            foreach ($records as $record)
460
            foreach ($records as $record) {
431
            {
461
                $jobDescritions[$record->uuid] = $record->name;
432
                $jobDescritions[$record->uuid] = $record->name;
Línea 462... Línea 433...
462
            }
433
            }
463
 
434
 
464
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
435
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
Línea 465... Línea 436...
465
            $jobCategory = $jobCategoryMapper->fetchOne($vacancy->job_category_id);
436
            $jobCategory = $jobCategoryMapper->fetchOne($vacancy->job_category_id);
466
            $jobCategories = [];
437
            $jobCategories = [];
467
 
438
 
-
 
439
            $records = $jobCategoryMapper->fetchAllActives();
468
            $records = $jobCategoryMapper->fetchAllActives();
440
            
469
 
441
            foreach ($records as $record)
Línea 470... Línea 442...
470
            foreach ($records as $record) {
442
            {
471
                $jobCategories[$record->uuid] = $record->name;
443
                $jobCategories[$record->uuid] = $record->name;
472
            }
444
            }
Línea 473... Línea 445...
473
 
445
 
474
            $industryMapper = IndustryMapper::getInstance($this->adapter);
446
            $industryMapper = IndustryMapper::getInstance($this->adapter);
475
            $industry = $industryMapper->fetchOne($vacancy->industry_id);
447
            $industry = $industryMapper->fetchOne($vacancy->industry_id);
-
 
448
            $industries = [];
476
            $industries = [];
449
 
477
 
450
            $records = $industryMapper->fetchAllActives();
Línea 478... Línea 451...
478
            $records = $industryMapper->fetchAllActives();
451
            
479
 
452
            foreach ($records as $record)
480
            foreach ($records as $record) {
453
            {
481
                $industries[$record->uuid] = $record->name;
454
                $industries[$record->uuid] = $record->name;
482
            }
455
            }
483
 
456
 
Línea 507... Línea 480...
507
                    'formatted_address' => $location->formatted_address,
480
                    'formatted_address' => $location->formatted_address,
508
                    'address1' => $location->address1,
481
                    'address1' => $location->address1,
509
                    'address2' => $location->address2,
482
                    'address2' => $location->address2,
510
                    'country' => $location->country,
483
                    'country' => $location->country,
511
                    'state' => $location->state,
484
                    'state' => $location->state,
512
                    'city1' => $location->city1,
485
                    'city1'=> $location->city1,
513
                    'city2' => $location->city2,
486
                    'city2' => $location->city2,
514
                    'postal_code' => $location->postal_code,
487
                    'postal_code' => $location->postal_code,
515
                    'latitude' => $location->latitude,
488
                    'latitude' => $location->latitude,
516
                    'longitude' => $location->longitude,
489
                    'longitude' => $location->longitude,
517
                    'job_category' => [
490
                    'job_category' => [
Línea 526... Línea 499...
526
                        'industry_options' => $industries,
499
                        'industry_options' => $industries,
527
                        'current_industry' => [
500
                        'current_industry' => [
528
                            'industry_id' => $industry->uuid,
501
                            'industry_id' => $industry->uuid,
529
                            'industry_name' => $industry->name,
502
                            'industry_name' => $industry->name,
530
                        ]
503
                        ]
531
                    ],
504
                    ], 
532
                    'last_date' => $vacancy->last_date,
505
                    'last_date' => $vacancy->last_date,
533
                    'status' => $vacancy->status,
506
                    'status' => $vacancy->status,
534
                    // 'content' => $vacancy->content ? json_decode($vacancy->content) : [],
507
                   // 'content' => $vacancy->content ? json_decode($vacancy->content) : [],
535
                ]
508
                ]
536
            ];
509
            ];
Línea 537... Línea 510...
537
 
510
 
538
            return new JsonModel($data);
511
            return new JsonModel($data);
Línea 546... Línea 519...
546
        }
519
        }
Línea 547... Línea 520...
547
 
520
 
548
        return new JsonModel($data);
521
        return new JsonModel($data);
Línea 549... Línea 522...
549
    }
522
    }
550
 
-
 
551
    public function deleteAction()
523
 
552
    {
524
    public function deleteAction() {
553
        $request = $this->getRequest();
525
        $request = $this->getRequest();
554
        $currentUserPlugin = $this->plugin('currentUserPlugin');
526
        $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 614... Línea 586...
614
            return new JsonModel($data);
586
            return new JsonModel($data);
615
        }
587
        }
Línea 616... Línea 588...
616
 
588
 
617
        return new JsonModel($data);
589
        return new JsonModel($data);
-
 
590
    }
-
 
591
 
-
 
592
   
618
    }
593