Proyectos de Subversion LeadersLinked - Backend

Rev

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

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