15461 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
16768 |
efrain |
8 |
|
15461 |
efrain |
9 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
10 |
use Laminas\Log\LoggerInterface;
|
|
|
11 |
use Laminas\View\Model\ViewModel;
|
|
|
12 |
use Laminas\View\Model\JsonModel;
|
|
|
13 |
use LeadersLinked\Library\Functions;
|
|
|
14 |
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
|
|
|
15 |
use LeadersLinked\Model\RecruitmentSelectionCandidate;
|
|
|
16 |
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
|
|
|
17 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
18 |
use Laminas\Hydrator\ArraySerializableHydrator;
|
|
|
19 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
20 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
21 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
22 |
use Laminas\Paginator\Paginator;
|
|
|
23 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationVacancyForm;
|
|
|
24 |
use LeadersLinked\Mapper\RecruitmentSelectionApplicationMapper;
|
|
|
25 |
use LeadersLinked\Model\RecruitmentSelectionApplication;
|
|
|
26 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationCandidateForm;
|
|
|
27 |
use LeadersLinked\Mapper\LocationMapper;
|
|
|
28 |
use LeadersLinked\Mapper\JobCategoryMapper;
|
|
|
29 |
use LeadersLinked\Mapper\IndustryMapper;
|
|
|
30 |
use LeadersLinked\Mapper\JobDescriptionMapper;
|
|
|
31 |
use LeadersLinked\Mapper\RecruitmentSelectionFileMapper;
|
|
|
32 |
use LeadersLinked\Mapper\RecruitmentSelectionInterviewMapper;
|
|
|
33 |
use LeadersLinked\Model\RecruitmentSelectionInterview;
|
|
|
34 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationFileForm;
|
|
|
35 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationPointsAndCommentForm;
|
|
|
36 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationLevelForm;
|
|
|
37 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationStatusForm;
|
|
|
38 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionApplicationInterviewForm;
|
|
|
39 |
|
|
|
40 |
class RecruitmentSelectionApplicationController extends AbstractActionController{
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
*
|
16769 |
efrain |
44 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
15461 |
efrain |
45 |
*/
|
|
|
46 |
private $adapter;
|
16768 |
efrain |
47 |
|
15461 |
efrain |
48 |
/**
|
|
|
49 |
*
|
16769 |
efrain |
50 |
* @var \LeadersLinked\Cache\CacheInterface
|
15461 |
efrain |
51 |
*/
|
16769 |
efrain |
52 |
private $cache;
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
*
|
|
|
57 |
* @var \Laminas\Log\LoggerInterface
|
|
|
58 |
*/
|
15461 |
efrain |
59 |
private $logger;
|
16768 |
efrain |
60 |
|
15461 |
efrain |
61 |
/**
|
|
|
62 |
*
|
|
|
63 |
* @var array
|
|
|
64 |
*/
|
|
|
65 |
private $config;
|
16768 |
efrain |
66 |
|
16769 |
efrain |
67 |
|
15461 |
efrain |
68 |
/**
|
|
|
69 |
*
|
16769 |
efrain |
70 |
* @var \Laminas\Mvc\I18n\Translator
|
|
|
71 |
*/
|
|
|
72 |
private $translator;
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
*
|
|
|
77 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
78 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
79 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
15461 |
efrain |
80 |
* @param array $config
|
16769 |
efrain |
81 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
15461 |
efrain |
82 |
*/
|
16769 |
efrain |
83 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
16768 |
efrain |
84 |
{
|
16769 |
efrain |
85 |
$this->adapter = $adapter;
|
|
|
86 |
$this->cache = $cache;
|
|
|
87 |
$this->logger = $logger;
|
|
|
88 |
$this->config = $config;
|
|
|
89 |
$this->translator = $translator;
|
15461 |
efrain |
90 |
}
|
|
|
91 |
|
|
|
92 |
public function indexAction() {
|
|
|
93 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
94 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
95 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
96 |
|
|
|
97 |
$request = $this->getRequest();
|
|
|
98 |
|
|
|
99 |
if ($request->isGet()) {
|
|
|
100 |
|
|
|
101 |
$headers = $request->getHeaders();
|
|
|
102 |
|
|
|
103 |
$isJson = false;
|
|
|
104 |
if ($headers->has('Accept')) {
|
|
|
105 |
$accept = $headers->get('Accept');
|
|
|
106 |
|
|
|
107 |
$prioritized = $accept->getPrioritized();
|
|
|
108 |
|
|
|
109 |
foreach ($prioritized as $key => $value) {
|
|
|
110 |
$raw = trim($value->getRaw());
|
|
|
111 |
|
|
|
112 |
if (!$isJson) {
|
|
|
113 |
$isJson = strpos($raw, 'json');
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
// $isJson = true;
|
|
|
119 |
if ($isJson) {
|
|
|
120 |
|
|
|
121 |
$vacancy_uuid = $this->params()->fromQuery('vacancy_id');
|
|
|
122 |
|
|
|
123 |
$data = [
|
|
|
124 |
'items' => [],
|
|
|
125 |
'total' => 0,
|
|
|
126 |
'link_add' => '',
|
|
|
127 |
];
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
if (!$vacancy_uuid) {
|
|
|
131 |
return new JsonModel([
|
|
|
132 |
'success' => true,
|
|
|
133 |
'data' => $data
|
|
|
134 |
]);
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
139 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
140 |
if (! $vacancy) {
|
|
|
141 |
return new JsonModel([
|
|
|
142 |
'success' => true,
|
|
|
143 |
'data' => 'ERROR_VACANCY_NOT_FOUND'
|
|
|
144 |
]);
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
if ( $vacancy->company_id != $currentCompany->id) {
|
|
|
148 |
return new JsonModel([
|
|
|
149 |
'success' => true,
|
|
|
150 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
151 |
]);
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
$search = $this->params()->fromQuery('search');
|
16778 |
efrain |
156 |
$search = empty($search['value']) ? '' : Functions::sanitizeFilterString($search['value']);
|
15461 |
efrain |
157 |
|
|
|
158 |
$start = intval($this->params()->fromQuery('start', 0), 10);
|
|
|
159 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
160 |
$page = intval($start / $records_x_page);
|
|
|
161 |
$page++;
|
|
|
162 |
|
|
|
163 |
$order = $this->params()->fromQuery('order', []);
|
|
|
164 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
16766 |
efrain |
165 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : Functions::sanitizeFilterString(filter_var($order[0]['dir']));
|
15461 |
efrain |
166 |
|
|
|
167 |
$fields = ['first_name', 'last_name', 'email'];
|
|
|
168 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
|
|
|
169 |
|
|
|
170 |
if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
171 |
$order_direction = 'ASC';
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
|
|
178 |
$allowAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/add');
|
|
|
179 |
$allowDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/delete');
|
|
|
180 |
$allowView = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/view');
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
185 |
$sql = $queryMapper->getSql();
|
|
|
186 |
$select = $sql->select();
|
|
|
187 |
$select->columns(['uuid', 'level', 'status']);
|
|
|
188 |
$select->from(['tb1' => RecruitmentSelectionApplicationMapper::_TABLE]);
|
|
|
189 |
$select->join(['tb2' => RecruitmentSelectionCandidateMapper::_TABLE], 'tb1.candidate_id = tb2.id', ['first_name', 'last_name', 'email']);
|
|
|
190 |
$select->where->equalTo('tb1.vacancy_id', $vacancy->id);
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
if($search) {
|
|
|
194 |
$select->where->nest()
|
|
|
195 |
->like('first_name', '%' . $search . '%')
|
|
|
196 |
->or->like('last_name', '%' . $search . '%')
|
|
|
197 |
->or->like('email', '%' . $search . '%')
|
|
|
198 |
->unnest();
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
$select->order($order_field . ' ' . $order_direction);
|
|
|
202 |
|
|
|
203 |
// echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
204 |
|
|
|
205 |
$hydrator = new ArraySerializableHydrator();
|
|
|
206 |
$resultset = new HydratingResultSet($hydrator);
|
|
|
207 |
|
|
|
208 |
$adapter = new DbSelect($select, $sql, $resultset);
|
|
|
209 |
$paginator = new Paginator($adapter);
|
|
|
210 |
$paginator->setItemCountPerPage($records_x_page);
|
|
|
211 |
$paginator->setCurrentPageNumber($page);
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
$items = [];
|
|
|
215 |
$records = $paginator->getCurrentItems();
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
foreach ($records as $record) {
|
|
|
219 |
|
|
|
220 |
switch($record['status'])
|
|
|
221 |
{
|
|
|
222 |
case RecruitmentSelectionApplication::STATUS_ACTIVE :
|
|
|
223 |
$status = 'LABEL_ACTIVE';
|
|
|
224 |
break;
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
case RecruitmentSelectionApplication::STATUS_INACTIVE :
|
|
|
228 |
$status = 'LABEL_INACTIVE';
|
|
|
229 |
break;
|
|
|
230 |
|
|
|
231 |
case RecruitmentSelectionApplication::STATUS_SELECTED :
|
|
|
232 |
$status = 'LABEL_SELECTED';
|
|
|
233 |
break;
|
|
|
234 |
|
|
|
235 |
case RecruitmentSelectionApplication::STATUS_REJECTED :
|
|
|
236 |
$status = 'LABEL_REJECTED';
|
|
|
237 |
break;
|
|
|
238 |
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
switch($record['level'])
|
|
|
242 |
{
|
|
|
243 |
case RecruitmentSelectionApplication::LEVEL_CAPTURE :
|
|
|
244 |
$level = 'LABEL_CAPTURE';
|
|
|
245 |
break;
|
|
|
246 |
|
|
|
247 |
case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
|
|
|
248 |
$level = 'LABEL_PRE_SELECTION';
|
|
|
249 |
break;
|
|
|
250 |
|
|
|
251 |
case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
|
|
|
252 |
$level = 'LABEL_HUMAN_RESOURCE';
|
|
|
253 |
break;
|
|
|
254 |
|
|
|
255 |
case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
|
|
|
256 |
$level = 'LABEL_BOSS_INTERVIEW';
|
|
|
257 |
break;
|
|
|
258 |
|
|
|
259 |
case RecruitmentSelectionApplication::LEVEL_FINISHED :
|
|
|
260 |
$level = 'LABEL_FINISHED';
|
|
|
261 |
break;
|
|
|
262 |
|
|
|
263 |
default :
|
|
|
264 |
$level = 'LABEL_UNKNOWN';
|
|
|
265 |
break;
|
|
|
266 |
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
$item = [
|
|
|
270 |
'first_name' => $record['first_name'],
|
|
|
271 |
'last_name' => $record['last_name'],
|
|
|
272 |
'email' => $record['email'],
|
|
|
273 |
'status' => $status,
|
|
|
274 |
'level' => $level,
|
|
|
275 |
'actions' => [
|
|
|
276 |
'link_delete' => $allowDelete ? $this->url()->fromRoute('recruitment-and-selection/applications/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $record['uuid']] ) : '',
|
|
|
277 |
'link_view' => $allowView ? $this->url()->fromRoute('recruitment-and-selection/applications/view', ['vacancy_id' => $vacancy->uuid, 'application_id' => $record['uuid']] ) : '',
|
|
|
278 |
]
|
|
|
279 |
];
|
|
|
280 |
|
|
|
281 |
array_push($items, $item);
|
|
|
282 |
}
|
|
|
283 |
|
|
|
284 |
$data['items'] = $items;
|
|
|
285 |
$data['total'] = $paginator->getTotalItemCount();
|
|
|
286 |
$data['link_add'] = $allowAdd ? $this->url()->fromRoute( 'recruitment-and-selection/applications/add', ['vacancy_id' => $vacancy->uuid ]) : '';
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
return new JsonModel([
|
|
|
290 |
'success' => true,
|
|
|
291 |
'data' => $data
|
|
|
292 |
]);
|
|
|
293 |
} else {
|
|
|
294 |
$formFile = new RecruitmentSelectionApplicationFileForm();
|
|
|
295 |
$formAdd = new RecruitmentSelectionApplicationCandidateForm($this->adapter);
|
|
|
296 |
$formFilter = new RecruitmentSelectionApplicationVacancyForm($this->adapter, $currentCompany->id);
|
|
|
297 |
$formComment = new RecruitmentSelectionApplicationPointsAndCommentForm();
|
|
|
298 |
$formLevel = new RecruitmentSelectionApplicationLevelForm();
|
|
|
299 |
$formStatus = new RecruitmentSelectionApplicationStatusForm();
|
|
|
300 |
$formInterview = new RecruitmentSelectionApplicationInterviewForm($this->adapter, $currentCompany->id);
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
304 |
$viewModel = new ViewModel();
|
|
|
305 |
$viewModel->setTemplate('leaders-linked/recruitment-and-selection-applications/index.phtml');
|
|
|
306 |
$viewModel->setVariables([
|
|
|
307 |
'formFilter' => $formFilter,
|
|
|
308 |
'formAdd' => $formAdd,
|
|
|
309 |
'formFile' => $formFile,
|
|
|
310 |
'formComment' => $formComment,
|
|
|
311 |
'formLevel' => $formLevel,
|
|
|
312 |
'formStatus' => $formStatus,
|
|
|
313 |
'formInterview' => $formInterview,
|
|
|
314 |
]);
|
|
|
315 |
|
|
|
316 |
return $viewModel;
|
|
|
317 |
}
|
|
|
318 |
} else {
|
|
|
319 |
return new JsonModel([
|
|
|
320 |
'success' => false,
|
|
|
321 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
322 |
]);
|
|
|
323 |
;
|
|
|
324 |
}
|
|
|
325 |
}
|
|
|
326 |
|
|
|
327 |
public function userByEmailAction()
|
|
|
328 |
{
|
|
|
329 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
330 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
331 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
$currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
|
|
|
335 |
$currentNetwork = $currentNetworkPlugin->getNetwork();
|
|
|
336 |
|
|
|
337 |
$request = $this->getRequest();
|
|
|
338 |
|
|
|
339 |
if ($request->isGet()) {
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
|
343 |
$email = trim(filter_var($this->params()->fromQuery('email'), FILTER_SANITIZE_EMAIL));
|
|
|
344 |
if($email) {
|
|
|
345 |
|
|
|
346 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
347 |
$user = $userMapper->fetchOneActiveByEmailAndNetworkId($email, $currentNetwork->id);
|
|
|
348 |
if($user) {
|
|
|
349 |
$data = [
|
|
|
350 |
'success' => true,
|
|
|
351 |
'data' => [
|
|
|
352 |
'uuid' => $user->uuid,
|
|
|
353 |
'first_name' => $user->first_name,
|
|
|
354 |
'last_name' => $user->last_name,
|
|
|
355 |
'email' => $user->email
|
|
|
356 |
]
|
|
|
357 |
];
|
|
|
358 |
} else {
|
15463 |
efrain |
359 |
$recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
360 |
$candidate = $recruitmentSelectionCandidateMapper->fetchOneActiveByEmailAndCompanyId($email, $currentCompany->id);
|
|
|
361 |
if($candidate) {
|
|
|
362 |
$data = [
|
|
|
363 |
'success' => true,
|
|
|
364 |
'data' => [
|
|
|
365 |
'uuid' => '',
|
|
|
366 |
'first_name' => $candidate->first_name,
|
|
|
367 |
'last_name' => $candidate->last_name,
|
|
|
368 |
'email' => $candidate->email
|
|
|
369 |
]
|
|
|
370 |
];
|
|
|
371 |
} else {
|
|
|
372 |
|
|
|
373 |
$data = [
|
|
|
374 |
'success' => false,
|
|
|
375 |
'data' => 'ERROR_EMAIL_NOT_FOUND'
|
|
|
376 |
];
|
|
|
377 |
}
|
15461 |
efrain |
378 |
}
|
|
|
379 |
} else {
|
|
|
380 |
$data = [
|
|
|
381 |
'success' => false,
|
|
|
382 |
'data' => 'ERROR_EMAIL_NOT_FOUND'
|
|
|
383 |
];
|
|
|
384 |
}
|
|
|
385 |
} else {
|
|
|
386 |
$data = [
|
|
|
387 |
'success' => false,
|
|
|
388 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
389 |
];
|
|
|
390 |
}
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
return new JsonModel($data);
|
|
|
394 |
|
|
|
395 |
}
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
public function addAction()
|
|
|
399 |
{
|
|
|
400 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
401 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
402 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
403 |
|
|
|
404 |
$request = $this->getRequest();
|
|
|
405 |
|
|
|
406 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_id');
|
|
|
407 |
|
|
|
408 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
409 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
410 |
|
|
|
411 |
if(!$vacancy) {
|
|
|
412 |
$data = [
|
|
|
413 |
'success' => false,
|
|
|
414 |
'data' => 'ERROR_VACANCY_NOT_FOUND'
|
|
|
415 |
];
|
|
|
416 |
|
|
|
417 |
return new JsonModel($data);
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
if($vacancy->company_id != $currentCompany->id) {
|
|
|
422 |
$data = [
|
|
|
423 |
'success' => false,
|
|
|
424 |
'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
|
|
|
425 |
];
|
|
|
426 |
|
|
|
427 |
return new JsonModel($data);
|
|
|
428 |
}
|
|
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
|
434 |
if($request->isPost()) {
|
|
|
435 |
$dataPost = $request->getPost()->toArray();
|
|
|
436 |
|
|
|
437 |
$form = new RecruitmentSelectionApplicationCandidateForm($this->adapter);
|
|
|
438 |
$form->setData($dataPost);
|
|
|
439 |
|
|
|
440 |
if($form->isValid()) {
|
|
|
441 |
$dataPost = (array) $form->getData();
|
|
|
442 |
|
|
|
443 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
444 |
$candidate = $candidateMapper->fetchOneByEmail($dataPost['email']);
|
|
|
445 |
if($candidate) {
|
|
|
446 |
|
|
|
447 |
|
|
|
448 |
$candidate->first_name = $dataPost['first_name'];
|
|
|
449 |
$candidate->last_name = $dataPost['last_name'];
|
|
|
450 |
|
|
|
451 |
$result = $candidateMapper->update($candidate);
|
|
|
452 |
|
|
|
453 |
} else {
|
|
|
454 |
|
|
|
455 |
$candidate = new RecruitmentSelectionCandidate();
|
|
|
456 |
$candidate->company_id = $currentCompany->id;
|
|
|
457 |
$candidate->email = strtolower($dataPost['email']);
|
|
|
458 |
$candidate->first_name = $dataPost['first_name'];
|
|
|
459 |
$candidate->last_name = $dataPost['last_name'];
|
|
|
460 |
|
|
|
461 |
$result = $candidateMapper->insert($candidate);
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
|
|
|
465 |
if(!$result) {
|
|
|
466 |
$data = [
|
|
|
467 |
'success' => false,
|
|
|
468 |
'data' => $candidateMapper->getError()
|
|
|
469 |
];
|
|
|
470 |
|
|
|
471 |
return new JsonModel($data);
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
$applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
|
|
|
475 |
$application = $applicationMapper->fetchOneByVancancyIdAndCandidateId($vacancy->id, $candidate->id);
|
|
|
476 |
|
|
|
477 |
|
|
|
478 |
if($application) {
|
|
|
479 |
$data = [
|
|
|
480 |
'success' => false,
|
|
|
481 |
'data' => 'ERROR_VACANCY_CANDIDATE_HAS_BEEN_PREVIOUSLY_ADDED',
|
|
|
482 |
];
|
|
|
483 |
|
|
|
484 |
return new JsonModel($data);
|
|
|
485 |
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
|
|
|
489 |
$application = new RecruitmentSelectionApplication();
|
|
|
490 |
$application->candidate_id = $candidate->id;
|
|
|
491 |
$application->company_id = $currentCompany->id;
|
|
|
492 |
$application->level = RecruitmentSelectionApplication::LEVEL_CAPTURE;
|
|
|
493 |
$application->status = RecruitmentSelectionApplication::STATUS_ACTIVE;
|
|
|
494 |
$application->vacancy_id = $vacancy->id;
|
|
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
if($applicationMapper->insert($application)) {
|
|
|
499 |
|
|
|
500 |
$this->logger->info('Se agrego la aplicación del candidato : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
501 |
|
|
|
502 |
$data = [
|
|
|
503 |
'success' => true,
|
|
|
504 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
505 |
];
|
|
|
506 |
} else {
|
|
|
507 |
$data = [
|
|
|
508 |
'success' => false,
|
|
|
509 |
'data' => $applicationMapper->getError()
|
|
|
510 |
];
|
|
|
511 |
|
|
|
512 |
}
|
|
|
513 |
|
|
|
514 |
return new JsonModel($data);
|
|
|
515 |
|
|
|
516 |
} else {
|
|
|
517 |
$messages = [];
|
|
|
518 |
$form_messages = (array) $form->getMessages();
|
|
|
519 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
520 |
|
|
|
521 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
522 |
}
|
|
|
523 |
|
|
|
524 |
return new JsonModel([
|
|
|
525 |
'success' => false,
|
|
|
526 |
'data' => $messages
|
|
|
527 |
]);
|
|
|
528 |
|
|
|
529 |
}
|
|
|
530 |
|
|
|
531 |
} else {
|
|
|
532 |
$data = [
|
|
|
533 |
'success' => false,
|
|
|
534 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
535 |
];
|
|
|
536 |
|
|
|
537 |
return new JsonModel($data);
|
|
|
538 |
}
|
|
|
539 |
|
|
|
540 |
return new JsonModel($data);
|
|
|
541 |
}
|
|
|
542 |
|
|
|
543 |
|
|
|
544 |
public function commentAction()
|
|
|
545 |
{
|
|
|
546 |
$request = $this->getRequest();
|
|
|
547 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
548 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
549 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
550 |
|
|
|
551 |
$request = $this->getRequest();
|
|
|
552 |
$application_id = $this->params()->fromRoute('application_id');
|
|
|
553 |
|
|
|
554 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_id');
|
|
|
555 |
|
|
|
556 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
557 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
558 |
|
|
|
559 |
if(!$vacancy) {
|
|
|
560 |
$data = [
|
|
|
561 |
'success' => false,
|
|
|
562 |
'data' => 'ERROR_VACANCY_NOT_FOUND'
|
|
|
563 |
];
|
|
|
564 |
|
|
|
565 |
return new JsonModel($data);
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
|
|
|
569 |
if($vacancy->company_id != $currentCompany->id) {
|
|
|
570 |
$data = [
|
|
|
571 |
'success' => false,
|
|
|
572 |
'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
|
|
|
573 |
];
|
|
|
574 |
|
|
|
575 |
return new JsonModel($data);
|
|
|
576 |
}
|
|
|
577 |
|
|
|
578 |
|
|
|
579 |
|
|
|
580 |
$applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
|
|
|
581 |
$application = $applicationMapper->fetchOneByUuid($application_id);
|
|
|
582 |
|
|
|
583 |
|
|
|
584 |
if (!$application) {
|
|
|
585 |
$data = [
|
|
|
586 |
'success' => false,
|
|
|
587 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
588 |
];
|
|
|
589 |
|
|
|
590 |
return new JsonModel($data);
|
|
|
591 |
}
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
if ($application->vacancy_id != $vacancy->id) {
|
|
|
595 |
return new JsonModel([
|
|
|
596 |
'success' => false,
|
|
|
597 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
598 |
]);
|
|
|
599 |
}
|
|
|
600 |
|
|
|
601 |
|
|
|
602 |
if ($request->isGet()) {
|
|
|
603 |
|
|
|
604 |
$data = [
|
|
|
605 |
'success' => true,
|
|
|
606 |
'data' => [
|
|
|
607 |
'points' => $application->points ? intval($application->points, 10) : 0,
|
|
|
608 |
'comment' => $application->comment ? trim($application->comment) : '',
|
|
|
609 |
]
|
|
|
610 |
];
|
|
|
611 |
|
|
|
612 |
return new JsonModel($data);
|
|
|
613 |
|
|
|
614 |
|
|
|
615 |
|
|
|
616 |
} else if ($request->isPost()) {
|
|
|
617 |
|
|
|
618 |
|
|
|
619 |
$dataPost = $request->getPost()->toArray();
|
|
|
620 |
|
|
|
621 |
$form = new RecruitmentSelectionApplicationPointsAndCommentForm();
|
|
|
622 |
$form->setData($dataPost);
|
|
|
623 |
|
|
|
624 |
if($form->isValid()) {
|
|
|
625 |
$dataPost = (array) $form->getData();
|
|
|
626 |
|
|
|
627 |
$application->points = $dataPost['points'];
|
|
|
628 |
$application->comment = $dataPost['comment'];
|
|
|
629 |
|
|
|
630 |
$result = $applicationMapper->update($application);
|
|
|
631 |
if ($result) {
|
|
|
632 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
633 |
$candidate = $candidateMapper->fetchOne($application->candidate_id);
|
|
|
634 |
|
|
|
635 |
|
|
|
636 |
$this->logger->info('Se actualizo los puntos y comentario de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
637 |
|
|
|
638 |
$data = [
|
|
|
639 |
'success' => true,
|
|
|
640 |
'data' => [
|
|
|
641 |
'message' => 'LABEL_RECORD_UPDATED',
|
|
|
642 |
'points' => $application->points ? intval($application->points, 10) : 0,
|
|
|
643 |
'comment' => $application->comment ? trim($application->comment) : '',
|
|
|
644 |
]
|
|
|
645 |
];
|
|
|
646 |
|
|
|
647 |
|
|
|
648 |
} else {
|
|
|
649 |
|
|
|
650 |
$data = [
|
|
|
651 |
'success' => false,
|
|
|
652 |
'data' => $applicationMapper->getError()
|
|
|
653 |
];
|
|
|
654 |
|
|
|
655 |
return new JsonModel($data);
|
|
|
656 |
}
|
|
|
657 |
|
|
|
658 |
|
|
|
659 |
} else {
|
|
|
660 |
$messages = [];
|
|
|
661 |
$form_messages = (array) $form->getMessages();
|
|
|
662 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
663 |
|
|
|
664 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
665 |
}
|
|
|
666 |
|
|
|
667 |
return new JsonModel([
|
|
|
668 |
'success' => false,
|
|
|
669 |
'data' => $messages
|
|
|
670 |
]);
|
|
|
671 |
}
|
|
|
672 |
|
|
|
673 |
|
|
|
674 |
} else {
|
|
|
675 |
$data = [
|
|
|
676 |
'success' => false,
|
|
|
677 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
678 |
];
|
|
|
679 |
|
|
|
680 |
return new JsonModel($data);
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
return new JsonModel($data);
|
|
|
684 |
}
|
|
|
685 |
|
|
|
686 |
|
|
|
687 |
public function statusAction()
|
|
|
688 |
{
|
|
|
689 |
$request = $this->getRequest();
|
|
|
690 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
691 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
692 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
693 |
|
|
|
694 |
$request = $this->getRequest();
|
|
|
695 |
$application_id = $this->params()->fromRoute('application_id');
|
|
|
696 |
|
|
|
697 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_id');
|
|
|
698 |
|
|
|
699 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
700 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
701 |
|
|
|
702 |
if(!$vacancy) {
|
|
|
703 |
$data = [
|
|
|
704 |
'success' => false,
|
|
|
705 |
'data' => 'ERROR_VACANCY_NOT_FOUND'
|
|
|
706 |
];
|
|
|
707 |
|
|
|
708 |
return new JsonModel($data);
|
|
|
709 |
}
|
|
|
710 |
|
|
|
711 |
|
|
|
712 |
if($vacancy->company_id != $currentCompany->id) {
|
|
|
713 |
$data = [
|
|
|
714 |
'success' => false,
|
|
|
715 |
'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
|
|
|
716 |
];
|
|
|
717 |
|
|
|
718 |
return new JsonModel($data);
|
|
|
719 |
}
|
|
|
720 |
|
|
|
721 |
|
|
|
722 |
|
|
|
723 |
$applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
|
|
|
724 |
$application = $applicationMapper->fetchOneByUuid($application_id);
|
|
|
725 |
|
|
|
726 |
|
|
|
727 |
if (!$application) {
|
|
|
728 |
$data = [
|
|
|
729 |
'success' => false,
|
|
|
730 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
731 |
];
|
|
|
732 |
|
|
|
733 |
return new JsonModel($data);
|
|
|
734 |
}
|
|
|
735 |
|
|
|
736 |
|
|
|
737 |
if ($application->vacancy_id != $vacancy->id) {
|
|
|
738 |
return new JsonModel([
|
|
|
739 |
'success' => false,
|
|
|
740 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
741 |
]);
|
|
|
742 |
}
|
|
|
743 |
|
|
|
744 |
|
|
|
745 |
if ($request->isGet()) {
|
|
|
746 |
|
|
|
747 |
$data = [
|
|
|
748 |
'success' => true,
|
|
|
749 |
'data' => [
|
|
|
750 |
'status' => $application->status
|
|
|
751 |
]
|
|
|
752 |
];
|
|
|
753 |
|
|
|
754 |
return new JsonModel($data);
|
|
|
755 |
|
|
|
756 |
|
|
|
757 |
|
|
|
758 |
} else if ($request->isPost()) {
|
|
|
759 |
|
|
|
760 |
|
|
|
761 |
$dataPost = $request->getPost()->toArray();
|
|
|
762 |
|
|
|
763 |
$form = new RecruitmentSelectionApplicationStatusForm();
|
|
|
764 |
$form->setData($dataPost);
|
|
|
765 |
|
|
|
766 |
if($form->isValid()) {
|
|
|
767 |
$dataPost = (array) $form->getData();
|
|
|
768 |
|
|
|
769 |
$application->status = $dataPost['status'];
|
|
|
770 |
|
|
|
771 |
$result = $applicationMapper->update($application);
|
|
|
772 |
if ($result) {
|
|
|
773 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
774 |
$candidate = $candidateMapper->fetchOne($application->candidate_id);
|
|
|
775 |
|
|
|
776 |
|
|
|
777 |
$this->logger->info('Se actualizo el estado de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
778 |
|
|
|
779 |
switch($application->status)
|
|
|
780 |
{
|
|
|
781 |
case RecruitmentSelectionApplication::STATUS_ACTIVE :
|
|
|
782 |
$status = 'LABEL_ACTIVE';
|
|
|
783 |
break;
|
|
|
784 |
|
|
|
785 |
|
|
|
786 |
case RecruitmentSelectionApplication::STATUS_INACTIVE :
|
|
|
787 |
$status = 'LABEL_INACTIVE';
|
|
|
788 |
break;
|
|
|
789 |
|
|
|
790 |
case RecruitmentSelectionApplication::STATUS_SELECTED :
|
|
|
791 |
$status = 'LABEL_SELECTED';
|
|
|
792 |
break;
|
|
|
793 |
|
|
|
794 |
case RecruitmentSelectionApplication::STATUS_REJECTED :
|
|
|
795 |
$status = 'LABEL_REJECTED';
|
|
|
796 |
break;
|
|
|
797 |
|
|
|
798 |
}
|
|
|
799 |
|
|
|
800 |
|
|
|
801 |
$data = [
|
|
|
802 |
'success' => true,
|
|
|
803 |
'data' => [
|
|
|
804 |
'message' => 'LABEL_RECORD_UPDATED',
|
|
|
805 |
'status' => $status
|
|
|
806 |
]
|
|
|
807 |
];
|
|
|
808 |
|
|
|
809 |
|
|
|
810 |
|
|
|
811 |
} else {
|
|
|
812 |
|
|
|
813 |
$data = [
|
|
|
814 |
'success' => false,
|
|
|
815 |
'data' => $applicationMapper->getError()
|
|
|
816 |
];
|
|
|
817 |
|
|
|
818 |
return new JsonModel($data);
|
|
|
819 |
}
|
|
|
820 |
|
|
|
821 |
|
|
|
822 |
} else {
|
|
|
823 |
$messages = [];
|
|
|
824 |
$form_messages = (array) $form->getMessages();
|
|
|
825 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
826 |
|
|
|
827 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
828 |
}
|
|
|
829 |
|
|
|
830 |
return new JsonModel([
|
|
|
831 |
'success' => false,
|
|
|
832 |
'data' => $messages
|
|
|
833 |
]);
|
|
|
834 |
}
|
|
|
835 |
|
|
|
836 |
|
|
|
837 |
} else {
|
|
|
838 |
$data = [
|
|
|
839 |
'success' => false,
|
|
|
840 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
841 |
];
|
|
|
842 |
|
|
|
843 |
return new JsonModel($data);
|
|
|
844 |
}
|
|
|
845 |
|
|
|
846 |
return new JsonModel($data);
|
|
|
847 |
}
|
|
|
848 |
|
|
|
849 |
|
|
|
850 |
public function levelAction()
|
|
|
851 |
{
|
|
|
852 |
$request = $this->getRequest();
|
|
|
853 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
854 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
855 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
856 |
|
|
|
857 |
$request = $this->getRequest();
|
|
|
858 |
$application_id = $this->params()->fromRoute('application_id');
|
|
|
859 |
|
|
|
860 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_id');
|
|
|
861 |
|
|
|
862 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
863 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
864 |
|
|
|
865 |
if(!$vacancy) {
|
|
|
866 |
$data = [
|
|
|
867 |
'success' => false,
|
|
|
868 |
'data' => 'ERROR_VACANCY_NOT_FOUND'
|
|
|
869 |
];
|
|
|
870 |
|
|
|
871 |
return new JsonModel($data);
|
|
|
872 |
}
|
|
|
873 |
|
|
|
874 |
|
|
|
875 |
if($vacancy->company_id != $currentCompany->id) {
|
|
|
876 |
$data = [
|
|
|
877 |
'success' => false,
|
|
|
878 |
'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
|
|
|
879 |
];
|
|
|
880 |
|
|
|
881 |
return new JsonModel($data);
|
|
|
882 |
}
|
|
|
883 |
|
|
|
884 |
|
|
|
885 |
|
|
|
886 |
$applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
|
|
|
887 |
$application = $applicationMapper->fetchOneByUuid($application_id);
|
|
|
888 |
|
|
|
889 |
|
|
|
890 |
if (!$application) {
|
|
|
891 |
$data = [
|
|
|
892 |
'success' => false,
|
|
|
893 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
894 |
];
|
|
|
895 |
|
|
|
896 |
return new JsonModel($data);
|
|
|
897 |
}
|
|
|
898 |
|
|
|
899 |
|
|
|
900 |
if ($application->vacancy_id != $vacancy->id) {
|
|
|
901 |
return new JsonModel([
|
|
|
902 |
'success' => false,
|
|
|
903 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
904 |
]);
|
|
|
905 |
}
|
|
|
906 |
|
|
|
907 |
|
|
|
908 |
if ($request->isGet()) {
|
|
|
909 |
|
|
|
910 |
$data = [
|
|
|
911 |
'success' => true,
|
|
|
912 |
'data' => [
|
|
|
913 |
'level' => $application->level
|
|
|
914 |
]
|
|
|
915 |
];
|
|
|
916 |
|
|
|
917 |
return new JsonModel($data);
|
|
|
918 |
|
|
|
919 |
|
|
|
920 |
|
|
|
921 |
} else if ($request->isPost()) {
|
|
|
922 |
|
|
|
923 |
|
|
|
924 |
$dataPost = $request->getPost()->toArray();
|
|
|
925 |
|
|
|
926 |
$form = new RecruitmentSelectionApplicationLevelForm();
|
|
|
927 |
$form->setData($dataPost);
|
|
|
928 |
|
|
|
929 |
if($form->isValid()) {
|
|
|
930 |
$dataPost = (array) $form->getData();
|
|
|
931 |
|
|
|
932 |
$application->level = $dataPost['level'];
|
|
|
933 |
|
|
|
934 |
$result = $applicationMapper->update($application);
|
|
|
935 |
if ($result) {
|
|
|
936 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
937 |
$candidate = $candidateMapper->fetchOne($application->candidate_id);
|
|
|
938 |
|
|
|
939 |
|
|
|
940 |
$this->logger->info('Se actualizo el nivel de la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
941 |
|
|
|
942 |
|
|
|
943 |
switch($application->level)
|
|
|
944 |
{
|
|
|
945 |
case RecruitmentSelectionApplication::LEVEL_CAPTURE :
|
|
|
946 |
$level = 'LABEL_CAPTURE';
|
|
|
947 |
break;
|
|
|
948 |
|
|
|
949 |
case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
|
|
|
950 |
$level = 'LABEL_PRE_SELECTION';
|
|
|
951 |
break;
|
|
|
952 |
|
|
|
953 |
case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
|
|
|
954 |
$level = 'LABEL_HUMAN_RESOURCE';
|
|
|
955 |
break;
|
|
|
956 |
|
|
|
957 |
case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
|
|
|
958 |
$level = 'LABEL_BOSS_INTERVIEW';
|
|
|
959 |
break;
|
|
|
960 |
|
|
|
961 |
case RecruitmentSelectionApplication::LEVEL_FINISHED :
|
|
|
962 |
$level = 'LABEL_FINISHED';
|
|
|
963 |
break;
|
|
|
964 |
|
|
|
965 |
default :
|
|
|
966 |
$level = 'LABEL_UNKNOWN';
|
|
|
967 |
break;
|
|
|
968 |
|
|
|
969 |
}
|
|
|
970 |
|
|
|
971 |
$data = [
|
|
|
972 |
'success' => true,
|
|
|
973 |
'data' => [
|
|
|
974 |
'message' => 'LABEL_RECORD_UPDATED',
|
|
|
975 |
'level' => $level
|
|
|
976 |
]
|
|
|
977 |
];
|
|
|
978 |
|
|
|
979 |
} else {
|
|
|
980 |
|
|
|
981 |
$data = [
|
|
|
982 |
'success' => false,
|
|
|
983 |
'data' => $applicationMapper->getError()
|
|
|
984 |
];
|
|
|
985 |
|
|
|
986 |
return new JsonModel($data);
|
|
|
987 |
}
|
|
|
988 |
|
|
|
989 |
|
|
|
990 |
} else {
|
|
|
991 |
$messages = [];
|
|
|
992 |
$form_messages = (array) $form->getMessages();
|
|
|
993 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
994 |
|
|
|
995 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
996 |
}
|
|
|
997 |
|
|
|
998 |
return new JsonModel([
|
|
|
999 |
'success' => false,
|
|
|
1000 |
'data' => $messages
|
|
|
1001 |
]);
|
|
|
1002 |
}
|
|
|
1003 |
|
|
|
1004 |
|
|
|
1005 |
} else {
|
|
|
1006 |
$data = [
|
|
|
1007 |
'success' => false,
|
|
|
1008 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1009 |
];
|
|
|
1010 |
|
|
|
1011 |
return new JsonModel($data);
|
|
|
1012 |
}
|
|
|
1013 |
|
|
|
1014 |
return new JsonModel($data);
|
|
|
1015 |
}
|
|
|
1016 |
|
|
|
1017 |
|
|
|
1018 |
public function deleteAction()
|
|
|
1019 |
{
|
|
|
1020 |
$request = $this->getRequest();
|
|
|
1021 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1022 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1023 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1024 |
|
|
|
1025 |
$request = $this->getRequest();
|
|
|
1026 |
$application_id = $this->params()->fromRoute('application_id');
|
|
|
1027 |
|
|
|
1028 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_id');
|
|
|
1029 |
|
|
|
1030 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
1031 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
1032 |
|
|
|
1033 |
if(!$vacancy) {
|
|
|
1034 |
$data = [
|
|
|
1035 |
'success' => false,
|
|
|
1036 |
'data' => 'ERROR_VACANCY_NOT_FOUND'
|
|
|
1037 |
];
|
|
|
1038 |
|
|
|
1039 |
return new JsonModel($data);
|
|
|
1040 |
}
|
|
|
1041 |
|
|
|
1042 |
|
|
|
1043 |
if($vacancy->company_id != $currentCompany->id) {
|
|
|
1044 |
$data = [
|
|
|
1045 |
'success' => false,
|
|
|
1046 |
'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
|
|
|
1047 |
];
|
|
|
1048 |
|
|
|
1049 |
return new JsonModel($data);
|
|
|
1050 |
}
|
|
|
1051 |
|
|
|
1052 |
|
|
|
1053 |
|
|
|
1054 |
$applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
|
|
|
1055 |
$application = $applicationMapper->fetchOneByUuid($application_id);
|
|
|
1056 |
|
|
|
1057 |
|
|
|
1058 |
if (!$application) {
|
|
|
1059 |
$data = [
|
|
|
1060 |
'success' => false,
|
|
|
1061 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
1062 |
];
|
|
|
1063 |
|
|
|
1064 |
return new JsonModel($data);
|
|
|
1065 |
}
|
|
|
1066 |
|
|
|
1067 |
|
|
|
1068 |
if ($application->vacancy_id != $vacancy->id) {
|
|
|
1069 |
return new JsonModel([
|
|
|
1070 |
'success' => false,
|
|
|
1071 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1072 |
]);
|
|
|
1073 |
}
|
|
|
1074 |
|
|
|
1075 |
|
|
|
1076 |
|
|
|
1077 |
if ($request->isPost()) {
|
|
|
1078 |
|
|
|
1079 |
$result = $applicationMapper->delete($application->id);
|
|
|
1080 |
if ($result) {
|
|
|
1081 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
1082 |
$candidate = $candidateMapper->fetchOne($application->candidate_id);
|
|
|
1083 |
|
|
|
1084 |
|
|
|
1085 |
|
|
|
1086 |
$this->logger->info('Se borro la aplicación : ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
1087 |
|
|
|
1088 |
$data = [
|
|
|
1089 |
'success' => true,
|
|
|
1090 |
'data' => 'LABEL_RECORD_DELETED'
|
|
|
1091 |
];
|
|
|
1092 |
} else {
|
|
|
1093 |
|
|
|
1094 |
$data = [
|
|
|
1095 |
'success' => false,
|
|
|
1096 |
'data' => $candidateMapper->getError()
|
|
|
1097 |
];
|
|
|
1098 |
|
|
|
1099 |
return new JsonModel($data);
|
|
|
1100 |
}
|
|
|
1101 |
} else {
|
|
|
1102 |
$data = [
|
|
|
1103 |
'success' => false,
|
|
|
1104 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1105 |
];
|
|
|
1106 |
|
|
|
1107 |
return new JsonModel($data);
|
|
|
1108 |
}
|
|
|
1109 |
|
|
|
1110 |
return new JsonModel($data);
|
|
|
1111 |
}
|
|
|
1112 |
|
|
|
1113 |
public function viewAction()
|
|
|
1114 |
{
|
|
|
1115 |
$request = $this->getRequest();
|
|
|
1116 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1117 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1118 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1119 |
|
|
|
1120 |
$request = $this->getRequest();
|
|
|
1121 |
$application_id = $this->params()->fromRoute('application_id');
|
|
|
1122 |
|
|
|
1123 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_id');
|
|
|
1124 |
|
|
|
1125 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
1126 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
1127 |
|
|
|
1128 |
if(!$vacancy) {
|
|
|
1129 |
$data = [
|
|
|
1130 |
'success' => false,
|
|
|
1131 |
'data' => 'ERROR_VACANCY_NOT_FOUND'
|
|
|
1132 |
];
|
|
|
1133 |
|
|
|
1134 |
return new JsonModel($data);
|
|
|
1135 |
}
|
|
|
1136 |
|
|
|
1137 |
|
|
|
1138 |
if($vacancy->company_id != $currentCompany->id) {
|
|
|
1139 |
$data = [
|
|
|
1140 |
'success' => false,
|
|
|
1141 |
'data' => 'ERROR_VACANCY_IS_OTHER_COMPANY',
|
|
|
1142 |
];
|
|
|
1143 |
|
|
|
1144 |
return new JsonModel($data);
|
|
|
1145 |
}
|
|
|
1146 |
|
|
|
1147 |
|
|
|
1148 |
|
|
|
1149 |
$applicationMapper = RecruitmentSelectionApplicationMapper::getInstance($this->adapter);
|
|
|
1150 |
$application = $applicationMapper->fetchOneByUuid($application_id);
|
|
|
1151 |
|
|
|
1152 |
|
|
|
1153 |
if (!$application) {
|
|
|
1154 |
$data = [
|
|
|
1155 |
'success' => false,
|
|
|
1156 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
1157 |
];
|
|
|
1158 |
|
|
|
1159 |
return new JsonModel($data);
|
|
|
1160 |
}
|
|
|
1161 |
|
|
|
1162 |
|
|
|
1163 |
if ($application->vacancy_id != $vacancy->id) {
|
|
|
1164 |
return new JsonModel([
|
|
|
1165 |
'success' => false,
|
|
|
1166 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1167 |
]);
|
|
|
1168 |
}
|
|
|
1169 |
|
|
|
1170 |
|
|
|
1171 |
|
|
|
1172 |
if ($request->isGet()) {
|
|
|
1173 |
|
|
|
1174 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
|
|
1175 |
$allowFile = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files');
|
|
|
1176 |
$allowFileAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/add');
|
|
|
1177 |
$allowFileDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/delete');
|
|
|
1178 |
$allowFileView = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/files/view');
|
|
|
1179 |
$allowInterview = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/interviews');
|
|
|
1180 |
$allowInterviewAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/interviews/add');
|
|
|
1181 |
$allowComment = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/comment');
|
|
|
1182 |
$allowLevel = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/level');
|
|
|
1183 |
$allowStatus = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/applications/status');
|
|
|
1184 |
|
|
|
1185 |
|
|
|
1186 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
1187 |
$candidate = $candidateMapper->fetchOne($application->candidate_id);
|
|
|
1188 |
|
|
|
1189 |
|
|
|
1190 |
switch($application->status)
|
|
|
1191 |
{
|
|
|
1192 |
case RecruitmentSelectionApplication::STATUS_ACTIVE :
|
|
|
1193 |
$status = 'LABEL_ACTIVE';
|
|
|
1194 |
break;
|
|
|
1195 |
|
|
|
1196 |
|
|
|
1197 |
case RecruitmentSelectionApplication::STATUS_INACTIVE :
|
|
|
1198 |
$status = 'LABEL_INACTIVE';
|
|
|
1199 |
break;
|
|
|
1200 |
|
|
|
1201 |
case RecruitmentSelectionApplication::STATUS_SELECTED :
|
|
|
1202 |
$status = 'LABEL_SELECTED';
|
|
|
1203 |
break;
|
|
|
1204 |
|
|
|
1205 |
case RecruitmentSelectionApplication::STATUS_REJECT :
|
|
|
1206 |
$status = 'LABEL_REJECTED';
|
|
|
1207 |
break;
|
|
|
1208 |
|
|
|
1209 |
}
|
|
|
1210 |
|
|
|
1211 |
switch($application->level)
|
|
|
1212 |
{
|
|
|
1213 |
case RecruitmentSelectionApplication::LEVEL_CAPTURE :
|
|
|
1214 |
$level = 'LABEL_CAPTURE';
|
|
|
1215 |
break;
|
|
|
1216 |
|
|
|
1217 |
case RecruitmentSelectionApplication::LEVEL_PRE_SELECTION :
|
|
|
1218 |
$level = 'LABEL_PRE_SELECTION';
|
|
|
1219 |
break;
|
|
|
1220 |
|
|
|
1221 |
case RecruitmentSelectionApplication::LEVEL_HUMAN_RESOURCE_INTERVIEW :
|
|
|
1222 |
$level = 'LABEL_HUMAN_RESOURCE';
|
|
|
1223 |
break;
|
|
|
1224 |
|
|
|
1225 |
case RecruitmentSelectionApplication::LEVEL_BOSS_RESOURCE_INTERVIEW :
|
|
|
1226 |
$level = 'LABEL_BOSS_INTERVIEW';
|
|
|
1227 |
break;
|
|
|
1228 |
|
|
|
1229 |
case RecruitmentSelectionApplication::LEVEL_FINISHED :
|
|
|
1230 |
$level = 'LABEL_FINISHED';
|
|
|
1231 |
break;
|
|
|
1232 |
|
|
|
1233 |
default :
|
|
|
1234 |
$level = 'LABEL_UNKNOWN';
|
|
|
1235 |
break;
|
|
|
1236 |
|
|
|
1237 |
}
|
|
|
1238 |
|
|
|
1239 |
$jobCategoryMapper = JobCategoryMapper::getInstance($this->adapter);
|
|
|
1240 |
$jobCategory = $jobCategoryMapper->fetchOne($vacancy->job_category_id);
|
|
|
1241 |
|
|
|
1242 |
$industryMapper = IndustryMapper::getInstance($this->adapter);
|
|
|
1243 |
$industry = $industryMapper->fetchOne($vacancy->industry_id);
|
|
|
1244 |
|
|
|
1245 |
|
|
|
1246 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
1247 |
$jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
|
|
|
1248 |
|
|
|
1249 |
|
|
|
1250 |
$locationMapper = LocationMapper::getInstance($this->adapter);
|
|
|
1251 |
$location = $locationMapper->fetchOne($vacancy->location_id);
|
|
|
1252 |
|
|
|
1253 |
|
|
|
1254 |
$dt = \DateTime::createFromFormat('Y-m-d', $vacancy->last_date);
|
|
|
1255 |
$last_date = $dt->format('d/m/Y');
|
|
|
1256 |
|
|
|
1257 |
|
|
|
1258 |
$recruitmentSelectionFileMapper = RecruitmentSelectionFileMapper::getInstance($this->adapter);
|
|
|
1259 |
|
|
|
1260 |
|
|
|
1261 |
$files = [];
|
16963 |
efrain |
1262 |
$records = $recruitmentSelectionFileMapper->fetchAllByVacancyIdAndApplicationId($vacancy->id, $application->id);
|
15461 |
efrain |
1263 |
foreach($records as $record)
|
|
|
1264 |
{
|
|
|
1265 |
array_push($files, [
|
|
|
1266 |
'name' => $record->name,
|
|
|
1267 |
'filename' => basename($record->file),
|
|
|
1268 |
'link_view' => $allowFileView ? $this->url()->fromRoute('recruitment-and-selection/applications/files/view', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]) : '',
|
|
|
1269 |
'link_delete' => $allowFileDelete ? $this->url()->fromRoute('recruitment-and-selection/applications/files/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]) : '',
|
|
|
1270 |
]);
|
|
|
1271 |
}
|
|
|
1272 |
|
|
|
1273 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1274 |
$interviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
1275 |
|
|
|
1276 |
|
|
|
1277 |
|
|
|
1278 |
|
|
|
1279 |
$interviews = [];
|
16968 |
efrain |
1280 |
$records = $interviewMapper->fetchAllByVacancyIdAndApplicationId($vacancy->id, $application->id);
|
15461 |
efrain |
1281 |
foreach($records as $record)
|
|
|
1282 |
{
|
|
|
1283 |
$status = '';
|
|
|
1284 |
switch($record->status)
|
|
|
1285 |
{
|
|
|
1286 |
case RecruitmentSelectionInterview::STATUS_ACCEPTED :
|
|
|
1287 |
$status = 'LABEL_ACCEPTED';
|
|
|
1288 |
$link_report = $this->url()->fromRoute('recruitment-and-selection/applications/interviews/report', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]);
|
|
|
1289 |
|
|
|
1290 |
break;
|
|
|
1291 |
|
|
|
1292 |
case RecruitmentSelectionInterview::STATUS_PENDING :
|
|
|
1293 |
$status = 'LABEL_PENDING';
|
|
|
1294 |
$link_report = '';
|
|
|
1295 |
break;
|
|
|
1296 |
|
|
|
1297 |
case RecruitmentSelectionInterview::STATUS_REJECTED :
|
|
|
1298 |
$status = 'LABEL_REJECTED';
|
|
|
1299 |
|
|
|
1300 |
$link_report = $this->url()->fromRoute('recruitment-and-selection/applications/interviews/report', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]);
|
|
|
1301 |
|
|
|
1302 |
break;
|
|
|
1303 |
|
|
|
1304 |
default :
|
|
|
1305 |
$status = 'LABEL_UNKNOWN';
|
|
|
1306 |
$link_report = '';
|
|
|
1307 |
break;
|
|
|
1308 |
|
|
|
1309 |
}
|
|
|
1310 |
|
|
|
1311 |
$type = '';
|
|
|
1312 |
switch($record->type)
|
|
|
1313 |
{
|
|
|
1314 |
case RecruitmentSelectionInterview::TYPE_BOSS :
|
|
|
1315 |
$type = 'LABEL_BOSS_INTERVIEW';
|
|
|
1316 |
break;
|
|
|
1317 |
|
|
|
1318 |
case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
|
|
|
1319 |
$type = 'LABEL_HUMAN_RESOURCE';
|
|
|
1320 |
break;
|
|
|
1321 |
|
|
|
1322 |
default :
|
|
|
1323 |
$type = 'LABEL_UNKNOWN';
|
|
|
1324 |
break;
|
|
|
1325 |
|
|
|
1326 |
}
|
|
|
1327 |
|
|
|
1328 |
$dt = \DateTime::createFromFormat('Y-m-d', $record->last_date);
|
|
|
1329 |
$last_date = $dt->format('d/m/Y');
|
|
|
1330 |
|
|
|
1331 |
|
|
|
1332 |
if($record->actual_date) {
|
|
|
1333 |
|
|
|
1334 |
$dt = \DateTime::createFromFormat('Y-m-d', $record->actual_date);
|
|
|
1335 |
$actual_date = $dt->format('d/m/Y');
|
|
|
1336 |
} else {
|
|
|
1337 |
$actual_date = '';
|
|
|
1338 |
}
|
|
|
1339 |
|
|
|
1340 |
$user = $userMapper->fetchOne($record->interviewer_id);
|
|
|
1341 |
$interviewer = $user->first_name . ' ' . $user->last_name . '(' . $user->email . ')';
|
|
|
1342 |
|
|
|
1343 |
|
|
|
1344 |
|
|
|
1345 |
|
|
|
1346 |
array_push($interviews, [
|
|
|
1347 |
'type' => $type,
|
|
|
1348 |
'status' => $status,
|
|
|
1349 |
'last_date' => $last_date,
|
|
|
1350 |
'actual_date' => $actual_date,
|
|
|
1351 |
'interviewer' => $interviewer,
|
|
|
1352 |
'points' => $record->points,
|
|
|
1353 |
'link_edit' => $this->url()->fromRoute('recruitment-and-selection/applications/interviews/edit', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]),
|
|
|
1354 |
'link_report' => $link_report,
|
|
|
1355 |
'link_delete' => $this->url()->fromRoute('recruitment-and-selection/applications/interviews/delete', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid, 'id' => $record->uuid]),
|
|
|
1356 |
|
|
|
1357 |
]);
|
|
|
1358 |
}
|
|
|
1359 |
|
|
|
1360 |
$data = [
|
|
|
1361 |
'success' => true,
|
|
|
1362 |
'data' => [
|
|
|
1363 |
'application' => [
|
|
|
1364 |
'first_name' => $candidate->first_name,
|
|
|
1365 |
'last_name' => $candidate->last_name,
|
|
|
1366 |
'email' => $candidate->email,
|
|
|
1367 |
'level' => $level,
|
|
|
1368 |
'status' => $status,
|
|
|
1369 |
'points' => $application->points,
|
|
|
1370 |
'comment' => $application->comment,
|
|
|
1371 |
],
|
|
|
1372 |
'vacancy' => [
|
|
|
1373 |
'name' => $vacancy->name,
|
|
|
1374 |
'last_date' => $last_date,
|
|
|
1375 |
'address' => $location->formatted_address,
|
|
|
1376 |
'industry' => $industry->name,
|
|
|
1377 |
'job_category' => $jobCategory->name,
|
|
|
1378 |
'job_description' => $jobDescription->name
|
|
|
1379 |
],
|
|
|
1380 |
'files' => $files,
|
|
|
1381 |
'interviews' => $interviews,
|
|
|
1382 |
'link_files' => $allowFile ? $this->url()->fromRoute('recruitment-and-selection/applications/files', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
|
|
|
1383 |
'link_files_add' => $allowFileAdd ? $this->url()->fromRoute('recruitment-and-selection/applications/files/add', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
|
|
|
1384 |
'interviews' => $interviews,
|
|
|
1385 |
'link_interviews' => $allowInterview ? $this->url()->fromRoute('recruitment-and-selection/applications/interviews', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
|
|
|
1386 |
'link_interviews_add' => $allowInterviewAdd ? $this->url()->fromRoute('recruitment-and-selection/applications/interviews/add', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
|
|
|
1387 |
'link_comment' => $allowComment ? $this->url()->fromRoute('recruitment-and-selection/applications/comment', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
|
|
|
1388 |
'link_level' => $allowLevel ? $this->url()->fromRoute('recruitment-and-selection/applications/level', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
|
|
|
1389 |
'link_status' => $allowStatus ? $this->url()->fromRoute('recruitment-and-selection/applications/status', ['vacancy_id' => $vacancy->uuid, 'application_id' => $application->uuid]) : '',
|
|
|
1390 |
|
|
|
1391 |
|
|
|
1392 |
|
|
|
1393 |
]
|
|
|
1394 |
];
|
|
|
1395 |
|
|
|
1396 |
return new JsonModel($data);
|
|
|
1397 |
} else {
|
|
|
1398 |
$data = [
|
|
|
1399 |
'success' => false,
|
|
|
1400 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1401 |
];
|
|
|
1402 |
|
|
|
1403 |
return new JsonModel($data);
|
|
|
1404 |
}
|
|
|
1405 |
|
|
|
1406 |
return new JsonModel($data);
|
|
|
1407 |
}
|
|
|
1408 |
|
|
|
1409 |
|
|
|
1410 |
|
|
|
1411 |
|
|
|
1412 |
|
|
|
1413 |
|
|
|
1414 |
|
|
|
1415 |
}
|