Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12165 Rev 12264
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 -... Línea 132...
-
 
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
 
129
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
156
                foreach ($records as $record) {
130
                $industryMapper = IndustryMapper::getInstance($this->adapter);
157
                    $jobDescritions[$record->uuid] = $record->name;
131
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
158
                }
132
 
159
 
133
                $items = [];
160
                $items = [];
134
                $records = $paginator->getCurrentItems();
161
                $records = $paginator->getCurrentItems();
Línea 135... Línea 162...
135
                
162
 
Línea 163... Línea 190...
163
 
190
 
Línea 164... Línea 191...
164
                $form = new RecruitmentSelectionVacancyForm($this->adapter, $currentCompany->id);
191
                $form = new RecruitmentSelectionVacancyForm($this->adapter, $currentCompany->id);
165
 
192
 
166
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
193
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
167
                $industryMapper = industryMapper::getInstance($this->adapter);
194
                $industryMapper = industryMapper::getInstance($this->adapter);
168
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);              
195
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
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('jobCategories', $jobCategories);
-
 
203
                $viewModel->setVariable('industries', $industries);
Línea 173... Línea -...
173
                $viewModel->setVariable('form', $form);
-
 
174
                $viewModel->setVariable('google_map_key', $google_map_key);
204
                $viewModel->setVariable('jobDescriptions', $jobDescritions);
175
 
205
 
176
                
206
 
177
                return $viewModel;
207
                return $viewModel;
178
            }
208
            }
179
        } else {
209
        } else {
180
            return new JsonModel([
210
            return new JsonModel([
181
                'success' => false,
-
 
182
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
211
                'success' => false,
183
            ]);
212
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
Línea 184... Línea 213...
184
            ;
213
            ]);;
-
 
214
        }
185
        }
215
    }
186
    }
216
 
187
 
217
    public function addAction()
188
    public function addAction() {
218
    {
Línea 206... Línea 236...
206
            //    'last' =>  $last_dt,
236
            //    'last' =>  $last_dt,
207
            //    'actual' => $actual_dt,
237
            //    'actual' => $actual_dt,
208
            //    'todb' => $dataPost['last_date']
238
            //    'todb' => $dataPost['last_date']
209
            //   ]                     
239
            //   ]                     
210
            //]);
240
            //]);
211
            if($actual_dt > $last_dt){
241
            if ($actual_dt > $last_dt) {
212
                 return new JsonModel([
242
                return new JsonModel([
213
                     'success' => false,
243
                    'success' => false,
214
                     'data' => 'ERROR_UNAUTHORIZED'
244
                    'data' => 'ERROR_UNAUTHORIZED'
215
                ]);   
245
                ]);
216
            }
246
            }
217
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionVacancy::STATUS_INACTIVE;
247
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionVacancy::STATUS_INACTIVE;
Línea 218... Línea 248...
218
 
248
 
Línea 223... Línea 253...
223
 
253
 
Línea 224... Línea 254...
224
                $hydrator = new ObjectPropertyHydrator();
254
                $hydrator = new ObjectPropertyHydrator();
225
 
255
 
226
                $location = new Location();
256
                $location = new Location();
227
                $hydrator->hydrate($dataPost, $location);
257
                $hydrator->hydrate($dataPost, $location);
228
                
258
 
Línea 229... Línea 259...
229
                $locationMapper= LocationMapper::getInstance($this->adapter);
259
                $locationMapper = LocationMapper::getInstance($this->adapter);
230
                $result = $locationMapper->insert($location);
260
                $result = $locationMapper->insert($location);
231
 
261
 
232
 
262
 
233
                if (!$result) {
263
                if (!$result) {
234
                    return new JsonModel([
264
                    return new JsonModel([
Línea 235... Línea 265...
235
                        'success'   => false,
265
                        'success'   => false,
236
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'                       
266
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
Línea 246... Línea 276...
246
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
276
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
247
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
277
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
248
                $vacancy->job_description_id = $jobDescription->id;
278
                $vacancy->job_description_id = $jobDescription->id;
Línea 249... Línea 279...
249
 
279
 
250
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
280
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
251
                $jobCategory = $jobCategoryMapper->fetchOneByUuid( $dataPost['job_category_id']);
281
                $jobCategory = $jobCategoryMapper->fetchOneByUuid($dataPost['job_category_id']);
Línea 252... Línea 282...
252
                $vacancy->job_category_id = $jobCategory->id;
282
                $vacancy->job_category_id = $jobCategory->id;
253
 
283
 
254
                $industryMapper = IndustryMapper::getInstance($this->adapter);
284
                $industryMapper = IndustryMapper::getInstance($this->adapter);
Línea 255... Línea 285...
255
                $industry = $industryMapper->fetchOneByUuid($dataPost['industry_id']);
285
                $industry = $industryMapper->fetchOneByUuid($dataPost['industry_id']);
256
                $vacancy->industry_id = $industry->id;
286
                $vacancy->industry_id = $industry->id;
257
 
287
 
258
                $vacancy->description = $dataPost['description'];
288
                $vacancy->description = $dataPost['description'];
259
                $vacancy->last_date = $dataPost['last_date'];
289
                $vacancy->last_date = $dataPost['last_date'];
260
                    
290
 
261
                $dt = \DateTime::createFromFormat('d/m/Y', $vacancy->last_date);
291
                $dt = \DateTime::createFromFormat('d/m/Y', $vacancy->last_date);
Línea 262... Línea 292...
262
                if($dt) {
292
                if ($dt) {
Línea 272... Línea 302...
272
 
302
 
273
                    $data = [
303
                    $data = [
274
                        'success' => true,
304
                        'success' => true,
275
                        'data' => 'LABEL_RECORD_ADDED'
305
                        'data' => 'LABEL_RECORD_ADDED'
276
                    ];
-
 
277
 
306
                    ];
278
                } else {
307
                } else {
279
                    $data = [
308
                    $data = [
280
                        'success' => false,
309
                        'success' => false,
281
                        'data' => $recruitmentSelectionVacancyMapper->getError()
310
                        'data' => $recruitmentSelectionVacancyMapper->getError()
Línea 306... Línea 335...
306
        }
335
        }
Línea 307... Línea 336...
307
 
336
 
308
        return new JsonModel($data);
337
        return new JsonModel($data);
Línea 309... Línea 338...
309
    }
338
    }
-
 
339
 
310
 
340
    public function editAction()
311
    public function editAction() {
341
    {
312
        $request = $this->getRequest();
342
        $request = $this->getRequest();
313
        $currentUserPlugin = $this->plugin('currentUserPlugin');
343
        $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 371... Línea 401...
371
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
401
                $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
372
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
402
                $jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
373
                $vacancy->job_description_id = $jobDescription->id;
403
                $vacancy->job_description_id = $jobDescription->id;
Línea 374... Línea 404...
374
 
404
 
375
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
405
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
376
                $jobCategory = $jobCategoryMapper->fetchOneByUuid( $dataPost['job_category_id']);
406
                $jobCategory = $jobCategoryMapper->fetchOneByUuid($dataPost['job_category_id']);
Línea 377... Línea 407...
377
                $vacancy->job_category_id = $jobCategory->id;
407
                $vacancy->job_category_id = $jobCategory->id;
378
 
408
 
379
                $industryMapper = IndustryMapper::getInstance($this->adapter);
409
                $industryMapper = IndustryMapper::getInstance($this->adapter);
Línea 383... Línea 413...
383
                $vacancy->job_description_id = $jobDescription->id;
413
                $vacancy->job_description_id = $jobDescription->id;
384
                $vacancy->job_category_id = $jobCategory->id;
414
                $vacancy->job_category_id = $jobCategory->id;
385
                $vacancy->industry_id = $industry->id;
415
                $vacancy->industry_id = $industry->id;
Línea 386... Línea 416...
386
 
416
 
387
                $result = $recruitmentSelectionVacancyMapper->update($vacancy);
417
                $result = $recruitmentSelectionVacancyMapper->update($vacancy);
Línea 388... Línea 418...
388
               
418
 
389
 
419
 
390
                if ($result) {
420
                if ($result) {
391
                    $this->logger->info('Se agrego el proceso de reclutamiento' . $vacancy->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
421
                    $this->logger->info('Se agrego el proceso de reclutamiento' . $vacancy->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
Línea 422... Línea 452...
422
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
452
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
423
            $jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
453
            $jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
424
            $jobDescritions = [];
454
            $jobDescritions = [];
Línea 425... Línea 455...
425
 
455
 
426
            $records = $currentCompany ?
456
            $records = $currentCompany ?
427
                    $jobDescriptionMapper->fetchAllActiveByCompanyId($currentCompany->id) :
457
                $jobDescriptionMapper->fetchAllActiveByCompanyId($currentCompany->id) :
428
                    $jobDescriptionMapper->fetchAllByDefault();
458
                $jobDescriptionMapper->fetchAllByDefault();
429
            
459
 
430
            foreach ($records as $record)
-
 
431
            {
460
            foreach ($records as $record) {
432
                $jobDescritions[$record->uuid] = $record->name;
461
                $jobDescritions[$record->uuid] = $record->name;
Línea 433... Línea 462...
433
            }
462
            }
434
 
463
 
435
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
464
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
Línea 436... Línea 465...
436
            $jobCategory = $jobCategoryMapper->fetchOne($vacancy->job_category_id);
465
            $jobCategory = $jobCategoryMapper->fetchOne($vacancy->job_category_id);
437
            $jobCategories = [];
466
            $jobCategories = [];
438
 
467
 
439
            $records = $jobCategoryMapper->fetchAllActives();
-
 
440
            
468
            $records = $jobCategoryMapper->fetchAllActives();
441
            foreach ($records as $record)
469
 
Línea 442... Línea 470...
442
            {
470
            foreach ($records as $record) {
443
                $jobCategories[$record->uuid] = $record->name;
471
                $jobCategories[$record->uuid] = $record->name;
444
            }
472
            }
Línea 445... Línea 473...
445
 
473
 
446
            $industryMapper = IndustryMapper::getInstance($this->adapter);
474
            $industryMapper = IndustryMapper::getInstance($this->adapter);
447
            $industry = $industryMapper->fetchOne($vacancy->industry_id);
475
            $industry = $industryMapper->fetchOne($vacancy->industry_id);
448
            $industries = [];
-
 
449
 
476
            $industries = [];
450
            $records = $industryMapper->fetchAllActives();
477
 
Línea 451... Línea 478...
451
            
478
            $records = $industryMapper->fetchAllActives();
452
            foreach ($records as $record)
479
 
453
            {
480
            foreach ($records as $record) {
454
                $industries[$record->uuid] = $record->name;
481
                $industries[$record->uuid] = $record->name;
455
            }
482
            }
456
 
483
 
Línea 480... Línea 507...
480
                    'formatted_address' => $location->formatted_address,
507
                    'formatted_address' => $location->formatted_address,
481
                    'address1' => $location->address1,
508
                    'address1' => $location->address1,
482
                    'address2' => $location->address2,
509
                    'address2' => $location->address2,
483
                    'country' => $location->country,
510
                    'country' => $location->country,
484
                    'state' => $location->state,
511
                    'state' => $location->state,
485
                    'city1'=> $location->city1,
512
                    'city1' => $location->city1,
486
                    'city2' => $location->city2,
513
                    'city2' => $location->city2,
487
                    'postal_code' => $location->postal_code,
514
                    'postal_code' => $location->postal_code,
488
                    'latitude' => $location->latitude,
515
                    'latitude' => $location->latitude,
489
                    'longitude' => $location->longitude,
516
                    'longitude' => $location->longitude,
490
                    'job_category' => [
517
                    'job_category' => [
Línea 499... Línea 526...
499
                        'industry_options' => $industries,
526
                        'industry_options' => $industries,
500
                        'current_industry' => [
527
                        'current_industry' => [
501
                            'industry_id' => $industry->uuid,
528
                            'industry_id' => $industry->uuid,
502
                            'industry_name' => $industry->name,
529
                            'industry_name' => $industry->name,
503
                        ]
530
                        ]
504
                    ], 
531
                    ],
505
                    'last_date' => $vacancy->last_date,
532
                    'last_date' => $vacancy->last_date,
506
                    'status' => $vacancy->status,
533
                    'status' => $vacancy->status,
507
                   // 'content' => $vacancy->content ? json_decode($vacancy->content) : [],
534
                    // 'content' => $vacancy->content ? json_decode($vacancy->content) : [],
508
                ]
535
                ]
509
            ];
536
            ];
Línea 510... Línea 537...
510
 
537
 
511
            return new JsonModel($data);
538
            return new JsonModel($data);
Línea 519... Línea 546...
519
        }
546
        }
Línea 520... Línea 547...
520
 
547
 
521
        return new JsonModel($data);
548
        return new JsonModel($data);
Línea 522... Línea 549...
522
    }
549
    }
-
 
550
 
523
 
551
    public function deleteAction()
524
    public function deleteAction() {
552
    {
525
        $request = $this->getRequest();
553
        $request = $this->getRequest();
526
        $currentUserPlugin = $this->plugin('currentUserPlugin');
554
        $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 586... Línea 614...
586
            return new JsonModel($data);
614
            return new JsonModel($data);
587
        }
615
        }
Línea 588... Línea 616...
588
 
616
 
589
        return new JsonModel($data);
617
        return new JsonModel($data);
590
    }
-
 
591
 
-
 
592
   
-
 
593
 
618
    }