Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 8367 Rev 11139
Línea 1... Línea 1...
1
<?php
1
<?php
-
 
2
 
2
/**
3
/**
3
 * 
4
 * 
4
 * Controlador: Mis Perfiles 
5
 * Controlador: Mis Perfiles 
5
 * 
6
 * 
6
 */
7
 */
-
 
8
 
7
declare(strict_types=1);
9
declare(strict_types=1);
Línea 8... Línea 10...
8
 
10
 
Línea 9... Línea 11...
9
namespace LeadersLinked\Controller;
11
namespace LeadersLinked\Controller;
Línea 64... Línea 66...
64
    /**
66
    /**
65
     *
67
     *
66
     * @var AdapterInterface
68
     * @var AdapterInterface
67
     */
69
     */
68
    private $adapter;
70
    private $adapter;
69
    
71
 
70
    
72
 
71
    /**
73
    /**
72
     *
74
     *
73
     * @var AbstractAdapter
75
     * @var AbstractAdapter
74
     */
76
     */
75
    private $cache;
77
    private $cache;
76
    
78
 
77
    /**
79
    /**
78
     *
80
     *
79
     * @var  LoggerInterface
81
     * @var  LoggerInterface
80
     */
82
     */
81
    private $logger;
83
    private $logger;
Línea 82... Línea 84...
82
 
84
 
83
    
85
 
84
    /**
86
    /**
85
     *
87
     *
86
     * @var array
88
     * @var array
87
     */
89
     */
88
    private $config;
90
    private $config;
89
    
91
 
90
    /**
92
    /**
91
     *
93
     *
92
     * @param AdapterInterface $adapter
94
     * @param AdapterInterface $adapter
93
     * @param AbstractAdapter $cache
95
     * @param AbstractAdapter $cache
94
     * @param LoggerInterface $logger
96
     * @param LoggerInterface $logger
95
     * @param array $config
97
     * @param array $config
96
     */
98
     */
97
    public function __construct($adapter, $cache , $logger,  $config)
99
    public function __construct($adapter, $cache, $logger,  $config)
98
    {
100
    {
99
        $this->adapter      = $adapter;
101
        $this->adapter      = $adapter;
100
        $this->cache        = $cache;
102
        $this->cache        = $cache;
101
        $this->logger       = $logger;
103
        $this->logger       = $logger;
102
        $this->config       = $config;
-
 
103
 
104
        $this->config       = $config;
104
    }
105
    }
105
    
106
 
106
    /**
107
    /**
107
     * 
108
     * 
108
     * Generación del listado de perfiles
109
     * Generación del listado de perfiles
109
     * {@inheritDoc}
110
     * {@inheritDoc}
Línea 112... Línea 113...
112
    public function indexAction()
113
    public function indexAction()
113
    {
114
    {
114
        $currentUserPlugin = $this->plugin('currentUserPlugin');
115
        $currentUserPlugin = $this->plugin('currentUserPlugin');
115
        $currentUser = $currentUserPlugin->getUser();
116
        $currentUser = $currentUserPlugin->getUser();
116
        $currentCompany = $currentUserPlugin->getCompany();
117
        $currentCompany = $currentUserPlugin->getCompany();
117
        
-
 
118
        
-
 
Línea -... Línea 118...
-
 
118
 
119
 
119
 
-
 
120
 
120
        
121
 
121
        $request = $this->getRequest();
122
        $request = $this->getRequest();
122
        if($request->isGet()) {
123
        if ($request->isGet()) {
123
            $sandbox = $this->config['leaderslinked.runmode.sandbox'];
124
            $sandbox = $this->config['leaderslinked.runmode.sandbox'];
124
            if($sandbox) {
125
            if ($sandbox) {
125
                $google_map_key  = $this->config['leaderslinked.google_map.sandbox_api_key'];
126
                $google_map_key  = $this->config['leaderslinked.google_map.sandbox_api_key'];
126
            } else {
127
            } else {
127
                $google_map_key  = $this->config['leaderslinked.google_map.production_api_key'];
128
                $google_map_key  = $this->config['leaderslinked.google_map.production_api_key'];
128
            }
129
            }
129
            
130
 
130
            $headers  = $request->getHeaders();
131
            $headers  = $request->getHeaders();
131
            
132
 
132
            $isJson = false;
133
            $isJson = false;
133
            if($headers->has('Accept')) {
134
            if ($headers->has('Accept')) {
134
                $accept = $headers->get('Accept');
135
                $accept = $headers->get('Accept');
135
                
136
 
136
                $prioritized = $accept->getPrioritized();
137
                $prioritized = $accept->getPrioritized();
137
                
138
 
138
                foreach($prioritized as $key => $value) {
139
                foreach ($prioritized as $key => $value) {
139
                    $raw = trim($value->getRaw());
140
                    $raw = trim($value->getRaw());
140
                    
141
 
141
                    if(!$isJson) {
142
                    if (!$isJson) {
142
                        $isJson = strpos($raw, 'json');
143
                        $isJson = strpos($raw, 'json');
143
                    }
-
 
144
                    
144
                    }
145
                }
145
                }
146
            }
146
            }
147
            
147
 
148
            if($isJson) {
148
            if ($isJson) {
149
                $search = $this->params()->fromQuery('search');
149
                $search = $this->params()->fromQuery('search');
150
                $search = empty($search) ? '' : filter_var($search, FILTER_SANITIZE_STRING);
150
                $search = empty($search) ? '' : filter_var($search, FILTER_SANITIZE_STRING);
151
                
151
 
152
                $page               = intval($this->params()->fromQuery('start', 1), 10);
152
                $page               = intval($this->params()->fromQuery('start', 1), 10);
153
                $records_x_page     = intval($this->params()->fromQuery('length', 10), 10);
153
                $records_x_page     = intval($this->params()->fromQuery('length', 10), 10);
154
                $order =  $this->params()->fromQuery('order', []);
154
                $order =  $this->params()->fromQuery('order', []);
155
                $order_field        = empty($order[0]['column']) ? 99 :  intval($order[0]['column'], 10);
155
                $order_field        = empty($order[0]['column']) ? 99 :  intval($order[0]['column'], 10);
156
                $order_direction    = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var( $order[0]['dir'], FILTER_SANITIZE_STRING));
156
                $order_direction    = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
157
                
157
 
158
                $fields =  ['last_date_of_application', 'titlte'];
158
                $fields =  ['last_date_of_application', 'titlte'];
159
                $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'last_date_of_application';
159
                $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'last_date_of_application';
160
                
160
 
161
                if(!in_array($order_direction, ['ASC', 'DESC'])) {
161
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
162
                    $order_direction = 'ASC';
162
                    $order_direction = 'ASC';
163
                }
163
                }
164
                
164
 
165
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
165
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
166
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'jobs/delete');
166
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'jobs/delete');
167
               
167
 
168
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'jobs/edit');
168
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'jobs/edit');
169
                $allowUsersWhoApplied = $acl->isAllowed($currentUser->usertype_id, 'jobs/users-who-applied');
169
                $allowUsersWhoApplied = $acl->isAllowed($currentUser->usertype_id, 'jobs/users-who-applied');
170
                
170
 
171
                
171
 
172
                
172
 
173
                $jobMapper = JobMapper::getInstance($this->adapter);
173
                $jobMapper = JobMapper::getInstance($this->adapter);
174
                $jobApplicationMapper = JobApplicationMapper::getInstance($this->adapter);
174
                $jobApplicationMapper = JobApplicationMapper::getInstance($this->adapter);
175
                $paginator = $jobMapper->fetchAllDataTableByCompanyId($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
175
                $paginator = $jobMapper->fetchAllDataTableByCompanyId($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
Línea 176... Línea 176...
176
                
176
 
Línea 177... Línea 177...
177
 
177
 
178
                $records = $paginator->getCurrentItems();
178
                $records = $paginator->getCurrentItems();
179
 
-
 
180
                $items = [];
179
 
181
                foreach($records as $record)
180
                $items = [];
182
                {
181
                foreach ($records as $record) {
183
                    
182
 
184
                    switch($record->status) {
183
                    switch ($record->status) {
185
                        case  Job::STATUS_ACTIVE :
184
                        case  Job::STATUS_ACTIVE:
186
                            $status = 'LABEL_ACTIVE';
185
                            $status = 'LABEL_ACTIVE';
187
                            break;
186
                            break;
188
                            
187
 
189
                        case  Job::STATUS_INACTIVE :
188
                        case  Job::STATUS_INACTIVE:
190
                            $status = 'LABEL_INACTIVE';
189
                            $status = 'LABEL_INACTIVE';
191
                            break;
190
                            break;
192
                            
191
 
193
                            
192
 
194
                        case  Job::STATUS_DELETED :
193
                        case  Job::STATUS_DELETED:
195
                            $status = 'LABEL_DELETED';
194
                            $status = 'LABEL_DELETED';
196
                            break;
195
                            break;
197
                            
196
 
198
                        default : 
197
                        default:
199
                            $status = '';
198
                            $status = '';
200
                            break;
199
                            break;
201
                    }
-
 
202
                    
200
                    }
203
                    switch($record->employment_type)
201
 
204
                    {
202
                    switch ($record->employment_type) {
205
                        case Job::EMPLOYMENT_TYPE_FULL_TIME : 
203
                        case Job::EMPLOYMENT_TYPE_FULL_TIME:
206
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
204
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
207
                            break;
205
                            break;
208
                        case Job::EMPLOYMENT_TYPE_PART_TIME : 
206
                        case Job::EMPLOYMENT_TYPE_PART_TIME:
209
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
207
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
210
                            break;
208
                            break;
211
                            
209
 
212
                        case Job::EMPLOYMENT_TYPE_CONTRACT : 
210
                        case Job::EMPLOYMENT_TYPE_CONTRACT:
213
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
211
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
214
                            break;
212
                            break;
215
                            
213
 
216
                        case Job::EMPLOYMENT_TYPE_TEMPORARY : 
214
                        case Job::EMPLOYMENT_TYPE_TEMPORARY:
217
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
215
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
218
                            break;
216
                            break;
219
                            
217
 
220
                        default : 
218
                        default:
221
                            $employment_type = '';
219
                            $employment_type = '';
222
                            break;
220
                            break;
223
                    }
221
                    }
224
                    
222
 
225
                    $users_who_applied = $jobApplicationMapper->fetchTotalApplicationsByJobId($record->id);
223
                    $users_who_applied = $jobApplicationMapper->fetchTotalApplicationsByJobId($record->id);
226
                    
224
 
Línea 227... Línea 225...
227
                   
225
 
228
                    $dt = \DateTime::createFromFormat('Y-m-d', $record->last_date_of_application );
226
                    $dt = \DateTime::createFromFormat('Y-m-d', $record->last_date_of_application);
229
                    
227
 
230
 
228
 
231
                    $item = [
229
                    $item = [
232
                        'last_date_of_application' => $dt->format('d/m/Y') ,
230
                        'last_date_of_application' => $dt->format('d/m/Y'),
233
                        'title' => $record->title, 
231
                        'title' => $record->title,
234
                        
232
 
235
                        
233
 
236
                        'details' => [
234
                        'details' => [
237
                            'status' => $status,
235
                            'status' => $status,
238
                            'employment_type' => $employment_type, 
236
                            'employment_type' => $employment_type,
239
                            'users_who_applied' => $users_who_applied,
237
                            'users_who_applied' => $users_who_applied,
240
                        ],
238
                        ],
241
                        'actions' => [
239
                        'actions' => [
242
                            'link_edit' => $allowEdit ? $this->url()->fromRoute('jobs/edit', ['id' => $record->uuid  ]) : '' ,
240
                            'link_edit' => $allowEdit ? $this->url()->fromRoute('jobs/edit', ['id' => $record->uuid]) : '',
243
                            'link_delete' => $allowDelete ? $this->url()->fromRoute('jobs/delete', [ 'id' => $record->uuid  ]) : '',
241
                            'link_delete' => $allowDelete ? $this->url()->fromRoute('jobs/delete', ['id' => $record->uuid]) : '',
244
                            'link_users_who_applied'  => $allowUsersWhoApplied && $users_who_applied  ? $this->url()->fromRoute('jobs/users-who-applied', ['id' => $record->uuid ]) : '',
242
                            'link_users_who_applied'  => $allowUsersWhoApplied && $users_who_applied  ? $this->url()->fromRoute('jobs/users-who-applied', ['id' => $record->uuid]) : '',
245
                         ]
243
                        ]
246
                    ];
-
 
Línea -... Línea 244...
-
 
244
                    ];
247
                    
245
 
248
                    array_push($items, $item);
246
                    array_push($items, $item);
249
                }
247
                }
250
                
248
 
251
 
249
 
252
                
250
 
253
                
251
 
254
                $response = [
252
                $response = [
255
                    'success' => true,
253
                    'success' => true,
256
                    'data' => [
254
                    'data' => [
257
                        'items' => $items,
255
                        'items' => $items,
258
                        'total' => $paginator->getTotalItemCount(),
-
 
259
                    ]
-
 
260
                ];
256
                        'total' => $paginator->getTotalItemCount(),
261
                
257
                    ]
262
                return new JsonModel($response);
258
                ];
263
                
259
 
264
                
260
                return new JsonModel($response);
265
            } else {
261
            } else {
266
               
262
 
267
                
263
 
Línea 276... Línea 272...
276
                $formDegree = new CompanyJobDegreeForm($this->adapter);
272
                $formDegree = new CompanyJobDegreeForm($this->adapter);
277
                $formLanguage = new CompanyJobLanguageForm($this->adapter);
273
                $formLanguage = new CompanyJobLanguageForm($this->adapter);
278
                $formSkill = new CompanyJobSkillForm($this->adapter);
274
                $formSkill = new CompanyJobSkillForm($this->adapter);
279
                $formStatus = new CompanyJobStatusForm();
275
                $formStatus = new CompanyJobStatusForm();
280
                $formTitle = new CompanyJobTitleForm();
276
                $formTitle = new CompanyJobTitleForm();
281
                
277
 
-
 
278
                $jobCategories = [];
-
 
279
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
-
 
280
                $records = $jobCategoryMapper->fetchAllActives();
-
 
281
 
-
 
282
                foreach ($records as $record) {
-
 
283
                    $jobCategories[$record->uuid] = $record->name;
-
 
284
                }
282
                
285
 
283
                $this->layout()->setTemplate('layout/layout-backend');
286
                $this->layout()->setTemplate('layout/layout-backend');
284
                $viewModel = new ViewModel();
287
                $viewModel = new ViewModel();
285
                $viewModel->setTemplate('leaders-linked/jobs/index.phtml');
288
                $viewModel->setTemplate('leaders-linked/jobs/index.phtml');
286
                $viewModel->setVariables([
289
                $viewModel->setVariables([
287
                    'formAdd'                   => $formAdd,
290
                    'formAdd'                   => $formAdd,
Línea 295... Línea 298...
295
                    'formDegree'                => $formDegree,
298
                    'formDegree'                => $formDegree,
296
                    'formLanguage'              => $formLanguage,
299
                    'formLanguage'              => $formLanguage,
297
                    'formSkill'                 => $formSkill,
300
                    'formSkill'                 => $formSkill,
298
                    'formStatus'                => $formStatus,
301
                    'formStatus'                => $formStatus,
299
                    'formTitle'                 => $formTitle,
302
                    'formTitle'                 => $formTitle,
300
                    
-
 
-
 
303
                    'job_categories'            => $jobCategories,
301
                    'google_map_key'    => $google_map_key,
304
                    'google_map_key'    => $google_map_key,
Línea 302... Línea 305...
302
 
305
 
303
                ]);
306
                ]);
304
                return $viewModel ;
307
                return $viewModel;
305
            }
-
 
306
            
308
            }
307
        } else {
309
        } else {
308
            return new JsonModel([
310
            return new JsonModel([
309
                'success' => false,
311
                'success' => false,
310
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
312
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
311
            ]);
313
            ]);
312
        }
314
        }
313
    }
315
    }
314
    
316
 
315
    /**
317
    /**
316
     * 
318
     * 
317
     * Agregar un nuevo perfil
319
     * Agregar un nuevo perfil
318
     * @return \Laminas\View\Model\JsonModel
320
     * @return \Laminas\View\Model\JsonModel
319
     */
321
     */
320
    public function addAction()
322
    public function addAction()
321
    {
323
    {
322
        $request = $this->getRequest();
324
        $request = $this->getRequest();
323
       
325
 
324
        
326
 
325
        $currentUserPlugin = $this->plugin('currentUserPlugin');
327
        $currentUserPlugin = $this->plugin('currentUserPlugin');
326
        $currentUser = $currentUserPlugin->getUser();
328
        $currentUser = $currentUserPlugin->getUser();
327
        $currentCompany = $currentUserPlugin->getCompany();
-
 
Línea -... Línea 329...
-
 
329
        $currentCompany = $currentUserPlugin->getCompany();
328
        
330
 
329
 
331
 
330
        
332
 
331
        if($request->isPost()) {
333
        if ($request->isPost()) {
332
            $form = new  CompanyJobCreateForm($this->adapter);
334
            $form = new  CompanyJobCreateForm($this->adapter);
333
            $dataPost = $request->getPost()->toArray();
335
            $dataPost = $request->getPost()->toArray();
334
            
336
 
335
            $form->setData($dataPost);
337
            $form->setData($dataPost);
336
            
338
 
337
            if($form->isValid()) {
339
            if ($form->isValid()) {
338
                $companyMapper = CompanyMapper::getInstance($this->adapter);
340
                $companyMapper = CompanyMapper::getInstance($this->adapter);
339
                $company = $companyMapper->fetchOne($currentCompany->id);
341
                $company = $companyMapper->fetchOne($currentCompany->id);
340
                
342
 
341
                
343
 
342
                $dataPost = (array) $form->getData();
344
                $dataPost = (array) $form->getData();
343
                
345
 
-
 
346
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
-
 
347
                $jobCategory = $jobCategoryMapper->fetchOneByUuid($dataPost['job_category_id']);
Línea 344... Línea -...
344
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
-
 
345
                $jobCategory = $jobCategoryMapper->fetchOneByUuid( $dataPost['job_category_id']);
-
 
346
 
348
 
347
                
349
 
348
                
350
 
349
                $hydrator = new ObjectPropertyHydrator();
351
                $hydrator = new ObjectPropertyHydrator();
350
                $location = new Location();
352
                $location = new Location();
351
                $hydrator->hydrate($dataPost, $location);
353
                $hydrator->hydrate($dataPost, $location);
352
                
354
 
353
                
355
 
354
                $locationMapper= LocationMapper::getInstance($this->adapter);
356
                $locationMapper = LocationMapper::getInstance($this->adapter);
Línea 355... Línea 357...
355
                $result = $locationMapper->insert($location);
357
                $result = $locationMapper->insert($location);
356
                
358
 
357
                if($result) {
359
                if ($result) {
358
 
360
 
359
                    $job = new Job();
361
                    $job = new Job();
360
                    $hydrator->hydrate($dataPost, $job);
362
                    $hydrator->hydrate($dataPost, $job);
361
                    
363
 
362
                    $job->location_id = $location->id;
364
                    $job->location_id = $location->id;
363
                    $job->status = Job::STATUS_INACTIVE;
365
                    $job->status = Job::STATUS_INACTIVE;
364
                    $job->company_id = $company->id;
366
                    $job->company_id = $company->id;
365
                    $job->job_category_id = $jobCategory->id;
367
                    $job->job_category_id = $jobCategory->id;
366
                    $job->description = '';
368
                    $job->description = '';
367
                    
369
 
368
                    $last_date_of_application = $job->last_date_of_application;
370
                    $last_date_of_application = $job->last_date_of_application;
369
                    
371
 
370
                    $dt = \DateTime::createFromFormat('d/m/Y', $last_date_of_application);
372
                    $dt = \DateTime::createFromFormat('d/m/Y', $last_date_of_application);
371
                    if($dt) {
373
                    if ($dt) {
372
                        $job->last_date_of_application = $dt->format('Y-m-d');
374
                        $job->last_date_of_application = $dt->format('Y-m-d');
373
                    }
375
                    }
374
                    
376
 
375
                    
377
 
376
                    
378
 
377
                    $jobMapper = JobMapper::getInstance($this->adapter);
379
                    $jobMapper = JobMapper::getInstance($this->adapter);
378
                    $result = $jobMapper->insert($job);
380
                    $result = $jobMapper->insert($job);
379
                    
381
 
380
                    if($result) {
382
                    if ($result) {
381
                        
-
 
382
                        $this->logger->info('Se agrego el empleo : ' . $job->title . ' a  la empresa ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
383
 
383
                        
384
                        $this->logger->info('Se agrego el empleo : ' . $job->title . ' a  la empresa ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
384
                        switch($job->employment_type)
385
 
385
                        {
386
                        switch ($job->employment_type) {
386
                            case Job::EMPLOYMENT_TYPE_FULL_TIME :
387
                            case Job::EMPLOYMENT_TYPE_FULL_TIME:
387
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
388
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
388
                                break;
389
                                break;
389
                            case Job::EMPLOYMENT_TYPE_PART_TIME :
390
                            case Job::EMPLOYMENT_TYPE_PART_TIME:
390
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
391
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
391
                                break;
392
                                break;
392
                                
393
 
393
                            case Job::EMPLOYMENT_TYPE_CONTRACT :
394
                            case Job::EMPLOYMENT_TYPE_CONTRACT:
394
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
395
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
395
                                break;
396
                                break;
396
                                
397
 
397
                            case Job::EMPLOYMENT_TYPE_TEMPORARY :
398
                            case Job::EMPLOYMENT_TYPE_TEMPORARY:
398
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
399
                                $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
399
                                break;
400
                                break;
400
                                
401
 
401
                            default :
402
                            default:
402
                                $employment_type = '';
403
                                $employment_type = '';
403
                                break;
404
                                break;
404
                        }
405
                        }
405
                        
406
 
406
                        $months = [
407
                        $months = [
Línea 415... Línea 416...
415
                            9 => 'LABEL_MONTH_SEPTEMBER',
416
                            9 => 'LABEL_MONTH_SEPTEMBER',
416
                            10 => 'LABEL_MONTH_OCTOBER',
417
                            10 => 'LABEL_MONTH_OCTOBER',
417
                            11 => 'LABEL_MONTH_NOVEMBER',
418
                            11 => 'LABEL_MONTH_NOVEMBER',
418
                            12 => 'LABEL_MONTH_DECEMBER',
419
                            12 => 'LABEL_MONTH_DECEMBER',
419
                        ];
420
                        ];
420
                        
421
 
421
                        $dt = \DateTime::createFromFormat('Y-m-d', $job->last_date_of_application);
422
                        $dt = \DateTime::createFromFormat('Y-m-d', $job->last_date_of_application);
422
                        $last_date_of_application = $dt->format('d') . ' de ' . $months[$dt->format('n')] . ' de ' . $dt->format('Y');
423
                        $last_date_of_application = $dt->format('d') . ' de ' . $months[$dt->format('n')] . ' de ' . $dt->format('Y');
423
                        
424
 
424
                        $job = $jobMapper->fetchOne($job->id);
425
                        $job = $jobMapper->fetchOne($job->id);
425
                        
426
 
426
                        
427
 
427
                        //'LABEL_RECORD_ADDED'
428
                        //'LABEL_RECORD_ADDED'
428
                        $response = [
429
                        $response = [
429
                            'success'   => true,
430
                            'success'   => true,
430
                            'data'   => [
431
                            'data'   => [
431
                                'title' => $job->title,
432
                                'title' => $job->title,
432
                                'status' => 'LABEL_INACTIVE',
433
                                'status' => 'LABEL_INACTIVE',
433
                                'employment_type' => $employment_type,
434
                                'employment_type' => $employment_type,
434
                                'job_category' => $jobCategory->name,
435
                                'job_category' => $jobCategory->name,
435
                                'last_date_of_application' => $last_date_of_application,
436
                                'last_date_of_application' => $last_date_of_application,
436
                                'location'  => $location->formatted_address,
437
                                'location'  => $location->formatted_address,
437
                                'route_status' => $this->url()->fromRoute('jobs/edit/status', [ 'id' => $job->uuid ]),
438
                                'route_status' => $this->url()->fromRoute('jobs/edit/status', ['id' => $job->uuid]),
438
                                'route_title' => $this->url()->fromRoute('jobs/edit/title', [ 'id' => $job->uuid ]),
439
                                'route_title' => $this->url()->fromRoute('jobs/edit/title', ['id' => $job->uuid]),
439
                                'route_extended' => $this->url()->fromRoute('jobs/edit/extended', [ 'id' => $job->uuid ]),
440
                                'route_extended' => $this->url()->fromRoute('jobs/edit/extended', ['id' => $job->uuid]),
440
                                'route_location' => $this->url()->fromRoute('jobs/edit/location', [ 'id' => $job->uuid ]),
441
                                'route_location' => $this->url()->fromRoute('jobs/edit/location', ['id' => $job->uuid]),
441
                                'route_job_category' => $this->url()->fromRoute('jobs/edit/job-category', [ 'id' => $job->uuid ]),
442
                                'route_job_category' => $this->url()->fromRoute('jobs/edit/job-category', ['id' => $job->uuid]),
442
                                'route_employment_type' => $this->url()->fromRoute('jobs/edit/employment-type', [ 'id' => $job->uuid ]),
443
                                'route_employment_type' => $this->url()->fromRoute('jobs/edit/employment-type', ['id' => $job->uuid]),
443
                                'route_salary' => $this->url()->fromRoute('jobs/edit/salary', [ 'id' => $job->uuid ]),
444
                                'route_salary' => $this->url()->fromRoute('jobs/edit/salary', ['id' => $job->uuid]),
444
                                'route_experience' => $this->url()->fromRoute('jobs/edit/experience', [ 'id' => $job->uuid ]),
445
                                'route_experience' => $this->url()->fromRoute('jobs/edit/experience', ['id' => $job->uuid]),
445
                                'route_languages' => $this->url()->fromRoute('jobs/edit/languages', [ 'id' => $job->uuid ]),
446
                                'route_languages' => $this->url()->fromRoute('jobs/edit/languages', ['id' => $job->uuid]),
446
                                'route_degrees' => $this->url()->fromRoute('jobs/edit/degrees', [ 'id' => $job->uuid ]),
447
                                'route_degrees' => $this->url()->fromRoute('jobs/edit/degrees', ['id' => $job->uuid]),
447
                                'route_skills' => $this->url()->fromRoute('jobs/edit/skills', [ 'id' => $job->uuid ]),
448
                                'route_skills' => $this->url()->fromRoute('jobs/edit/skills', ['id' => $job->uuid]),
448
                                'route_last_date_of_application' => $this->url()->fromRoute('jobs/edit/last-date-of-application', [ 'id' => $job->uuid ]),
449
                                'route_last_date_of_application' => $this->url()->fromRoute('jobs/edit/last-date-of-application', ['id' => $job->uuid]),
449
                                
450
 
450
                            ]
451
                            ]
451
                        ];
452
                        ];
452
                    } else {
453
                    } else {
453
                        $response = [
454
                        $response = [
454
                            'success'   => false,
455
                            'success'   => false,
455
                            'data' => 'ERROR_THERE_WAS_AN_ERROR'
456
                            'data' => 'ERROR_THERE_WAS_AN_ERROR'
456
                        ];
457
                        ];
457
                    }
458
                    }
458
                    
-
 
459
                } else {
459
                } else {
460
                    $response = [
460
                    $response = [
461
                        'success'   => false,
461
                        'success'   => false,
462
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
462
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
463
                    ];
463
                    ];
464
                }
464
                }
465
                
-
 
466
                
-
 
467
                
-
 
468
            } else {
465
            } else {
469
                $messages = [];
466
                $messages = [];
470
                $form_messages = (array) $form->getMessages();
467
                $form_messages = (array) $form->getMessages();
471
                foreach($form_messages  as $fieldname => $field_messages)
468
                foreach ($form_messages  as $fieldname => $field_messages) {
472
                {
-
 
473
                    
469
 
474
                    $messages[$fieldname] = array_values($field_messages);
470
                    $messages[$fieldname] = array_values($field_messages);
475
                }
471
                }
476
                
472
 
477
                return new JsonModel([
473
                return new JsonModel([
478
                    'success'   => false,
474
                    'success'   => false,
479
                    'data'   => $messages
475
                    'data'   => $messages
480
                ]);
476
                ]);
481
            }
477
            }
482
            
-
 
483
        } else {
478
        } else {
484
            $response = [
479
            $response = [
485
                'success' => false,
480
                'success' => false,
486
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
481
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
487
            ];
482
            ];
488
            
-
 
489
 
-
 
490
        }
483
        }
491
        
484
 
492
        return new JsonModel($response);
485
        return new JsonModel($response);
493
    }
486
    }
494
    
487
 
495
    /**
488
    /**
496
     * 
489
     * 
497
     * Borrar un perfil excepto el público
490
     * Borrar un perfil excepto el público
498
     * @return \Laminas\View\Model\JsonModel
491
     * @return \Laminas\View\Model\JsonModel
499
     */
492
     */
500
    public function deleteAction()
493
    public function deleteAction()
501
    {
494
    {
502
        
495
 
503
        $currentUserPlugin = $this->plugin('currentUserPlugin');
496
        $currentUserPlugin = $this->plugin('currentUserPlugin');
504
        $currentUser = $currentUserPlugin->getUser();
497
        $currentUser = $currentUserPlugin->getUser();
505
        $currentCompany = $currentUserPlugin->getCompany();
498
        $currentCompany = $currentUserPlugin->getCompany();
506
        
499
 
507
        
500
 
508
        $request = $this->getRequest();
501
        $request = $this->getRequest();
509
        $id = $this->params()->fromRoute('id');
502
        $id = $this->params()->fromRoute('id');
510
        
503
 
511
        if(!$id) {
504
        if (!$id) {
512
            $data = [
505
            $data = [
513
                'success'   => false,
506
                'success'   => false,
514
                'data'   => 'ERROR_INVALID_PARAMETER'
507
                'data'   => 'ERROR_INVALID_PARAMETER'
515
            ];
508
            ];
516
            
509
 
517
            return new JsonModel($data);
510
            return new JsonModel($data);
518
        }
511
        }
519
        
512
 
520
        $jobMapper = JobMapper::getInstance($this->adapter);
513
        $jobMapper = JobMapper::getInstance($this->adapter);
521
        $job = $jobMapper->fetchOneByUuid($id);
514
        $job = $jobMapper->fetchOneByUuid($id);
522
        if(!$job) {
515
        if (!$job) {
523
            $data = [
516
            $data = [
524
                'success'   => false,
517
                'success'   => false,
525
                'data'   => 'ERROR_JOB_NOT_FOUND'
518
                'data'   => 'ERROR_JOB_NOT_FOUND'
526
            ];
519
            ];
527
            
520
 
528
            return new JsonModel($data);
521
            return new JsonModel($data);
529
        }
522
        }
530
        
523
 
531
        if($job->company_id != $currentCompany->id) {
524
        if ($job->company_id != $currentCompany->id) {
532
            $data = [
525
            $data = [
533
                'success'   => false,
526
                'success'   => false,
534
                'data'   => 'ERROR_UNAUTHORIZED'
527
                'data'   => 'ERROR_UNAUTHORIZED'
535
            ];
528
            ];
536
            
529
 
537
            return new JsonModel($data);
530
            return new JsonModel($data);
538
        }
531
        }
539
        
-
 
Línea -... Línea 532...
-
 
532
 
540
 
533
 
541
        
534
 
542
        if($request->isPost()) {
535
        if ($request->isPost()) {
543
            $companyMapper = CompanyMapper::getInstance($this->adapter);
536
            $companyMapper = CompanyMapper::getInstance($this->adapter);
544
            $company = $companyMapper->fetchOne($currentCompany->id);
537
            $company = $companyMapper->fetchOne($currentCompany->id);
545
            
538
 
546
            $result = $jobMapper->delete($job);
539
            $result = $jobMapper->delete($job);
547
            if($result) {
540
            if ($result) {
548
                $this->logger->info('Se borro el empleo : ' . $job->title . ' de la empresa : ' .  $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
541
                $this->logger->info('Se borro el empleo : ' . $job->title . ' de la empresa : ' .  $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
549
                
542
 
550
                $data = [
543
                $data = [
551
                    'success' => true,
544
                    'success' => true,
552
                    'data' => 'LABEL_RECORD_DELETED'
545
                    'data' => 'LABEL_RECORD_DELETED'
553
                ];
546
                ];
554
            } else {
547
            } else {
555
                
548
 
556
                $data = [
549
                $data = [
557
                    'success'   => false,
550
                    'success'   => false,
558
                    'data'      => $job->getError()
551
                    'data'      => $job->getError()
559
                ];
552
                ];
560
                
553
 
561
                return new JsonModel($data);
554
                return new JsonModel($data);
562
            }
-
 
563
            
555
            }
564
        } else {
556
        } else {
565
            $data = [
557
            $data = [
566
                'success' => false,
558
                'success' => false,
567
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
559
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
568
            ];
560
            ];
569
            
561
 
570
            return new JsonModel($data);
562
            return new JsonModel($data);
571
        }
563
        }
572
        
564
 
573
        return new JsonModel($data);
565
        return new JsonModel($data);
574
    }
566
    }
575
    
567
 
576
    /**
568
    /**
577
     * Presenta el perfil con las opciónes de edición de cada sección
569
     * Presenta el perfil con las opciónes de edición de cada sección
578
     * @return \Laminas\Http\Response|\Laminas\View\Model\ViewModel|\Laminas\View\Model\JsonModel
570
     * @return \Laminas\Http\Response|\Laminas\View\Model\ViewModel|\Laminas\View\Model\JsonModel
579
     */
571
     */
580
    public function editAction()
572
    public function editAction()
581
    {
573
    {
582
        $currentUserPlugin = $this->plugin('currentUserPlugin');
574
        $currentUserPlugin = $this->plugin('currentUserPlugin');
583
        $currentUser = $currentUserPlugin->getUser();
575
        $currentUser = $currentUserPlugin->getUser();
584
        $currentCompany = $currentUserPlugin->getCompany();
576
        $currentCompany = $currentUserPlugin->getCompany();
585
        
577
 
586
        
578
 
587
        $request = $this->getRequest();
579
        $request = $this->getRequest();
588
        $id = $this->params()->fromRoute('id');
580
        $id = $this->params()->fromRoute('id');
589
        
581
 
590
        if(!$id) {
582
        if (!$id) {
591
            $data = [
583
            $data = [
592
                'success'   => false,
584
                'success'   => false,
593
                'data'   => 'ERROR_INVALID_PARAMETER'
585
                'data'   => 'ERROR_INVALID_PARAMETER'
594
            ];
586
            ];
595
            
587
 
596
            return new JsonModel($data);
588
            return new JsonModel($data);
597
        }
589
        }
598
        
590
 
599
        $jobMapper = JobMapper::getInstance($this->adapter);
591
        $jobMapper = JobMapper::getInstance($this->adapter);
600
        $job = $jobMapper->fetchOneByUuid($id);
592
        $job = $jobMapper->fetchOneByUuid($id);
601
        if(!$job) {
593
        if (!$job) {
602
            $data = [
594
            $data = [
603
                'success'   => false,
595
                'success'   => false,
604
                'data'   => 'ERROR_JOB_NOT_FOUND'
596
                'data'   => 'ERROR_JOB_NOT_FOUND'
605
            ];
597
            ];
606
            
598
 
607
            return new JsonModel($data);
599
            return new JsonModel($data);
608
        }
600
        }
609
        
601
 
610
        if($job->company_id != $currentCompany->id) {
602
        if ($job->company_id != $currentCompany->id) {
611
            $data = [
603
            $data = [
612
                'success'   => false,
604
                'success'   => false,
613
                'data'   => 'ERROR_UNAUTHORIZED'
605
                'data'   => 'ERROR_UNAUTHORIZED'
614
            ];
606
            ];
615
            
607
 
616
            return new JsonModel($data);
608
            return new JsonModel($data);
617
        }
-
 
Línea -... Línea 609...
-
 
609
        }
618
        
610
 
619
 
611
 
620
        if($request->isGet()) {
612
        if ($request->isGet()) {
621
            $months = [
613
            $months = [
622
                1 => 'LABEL_MONTH_JANUARY',
614
                1 => 'LABEL_MONTH_JANUARY',
623
                2 => 'LABEL_MONTH_FEBRUARY',
615
                2 => 'LABEL_MONTH_FEBRUARY',
Línea 630... Línea 622...
630
                9 => 'LABEL_MONTH_SEPTEMBER',
622
                9 => 'LABEL_MONTH_SEPTEMBER',
631
                10 => 'LABEL_MONTH_OCTOBER',
623
                10 => 'LABEL_MONTH_OCTOBER',
632
                11 => 'LABEL_MONTH_NOVEMBER',
624
                11 => 'LABEL_MONTH_NOVEMBER',
633
                12 => 'LABEL_MONTH_DECEMBER',
625
                12 => 'LABEL_MONTH_DECEMBER',
634
            ];
626
            ];
635
            
627
 
636
            $dt = \DateTime::createFromFormat('Y-m-d', $job->last_date_of_application);
628
            $dt = \DateTime::createFromFormat('Y-m-d', $job->last_date_of_application);
637
            $last_date_of_application = $dt->format('d') . ' de ' . $months[$dt->format('n')] . ' de ' . $dt->format('Y');
629
            $last_date_of_application = $dt->format('d') . ' de ' . $months[$dt->format('n')] . ' de ' . $dt->format('Y');
638
            
630
 
639
            
631
 
640
            
632
 
641
            $locationMapper = LocationMapper::getInstance($this->adapter);
633
            $locationMapper = LocationMapper::getInstance($this->adapter);
642
            $location = $locationMapper->fetchOne($job->location_id);
634
            $location = $locationMapper->fetchOne($job->location_id);
643
            
635
 
644
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
636
            $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
645
            $jobCategory = $jobCategoryMapper->fetchOne($job->job_category_id);
637
            $jobCategory = $jobCategoryMapper->fetchOne($job->job_category_id);
646
            
638
 
647
            switch($job->employment_type)
639
            switch ($job->employment_type) {
648
            {
-
 
649
                case Job::EMPLOYMENT_TYPE_FULL_TIME :
640
                case Job::EMPLOYMENT_TYPE_FULL_TIME:
650
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
641
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
651
                    break;
642
                    break;
652
                case Job::EMPLOYMENT_TYPE_PART_TIME :
643
                case Job::EMPLOYMENT_TYPE_PART_TIME:
653
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
644
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
654
                    break;
645
                    break;
655
                    
646
 
656
                case Job::EMPLOYMENT_TYPE_CONTRACT :
647
                case Job::EMPLOYMENT_TYPE_CONTRACT:
657
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
648
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
658
                    break;
649
                    break;
659
                    
650
 
660
                case Job::EMPLOYMENT_TYPE_TEMPORARY :
651
                case Job::EMPLOYMENT_TYPE_TEMPORARY:
661
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
652
                    $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
662
                    break;
653
                    break;
663
                    
654
 
664
                default :
655
                default:
665
                    $employment_type = '';
656
                    $employment_type = '';
666
                    break;
657
                    break;
667
            }
658
            }
Línea 668... Línea 659...
668
 
659
 
669
            switch($job->status)
-
 
670
            {
660
            switch ($job->status) {
671
                case Job::STATUS_ACTIVE : 
661
                case Job::STATUS_ACTIVE:
672
                    $status = 'LABEL_ACTIVE';
662
                    $status = 'LABEL_ACTIVE';
673
                    break;
663
                    break;
674
                    
664
 
675
                case Job::STATUS_INACTIVE : 
665
                case Job::STATUS_INACTIVE:
676
                    $status = 'LABEL_INACTIVE';
666
                    $status = 'LABEL_INACTIVE';
677
                    break;
667
                    break;
678
                    
668
 
679
                default :
669
                default:
680
                    $status = '';
670
                    $status = '';
681
                    break;
671
                    break;
682
            }
672
            }
683
            
673
 
684
           
674
 
685
            $degreeMapper = DegreeMapper::getInstance($this->adapter);
675
            $degreeMapper = DegreeMapper::getInstance($this->adapter);
686
            
676
 
687
            $jobDegreeMapper = JobDegreeMapper::getInstance($this->adapter);
677
            $jobDegreeMapper = JobDegreeMapper::getInstance($this->adapter);
688
            $records = $jobDegreeMapper->fetchAllByJobId($job->id);
678
            $records = $jobDegreeMapper->fetchAllByJobId($job->id);
689
            
679
 
690
            $job_degrees = [];
680
            $job_degrees = [];
691
            foreach($records as $record) 
-
 
692
            {
681
            foreach ($records as $record) {
693
                $degree = $degreeMapper->fetchOne($record->degree_id);
682
                $degree = $degreeMapper->fetchOne($record->degree_id);
694
                array_push($job_degrees, $degree->name);
683
                array_push($job_degrees, $degree->name);
695
            }
684
            }
Línea 696... Línea 685...
696
                
685
 
697
 
686
 
698
            $languageMapper = LanguageMapper::getInstance($this->adapter);
687
            $languageMapper = LanguageMapper::getInstance($this->adapter);
699
            $jobLanguageMapper = JobLanguageMapper::getInstance($this->adapter);
688
            $jobLanguageMapper = JobLanguageMapper::getInstance($this->adapter);
700
            $records = $jobLanguageMapper->fetchAllByJobId($job->id);
689
            $records = $jobLanguageMapper->fetchAllByJobId($job->id);
701
            
690
 
702
            $job_languages = [];
-
 
703
            foreach($records as $record) 
691
            $job_languages = [];
704
            {
692
            foreach ($records as $record) {
705
                $language = $languageMapper->fetchOne($record->language_id);
693
                $language = $languageMapper->fetchOne($record->language_id);
706
                array_push($job_languages, $language->name);
694
                array_push($job_languages, $language->name);
707
            }
695
            }
708
            
696
 
709
            $skillMapper = SkillMapper::getInstance($this->adapter);
697
            $skillMapper = SkillMapper::getInstance($this->adapter);
710
            
698
 
711
            $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
699
            $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
712
            $records = $jobSkillMapper->fetchAllByJobId($job->id);
700
            $records = $jobSkillMapper->fetchAllByJobId($job->id);
713
            
701
 
714
            $job_skills = [];
-
 
715
            foreach($records as $record) 
702
            $job_skills = [];
716
            {
703
            foreach ($records as $record) {
717
                $skill = $skillMapper->fetchOne($record->skill_id);
704
                $skill = $skillMapper->fetchOne($record->skill_id);
718
                array_push($job_skills, $skill->name);
705
                array_push($job_skills, $skill->name);
Línea 719... Línea 706...
719
            }
706
            }
720
            
707
 
721
 
708
 
722
 
709
 
723
            return new JsonModel([
710
            return new JsonModel([
724
                'success' => true, 
711
                'success' => true,
725
                'data' => [
712
                'data' => [
Línea 733... Línea 720...
733
                    'experience'                => $job->experience_visible ? $job->experience_min . '-' . $job->experience_max : '',
720
                    'experience'                => $job->experience_visible ? $job->experience_min . '-' . $job->experience_max : '',
734
                    'salary'                    => $job->salary_visible ==  Job::SALARY_VISIBLE_YES ? $job->salary_min . '-' . $job->salary_max . ' ' . $job->salary_currency : '',
721
                    'salary'                    => $job->salary_visible ==  Job::SALARY_VISIBLE_YES ? $job->salary_min . '-' . $job->salary_max . ' ' . $job->salary_currency : '',
735
                    'degrees'                   => $job_degrees,
722
                    'degrees'                   => $job_degrees,
736
                    'languages'                 => $job_languages,
723
                    'languages'                 => $job_languages,
737
                    'skills'                    => $job_skills,
724
                    'skills'                    => $job_skills,
738
                    
725
 
739
                    'route_status'              => $this->url()->fromRoute('jobs/edit/status', [ 'id' => $job->uuid ]),
726
                    'route_status'              => $this->url()->fromRoute('jobs/edit/status', ['id' => $job->uuid]),
740
                    'route_title'               => $this->url()->fromRoute('jobs/edit/title', [ 'id' => $job->uuid ]),
727
                    'route_title'               => $this->url()->fromRoute('jobs/edit/title', ['id' => $job->uuid]),
741
                    'route_extended'            => $this->url()->fromRoute('jobs/edit/extended', [ 'id' => $job->uuid ]),
728
                    'route_extended'            => $this->url()->fromRoute('jobs/edit/extended', ['id' => $job->uuid]),
742
                    'route_location'            => $this->url()->fromRoute('jobs/edit/location', [ 'id' => $job->uuid ]),
729
                    'route_location'            => $this->url()->fromRoute('jobs/edit/location', ['id' => $job->uuid]),
743
                    'route_job_category'        => $this->url()->fromRoute('jobs/edit/job-category', [ 'id' => $job->uuid ]),
730
                    'route_job_category'        => $this->url()->fromRoute('jobs/edit/job-category', ['id' => $job->uuid]),
744
                    'route_employment_type'     => $this->url()->fromRoute('jobs/edit/employment-type', [ 'id' => $job->uuid ]),
731
                    'route_employment_type'     => $this->url()->fromRoute('jobs/edit/employment-type', ['id' => $job->uuid]),
745
                    'route_salary'              => $this->url()->fromRoute('jobs/edit/salary', [ 'id' => $job->uuid ]),
732
                    'route_salary'              => $this->url()->fromRoute('jobs/edit/salary', ['id' => $job->uuid]),
746
                    'route_experience'          => $this->url()->fromRoute('jobs/edit/experience', [ 'id' => $job->uuid ]),
733
                    'route_experience'          => $this->url()->fromRoute('jobs/edit/experience', ['id' => $job->uuid]),
747
                    'route_languages'           => $this->url()->fromRoute('jobs/edit/languages', [ 'id' => $job->uuid ]),
734
                    'route_languages'           => $this->url()->fromRoute('jobs/edit/languages', ['id' => $job->uuid]),
748
                    'route_degrees'             => $this->url()->fromRoute('jobs/edit/degrees', [ 'id' => $job->uuid ]),
735
                    'route_degrees'             => $this->url()->fromRoute('jobs/edit/degrees', ['id' => $job->uuid]),
749
                    'route_skills'              => $this->url()->fromRoute('jobs/edit/skills', [ 'id' => $job->uuid ]),
736
                    'route_skills'              => $this->url()->fromRoute('jobs/edit/skills', ['id' => $job->uuid]),
750
                    'route_last_date_of_application'    => $this->url()->fromRoute('jobs/edit/last-date-of-application', [ 'id' => $job->uuid ]),
737
                    'route_last_date_of_application'    => $this->url()->fromRoute('jobs/edit/last-date-of-application', ['id' => $job->uuid]),
751
                ]
738
                ]
752
            ]);
739
            ]);
753
            
-
 
754
        } else {
740
        } else {
755
            $data = [
741
            $data = [
756
                'success' => false,
742
                'success' => false,
757
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
743
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
758
            ];
744
            ];
759
            
745
 
760
            return new JsonModel($data);
746
            return new JsonModel($data);
761
        }
747
        }
762
        
748
 
763
        return new JsonModel($data);
749
        return new JsonModel($data);
764
    }
750
    }
765
    
751
 
766
    
752
 
767
    
753
 
768
    /**
754
    /**
769
     * Actualización de la descripción y cualquier otro campo extendido del perfil a futuro
755
     * Actualización de la descripción y cualquier otro campo extendido del perfil a futuro
770
     * @return \Laminas\View\Model\JsonModel
756
     * @return \Laminas\View\Model\JsonModel
771
     */
757
     */
772
    public function extendedAction()
758
    public function extendedAction()
773
    {
759
    {
774
        $currentUserPlugin = $this->plugin('currentUserPlugin');
760
        $currentUserPlugin = $this->plugin('currentUserPlugin');
775
        $currentUser = $currentUserPlugin->getUser();
761
        $currentUser = $currentUserPlugin->getUser();
776
        $currentCompany = $currentUserPlugin->getCompany();
762
        $currentCompany = $currentUserPlugin->getCompany();
777
        
763
 
778
        
764
 
779
        $request = $this->getRequest();
765
        $request = $this->getRequest();
780
        $id = $this->params()->fromRoute('id');
766
        $id = $this->params()->fromRoute('id');
Línea 781... Línea 767...
781
 
767
 
782
        
768
 
783
        if(!$id) {
769
        if (!$id) {
784
            $response = [
770
            $response = [
785
                'success' => false,
771
                'success' => false,
786
                'data' => 'ERROR_INVALID_PARAMETER'
772
                'data' => 'ERROR_INVALID_PARAMETER'
787
            ];
773
            ];
788
            
774
 
789
            return new JsonModel($response);
-
 
790
            
775
            return new JsonModel($response);
791
        }
776
        }
792
        
777
 
793
        $jobMapper = JobMapper::getInstance($this->adapter);
778
        $jobMapper = JobMapper::getInstance($this->adapter);
794
        $job = $jobMapper->fetchOneByUuid($id);
779
        $job = $jobMapper->fetchOneByUuid($id);
795
        
780
 
796
        if(!$job) {
781
        if (!$job) {
797
            $response = [
782
            $response = [
798
                'success' => false,
783
                'success' => false,
799
                'data' => 'ERROR_JOB_NOT_FOUND'
784
                'data' => 'ERROR_JOB_NOT_FOUND'
800
            ];
785
            ];
801
            
786
 
802
            return new JsonModel($response);
787
            return new JsonModel($response);
803
        }
788
        }
804
        
789
 
805
        if($job->company_id != $currentCompany->id) {
790
        if ($job->company_id != $currentCompany->id) {
806
            $response = [
791
            $response = [
807
                'success' => false,
792
                'success' => false,
808
                'data' => 'ERROR_UNAUTHORIZED'
793
                'data' => 'ERROR_UNAUTHORIZED'
809
            ];
794
            ];
810
            
795
 
811
            return new JsonModel($response);
796
            return new JsonModel($response);
812
        }
797
        }
813
        
798
 
814
        
799
 
815
        $companyMapper = CompanyMapper::getInstance($this->adapter);
800
        $companyMapper = CompanyMapper::getInstance($this->adapter);
816
        $company = $companyMapper->fetchOne($currentCompany->id);
801
        $company = $companyMapper->fetchOne($currentCompany->id);
817
        if(!$company) {
802
        if (!$company) {
818
            $response = [
803
            $response = [
819
                'success' => false,
804
                'success' => false,
820
                'data' => 'ERROR_COMPANY_NOT_FOUND'
805
                'data' => 'ERROR_COMPANY_NOT_FOUND'
821
            ];
806
            ];
822
            
807
 
823
            return new JsonModel($response);
808
            return new JsonModel($response);
Línea 824... Línea 809...
824
        }
809
        }
825
 
810
 
826
 
811
 
827
        
812
 
828
        
813
 
829
        $request = $this->getRequest();
814
        $request = $this->getRequest();
830
        if($request->isGet()) {
815
        if ($request->isGet()) {
831
            $data = [
816
            $data = [
832
                'success' => true,
817
                'success' => true,
833
                'data' => [
818
                'data' => [
834
                    'description' => strip_tags($job->description, 'p'),
819
                    'description' => strip_tags($job->description, 'p'),
835
                ]
820
                ]
836
            ];
-
 
837
            
-
 
838
            return new JsonModel($data);
821
            ];
839
            
822
 
840
            
823
            return new JsonModel($data);
841
        } else if($request->isPost()) {
824
        } else if ($request->isPost()) {
842
            
825
 
843
            
826
 
844
            $form = new CompanyJobExtendedForm();
827
            $form = new CompanyJobExtendedForm();
845
            $dataPost = $request->getPost()->toArray();
828
            $dataPost = $request->getPost()->toArray();
846
            
829
 
847
            $form->setData($dataPost);
830
            $form->setData($dataPost);
848
            
831
 
849
            if($form->isValid()) {
832
            if ($form->isValid()) {
850
                $dataPost = (array) $form->getData();
833
                $dataPost = (array) $form->getData();
851
                
834
 
852
                $hydrator = new ObjectPropertyHydrator();
835
                $hydrator = new ObjectPropertyHydrator();
853
                $hydrator->hydrate($dataPost, $job);
836
                $hydrator->hydrate($dataPost, $job);
854
                
837
 
855
                $jobMapper->updateExtended($job);
838
                $jobMapper->updateExtended($job);
856
            
839
 
857
                $this->logger->info('Se actualizo las descripción del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
840
                $this->logger->info('Se actualizo las descripción del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
858
                
841
 
859
                return new JsonModel([
842
                return new JsonModel([
860
                    'success'   => true,
843
                    'success'   => true,
861
                    'data' => [
844
                    'data' => [
862
                        'description' => strip_tags($job->description, 'p'),
-
 
863
                    ]
845
                        'description' => strip_tags($job->description, 'p'),
864
                ]);
846
                    ]
865
                
847
                ]);
866
            } else {
848
            } else {
867
                $messages = [];
-
 
868
                $form_messages = (array) $form->getMessages();
849
                $messages = [];
869
                foreach($form_messages  as $fieldname => $field_messages)
850
                $form_messages = (array) $form->getMessages();
870
                {
851
                foreach ($form_messages  as $fieldname => $field_messages) {
871
                    $messages[$fieldname] = array_values($field_messages);
852
                    $messages[$fieldname] = array_values($field_messages);
872
                }
853
                }
873
                
854
 
874
                return new JsonModel([
855
                return new JsonModel([
875
                    'success'   => false,
856
                    'success'   => false,
876
                    'data'   => $messages
857
                    'data'   => $messages
877
                ]);
858
                ]);
878
            }
859
            }
879
        }
860
        }
880
        
861
 
881
        
862
 
882
        $data = [
863
        $data = [
883
            'success' => false,
864
            'success' => false,
884
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
865
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
885
        ];
866
        ];
886
        
867
 
887
        
868
 
888
        return new JsonModel($data);
869
        return new JsonModel($data);
889
    }
870
    }
890
    
871
 
891
    
872
 
892
    public function locationAction()
873
    public function locationAction()
893
    {
874
    {
894
        
875
 
895
        $currentUserPlugin = $this->plugin('currentUserPlugin');
876
        $currentUserPlugin = $this->plugin('currentUserPlugin');
896
        $currentUser = $currentUserPlugin->getUser();
877
        $currentUser = $currentUserPlugin->getUser();
897
        $currentCompany = $currentUserPlugin->getCompany();
878
        $currentCompany = $currentUserPlugin->getCompany();
898
        
879
 
899
        
880
 
900
        $request = $this->getRequest();
881
        $request = $this->getRequest();
901
        $id = $this->params()->fromRoute('id');
882
        $id = $this->params()->fromRoute('id');
902
        
883
 
903
        
884
 
904
        if(!$id) {
885
        if (!$id) {
905
            $response = [
886
            $response = [
906
                'success' => false,
887
                'success' => false,
907
                'data' => 'ERROR_INVALID_PARAMETER'
888
                'data' => 'ERROR_INVALID_PARAMETER'
908
            ];
-
 
909
            
889
            ];
910
            return new JsonModel($response);
890
 
911
            
891
            return new JsonModel($response);
912
        }
892
        }
913
        
893
 
914
        $jobMapper = JobMapper::getInstance($this->adapter);
894
        $jobMapper = JobMapper::getInstance($this->adapter);
915
        $job = $jobMapper->fetchOneByUuid($id);
895
        $job = $jobMapper->fetchOneByUuid($id);
916
        
896
 
917
        if(!$job) {
897
        if (!$job) {
918
            $response = [
898
            $response = [
919
                'success' => false,
899
                'success' => false,
920
                'data' => 'ERROR_JOB_NOT_FOUND'
900
                'data' => 'ERROR_JOB_NOT_FOUND'
921
            ];
901
            ];
922
            
902
 
923
            return new JsonModel($response);
903
            return new JsonModel($response);
924
        }
904
        }
925
        
905
 
926
        if($job->company_id != $currentCompany->id) {
906
        if ($job->company_id != $currentCompany->id) {
927
            $response = [
907
            $response = [
928
                'success' => false,
908
                'success' => false,
929
                'data' => 'ERROR_UNAUTHORIZED'
909
                'data' => 'ERROR_UNAUTHORIZED'
930
            ];
910
            ];
931
            
911
 
932
            return new JsonModel($response);
912
            return new JsonModel($response);
933
        }
913
        }
934
        
914
 
935
        
915
 
936
        $companyMapper = CompanyMapper::getInstance($this->adapter);
916
        $companyMapper = CompanyMapper::getInstance($this->adapter);
937
        $company = $companyMapper->fetchOne($currentCompany->id);
917
        $company = $companyMapper->fetchOne($currentCompany->id);
938
        if(!$company) {
918
        if (!$company) {
939
            $response = [
919
            $response = [
940
                'success' => false,
920
                'success' => false,
941
                'data' => 'ERROR_COMPANY_NOT_FOUND'
921
                'data' => 'ERROR_COMPANY_NOT_FOUND'
942
            ];
922
            ];
943
            
923
 
944
            return new JsonModel($response);
924
            return new JsonModel($response);
945
        }
925
        }
946
        
926
 
947
        
927
 
948
        $request = $this->getRequest();
928
        $request = $this->getRequest();
949
        if($request->isPost()) {
929
        if ($request->isPost()) {
950
            $form = new CompanyJobLocationForm();
930
            $form = new CompanyJobLocationForm();
951
            $dataPost = $request->getPost()->toArray();
931
            $dataPost = $request->getPost()->toArray();
952
                
932
 
953
            $form->setData($dataPost);
933
            $form->setData($dataPost);
954
            if($form->isValid()) {
934
            if ($form->isValid()) {
955
                $dataPost = (array) $form->getData();
935
                $dataPost = (array) $form->getData();
956
                
936
 
957
                $locationMapper = LocationMapper::getInstance($this->adapter);
937
                $locationMapper = LocationMapper::getInstance($this->adapter);
958
                $location = $locationMapper->fetchOne($job->location_id);
938
                $location = $locationMapper->fetchOne($job->location_id);
959
                
939
 
960
                $hydrator = new ObjectPropertyHydrator();
940
                $hydrator = new ObjectPropertyHydrator();
961
                $hydrator->hydrate($dataPost, $location);
941
                $hydrator->hydrate($dataPost, $location);
962
   
942
 
963
                if($locationMapper->update($location)) {
943
                if ($locationMapper->update($location)) {
964
                     $this->logger->info('Se actualizo una ubicación del empleo: '. $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
944
                    $this->logger->info('Se actualizo una ubicación del empleo: ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
965
                        
945
 
966
                     $response = [
946
                    $response = [
967
                         'success' => true,
947
                        'success' => true,
968
                         'data' =>  $location->formatted_address
948
                        'data' =>  $location->formatted_address
969
                     ];
949
                    ];
970
                } else {
950
                } else {
971
                    $response = [
951
                    $response = [
Línea 977... Línea 957...
977
                $response = [
957
                $response = [
978
                    'success'   => false,
958
                    'success'   => false,
979
                    'data'   =>   'ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY'
959
                    'data'   =>   'ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY'
980
                ];
960
                ];
981
            }
961
            }
982
            
962
 
983
            return new JsonModel($response);
963
            return new JsonModel($response);
984
            
-
 
985
        }
964
        }
986
        
965
 
987
        $response = [
966
        $response = [
988
            'success' => false,
967
            'success' => false,
989
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
968
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
990
        ];
969
        ];
991
        
970
 
992
        
971
 
993
        return new JsonModel($response);
972
        return new JsonModel($response);
994
    }
973
    }
995
    
974
 
996
    public function employmentTypeAction()
975
    public function employmentTypeAction()
997
    {
976
    {
998
        
977
 
999
        $currentUserPlugin = $this->plugin('currentUserPlugin');
978
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1000
        $currentUser = $currentUserPlugin->getUser();
979
        $currentUser = $currentUserPlugin->getUser();
1001
        $currentCompany = $currentUserPlugin->getCompany();
980
        $currentCompany = $currentUserPlugin->getCompany();
1002
        
981
 
1003
        
982
 
1004
        $request = $this->getRequest();
983
        $request = $this->getRequest();
1005
        $id = $this->params()->fromRoute('id');
984
        $id = $this->params()->fromRoute('id');
1006
        
985
 
1007
        
986
 
1008
        if(!$id) {
987
        if (!$id) {
1009
            $response = [
988
            $response = [
1010
                'success' => false,
989
                'success' => false,
1011
                'data' => 'ERROR_INVALID_PARAMETER'
990
                'data' => 'ERROR_INVALID_PARAMETER'
1012
            ];
991
            ];
1013
            
992
 
1014
            return new JsonModel($response);
993
            return new JsonModel($response);
1015
            
-
 
1016
        }
994
        }
1017
        
995
 
1018
        $jobMapper = JobMapper::getInstance($this->adapter);
996
        $jobMapper = JobMapper::getInstance($this->adapter);
1019
        $job = $jobMapper->fetchOneByUuid($id);
997
        $job = $jobMapper->fetchOneByUuid($id);
1020
        
998
 
1021
        if(!$job) {
999
        if (!$job) {
1022
            $response = [
1000
            $response = [
1023
                'success' => false,
1001
                'success' => false,
1024
                'data' => 'ERROR_JOB_NOT_FOUND'
1002
                'data' => 'ERROR_JOB_NOT_FOUND'
1025
            ];
1003
            ];
1026
            
1004
 
1027
            return new JsonModel($response);
1005
            return new JsonModel($response);
1028
        }
1006
        }
1029
        
1007
 
1030
        if($job->company_id != $currentCompany->id) {
1008
        if ($job->company_id != $currentCompany->id) {
1031
            $response = [
1009
            $response = [
1032
                'success' => false,
1010
                'success' => false,
1033
                'data' => 'ERROR_UNAUTHORIZED'
1011
                'data' => 'ERROR_UNAUTHORIZED'
1034
            ];
1012
            ];
1035
            
1013
 
1036
            return new JsonModel($response);
1014
            return new JsonModel($response);
1037
        }
1015
        }
1038
        
1016
 
1039
        
1017
 
1040
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1018
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1041
        $company = $companyMapper->fetchOne($currentCompany->id);
1019
        $company = $companyMapper->fetchOne($currentCompany->id);
1042
        if(!$company) {
1020
        if (!$company) {
1043
            $response = [
1021
            $response = [
1044
                'success' => false,
1022
                'success' => false,
1045
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1023
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1046
            ];
1024
            ];
1047
            
1025
 
1048
            return new JsonModel($response);
1026
            return new JsonModel($response);
1049
        }
1027
        }
1050
        
1028
 
1051
        $employment_types = [];
1029
        $employment_types = [];
1052
        $employment_types[Job::EMPLOYMENT_TYPE_FULL_TIME] = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
1030
        $employment_types[Job::EMPLOYMENT_TYPE_FULL_TIME] = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
1053
        $employment_types[Job::EMPLOYMENT_TYPE_PART_TIME] = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
1031
        $employment_types[Job::EMPLOYMENT_TYPE_PART_TIME] = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
1054
        $employment_types[Job::EMPLOYMENT_TYPE_CONTRACT] = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
1032
        $employment_types[Job::EMPLOYMENT_TYPE_CONTRACT] = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
1055
        $employment_types[Job::EMPLOYMENT_TYPE_TEMPORARY] = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
1033
        $employment_types[Job::EMPLOYMENT_TYPE_TEMPORARY] = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
Línea 1056... Línea 1034...
1056
 
1034
 
1057
        
1035
 
1058
        $request = $this->getRequest();
1036
        $request = $this->getRequest();
1059
        if($request->isGet()) {
1037
        if ($request->isGet()) {
1060
            $data = [
1038
            $data = [
1061
                'success' => true,
1039
                'success' => true,
1062
                'data' => [
1040
                'data' => [
1063
                    'employment_type' => $job->employment_type,
1041
                    'employment_type' => $job->employment_type,
1064
                    'employment_types' => $employment_types
1042
                    'employment_types' => $employment_types
1065
                ]    
1043
                ]
1066
            ];
1044
            ];
1067
            
1045
 
1068
            return new JsonModel($data);
-
 
1069
            
-
 
1070
            
1046
            return new JsonModel($data);
1071
        } else if($request->isPost()) {
1047
        } else if ($request->isPost()) {
1072
            
1048
 
1073
            $form = new CompanyJobEmploymentTypeForm();
1049
            $form = new CompanyJobEmploymentTypeForm();
1074
            $dataPost = $request->getPost()->toArray();
1050
            $dataPost = $request->getPost()->toArray();
1075
            
1051
 
1076
            $form->setData($dataPost);
1052
            $form->setData($dataPost);
1077
            
1053
 
1078
            if($form->isValid()) {
1054
            if ($form->isValid()) {
1079
                
1055
 
1080
                $dataPost = (array) $form->getData();
1056
                $dataPost = (array) $form->getData();
1081
                
1057
 
1082
                $hydrator = new ObjectPropertyHydrator();
1058
                $hydrator = new ObjectPropertyHydrator();
1083
                $hydrator->hydrate($dataPost, $job);
1059
                $hydrator->hydrate($dataPost, $job);
1084
                
1060
 
1085
                if($jobMapper->updateEmploymentType($job)) {
1061
                if ($jobMapper->updateEmploymentType($job)) {
1086
                    $this->logger->info('Se actualizo tipo de empleo: '. $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1062
                    $this->logger->info('Se actualizo tipo de empleo: ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1087
                    
1063
 
1088
                    switch($job->employment_type)
-
 
1089
                    {
1064
                    switch ($job->employment_type) {
1090
                        case Job::EMPLOYMENT_TYPE_FULL_TIME :
1065
                        case Job::EMPLOYMENT_TYPE_FULL_TIME:
1091
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
1066
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_FULL_TIME';
1092
                            break;
1067
                            break;
1093
                        case Job::EMPLOYMENT_TYPE_PART_TIME :
1068
                        case Job::EMPLOYMENT_TYPE_PART_TIME:
1094
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
1069
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_PART_TIME';
1095
                            break;
1070
                            break;
1096
                            
1071
 
1097
                        case Job::EMPLOYMENT_TYPE_CONTRACT :
1072
                        case Job::EMPLOYMENT_TYPE_CONTRACT:
1098
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
1073
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_CONTRACT';
1099
                            break;
1074
                            break;
1100
                            
1075
 
1101
                        case Job::EMPLOYMENT_TYPE_TEMPORARY :
1076
                        case Job::EMPLOYMENT_TYPE_TEMPORARY:
1102
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
1077
                            $employment_type = 'LABEL_EMPLOYMENT_TYPE_TEMPORARY';
1103
                            break;
1078
                            break;
1104
                            
1079
 
1105
                        default :
1080
                        default:
1106
                            $employment_type = '';
1081
                            $employment_type = '';
1107
                            break;
1082
                            break;
Línea 1108... Línea 1083...
1108
                    }
1083
                    }
1109
 
1084
 
1110
                    
1085
 
1111
                    
1086
 
1112
                    return new JsonModel([
1087
                    return new JsonModel([
1113
                        'success'   => true,
1088
                        'success'   => true,
1114
                        'data' => $employment_type
1089
                        'data' => $employment_type
1115
                    ]);
1090
                    ]);
1116
                }  else {
1091
                } else {
1117
                    return new JsonModel([
1092
                    return new JsonModel([
1118
                        'success'   => false,
1093
                        'success'   => false,
1119
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
1094
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
1120
                    ]);
-
 
1121
                }
-
 
1122
                
1095
                    ]);
1123
                
1096
                }
1124
            } else {
1097
            } else {
1125
                $messages = [];
1098
                $messages = [];
1126
                $form_messages = (array) $form->getMessages();
-
 
1127
                foreach($form_messages  as $fieldname => $field_messages)
1099
                $form_messages = (array) $form->getMessages();
1128
                {
1100
                foreach ($form_messages  as $fieldname => $field_messages) {
1129
                    $messages[$fieldname] = array_values($field_messages);
1101
                    $messages[$fieldname] = array_values($field_messages);
1130
                }
1102
                }
1131
                
1103
 
1132
                return new JsonModel([
1104
                return new JsonModel([
1133
                    'success'   => false,
1105
                    'success'   => false,
1134
                    'data'   => $messages
1106
                    'data'   => $messages
1135
                ]);
1107
                ]);
1136
            }
1108
            }
1137
        }
1109
        }
1138
        
1110
 
1139
        
1111
 
1140
        $data = [
1112
        $data = [
1141
            'success' => false,
1113
            'success' => false,
1142
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1114
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1143
        ];
1115
        ];
1144
        
1116
 
1145
        
1117
 
1146
        return new JsonModel($data);
1118
        return new JsonModel($data);
1147
    }
1119
    }
1148
    
1120
 
1149
    public function jobCategoryAction()
1121
    public function jobCategoryAction()
1150
    {
1122
    {
1151
        
1123
 
1152
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1124
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1153
        $currentUser = $currentUserPlugin->getUser();
1125
        $currentUser = $currentUserPlugin->getUser();
1154
        $currentCompany = $currentUserPlugin->getCompany();
1126
        $currentCompany = $currentUserPlugin->getCompany();
1155
        
1127
 
1156
        
1128
 
1157
        $request = $this->getRequest();
1129
        $request = $this->getRequest();
1158
        $id = $this->params()->fromRoute('id');
1130
        $id = $this->params()->fromRoute('id');
1159
        
1131
 
1160
        
1132
 
1161
        if(!$id) {
1133
        if (!$id) {
1162
            $response = [
1134
            $response = [
1163
                'success' => false,
1135
                'success' => false,
1164
                'data' => 'ERROR_INVALID_PARAMETER'
1136
                'data' => 'ERROR_INVALID_PARAMETER'
1165
            ];
1137
            ];
1166
            
-
 
1167
            return new JsonModel($response);
1138
 
1168
            
1139
            return new JsonModel($response);
1169
        }
1140
        }
1170
        
1141
 
1171
        $jobMapper = JobMapper::getInstance($this->adapter);
1142
        $jobMapper = JobMapper::getInstance($this->adapter);
1172
        $job = $jobMapper->fetchOneByUuid($id);
1143
        $job = $jobMapper->fetchOneByUuid($id);
1173
        
1144
 
1174
        if(!$job) {
1145
        if (!$job) {
1175
            $response = [
1146
            $response = [
1176
                'success' => false,
1147
                'success' => false,
1177
                'data' => 'ERROR_JOB_NOT_FOUND'
1148
                'data' => 'ERROR_JOB_NOT_FOUND'
1178
            ];
1149
            ];
1179
            
1150
 
1180
            return new JsonModel($response);
1151
            return new JsonModel($response);
1181
        }
1152
        }
1182
        
1153
 
1183
        if($job->company_id != $currentCompany->id) {
1154
        if ($job->company_id != $currentCompany->id) {
1184
            $response = [
1155
            $response = [
1185
                'success' => false,
1156
                'success' => false,
1186
                'data' => 'ERROR_UNAUTHORIZED'
1157
                'data' => 'ERROR_UNAUTHORIZED'
1187
            ];
1158
            ];
1188
            
1159
 
1189
            return new JsonModel($response);
1160
            return new JsonModel($response);
1190
        }
1161
        }
1191
        
1162
 
1192
        
1163
 
1193
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1164
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1194
        $company = $companyMapper->fetchOne($currentCompany->id);
1165
        $company = $companyMapper->fetchOne($currentCompany->id);
1195
        if(!$company) {
1166
        if (!$company) {
1196
            $response = [
1167
            $response = [
1197
                'success' => false,
1168
                'success' => false,
1198
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1169
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1199
            ];
1170
            ];
1200
            
1171
 
1201
            return new JsonModel($response);
1172
            return new JsonModel($response);
1202
        }
1173
        }
1203
        
1174
 
1204
        $jobCategories = [];
1175
        $jobCategories = [];
1205
        $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
1176
        $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
1206
        $records = $jobCategoryMapper->fetchAllActives();
1177
        $records = $jobCategoryMapper->fetchAllActives();
1207
        
-
 
1208
        foreach($records as $record)
1178
 
1209
        {
1179
        foreach ($records as $record) {
1210
            $jobCategories[$record->uuid] = $record->name;
1180
            $jobCategories[$record->uuid] = $record->name;
1211
        }
1181
        }
1212
        
1182
 
1213
        
1183
 
1214
        $jobCategory = $jobCategoryMapper->fetchOne( $job->job_category_id );
1184
        $jobCategory = $jobCategoryMapper->fetchOne($job->job_category_id);
1215
        
1185
 
1216
        
1186
 
1217
        $request = $this->getRequest();
1187
        $request = $this->getRequest();
1218
        if($request->isGet()) {
1188
        if ($request->isGet()) {
1219
            $data = [
1189
            $data = [
1220
                'success' => true,
1190
                'success' => true,
1221
                'data' => [
1191
                'data' => [
1222
                    'job_category' => $jobCategory->uuid,
1192
                    'job_category' => $jobCategory->uuid,
1223
                    'job_categories' => $jobCategories
1193
                    'job_categories' => $jobCategories
1224
                 ],
1194
                ],
1225
            ];
1195
            ];
1226
            
-
 
1227
            return new JsonModel($data);
-
 
1228
            
1196
 
1229
            
1197
            return new JsonModel($data);
1230
        } else if($request->isPost()) {
1198
        } else if ($request->isPost()) {
1231
            
1199
 
1232
            $form = new CompanyJobCategoryForm($this->adapter);
1200
            $form = new CompanyJobCategoryForm($this->adapter);
1233
            $dataPost = $request->getPost()->toArray();
1201
            $dataPost = $request->getPost()->toArray();
1234
            
1202
 
1235
            $form->setData($dataPost);
1203
            $form->setData($dataPost);
1236
            
1204
 
1237
            if($form->isValid()) {
1205
            if ($form->isValid()) {
1238
                $this->logger->info('Se actualizaron la categoría de la empresa: '. $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1206
                $this->logger->info('Se actualizaron la categoría de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1239
                
1207
 
1240
                $dataPost = (array) $form->getData();
1208
                $dataPost = (array) $form->getData();
1241
                   
1209
 
Línea 1242... Línea 1210...
1242
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
1210
                $jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
1243
                $jobCategory = $jobCategoryMapper->fetchOneByUuid( $dataPost['job_category_id'] );
1211
                $jobCategory = $jobCategoryMapper->fetchOneByUuid($dataPost['job_category_id']);
1244
 
1212
 
1245
                $job->job_category_id = $jobCategory->id;
1213
                $job->job_category_id = $jobCategory->id;
1246
                
1214
 
1247
                if($jobMapper->updateJobCategory($job)) {
1215
                if ($jobMapper->updateJobCategory($job)) {
1248
                    
1216
 
1249
                      
1217
 
1250
                    return new JsonModel([
1218
                    return new JsonModel([
1251
                        'success'   => true,
1219
                        'success'   => true,
1252
                        'data' => $jobCategory->name
1220
                        'data' => $jobCategory->name
1253
                    ]);
1221
                    ]);
1254
                }  else {
1222
                } else {
1255
                    return new JsonModel([
1223
                    return new JsonModel([
1256
                        'success'   => false,
1224
                        'success'   => false,
1257
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
-
 
1258
                    ]);
-
 
1259
                }
1225
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
1260
 
1226
                    ]);
1261
                
1227
                }
1262
            } else {
1228
            } else {
1263
                $messages = [];
-
 
1264
                $form_messages = (array) $form->getMessages();
1229
                $messages = [];
1265
                foreach($form_messages  as $fieldname => $field_messages)
1230
                $form_messages = (array) $form->getMessages();
1266
                {
1231
                foreach ($form_messages  as $fieldname => $field_messages) {
1267
                    $messages[$fieldname] = array_values($field_messages);
1232
                    $messages[$fieldname] = array_values($field_messages);
1268
                }
1233
                }
1269
                
1234
 
1270
                return new JsonModel([
1235
                return new JsonModel([
1271
                    'success'   => false,
1236
                    'success'   => false,
1272
                    'data'   => $messages
1237
                    'data'   => $messages
1273
                ]);
1238
                ]);
1274
            }
1239
            }
1275
        }
1240
        }
1276
        
1241
 
1277
        
1242
 
1278
        $data = [
1243
        $data = [
1279
            'success' => false,
1244
            'success' => false,
1280
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1245
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1281
        ];
1246
        ];
1282
        
1247
 
1283
        
1248
 
Línea 1284... Línea 1249...
1284
        return new JsonModel($data);
1249
        return new JsonModel($data);
1285
    }
1250
    }
1286
    
1251
 
1287
 
1252
 
1288
    public function salaryAction()
1253
    public function salaryAction()
1289
    {
1254
    {
1290
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1255
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1291
        $currentUser = $currentUserPlugin->getUser();
1256
        $currentUser = $currentUserPlugin->getUser();
1292
        $currentCompany = $currentUserPlugin->getCompany();
1257
        $currentCompany = $currentUserPlugin->getCompany();
1293
        
1258
 
1294
        
1259
 
1295
        $request = $this->getRequest();
1260
        $request = $this->getRequest();
1296
        $id = $this->params()->fromRoute('id');
1261
        $id = $this->params()->fromRoute('id');
1297
        
1262
 
1298
        
1263
 
1299
        if(!$id) {
1264
        if (!$id) {
1300
            $response = [
1265
            $response = [
1301
                'success' => false,
1266
                'success' => false,
1302
                'data' => 'ERROR_INVALID_PARAMETER'
-
 
1303
            ];
1267
                'data' => 'ERROR_INVALID_PARAMETER'
1304
            
1268
            ];
1305
            return new JsonModel($response);
1269
 
1306
            
1270
            return new JsonModel($response);
1307
        }
1271
        }
1308
        
1272
 
1309
        $jobMapper = JobMapper::getInstance($this->adapter);
1273
        $jobMapper = JobMapper::getInstance($this->adapter);
1310
        $job = $jobMapper->fetchOneByUuid($id);
1274
        $job = $jobMapper->fetchOneByUuid($id);
1311
        
1275
 
1312
        if(!$job) {
1276
        if (!$job) {
1313
            $response = [
1277
            $response = [
1314
                'success' => false,
1278
                'success' => false,
1315
                'data' => 'ERROR_JOB_NOT_FOUND'
1279
                'data' => 'ERROR_JOB_NOT_FOUND'
1316
            ];
1280
            ];
1317
            
1281
 
1318
            return new JsonModel($response);
1282
            return new JsonModel($response);
1319
        }
1283
        }
1320
        
1284
 
1321
        if($job->company_id != $currentCompany->id) {
1285
        if ($job->company_id != $currentCompany->id) {
1322
            $response = [
1286
            $response = [
1323
                'success' => false,
1287
                'success' => false,
1324
                'data' => 'ERROR_UNAUTHORIZED'
1288
                'data' => 'ERROR_UNAUTHORIZED'
1325
            ];
1289
            ];
1326
            
1290
 
1327
            return new JsonModel($response);
1291
            return new JsonModel($response);
1328
        }
1292
        }
1329
        
1293
 
1330
        
1294
 
1331
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1295
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1332
        $company = $companyMapper->fetchOne($currentCompany->id);
1296
        $company = $companyMapper->fetchOne($currentCompany->id);
1333
        if(!$company) {
1297
        if (!$company) {
1334
            $response = [
1298
            $response = [
1335
                'success' => false,
1299
                'success' => false,
1336
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1300
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1337
            ];
1301
            ];
1338
            
1302
 
1339
            return new JsonModel($response);
1303
            return new JsonModel($response);
1340
        }
1304
        }
1341
        
1305
 
1342
        
1306
 
1343
        
1307
 
1344
        $request = $this->getRequest();
1308
        $request = $this->getRequest();
1345
        if($request->isGet()) {
1309
        if ($request->isGet()) {
1346
            $data = [
1310
            $data = [
1347
                'success' => true,
1311
                'success' => true,
1348
                'data' => [
1312
                'data' => [
1349
                    'salary_visible' => $job->salary_visible,
1313
                    'salary_visible' => $job->salary_visible,
1350
                    'salary_currency' => $job->salary_currency,
1314
                    'salary_currency' => $job->salary_currency,
1351
                    'salary_min' => $job->salary_min,
1315
                    'salary_min' => $job->salary_min,
1352
                    'salary_max' =>  $job->salary_max
1316
                    'salary_max' =>  $job->salary_max
1353
                ]
-
 
1354
            ];
-
 
1355
            
1317
                ]
1356
            return new JsonModel($data);
1318
            ];
1357
            
1319
 
1358
            
1320
            return new JsonModel($data);
1359
        } else if($request->isPost()) {
1321
        } else if ($request->isPost()) {
Línea 1360... Línea 1322...
1360
            
1322
 
1361
            
1323
 
1362
            $form = new CompanyJobSalaryForm($this->adapter);
1324
            $form = new CompanyJobSalaryForm($this->adapter);
1363
            $dataPost = $request->getPost()->toArray();
1325
            $dataPost = $request->getPost()->toArray();
1364
 
1326
 
1365
            $dataPost['salary_visible'] = empty( $dataPost['salary_visible']) ? Job::SALARY_VISIBLE_NO :  $dataPost['salary_visible'];
1327
            $dataPost['salary_visible'] = empty($dataPost['salary_visible']) ? Job::SALARY_VISIBLE_NO :  $dataPost['salary_visible'];
1366
            $dataPost['salary_currency'] = empty( $dataPost['salary_currency']) ? 'USD' :  $dataPost['salary_currency'];
1328
            $dataPost['salary_currency'] = empty($dataPost['salary_currency']) ? 'USD' :  $dataPost['salary_currency'];
1367
            
1329
 
1368
    
1330
 
1369
            $form->setData($dataPost);
1331
            $form->setData($dataPost);
1370
            
1332
 
1371
            if($form->isValid()) {
1333
            if ($form->isValid()) {
1372
                $dataPost = (array) $form->getData();
1334
                $dataPost = (array) $form->getData();
1373
                
1335
 
1374
                $hydrator = new ObjectPropertyHydrator();
1336
                $hydrator = new ObjectPropertyHydrator();
1375
                $hydrator->hydrate($dataPost, $job);
1337
                $hydrator->hydrate($dataPost, $job);
1376
                
1338
 
1377
                $jobMapper->updateSalary($job);
1339
                $jobMapper->updateSalary($job);
1378
                
1340
 
1379
                $this->logger->info('Se actualizo el salario del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1341
                $this->logger->info('Se actualizo el salario del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1380
                
-
 
1381
                return new JsonModel([
1342
 
1382
                    'success'   => true,
1343
                return new JsonModel([
1383
                    'data' =>  $job->salary_visible == Job::SALARY_VISIBLE_YES ?  $job->salary_min . '-' . $job->salary_max . ' ' . $job->salary_currency: ''
1344
                    'success'   => true,
1384
                ]);
1345
                    'data' =>  $job->salary_visible == Job::SALARY_VISIBLE_YES ?  $job->salary_min . '-' . $job->salary_max . ' ' . $job->salary_currency : ''
1385
                
-
 
1386
            } else {
1346
                ]);
1387
                $messages = [];
1347
            } else {
1388
                $form_messages = (array) $form->getMessages();
1348
                $messages = [];
1389
                foreach($form_messages  as $fieldname => $field_messages)
1349
                $form_messages = (array) $form->getMessages();
1390
                {
1350
                foreach ($form_messages  as $fieldname => $field_messages) {
1391
                    $messages[$fieldname] = array_values($field_messages);
1351
                    $messages[$fieldname] = array_values($field_messages);
1392
                }
1352
                }
1393
                
1353
 
1394
                return new JsonModel([
1354
                return new JsonModel([
1395
                    'success'   => false,
1355
                    'success'   => false,
1396
                    'data'   => $messages
1356
                    'data'   => $messages
1397
                ]);
1357
                ]);
1398
            }
1358
            }
1399
        }
1359
        }
1400
        
1360
 
1401
        
1361
 
1402
        $data = [
1362
        $data = [
1403
            'success' => false,
1363
            'success' => false,
1404
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1364
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1405
        ];
1365
        ];
1406
        
1366
 
1407
        
1367
 
1408
        return new JsonModel($data);
1368
        return new JsonModel($data);
1409
    }
1369
    }
1410
    
1370
 
1411
    public function experienceAction()
1371
    public function experienceAction()
1412
    {
1372
    {
1413
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1373
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1414
        $currentUser = $currentUserPlugin->getUser();
1374
        $currentUser = $currentUserPlugin->getUser();
1415
        $currentCompany = $currentUserPlugin->getCompany();
1375
        $currentCompany = $currentUserPlugin->getCompany();
1416
        
1376
 
1417
        
1377
 
1418
        $request = $this->getRequest();
1378
        $request = $this->getRequest();
1419
        $id = $this->params()->fromRoute('id');
1379
        $id = $this->params()->fromRoute('id');
1420
        
1380
 
1421
        
1381
 
1422
        if(!$id) {
1382
        if (!$id) {
1423
            $response = [
1383
            $response = [
1424
                'success' => false,
-
 
1425
                'data' => 'ERROR_INVALID_PARAMETER'
1384
                'success' => false,
1426
            ];
1385
                'data' => 'ERROR_INVALID_PARAMETER'
1427
            
1386
            ];
1428
            return new JsonModel($response);
1387
 
1429
            
1388
            return new JsonModel($response);
1430
        }
1389
        }
1431
        
1390
 
1432
        $jobMapper = JobMapper::getInstance($this->adapter);
1391
        $jobMapper = JobMapper::getInstance($this->adapter);
1433
        $job = $jobMapper->fetchOneByUuid($id);
1392
        $job = $jobMapper->fetchOneByUuid($id);
1434
        
1393
 
1435
        if(!$job) {
1394
        if (!$job) {
1436
            $response = [
1395
            $response = [
1437
                'success' => false,
1396
                'success' => false,
1438
                'data' => 'ERROR_JOB_NOT_FOUND'
1397
                'data' => 'ERROR_JOB_NOT_FOUND'
1439
            ];
1398
            ];
1440
            
1399
 
1441
            return new JsonModel($response);
1400
            return new JsonModel($response);
1442
        }
1401
        }
1443
        
1402
 
1444
        if($job->company_id != $currentCompany->id) {
1403
        if ($job->company_id != $currentCompany->id) {
1445
            $response = [
1404
            $response = [
1446
                'success' => false,
1405
                'success' => false,
1447
                'data' => 'ERROR_UNAUTHORIZED'
1406
                'data' => 'ERROR_UNAUTHORIZED'
1448
            ];
1407
            ];
1449
            
1408
 
1450
            return new JsonModel($response);
1409
            return new JsonModel($response);
1451
        }
1410
        }
1452
        
1411
 
1453
        
1412
 
1454
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1413
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1455
        $company = $companyMapper->fetchOne($currentCompany->id);
1414
        $company = $companyMapper->fetchOne($currentCompany->id);
1456
        if(!$company) {
1415
        if (!$company) {
1457
            $response = [
1416
            $response = [
1458
                'success' => false,
1417
                'success' => false,
1459
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1418
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1460
            ];
1419
            ];
1461
            
1420
 
1462
            return new JsonModel($response);
1421
            return new JsonModel($response);
1463
        }
1422
        }
1464
        
1423
 
1465
        $request = $this->getRequest();
1424
        $request = $this->getRequest();
1466
        if($request->isGet()) {
1425
        if ($request->isGet()) {
1467
            $data = [
1426
            $data = [
1468
                'success' => true,
1427
                'success' => true,
1469
                'data' =>  [
1428
                'data' =>  [
1470
                    'experience_visible' => $job->experience_visible,
1429
                    'experience_visible' => $job->experience_visible,
1471
                    'experience_min' => $job->experience_min,
1430
                    'experience_min' => $job->experience_min,
1472
                    'experience_max' => $job->experience_max
-
 
1473
                ] 
-
 
1474
            ];
1431
                    'experience_max' => $job->experience_max
1475
            
1432
                ]
1476
            return new JsonModel($data);
1433
            ];
1477
            
1434
 
1478
            
1435
            return new JsonModel($data);
1479
        } else if($request->isPost()) {
1436
        } else if ($request->isPost()) {
1480
            
1437
 
1481
            
1438
 
1482
            $form = new CompanyJobExperienceForm();
1439
            $form = new CompanyJobExperienceForm();
1483
            $dataPost = $request->getPost()->toArray();
1440
            $dataPost = $request->getPost()->toArray();
1484
            
1441
 
1485
            $form->setData($dataPost);
1442
            $form->setData($dataPost);
1486
            
1443
 
1487
            if($form->isValid()) {
1444
            if ($form->isValid()) {
1488
                $dataPost = (array) $form->getData();
1445
                $dataPost = (array) $form->getData();
1489
                
1446
 
1490
                $hydrator = new ObjectPropertyHydrator();
1447
                $hydrator = new ObjectPropertyHydrator();
1491
                $hydrator->hydrate($dataPost, $job);
1448
                $hydrator->hydrate($dataPost, $job);
1492
                
1449
 
1493
                $jobMapper->updateExperience($job);
1450
                $jobMapper->updateExperience($job);
1494
                
1451
 
1495
                $this->logger->info('Se actualizo el experiencia del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1452
                $this->logger->info('Se actualizo el experiencia del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1496
                
-
 
1497
                return new JsonModel([
1453
 
1498
                    'success'   => true,
1454
                return new JsonModel([
1499
                    'data' => $job->experience_visible ? $job->experience_min . '-' . $job->experience_max . ' LABEL_YEARS' : ''
1455
                    'success'   => true,
1500
                ]);
1456
                    'data' => $job->experience_visible ? $job->experience_min . '-' . $job->experience_max . ' LABEL_YEARS' : ''
1501
                
-
 
1502
            } else {
1457
                ]);
1503
                $messages = [];
1458
            } else {
1504
                $form_messages = (array) $form->getMessages();
1459
                $messages = [];
1505
                foreach($form_messages  as $fieldname => $field_messages)
1460
                $form_messages = (array) $form->getMessages();
1506
                {
1461
                foreach ($form_messages  as $fieldname => $field_messages) {
1507
                    $messages[$fieldname] = array_values($field_messages);
1462
                    $messages[$fieldname] = array_values($field_messages);
1508
                }
1463
                }
1509
                
1464
 
1510
                return new JsonModel([
1465
                return new JsonModel([
1511
                    'success'   => false,
1466
                    'success'   => false,
1512
                    'data'   => $messages
1467
                    'data'   => $messages
1513
                ]);
1468
                ]);
1514
            }
1469
            }
1515
        }
1470
        }
1516
        
1471
 
1517
        
1472
 
1518
        $data = [
1473
        $data = [
1519
            'success' => false,
1474
            'success' => false,
1520
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1475
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1521
        ];
1476
        ];
1522
        
1477
 
1523
        
1478
 
1524
        return new JsonModel($data);
1479
        return new JsonModel($data);
1525
    }
1480
    }
1526
    
1481
 
1527
    public function skillAction()
1482
    public function skillAction()
1528
    {
1483
    {
1529
        
1484
 
1530
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1485
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1531
        $currentUser = $currentUserPlugin->getUser();
1486
        $currentUser = $currentUserPlugin->getUser();
1532
        $currentCompany = $currentUserPlugin->getCompany();
1487
        $currentCompany = $currentUserPlugin->getCompany();
1533
        
1488
 
1534
        
1489
 
1535
        $request = $this->getRequest();
1490
        $request = $this->getRequest();
1536
        $id = $this->params()->fromRoute('id');
1491
        $id = $this->params()->fromRoute('id');
1537
        
1492
 
1538
        
1493
 
1539
        if(!$id) {
1494
        if (!$id) {
1540
            $response = [
1495
            $response = [
1541
                'success' => false,
-
 
1542
                'data' => 'ERROR_INVALID_PARAMETER'
1496
                'success' => false,
1543
            ];
1497
                'data' => 'ERROR_INVALID_PARAMETER'
1544
            
1498
            ];
1545
            return new JsonModel($response);
1499
 
1546
            
1500
            return new JsonModel($response);
1547
        }
1501
        }
1548
        
1502
 
1549
        $jobMapper = JobMapper::getInstance($this->adapter);
1503
        $jobMapper = JobMapper::getInstance($this->adapter);
1550
        $job = $jobMapper->fetchOneByUuid($id);
1504
        $job = $jobMapper->fetchOneByUuid($id);
1551
        
1505
 
1552
        if(!$job) {
1506
        if (!$job) {
1553
            $response = [
1507
            $response = [
1554
                'success' => false,
1508
                'success' => false,
1555
                'data' => 'ERROR_JOB_NOT_FOUND'
1509
                'data' => 'ERROR_JOB_NOT_FOUND'
1556
            ];
1510
            ];
1557
            
1511
 
1558
            return new JsonModel($response);
1512
            return new JsonModel($response);
1559
        }
1513
        }
1560
        
1514
 
1561
        if($job->company_id != $currentCompany->id) {
1515
        if ($job->company_id != $currentCompany->id) {
1562
            $response = [
1516
            $response = [
1563
                'success' => false,
1517
                'success' => false,
1564
                'data' => 'ERROR_UNAUTHORIZED'
1518
                'data' => 'ERROR_UNAUTHORIZED'
1565
            ];
1519
            ];
1566
            
1520
 
1567
            return new JsonModel($response);
1521
            return new JsonModel($response);
1568
        }
1522
        }
1569
        
1523
 
1570
        
1524
 
1571
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1525
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1572
        $company = $companyMapper->fetchOne($currentCompany->id);
1526
        $company = $companyMapper->fetchOne($currentCompany->id);
1573
        if(!$company) {
1527
        if (!$company) {
1574
            $response = [
1528
            $response = [
1575
                'success' => false,
1529
                'success' => false,
1576
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1530
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1577
            ];
1531
            ];
1578
            
1532
 
1579
            return new JsonModel($response);
1533
            return new JsonModel($response);
1580
        }
1534
        }
1581
        
1535
 
1582
        
1536
 
1583
        
1537
 
1584
        $request = $this->getRequest();
1538
        $request = $this->getRequest();
1585
        if($request->isGet()) {
1539
        if ($request->isGet()) {
1586
            
1540
 
1587
            $skills = [];
-
 
1588
            $skillMapper = SkillMapper::getInstance($this->adapter);
1541
            $skills = [];
1589
            $records = $skillMapper->fetchAllActives();
1542
            $skillMapper = SkillMapper::getInstance($this->adapter);
1590
            
1543
            $records = $skillMapper->fetchAllActives();
1591
            foreach($records as $record)
1544
 
1592
            {
1545
            foreach ($records as $record) {
1593
                $skills[$record->uuid] = $record->name;
1546
                $skills[$record->uuid] = $record->name;
1594
            }
1547
            }
1595
            
1548
 
1596
            $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
-
 
1597
            $skillsByjob  = $jobSkillMapper->fetchAllByJobId($job->id);
1549
            $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
1598
            
1550
            $skillsByjob  = $jobSkillMapper->fetchAllByJobId($job->id);
1599
            $items = [];
1551
 
1600
            foreach($skillsByjob as $skill)
1552
            $items = [];
1601
            {
1553
            foreach ($skillsByjob as $skill) {
1602
                $skill = $skillMapper->fetchOne( $skill->skill_id );
1554
                $skill = $skillMapper->fetchOne($skill->skill_id);
1603
                
1555
 
1604
                
1556
 
1605
                array_push($items, $skill->uuid );
1557
                array_push($items, $skill->uuid);
1606
            }
1558
            }
1607
            
1559
 
1608
            $data = [
1560
            $data = [
1609
                'success' => true,
1561
                'success' => true,
1610
                'data' => [
1562
                'data' => [
1611
                    'skills_selected' => $items,
1563
                    'skills_selected' => $items,
1612
                    'skills_available' => $skills
-
 
1613
                 ]
-
 
1614
            ];
1564
                    'skills_available' => $skills
1615
            
1565
                ]
1616
            return new JsonModel($data);
1566
            ];
1617
            
1567
 
1618
            
1568
            return new JsonModel($data);
1619
        } else if($request->isPost()) {
1569
        } else if ($request->isPost()) {
1620
            
1570
 
1621
            $form = new CompanyJobSkillForm($this->adapter);
1571
            $form = new CompanyJobSkillForm($this->adapter);
1622
            $dataPost = $request->getPost()->toArray();
1572
            $dataPost = $request->getPost()->toArray();
1623
            
1573
 
1624
            $form->setData($dataPost);
1574
            $form->setData($dataPost);
1625
            
1575
 
1626
            if($form->isValid()) {
1576
            if ($form->isValid()) {
1627
                $this->logger->info('Se actualizaron las habilidades requeridas del empleo : ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1577
                $this->logger->info('Se actualizaron las habilidades requeridas del empleo : ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1628
                
1578
 
1629
                $skillMapper = SkillMapper::getInstance($this->adapter);
1579
                $skillMapper = SkillMapper::getInstance($this->adapter);
1630
                
1580
 
1631
                $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
1581
                $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
1632
                $jobSkillMapper->deleteByJobId($job->id);
-
 
1633
                
1582
                $jobSkillMapper->deleteByJobId($job->id);
1634
                $dataPost = (array) $form->getData();
1583
 
1635
                $skills = $dataPost['skills'];
1584
                $dataPost = (array) $form->getData();
1636
                foreach($skills as $skill_id)
1585
                $skills = $dataPost['skills'];
1637
                {
1586
                foreach ($skills as $skill_id) {
1638
                    $skill = $skillMapper->fetchOneByUuid( $skill_id );
1587
                    $skill = $skillMapper->fetchOneByUuid($skill_id);
1639
                    
1588
 
1640
                    $jobSkill = new JobSkill();
1589
                    $jobSkill = new JobSkill();
1641
                    $jobSkill->job_id = $job->id;
1590
                    $jobSkill->job_id = $job->id;
1642
                    $jobSkill->skill_id = $skill->id;
1591
                    $jobSkill->skill_id = $skill->id;
1643
                    
1592
 
1644
                    $jobSkillMapper->insert($jobSkill);
1593
                    $jobSkillMapper->insert($jobSkill);
1645
                }
-
 
1646
                
1594
                }
1647
                $items = [];
1595
 
1648
                $records = $jobSkillMapper->fetchAllByJobId( $job->id );
1596
                $items = [];
1649
                foreach($records as $record)
1597
                $records = $jobSkillMapper->fetchAllByJobId($job->id);
1650
                {
1598
                foreach ($records as $record) {
1651
                    $skill = $skillMapper->fetchOne($record->skill_id);
1599
                    $skill = $skillMapper->fetchOne($record->skill_id);
1652
                    
1600
 
1653
                    array_push($items,  ['value' => $skill->uuid, 'label' => $skill->name ]);
1601
                    array_push($items,  ['value' => $skill->uuid, 'label' => $skill->name]);
1654
                }
1602
                }
1655
                
-
 
1656
                return new JsonModel([
1603
 
1657
                    'success'   => true,
1604
                return new JsonModel([
1658
                    'data'   => $items
1605
                    'success'   => true,
1659
                ]);
1606
                    'data'   => $items
1660
                
-
 
1661
            } else {
1607
                ]);
1662
                $messages = [];
1608
            } else {
1663
                $form_messages = (array) $form->getMessages();
1609
                $messages = [];
1664
                foreach($form_messages  as $fieldname => $field_messages)
1610
                $form_messages = (array) $form->getMessages();
1665
                {
1611
                foreach ($form_messages  as $fieldname => $field_messages) {
1666
                    $messages[$fieldname] = array_values($field_messages);
1612
                    $messages[$fieldname] = array_values($field_messages);
1667
                }
1613
                }
1668
                
1614
 
1669
                return new JsonModel([
1615
                return new JsonModel([
1670
                    'success'   => false,
1616
                    'success'   => false,
1671
                    'data'   => $messages
-
 
1672
                ]);
1617
                    'data'   => $messages
1673
            }
1618
                ]);
1674
            
1619
            }
1675
            $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
1620
 
1676
            
1621
            $jobSkillMapper = JobSkillMapper::getInstance($this->adapter);
1677
        }
1622
        }
1678
        
1623
 
1679
        
1624
 
1680
        $data = [
1625
        $data = [
1681
            'success' => false,
1626
            'success' => false,
1682
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1627
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1683
        ];
1628
        ];
Línea 1684... Línea 1629...
1684
        
1629
 
1685
        
1630
 
1686
        return new JsonModel($data);
1631
        return new JsonModel($data);
1687
    }
1632
    }
1688
    
1633
 
1689
 
1634
 
1690
    public function languageAction()
1635
    public function languageAction()
1691
    {
1636
    {
1692
        
1637
 
1693
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1638
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1694
        $currentUser = $currentUserPlugin->getUser();
1639
        $currentUser = $currentUserPlugin->getUser();
1695
        $currentCompany = $currentUserPlugin->getCompany();
1640
        $currentCompany = $currentUserPlugin->getCompany();
1696
        
1641
 
1697
        
1642
 
1698
        $request = $this->getRequest();
1643
        $request = $this->getRequest();
1699
        $id = $this->params()->fromRoute('id');
1644
        $id = $this->params()->fromRoute('id');
1700
        
1645
 
1701
        
1646
 
1702
        if(!$id) {
1647
        if (!$id) {
1703
            $response = [
-
 
1704
                'success' => false,
1648
            $response = [
1705
                'data' => 'ERROR_INVALID_PARAMETER'
1649
                'success' => false,
1706
            ];
1650
                'data' => 'ERROR_INVALID_PARAMETER'
1707
            
1651
            ];
1708
            return new JsonModel($response);
1652
 
1709
            
1653
            return new JsonModel($response);
1710
        }
1654
        }
1711
        
1655
 
1712
        $jobMapper = JobMapper::getInstance($this->adapter);
1656
        $jobMapper = JobMapper::getInstance($this->adapter);
1713
        $job = $jobMapper->fetchOneByUuid($id);
1657
        $job = $jobMapper->fetchOneByUuid($id);
1714
        
1658
 
1715
        if(!$job) {
1659
        if (!$job) {
1716
            $response = [
1660
            $response = [
1717
                'success' => false,
1661
                'success' => false,
1718
                'data' => 'ERROR_JOB_NOT_FOUND'
1662
                'data' => 'ERROR_JOB_NOT_FOUND'
1719
            ];
1663
            ];
1720
            
1664
 
1721
            return new JsonModel($response);
1665
            return new JsonModel($response);
1722
        }
1666
        }
1723
        
1667
 
1724
        if($job->company_id != $currentCompany->id) {
1668
        if ($job->company_id != $currentCompany->id) {
1725
            $response = [
1669
            $response = [
1726
                'success' => false,
1670
                'success' => false,
1727
                'data' => 'ERROR_UNAUTHORIZED'
1671
                'data' => 'ERROR_UNAUTHORIZED'
1728
            ];
1672
            ];
1729
            
1673
 
1730
            return new JsonModel($response);
1674
            return new JsonModel($response);
1731
        }
1675
        }
1732
        
1676
 
1733
        
1677
 
1734
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1678
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1735
        $company = $companyMapper->fetchOne($currentCompany->id);
1679
        $company = $companyMapper->fetchOne($currentCompany->id);
1736
        if(!$company) {
1680
        if (!$company) {
1737
            $response = [
1681
            $response = [
1738
                'success' => false,
1682
                'success' => false,
1739
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1683
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1740
            ];
1684
            ];
1741
            
1685
 
1742
            return new JsonModel($response);
1686
            return new JsonModel($response);
1743
        }
1687
        }
1744
        
1688
 
1745
        
1689
 
1746
        
1690
 
1747
        $request = $this->getRequest();
1691
        $request = $this->getRequest();
1748
        if($request->isGet()) {
1692
        if ($request->isGet()) {
1749
            $this->logger->info('Se actualizaron los idiomas requeridos del empleo : ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1693
            $this->logger->info('Se actualizaron los idiomas requeridos del empleo : ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1750
            
-
 
1751
            $languages = [];
1694
 
1752
            $languageMapper = LanguageMapper::getInstance($this->adapter);
1695
            $languages = [];
1753
            $records = $languageMapper->fetchAllActives();
1696
            $languageMapper = LanguageMapper::getInstance($this->adapter);
1754
            
1697
            $records = $languageMapper->fetchAllActives();
1755
            foreach($records as $record)
1698
 
1756
            {
1699
            foreach ($records as $record) {
1757
                $languages[$record->id] = $record->name;
1700
                $languages[$record->id] = $record->name;
1758
            }
1701
            }
1759
            
-
 
1760
            $jobLanguageMapper = JobLanguageMapper::getInstance($this->adapter);
1702
 
1761
            $languagesSelected  = $jobLanguageMapper->fetchAllByJobId($job->id);
1703
            $jobLanguageMapper = JobLanguageMapper::getInstance($this->adapter);
1762
            
1704
            $languagesSelected  = $jobLanguageMapper->fetchAllByJobId($job->id);
1763
            $items = [];
1705
 
1764
            foreach($languagesSelected as $language)
1706
            $items = [];
1765
            {
1707
            foreach ($languagesSelected as $language) {
1766
                array_push($items, $language->language_id);
1708
                array_push($items, $language->language_id);
1767
            }
1709
            }
1768
            
1710
 
1769
            $data = [
1711
            $data = [
1770
                'success' => true,
1712
                'success' => true,
1771
                'data' => [
1713
                'data' => [
1772
                    'languages_selected' => $items,
-
 
1773
                    'languages_available' => $languages
-
 
1774
                ]    
1714
                    'languages_selected' => $items,
1775
            ];
1715
                    'languages_available' => $languages
1776
            
1716
                ]
1777
            return new JsonModel($data);
1717
            ];
1778
            
1718
 
1779
            
1719
            return new JsonModel($data);
1780
        } else if($request->isPost()) {
1720
        } else if ($request->isPost()) {
1781
            
1721
 
1782
            $form = new CompanyJobLanguageForm($this->adapter);
1722
            $form = new CompanyJobLanguageForm($this->adapter);
1783
            $dataPost = $request->getPost()->toArray();
1723
            $dataPost = $request->getPost()->toArray();
1784
            
1724
 
1785
            $form->setData($dataPost);
1725
            $form->setData($dataPost);
1786
            
1726
 
1787
            if($form->isValid()) {
1727
            if ($form->isValid()) {
1788
                $languageMapper = LanguageMapper::getInstance($this->adapter);
1728
                $languageMapper = LanguageMapper::getInstance($this->adapter);
1789
                
1729
 
1790
                $jobLanguageMapper = JobLanguageMapper::getInstance($this->adapter);
-
 
1791
                $jobLanguageMapper->deleteByJobId($job->id);
1730
                $jobLanguageMapper = JobLanguageMapper::getInstance($this->adapter);
1792
                
1731
                $jobLanguageMapper->deleteByJobId($job->id);
1793
                $dataPost = (array) $form->getData();
1732
 
1794
                $languages = $dataPost['languages'];
1733
                $dataPost = (array) $form->getData();
1795
                foreach($languages as $language_id)
1734
                $languages = $dataPost['languages'];
1796
                {
1735
                foreach ($languages as $language_id) {
1797
                    $language = $languageMapper->fetchOne($language_id);
1736
                    $language = $languageMapper->fetchOne($language_id);
1798
                    
1737
 
1799
                    $jobLanguage = new JobLanguage();
1738
                    $jobLanguage = new JobLanguage();
1800
                    $jobLanguage->job_id = $job->id;
1739
                    $jobLanguage->job_id = $job->id;
1801
                    $jobLanguage->language_id = $language->id;
1740
                    $jobLanguage->language_id = $language->id;
1802
                    
1741
 
1803
                    $jobLanguageMapper->insert($jobLanguage);
-
 
1804
                }
1742
                    $jobLanguageMapper->insert($jobLanguage);
1805
                
1743
                }
1806
                $items = [];
1744
 
1807
                $records = $jobLanguageMapper->fetchAllByJobId($job->id);
1745
                $items = [];
1808
                foreach($records as $record)
1746
                $records = $jobLanguageMapper->fetchAllByJobId($job->id);
1809
                {
1747
                foreach ($records as $record) {
1810
                    $language = $languageMapper->fetchOne($record->language_id);
1748
                    $language = $languageMapper->fetchOne($record->language_id);
1811
                    
1749
 
1812
                    array_push($items,  ['value' => $language->id, 'label' => $language->name]);
1750
                    array_push($items,  ['value' => $language->id, 'label' => $language->name]);
1813
                }
-
 
1814
                
1751
                }
1815
                return new JsonModel([
1752
 
1816
                    'success'   => true,
1753
                return new JsonModel([
1817
                    'data'   => $items
1754
                    'success'   => true,
1818
                ]);
-
 
1819
                
1755
                    'data'   => $items
1820
            } else {
1756
                ]);
1821
                $messages = [];
1757
            } else {
1822
                $form_messages = (array) $form->getMessages();
1758
                $messages = [];
1823
                foreach($form_messages  as $fieldname => $field_messages)
1759
                $form_messages = (array) $form->getMessages();
1824
                {
1760
                foreach ($form_messages  as $fieldname => $field_messages) {
1825
                    $messages[$fieldname] = array_values($field_messages);
1761
                    $messages[$fieldname] = array_values($field_messages);
1826
                }
1762
                }
1827
                
1763
 
1828
                return new JsonModel([
1764
                return new JsonModel([
1829
                    'success'   => false,
1765
                    'success'   => false,
1830
                    'data'   => $messages
1766
                    'data'   => $messages
1831
                ]);
1767
                ]);
1832
            }
1768
            }
1833
        }
1769
        }
1834
        
1770
 
1835
        
1771
 
1836
        $data = [
1772
        $data = [
1837
            'success' => false,
1773
            'success' => false,
1838
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1774
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1839
        ];
1775
        ];
1840
        
1776
 
1841
        
1777
 
1842
        return new JsonModel($data);
1778
        return new JsonModel($data);
1843
    }
1779
    }
1844
    
1780
 
1845
    public function degreeAction()
1781
    public function degreeAction()
1846
    {
1782
    {
1847
        
1783
 
1848
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1784
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1849
        $currentUser = $currentUserPlugin->getUser();
1785
        $currentUser = $currentUserPlugin->getUser();
1850
        $currentCompany = $currentUserPlugin->getCompany();
1786
        $currentCompany = $currentUserPlugin->getCompany();
1851
        
1787
 
1852
        
1788
 
1853
        $request = $this->getRequest();
1789
        $request = $this->getRequest();
1854
        $id = $this->params()->fromRoute('id');
1790
        $id = $this->params()->fromRoute('id');
1855
        
1791
 
1856
        
1792
 
1857
        if(!$id) {
1793
        if (!$id) {
1858
            $response = [
-
 
1859
                'success' => false,
1794
            $response = [
1860
                'data' => 'ERROR_INVALID_PARAMETER'
1795
                'success' => false,
1861
            ];
1796
                'data' => 'ERROR_INVALID_PARAMETER'
1862
            
1797
            ];
1863
            return new JsonModel($response);
1798
 
1864
            
1799
            return new JsonModel($response);
1865
        }
1800
        }
1866
        
1801
 
1867
        $jobMapper = JobMapper::getInstance($this->adapter);
1802
        $jobMapper = JobMapper::getInstance($this->adapter);
1868
        $job = $jobMapper->fetchOneByUuid($id);
1803
        $job = $jobMapper->fetchOneByUuid($id);
1869
        
1804
 
1870
        if(!$job) {
1805
        if (!$job) {
1871
            $response = [
1806
            $response = [
1872
                'success' => false,
1807
                'success' => false,
1873
                'data' => 'ERROR_JOB_NOT_FOUND'
1808
                'data' => 'ERROR_JOB_NOT_FOUND'
1874
            ];
1809
            ];
1875
            
1810
 
1876
            return new JsonModel($response);
1811
            return new JsonModel($response);
1877
        }
1812
        }
1878
        
1813
 
1879
        if($job->company_id != $currentCompany->id) {
1814
        if ($job->company_id != $currentCompany->id) {
1880
            $response = [
1815
            $response = [
1881
                'success' => false,
1816
                'success' => false,
1882
                'data' => 'ERROR_UNAUTHORIZED'
1817
                'data' => 'ERROR_UNAUTHORIZED'
1883
            ];
1818
            ];
1884
            
1819
 
1885
            return new JsonModel($response);
1820
            return new JsonModel($response);
1886
        }
1821
        }
1887
        
1822
 
1888
        
1823
 
1889
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1824
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1890
        $company = $companyMapper->fetchOne($currentCompany->id);
1825
        $company = $companyMapper->fetchOne($currentCompany->id);
1891
        if(!$company) {
1826
        if (!$company) {
1892
            $response = [
1827
            $response = [
1893
                'success' => false,
1828
                'success' => false,
1894
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1829
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1895
            ];
1830
            ];
1896
            
1831
 
1897
            return new JsonModel($response);
1832
            return new JsonModel($response);
1898
        }
1833
        }
1899
        
1834
 
1900
        
1835
 
1901
        
1836
 
1902
        $request = $this->getRequest();
1837
        $request = $this->getRequest();
1903
        if($request->isGet()) {
1838
        if ($request->isGet()) {
1904
            $this->logger->info('Se actualizaron los idiomas requeridos del empleo : ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1839
            $this->logger->info('Se actualizaron los idiomas requeridos del empleo : ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1905
            
1840
 
1906
            
-
 
1907
            $degrees_available = [];
1841
 
1908
            $degreeMapper = DegreeMapper::getInstance($this->adapter);
-
 
1909
            
1842
            $degrees_available = [];
1910
            $records = $degreeMapper->fetchAllActives();
1843
            $degreeMapper = DegreeMapper::getInstance($this->adapter);
1911
            foreach($records as $record)
1844
 
1912
            {
1845
            $records = $degreeMapper->fetchAllActives();
1913
                $degrees_available[$record->uuid] = $record->name;
1846
            foreach ($records as $record) {
1914
                
1847
                $degrees_available[$record->uuid] = $record->name;
1915
            }
1848
            }
1916
            
-
 
1917
            $jobDegreeMapper = JobDegreeMapper::getInstance($this->adapter);
1849
 
1918
            $records  = $jobDegreeMapper->fetchAllByJobId($job->id);
1850
            $jobDegreeMapper = JobDegreeMapper::getInstance($this->adapter);
1919
            
1851
            $records  = $jobDegreeMapper->fetchAllByJobId($job->id);
1920
            $items = [];
-
 
1921
            foreach($records as $record)
1852
 
1922
            {
1853
            $items = [];
1923
                $degree = $degreeMapper->fetchOne($record->degree_id);
1854
            foreach ($records as $record) {
1924
                
1855
                $degree = $degreeMapper->fetchOne($record->degree_id);
1925
                array_push($items, $degree->uuid);
1856
 
1926
                
1857
                array_push($items, $degree->uuid);
1927
            }
1858
            }
1928
            
1859
 
1929
            $data = [
1860
            $data = [
1930
                'success' => true,
1861
                'success' => true,
1931
                'data' => [
1862
                'data' => [
1932
                    'degrees_selected' => $items,
-
 
1933
                    'degrees_available' => $degrees_available
-
 
1934
                ]    
1863
                    'degrees_selected' => $items,
1935
            ];
1864
                    'degrees_available' => $degrees_available
1936
            
1865
                ]
1937
            return new JsonModel($data);
1866
            ];
1938
            
1867
 
1939
            
1868
            return new JsonModel($data);
1940
        } else if($request->isPost()) {
1869
        } else if ($request->isPost()) {
1941
            
1870
 
1942
            $form = new CompanyJobDegreeForm($this->adapter);
1871
            $form = new CompanyJobDegreeForm($this->adapter);
1943
            $dataPost = $request->getPost()->toArray();
1872
            $dataPost = $request->getPost()->toArray();
1944
            
1873
 
1945
            $form->setData($dataPost);
1874
            $form->setData($dataPost);
1946
            
1875
 
1947
            if($form->isValid()) {
1876
            if ($form->isValid()) {
1948
                $degreeMapper = DegreeMapper::getInstance($this->adapter);
1877
                $degreeMapper = DegreeMapper::getInstance($this->adapter);
1949
                
1878
 
1950
                $jobDegreeMapper = JobDegreeMapper::getInstance($this->adapter);
-
 
1951
                $jobDegreeMapper->deleteByJobId($job->id);
1879
                $jobDegreeMapper = JobDegreeMapper::getInstance($this->adapter);
1952
                
1880
                $jobDegreeMapper->deleteByJobId($job->id);
1953
                $dataPost = (array) $form->getData();
1881
 
1954
                $degrees = $dataPost['degrees'];
1882
                $dataPost = (array) $form->getData();
1955
                foreach($degrees as $degree_id)
1883
                $degrees = $dataPost['degrees'];
1956
                {
1884
                foreach ($degrees as $degree_id) {
1957
                    $degree = $degreeMapper->fetchOneByUuid($degree_id);
1885
                    $degree = $degreeMapper->fetchOneByUuid($degree_id);
1958
                    
1886
 
1959
                    $jobDegree = new JobDegree();
1887
                    $jobDegree = new JobDegree();
1960
                    $jobDegree->job_id = $job->id;
1888
                    $jobDegree->job_id = $job->id;
1961
                    $jobDegree->degree_id = $degree->id;
1889
                    $jobDegree->degree_id = $degree->id;
1962
                    $jobDegreeMapper->insert($jobDegree);
-
 
1963
                }
1890
                    $jobDegreeMapper->insert($jobDegree);
1964
                
1891
                }
1965
                $items = [];
1892
 
1966
                $records = $jobDegreeMapper->fetchAllByJobId($job->id);
1893
                $items = [];
1967
                foreach($records as $record)
1894
                $records = $jobDegreeMapper->fetchAllByJobId($job->id);
1968
                {
1895
                foreach ($records as $record) {
1969
                    $degree = $degreeMapper->fetchOne($record->degree_id);
1896
                    $degree = $degreeMapper->fetchOne($record->degree_id);
1970
                    array_push($items,  ['value' => $degree->uuid, 'label' => $degree->name]);
1897
                    array_push($items,  ['value' => $degree->uuid, 'label' => $degree->name]);
1971
                }
-
 
1972
                
1898
                }
1973
                return new JsonModel([
1899
 
1974
                    'success'   => true,
1900
                return new JsonModel([
1975
                    'data'   => $items
1901
                    'success'   => true,
1976
                ]);
-
 
1977
                
1902
                    'data'   => $items
1978
            } else {
1903
                ]);
1979
                $messages = [];
1904
            } else {
1980
                $form_messages = (array) $form->getMessages();
1905
                $messages = [];
1981
                foreach($form_messages  as $fieldname => $field_messages)
1906
                $form_messages = (array) $form->getMessages();
1982
                {
1907
                foreach ($form_messages  as $fieldname => $field_messages) {
1983
                    $messages[$fieldname] = array_values($field_messages);
1908
                    $messages[$fieldname] = array_values($field_messages);
1984
                }
1909
                }
1985
                
-
 
1986
                return new JsonModel([
1910
 
1987
                    'success'   => false,
1911
                return new JsonModel([
1988
                    'data'   => $messages
1912
                    'success'   => false,
1989
                ]);
1913
                    'data'   => $messages
1990
            }
1914
                ]);
1991
            
1915
            }
1992
        }
1916
        }
1993
        
1917
 
1994
        
1918
 
1995
        $data = [
1919
        $data = [
1996
            'success' => false,
1920
            'success' => false,
1997
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1921
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1998
        ];
1922
        ];
1999
        
1923
 
2000
        
1924
 
2001
        return new JsonModel($data);
1925
        return new JsonModel($data);
2002
    }
1926
    }
2003
    
1927
 
2004
    public function lastDateOfApplicationAction()
1928
    public function lastDateOfApplicationAction()
2005
    {
1929
    {
2006
        
1930
 
2007
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1931
        $currentUserPlugin = $this->plugin('currentUserPlugin');
2008
        $currentUser = $currentUserPlugin->getUser();
1932
        $currentUser = $currentUserPlugin->getUser();
2009
        $currentCompany = $currentUserPlugin->getCompany();
1933
        $currentCompany = $currentUserPlugin->getCompany();
2010
        
1934
 
2011
        
1935
 
2012
        $request = $this->getRequest();
1936
        $request = $this->getRequest();
2013
        $id = $this->params()->fromRoute('id');
1937
        $id = $this->params()->fromRoute('id');
2014
        
1938
 
2015
        
1939
 
2016
        if(!$id) {
1940
        if (!$id) {
2017
            $response = [
-
 
2018
                'success' => false,
1941
            $response = [
2019
                'data' => 'ERROR_INVALID_PARAMETER'
1942
                'success' => false,
2020
            ];
1943
                'data' => 'ERROR_INVALID_PARAMETER'
2021
            
1944
            ];
2022
            return new JsonModel($response);
1945
 
2023
            
1946
            return new JsonModel($response);
2024
        }
1947
        }
2025
        
1948
 
2026
        $jobMapper = JobMapper::getInstance($this->adapter);
1949
        $jobMapper = JobMapper::getInstance($this->adapter);
2027
        $job = $jobMapper->fetchOneByUuid($id);
1950
        $job = $jobMapper->fetchOneByUuid($id);
2028
        
1951
 
2029
        if(!$job) {
1952
        if (!$job) {
2030
            $response = [
1953
            $response = [
2031
                'success' => false,
1954
                'success' => false,
2032
                'data' => 'ERROR_JOB_NOT_FOUND'
1955
                'data' => 'ERROR_JOB_NOT_FOUND'
2033
            ];
1956
            ];
2034
            
1957
 
2035
            return new JsonModel($response);
1958
            return new JsonModel($response);
2036
        }
1959
        }
2037
        
1960
 
2038
        if($job->company_id != $currentCompany->id) {
1961
        if ($job->company_id != $currentCompany->id) {
2039
            $response = [
1962
            $response = [
2040
                'success' => false,
1963
                'success' => false,
2041
                'data' => 'ERROR_UNAUTHORIZED'
1964
                'data' => 'ERROR_UNAUTHORIZED'
2042
            ];
1965
            ];
2043
            
1966
 
2044
            return new JsonModel($response);
1967
            return new JsonModel($response);
2045
        }
1968
        }
2046
        
1969
 
2047
        
1970
 
2048
        $companyMapper = CompanyMapper::getInstance($this->adapter);
1971
        $companyMapper = CompanyMapper::getInstance($this->adapter);
2049
        $company = $companyMapper->fetchOne($currentCompany->id);
1972
        $company = $companyMapper->fetchOne($currentCompany->id);
2050
        if(!$company) {
1973
        if (!$company) {
2051
            $response = [
1974
            $response = [
2052
                'success' => false,
1975
                'success' => false,
2053
                'data' => 'ERROR_COMPANY_NOT_FOUND'
1976
                'data' => 'ERROR_COMPANY_NOT_FOUND'
2054
            ];
1977
            ];
2055
            
1978
 
2056
            return new JsonModel($response);
1979
            return new JsonModel($response);
2057
        }
1980
        }
2058
        
1981
 
2059
        
1982
 
2060
        
1983
 
2061
        $request = $this->getRequest();
1984
        $request = $this->getRequest();
2062
        if($request->isGet()) {
1985
        if ($request->isGet()) {
2063
            $dt = \DateTime::createFromFormat('Y-m-d', $job->last_date_of_application);
1986
            $dt = \DateTime::createFromFormat('Y-m-d', $job->last_date_of_application);
2064
            
1987
 
2065
            $data = [
-
 
2066
                'success' => true,
-
 
2067
                'data' => $dt->format('d/m/Y'),
1988
            $data = [
2068
            ];
1989
                'success' => true,
2069
            
1990
                'data' => $dt->format('d/m/Y'),
2070
            return new JsonModel($data);
1991
            ];
2071
            
1992
 
2072
            
1993
            return new JsonModel($data);
2073
        } else if($request->isPost()) {
1994
        } else if ($request->isPost()) {
2074
            
1995
 
2075
            $form = new CompanyJobLastDateOfApplicationForm();
1996
            $form = new CompanyJobLastDateOfApplicationForm();
2076
            $dataPost = $request->getPost()->toArray();
1997
            $dataPost = $request->getPost()->toArray();
2077
            
1998
 
2078
            $form->setData($dataPost);
1999
            $form->setData($dataPost);
2079
            
2000
 
2080
            if($form->isValid()) {
2001
            if ($form->isValid()) {
2081
                $this->logger->info('Se actualizo la última fecha de aplicación de la empresa: '. $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2002
                $this->logger->info('Se actualizo la última fecha de aplicación de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2082
                
2003
 
2083
                $dt = \DateTime::createFromFormat('d/m/Y', $form->get('last_date_of_application')->getValue());
2004
                $dt = \DateTime::createFromFormat('d/m/Y', $form->get('last_date_of_application')->getValue());
2084
                $job->last_date_of_application = $dt->format('Y-m-d');
2005
                $job->last_date_of_application = $dt->format('Y-m-d');
2085
                
2006
 
Línea 2096... Línea 2017...
2096
                        9 => 'LABEL_MONTH_SEPTEMBER',
2017
                        9 => 'LABEL_MONTH_SEPTEMBER',
2097
                        10 => 'LABEL_MONTH_OCTOBER',
2018
                        10 => 'LABEL_MONTH_OCTOBER',
2098
                        11 => 'LABEL_MONTH_NOVEMBER',
2019
                        11 => 'LABEL_MONTH_NOVEMBER',
2099
                        12 => 'LABEL_MONTH_DECEMBER',
2020
                        12 => 'LABEL_MONTH_DECEMBER',
2100
                    ];
2021
                    ];
2101
                    
2022
 
2102
                   $last_date_of_application = $dt->format('d') . ' de ' . $months[$dt->format('n')] . ' de ' . $dt->format('Y');
2023
                    $last_date_of_application = $dt->format('d') . ' de ' . $months[$dt->format('n')] . ' de ' . $dt->format('Y');
2103
                    
2024
 
2104
                    
2025
 
2105
                    return new JsonModel([
2026
                    return new JsonModel([
2106
                        'success'   => true,
2027
                        'success'   => true,
2107
                        'data' => $last_date_of_application
2028
                        'data' => $last_date_of_application
2108
                    ]);
2029
                    ]);
2109
                }  else {
2030
                } else {
2110
                    return new JsonModel([
2031
                    return new JsonModel([
2111
                        'success'   => false,
2032
                        'success'   => false,
2112
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
2033
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
2113
                    ]);
2034
                    ]);
2114
                }
2035
                }
2115
                
-
 
2116
                
-
 
2117
            } else {
2036
            } else {
2118
                $messages = [];
2037
                $messages = [];
2119
                $form_messages = (array) $form->getMessages();
2038
                $form_messages = (array) $form->getMessages();
2120
                foreach($form_messages  as $fieldname => $field_messages)
2039
                foreach ($form_messages  as $fieldname => $field_messages) {
2121
                {
-
 
2122
                    $messages[$fieldname] = array_values($field_messages);
2040
                    $messages[$fieldname] = array_values($field_messages);
2123
                }
2041
                }
2124
                
2042
 
2125
                return new JsonModel([
2043
                return new JsonModel([
2126
                    'success'   => false,
2044
                    'success'   => false,
2127
                    'data'   => $messages
2045
                    'data'   => $messages
2128
                ]);
2046
                ]);
2129
            }
2047
            }
2130
        }
2048
        }
2131
        
2049
 
2132
        
2050
 
2133
        $data = [
2051
        $data = [
2134
            'success' => false,
2052
            'success' => false,
2135
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
2053
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
2136
        ];
2054
        ];
2137
        
2055
 
2138
        
2056
 
2139
        return new JsonModel($data);
2057
        return new JsonModel($data);
2140
    }
2058
    }
2141
    
2059
 
2142
    public function usersWhoAppliedAction()
2060
    public function usersWhoAppliedAction()
2143
    {
2061
    {
2144
        $currentUserPlugin = $this->plugin('currentUserPlugin');
2062
        $currentUserPlugin = $this->plugin('currentUserPlugin');
2145
        $currentUser = $currentUserPlugin->getUser();
2063
        $currentUser = $currentUserPlugin->getUser();
2146
        $currentCompany = $currentUserPlugin->getCompany();
2064
        $currentCompany = $currentUserPlugin->getCompany();
2147
        
2065
 
2148
        
2066
 
2149
        $request = $this->getRequest();
2067
        $request = $this->getRequest();
2150
        $id = $this->params()->fromRoute('id');
2068
        $id = $this->params()->fromRoute('id');
2151
        
2069
 
2152
        if(!$id) {
2070
        if (!$id) {
2153
            $data = [
2071
            $data = [
2154
                'success'   => false,
2072
                'success'   => false,
2155
                'data'   => 'ERROR_INVALID_PARAMETER'
2073
                'data'   => 'ERROR_INVALID_PARAMETER'
2156
            ];
2074
            ];
2157
            
2075
 
2158
            return new JsonModel($data);
2076
            return new JsonModel($data);
2159
        }
2077
        }
2160
        
2078
 
2161
        $jobMapper = JobMapper::getInstance($this->adapter);
2079
        $jobMapper = JobMapper::getInstance($this->adapter);
2162
        $job = $jobMapper->fetchOneByUuid($id);
2080
        $job = $jobMapper->fetchOneByUuid($id);
2163
        if(!$job) {
2081
        if (!$job) {
2164
            $data = [
2082
            $data = [
2165
                'success'   => false,
2083
                'success'   => false,
2166
                'data'   => 'ERROR_JOB_NOT_FOUND'
2084
                'data'   => 'ERROR_JOB_NOT_FOUND'
2167
            ];
2085
            ];
2168
            
2086
 
2169
            return new JsonModel($data);
2087
            return new JsonModel($data);
2170
        }
2088
        }
2171
        
2089
 
2172
        if($job->company_id != $currentCompany->id) {
2090
        if ($job->company_id != $currentCompany->id) {
2173
            $data = [
2091
            $data = [
2174
                'success'   => false,
2092
                'success'   => false,
2175
                'data'   => 'ERROR_UNAUTHORIZED'
2093
                'data'   => 'ERROR_UNAUTHORIZED'
2176
            ];
2094
            ];
2177
            
2095
 
2178
            return new JsonModel($data);
2096
            return new JsonModel($data);
2179
        }
2097
        }
Línea 2180... Línea 2098...
2180
 
2098
 
2181
        
2099
 
2182
        $request = $this->getRequest();
2100
        $request = $this->getRequest();
2183
        if($request->isGet()) {
2101
        if ($request->isGet()) {
2184
            
2102
 
2185
            $sandbox = $this->config['leaderslinked.runmode.sandbox'];
2103
            $sandbox = $this->config['leaderslinked.runmode.sandbox'];
2186
            if($sandbox) {
2104
            if ($sandbox) {
2187
                $user_profile_url = $this->config['leaderslinked.frontend.sandbox_user_profile'];
2105
                $user_profile_url = $this->config['leaderslinked.frontend.sandbox_user_profile'];
2188
            } else {
2106
            } else {
2189
                $user_profile_url = $this->config['leaderslinked.frontend.production_user_profile'];
2107
                $user_profile_url = $this->config['leaderslinked.frontend.production_user_profile'];
2190
            }
2108
            }
Línea 2191... Línea 2109...
2191
            
2109
 
2192
 
2110
 
2193
            $queryMapper = QueryMapper::getInstance($this->adapter);
2111
            $queryMapper = QueryMapper::getInstance($this->adapter);
2194
            $select = $queryMapper->getSql()->select();
2112
            $select = $queryMapper->getSql()->select();
2195
            $select->columns(['id',  'user_uuid' => 'uuid', 'first_name','last_name', 'email']);
2113
            $select->columns(['id',  'user_uuid' => 'uuid', 'first_name', 'last_name', 'email']);
2196
            $select->from(['u' => UserMapper::_TABLE]);
2114
            $select->from(['u' => UserMapper::_TABLE]);
2197
            $select->join(['ja' => JobApplicationMapper::_TABLE], 'ja.user_id = u.id', ['user_profile_id']);
2115
            $select->join(['ja' => JobApplicationMapper::_TABLE], 'ja.user_id = u.id', ['user_profile_id']);
2198
            $select->join(['up' => UserProfileMapper::_TABLE], 'ja.user_profile_id = up.id', ['user_profile_uuid' => 'uuid']);
2116
            $select->join(['up' => UserProfileMapper::_TABLE], 'ja.user_profile_id = up.id', ['user_profile_uuid' => 'uuid']);
2199
            $select->where->equalTo('u.status', User::STATUS_ACTIVE);
2117
            $select->where->equalTo('u.status', User::STATUS_ACTIVE);
2200
            $select->order(['first_name', 'last_name']);                    
2118
            $select->order(['first_name', 'last_name']);
2201
                
2119
 
2202
            $items = [];
2120
            $items = [];
2203
            $records = $queryMapper->fetchAll($select); 
2121
            $records = $queryMapper->fetchAll($select);
2204
                    
-
 
2205
            foreach($records as $record)
2122
 
2206
            {
2123
            foreach ($records as $record) {
2207
                $item = [
2124
                $item = [
2208
                    'first_name' => $record['first_name'],
2125
                    'first_name' => $record['first_name'],
2209
                    'last_name' => $record['last_name'],
2126
                    'last_name' => $record['last_name'],
Línea 2210... Línea 2127...
2210
                    'email' => $record['email'],
2127
                    'email' => $record['email'],
2211
                    'link_view' => str_replace('[uuid]', $record['user_profile_uuid'], $user_profile_url),
2128
                    'link_view' => str_replace('[uuid]', $record['user_profile_uuid'], $user_profile_url),
2212
 
2129
 
2213
                ];
2130
                ];
Línea 2214... Línea 2131...
2214
                     
2131
 
2215
                array_push($items, $item);
2132
                array_push($items, $item);
2216
            }
2133
            }
2217
 
2134
 
2218
                    
2135
 
Línea 2219... Línea 2136...
2219
            $response = [
2136
            $response = [
2220
                'success' => true,
-
 
2221
                'data' => $items
-
 
2222
            ];
2137
                'success' => true,
2223
 
2138
                'data' => $items
2224
            return new JsonModel($response);
2139
            ];
2225
   
2140
 
2226
            
2141
            return new JsonModel($response);
2227
        } else {
2142
        } else {
2228
            return new JsonModel([
2143
            return new JsonModel([
2229
                'success' => false,
2144
                'success' => false,
2230
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
2145
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
2231
            ]);
2146
            ]);
2232
        }
2147
        }
2233
    }
2148
    }
2234
    
2149
 
2235
    
2150
 
2236
    public function statusAction()
2151
    public function statusAction()
2237
    {
2152
    {
2238
        $currentUserPlugin = $this->plugin('currentUserPlugin');
2153
        $currentUserPlugin = $this->plugin('currentUserPlugin');
2239
        $currentUser = $currentUserPlugin->getUser();
2154
        $currentUser = $currentUserPlugin->getUser();
2240
        $currentCompany = $currentUserPlugin->getCompany();
2155
        $currentCompany = $currentUserPlugin->getCompany();
2241
        
2156
 
2242
        
2157
 
2243
        $request = $this->getRequest();
2158
        $request = $this->getRequest();
2244
        $id = $this->params()->fromRoute('id');
2159
        $id = $this->params()->fromRoute('id');
2245
        
2160
 
2246
        
2161
 
2247
        if(!$id) {
2162
        if (!$id) {
2248
            $response = [
2163
            $response = [
2249
                'success' => false,
-
 
2250
                'data' => 'ERROR_INVALID_PARAMETER'
2164
                'success' => false,
2251
            ];
2165
                'data' => 'ERROR_INVALID_PARAMETER'
2252
            
2166
            ];
2253
            return new JsonModel($response);
2167
 
2254
            
2168
            return new JsonModel($response);
2255
        }
2169
        }
2256
        
2170
 
2257
        $jobMapper = JobMapper::getInstance($this->adapter);
2171
        $jobMapper = JobMapper::getInstance($this->adapter);
2258
        $job = $jobMapper->fetchOneByUuid($id);
2172
        $job = $jobMapper->fetchOneByUuid($id);
2259
        
2173
 
2260
        if(!$job) {
2174
        if (!$job) {
2261
            $response = [
2175
            $response = [
2262
                'success' => false,
2176
                'success' => false,
2263
                'data' => 'ERROR_JOB_NOT_FOUND'
2177
                'data' => 'ERROR_JOB_NOT_FOUND'
2264
            ];
2178
            ];
2265
            
2179
 
2266
            return new JsonModel($response);
2180
            return new JsonModel($response);
2267
        }
2181
        }
2268
        
2182
 
2269
        if($job->company_id != $currentCompany->id) {
2183
        if ($job->company_id != $currentCompany->id) {
2270
            $response = [
2184
            $response = [
2271
                'success' => false,
2185
                'success' => false,
2272
                'data' => 'ERROR_UNAUTHORIZED'
2186
                'data' => 'ERROR_UNAUTHORIZED'
2273
            ];
2187
            ];
2274
            
2188
 
2275
            return new JsonModel($response);
2189
            return new JsonModel($response);
2276
        }
2190
        }
2277
        
2191
 
2278
        
2192
 
2279
        $companyMapper = CompanyMapper::getInstance($this->adapter);
2193
        $companyMapper = CompanyMapper::getInstance($this->adapter);
2280
        $company = $companyMapper->fetchOne($currentCompany->id);
2194
        $company = $companyMapper->fetchOne($currentCompany->id);
2281
        if(!$company) {
2195
        if (!$company) {
2282
            $response = [
2196
            $response = [
2283
                'success' => false,
2197
                'success' => false,
2284
                'data' => 'ERROR_COMPANY_NOT_FOUND'
2198
                'data' => 'ERROR_COMPANY_NOT_FOUND'
2285
            ];
2199
            ];
2286
            
2200
 
2287
            return new JsonModel($response);
2201
            return new JsonModel($response);
2288
        }
2202
        }
2289
        
2203
 
2290
        
2204
 
2291
        
2205
 
2292
        
2206
 
2293
        $request = $this->getRequest();
2207
        $request = $this->getRequest();
2294
        if($request->isGet()) {
2208
        if ($request->isGet()) {
2295
            $data = [
2209
            $data = [
2296
                'success' => true,
2210
                'success' => true,
2297
                'data' => [
2211
                'data' => [
2298
                    'status' => $job->status,
-
 
2299
                ]
-
 
2300
            ];
2212
                    'status' => $job->status,
2301
            
2213
                ]
2302
            return new JsonModel($data);
2214
            ];
2303
            
2215
 
2304
            
2216
            return new JsonModel($data);
2305
        } else if($request->isPost()) {
2217
        } else if ($request->isPost()) {
2306
            
2218
 
2307
            
2219
 
2308
            $form = new CompanyJobStatusForm();
2220
            $form = new CompanyJobStatusForm();
2309
            $dataPost = $request->getPost()->toArray();
2221
            $dataPost = $request->getPost()->toArray();
2310
            
2222
 
2311
            $form->setData($dataPost);
2223
            $form->setData($dataPost);
2312
            
2224
 
2313
            if($form->isValid()) {
2225
            if ($form->isValid()) {
2314
                $dataPost = (array) $form->getData();
2226
                $dataPost = (array) $form->getData();
2315
                
2227
 
2316
                $hydrator = new ObjectPropertyHydrator();
2228
                $hydrator = new ObjectPropertyHydrator();
2317
                $hydrator->hydrate($dataPost, $job);
2229
                $hydrator->hydrate($dataPost, $job);
2318
                
2230
 
2319
                $jobMapper->updateStatus($job);
2231
                $jobMapper->updateStatus($job);
2320
                
2232
 
2321
                $this->logger->info('Se actualizo el estatus del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2233
                $this->logger->info('Se actualizo el estatus del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2322
                
2234
 
2323
                switch($job->status) {
2235
                switch ($job->status) {
2324
                    case  Job::STATUS_ACTIVE :
2236
                    case  Job::STATUS_ACTIVE:
2325
                        $status = 'LABEL_ACTIVE';
2237
                        $status = 'LABEL_ACTIVE';
2326
                        break;
2238
                        break;
2327
                        
2239
 
2328
                    case  Job::STATUS_INACTIVE :
2240
                    case  Job::STATUS_INACTIVE:
2329
                        $status = 'LABEL_INACTIVE';
2241
                        $status = 'LABEL_INACTIVE';
2330
                        break;
2242
                        break;
2331
                        
2243
 
2332
                        
2244
 
2333
                    case  Job::STATUS_DELETED :
2245
                    case  Job::STATUS_DELETED:
2334
                        $status = 'LABEL_DELETED';
2246
                        $status = 'LABEL_DELETED';
2335
                        break;
2247
                        break;
2336
                        
2248
 
2337
                    default :
2249
                    default:
2338
                        $status = '';
2250
                        $status = '';
2339
                        break;
2251
                        break;
2340
                }
2252
                }
2341
                
2253
 
2342
                
2254
 
2343
                return new JsonModel([
2255
                return new JsonModel([
2344
                    'success'   => true,
-
 
2345
                    'data' => [
2256
                    'success'   => true,
2346
                        'status' => $status,
2257
                    'data' => [
2347
                    ]
2258
                        'status' => $status,
2348
                ]);
2259
                    ]
2349
                
-
 
2350
            } else {
2260
                ]);
2351
                $messages = [];
2261
            } else {
2352
                $form_messages = (array) $form->getMessages();
2262
                $messages = [];
2353
                foreach($form_messages  as $fieldname => $field_messages)
2263
                $form_messages = (array) $form->getMessages();
2354
                {
2264
                foreach ($form_messages  as $fieldname => $field_messages) {
2355
                    $messages[$fieldname] = array_values($field_messages);
2265
                    $messages[$fieldname] = array_values($field_messages);
2356
                }
2266
                }
2357
                
2267
 
2358
                return new JsonModel([
2268
                return new JsonModel([
2359
                    'success'   => false,
2269
                    'success'   => false,
2360
                    'data'   => $messages
2270
                    'data'   => $messages
2361
                ]);
2271
                ]);
2362
            }
2272
            }
2363
        }
2273
        }
2364
        
2274
 
2365
        
2275
 
2366
        $data = [
2276
        $data = [
2367
            'success' => false,
2277
            'success' => false,
2368
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
2278
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
2369
        ];
2279
        ];
2370
        
2280
 
2371
        
2281
 
2372
        return new JsonModel($data);
2282
        return new JsonModel($data);
2373
    }
2283
    }
2374
    
2284
 
2375
    
2285
 
2376
    public function titleAction()
2286
    public function titleAction()
2377
    {
2287
    {
2378
        $currentUserPlugin = $this->plugin('currentUserPlugin');
2288
        $currentUserPlugin = $this->plugin('currentUserPlugin');
2379
        $currentUser = $currentUserPlugin->getUser();
2289
        $currentUser = $currentUserPlugin->getUser();
2380
        $currentCompany = $currentUserPlugin->getCompany();
2290
        $currentCompany = $currentUserPlugin->getCompany();
2381
        
2291
 
2382
        
2292
 
2383
        $request = $this->getRequest();
2293
        $request = $this->getRequest();
2384
        $id = $this->params()->fromRoute('id');
2294
        $id = $this->params()->fromRoute('id');
2385
        
2295
 
2386
        
2296
 
2387
        if(!$id) {
2297
        if (!$id) {
2388
            $response = [
2298
            $response = [
2389
                'success' => false,
-
 
2390
                'data' => 'ERROR_INVALID_PARAMETER'
2299
                'success' => false,
2391
            ];
2300
                'data' => 'ERROR_INVALID_PARAMETER'
2392
            
2301
            ];
2393
            return new JsonModel($response);
2302
 
2394
            
2303
            return new JsonModel($response);
2395
        }
2304
        }
2396
        
2305
 
2397
        $jobMapper = JobMapper::getInstance($this->adapter);
2306
        $jobMapper = JobMapper::getInstance($this->adapter);
2398
        $job = $jobMapper->fetchOneByUuid($id);
2307
        $job = $jobMapper->fetchOneByUuid($id);
2399
        
2308
 
2400
        if(!$job) {
2309
        if (!$job) {
2401
            $response = [
2310
            $response = [
2402
                'success' => false,
2311
                'success' => false,
2403
                'data' => 'ERROR_JOB_NOT_FOUND'
2312
                'data' => 'ERROR_JOB_NOT_FOUND'
2404
            ];
2313
            ];
2405
            
2314
 
2406
            return new JsonModel($response);
2315
            return new JsonModel($response);
2407
        }
2316
        }
2408
        
2317
 
2409
        if($job->company_id != $currentCompany->id) {
2318
        if ($job->company_id != $currentCompany->id) {
2410
            $response = [
2319
            $response = [
2411
                'success' => false,
2320
                'success' => false,
2412
                'data' => 'ERROR_UNAUTHORIZED'
2321
                'data' => 'ERROR_UNAUTHORIZED'
2413
            ];
2322
            ];
2414
            
2323
 
2415
            return new JsonModel($response);
2324
            return new JsonModel($response);
2416
        }
2325
        }
2417
        
2326
 
2418
        
2327
 
2419
        $companyMapper = CompanyMapper::getInstance($this->adapter);
2328
        $companyMapper = CompanyMapper::getInstance($this->adapter);
2420
        $company = $companyMapper->fetchOne($currentCompany->id);
2329
        $company = $companyMapper->fetchOne($currentCompany->id);
2421
        if(!$company) {
2330
        if (!$company) {
2422
            $response = [
2331
            $response = [
2423
                'success' => false,
2332
                'success' => false,
2424
                'data' => 'ERROR_COMPANY_NOT_FOUND'
2333
                'data' => 'ERROR_COMPANY_NOT_FOUND'
2425
            ];
2334
            ];
2426
            
2335
 
2427
            return new JsonModel($response);
2336
            return new JsonModel($response);
2428
        }
2337
        }
2429
        
2338
 
2430
        
2339
 
2431
        
2340
 
2432
        
2341
 
2433
        $request = $this->getRequest();
2342
        $request = $this->getRequest();
2434
        if($request->isGet()) {
2343
        if ($request->isGet()) {
2435
            $data = [
2344
            $data = [
2436
                'success' => true,
2345
                'success' => true,
2437
                'data' => [
2346
                'data' => [
2438
                    'title' => $job->title,
-
 
2439
                ]
-
 
2440
            ];
2347
                    'title' => $job->title,
2441
            
2348
                ]
2442
            return new JsonModel($data);
2349
            ];
2443
            
2350
 
2444
            
2351
            return new JsonModel($data);
2445
        } else if($request->isPost()) {
2352
        } else if ($request->isPost()) {
2446
            
2353
 
2447
            
2354
 
2448
            $form = new CompanyJobTitleForm();
2355
            $form = new CompanyJobTitleForm();
2449
            $dataPost = $request->getPost()->toArray();
2356
            $dataPost = $request->getPost()->toArray();
2450
            
2357
 
2451
            $form->setData($dataPost);
2358
            $form->setData($dataPost);
2452
            
2359
 
2453
            if($form->isValid()) {
2360
            if ($form->isValid()) {
2454
                $dataPost = (array) $form->getData();
2361
                $dataPost = (array) $form->getData();
2455
                
2362
 
2456
                $hydrator = new ObjectPropertyHydrator();
2363
                $hydrator = new ObjectPropertyHydrator();
2457
                $hydrator->hydrate($dataPost, $job);
2364
                $hydrator->hydrate($dataPost, $job);
2458
                
2365
 
2459
                $jobMapper->updateTitle($job);
2366
                $jobMapper->updateTitle($job);
2460
                
2367
 
2461
                $this->logger->info('Se actualizo el título del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2368
                $this->logger->info('Se actualizo el título del empleo ' . $job->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
2462
                
2369
 
2463
                return new JsonModel([
2370
                return new JsonModel([
2464
                    'success'   => true,
-
 
2465
                    'data' => [
2371
                    'success'   => true,
2466
                        'title' => $job->title,
2372
                    'data' => [
2467
                    ]
2373
                        'title' => $job->title,
2468
                ]);
2374
                    ]
2469
                
-
 
2470
            } else {
2375
                ]);
2471
                $messages = [];
2376
            } else {
2472
                $form_messages = (array) $form->getMessages();
2377
                $messages = [];
2473
                foreach($form_messages  as $fieldname => $field_messages)
2378
                $form_messages = (array) $form->getMessages();
2474
                {
2379
                foreach ($form_messages  as $fieldname => $field_messages) {
2475
                    $messages[$fieldname] = array_values($field_messages);
2380
                    $messages[$fieldname] = array_values($field_messages);
2476
                }
2381
                }
2477
                
2382
 
2478
                return new JsonModel([
2383
                return new JsonModel([
2479
                    'success'   => false,
2384
                    'success'   => false,
2480
                    'data'   => $messages
2385
                    'data'   => $messages
2481
                ]);
2386
                ]);
2482
            }
2387
            }
2483
        }
2388
        }
2484
        
2389
 
2485
        
2390
 
2486
        $data = [
2391
        $data = [
2487
            'success' => false,
2392
            'success' => false,
2488
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
2393
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
2489
        ];
-
 
2490
        
-
 
2491
        
-
 
2492
        return new JsonModel($data);
-
 
2493
    }
-
 
2494
    
-
 
2495
    
2394
        ];