15461 |
efrain |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Controller;
|
|
|
5 |
|
|
|
6 |
use Laminas\Db\Adapter\AdapterInterface;
|
16768 |
efrain |
7 |
|
15461 |
efrain |
8 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
9 |
use Laminas\Log\LoggerInterface;
|
|
|
10 |
use Laminas\View\Model\JsonModel;
|
|
|
11 |
use Laminas\View\Model\ViewModel;
|
|
|
12 |
use LeadersLinked\Library\Functions;
|
|
|
13 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
14 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
15 |
use Laminas\Hydrator\ArraySerializableHydrator;
|
|
|
16 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
17 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
18 |
use Laminas\Paginator\Paginator;
|
|
|
19 |
use LeadersLinked\Form\RecruitmentSelection\RecruitmentSelectionTakeAnTestForm;
|
|
|
20 |
use Laminas\Mvc\I18n\Translator;
|
|
|
21 |
use LeadersLinked\Mapper\RecruitmentSelectionInterviewMapper;
|
|
|
22 |
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
|
|
|
23 |
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
|
|
|
24 |
use LeadersLinked\Model\RecruitmentSelectionInterview;
|
|
|
25 |
use LeadersLinked\Library\RecruitmentSelectionInterviewPDF;
|
16768 |
efrain |
26 |
use LeadersLinked\Cache\CacheInterface;
|
|
|
27 |
use LeadersLinked\Cache\CacheImpl;
|
15461 |
efrain |
28 |
|
|
|
29 |
class ActivityCenterRecruitmentSelectionController extends AbstractActionController
|
|
|
30 |
{
|
|
|
31 |
/**
|
|
|
32 |
*
|
16769 |
efrain |
33 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
15461 |
efrain |
34 |
*/
|
|
|
35 |
private $adapter;
|
16769 |
efrain |
36 |
|
15461 |
efrain |
37 |
/**
|
|
|
38 |
*
|
16769 |
efrain |
39 |
* @var \LeadersLinked\Cache\CacheInterface
|
15461 |
efrain |
40 |
*/
|
16769 |
efrain |
41 |
private $cache;
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
*
|
|
|
46 |
* @var \Laminas\Log\LoggerInterface
|
|
|
47 |
*/
|
15461 |
efrain |
48 |
private $logger;
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
*
|
|
|
52 |
* @var array
|
|
|
53 |
*/
|
|
|
54 |
private $config;
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
/**
|
16769 |
efrain |
58 |
*
|
|
|
59 |
* @var \Laminas\Mvc\I18n\Translator
|
15461 |
efrain |
60 |
*/
|
|
|
61 |
private $translator;
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
*
|
16769 |
efrain |
66 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
67 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
68 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
15461 |
efrain |
69 |
* @param array $config
|
16769 |
efrain |
70 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
15461 |
efrain |
71 |
*/
|
16769 |
efrain |
72 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
15461 |
efrain |
73 |
{
|
|
|
74 |
$this->adapter = $adapter;
|
16769 |
efrain |
75 |
$this->cache = $cache;
|
15461 |
efrain |
76 |
$this->logger = $logger;
|
|
|
77 |
$this->config = $config;
|
|
|
78 |
$this->translator = $translator;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public function indexAction()
|
|
|
82 |
{
|
|
|
83 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
84 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
85 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
$request = $this->getRequest();
|
|
|
92 |
|
|
|
93 |
if ($request->isGet()) {
|
|
|
94 |
|
|
|
95 |
$headers = $request->getHeaders();
|
|
|
96 |
|
|
|
97 |
$isJson = false;
|
|
|
98 |
if ($headers->has('Accept')) {
|
|
|
99 |
$accept = $headers->get('Accept');
|
|
|
100 |
|
|
|
101 |
$prioritized = $accept->getPrioritized();
|
|
|
102 |
|
|
|
103 |
foreach ($prioritized as $key => $value) {
|
|
|
104 |
$raw = trim($value->getRaw());
|
|
|
105 |
|
|
|
106 |
if (!$isJson) {
|
|
|
107 |
$isJson = strpos($raw, 'json');
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
if ($isJson) {
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
$data = [
|
|
|
117 |
'items' => [],
|
|
|
118 |
'total' => 0,
|
|
|
119 |
];
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
$search = $this->params()->fromQuery('search');
|
16766 |
efrain |
123 |
$search = empty($search['value']) ? '' : Functions::sanitizeFilterString($search['value']);
|
15461 |
efrain |
124 |
|
|
|
125 |
$start = intval($this->params()->fromQuery('start', 0), 10);
|
|
|
126 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
127 |
$page = intval($start / $records_x_page);
|
|
|
128 |
$page++;
|
|
|
129 |
|
|
|
130 |
$order = $this->params()->fromQuery('order', []);
|
|
|
131 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
16766 |
efrain |
132 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : Functions::sanitizeFilterString(filter_var($order[0]['dir']));
|
15461 |
efrain |
133 |
|
|
|
134 |
$fields = ['max_date'];
|
|
|
135 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
|
|
|
136 |
|
|
|
137 |
if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
138 |
$order_direction = 'ASC';
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
|
|
145 |
//$allowDelete = $acl->isAllowed($currentUser->usertype_id, 'performance-evaluation/evaluations/delete');
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
150 |
$sql = $queryMapper->getSql();
|
|
|
151 |
$select = $sql->select();
|
|
|
152 |
$select->columns([
|
|
|
153 |
'id',
|
|
|
154 |
'uuid',
|
|
|
155 |
'last_date',
|
|
|
156 |
'status',
|
|
|
157 |
'type',
|
|
|
158 |
'added_on',
|
|
|
159 |
'updated_on'
|
|
|
160 |
|
|
|
161 |
]);
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
$select->from(['tb1' => RecruitmentSelectionInterviewMapper::_TABLE]);
|
|
|
165 |
$select->join(['tb2' => RecruitmentSelectionVacancyMapper::_TABLE], 'tb1.vacancy_id = tb2.id ', ['vacancy' => 'name']);
|
|
|
166 |
$select->join(['tb3' => RecruitmentSelectionCandidateMapper::_TABLE], 'tb1.candidate_id = tb3.id ', ['first_name', 'last_name', 'email']);
|
|
|
167 |
|
|
|
168 |
$select->where->equalTo('tb1.company_id', $currentCompany->id);
|
|
|
169 |
$select->where->equalTo('tb1.interviewer_id', $currentUser->id);
|
|
|
170 |
|
|
|
171 |
if ($search) {
|
|
|
172 |
$select->where->nest()
|
|
|
173 |
->like('tb2.name', '%' . $search . '%')
|
|
|
174 |
->or->like('tb1.uuid', '%' . $search . '%')
|
|
|
175 |
->unnest();
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
$select->order('tb1.last_date DESC, tb2.name ASC');
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
$hydrator = new ArraySerializableHydrator();
|
|
|
184 |
$resultset = new HydratingResultSet($hydrator);
|
|
|
185 |
|
|
|
186 |
$adapter = new DbSelect($select, $sql, $resultset);
|
|
|
187 |
$paginator = new Paginator($adapter);
|
|
|
188 |
$paginator->setItemCountPerPage($records_x_page);
|
|
|
189 |
$paginator->setCurrentPageNumber($page);
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
$items = [];
|
|
|
194 |
$records = $paginator->getCurrentItems();
|
|
|
195 |
foreach ($records as $record)
|
|
|
196 |
{
|
|
|
197 |
|
|
|
198 |
$dt = \DateTime::createFromFormat('Y-m-d', $record['last_date']);
|
|
|
199 |
$last_date = $dt->format('d/m/Y');
|
|
|
200 |
|
|
|
201 |
switch($record['status'])
|
|
|
202 |
{
|
|
|
203 |
case RecruitmentSelectionInterview::STATUS_PENDING :
|
|
|
204 |
$status = 'LABEL_PENDING';
|
|
|
205 |
break;
|
|
|
206 |
|
|
|
207 |
case RecruitmentSelectionInterview::STATUS_ACCEPTED :
|
|
|
208 |
$status = 'LABEL_ACCEPTED';
|
|
|
209 |
break;
|
|
|
210 |
|
|
|
211 |
case RecruitmentSelectionInterview::STATUS_REJECTED :
|
|
|
212 |
$status = 'LABEL_REJECTED';
|
|
|
213 |
break;
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
default :
|
|
|
217 |
$status = 'LABEL_UNKNOW';
|
|
|
218 |
break;
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
switch($record['type'])
|
|
|
222 |
{
|
|
|
223 |
case RecruitmentSelectionInterview::TYPE_BOSS :
|
|
|
224 |
$type = 'LABEL_BOSS_INTERVIEW';
|
|
|
225 |
break;
|
|
|
226 |
|
|
|
227 |
case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
|
|
|
228 |
$type = 'LABEL_HUMAN_RESOURCE';
|
|
|
229 |
break;
|
|
|
230 |
|
|
|
231 |
default :
|
|
|
232 |
$type = 'LABEL_UNKNOWN';
|
|
|
233 |
break;
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
/*
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
'activities-center/recruitment-and-selection',
|
|
|
242 |
'activities-center/recruitment-and-selection/take-a-test',
|
|
|
243 |
'activities-center/recruitment-and-selection/report',
|
|
|
244 |
*/
|
|
|
245 |
|
|
|
246 |
if($record['status'] != RecruitmentSelectionInterview::STATUS_PENDING) {
|
|
|
247 |
$link_pdf = $this->url()->fromRoute('activities-center/recruitment-and-selection/report', ['id' => $record['uuid']]);
|
|
|
248 |
$link_take_a_test = '';
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
} else {
|
|
|
252 |
$link_pdf = '';
|
|
|
253 |
$link_take_a_test = $this->url()->fromRoute('activities-center/recruitment-and-selection/take-a-test', ['id' => $record['uuid']]);
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
$item = [
|
|
|
258 |
'last_date' => $last_date,
|
|
|
259 |
'vacancy' => $record['vacancy'],
|
|
|
260 |
'type' => $type,
|
|
|
261 |
'candidate' => $record['first_name'] . ' '. $record['last_name'],
|
|
|
262 |
|
|
|
263 |
'status' => $status,
|
|
|
264 |
'actions' => [
|
|
|
265 |
'link_pdf' => $link_pdf,
|
|
|
266 |
'link_take_a_test' => $link_take_a_test,
|
|
|
267 |
]
|
|
|
268 |
];
|
|
|
269 |
/*
|
|
|
270 |
if($testSelf) {
|
|
|
271 |
$item['actions']['link_report_self'] = $this->url()->fromRoute('performance-evaluation/evaluations/report-self', ['id' => $record['uuid'] ]);
|
|
|
272 |
} else{
|
|
|
273 |
$item['actions']['link_self'] = $this->url()->fromRoute('performance-evaluation/evaluations/self', ['id' => $record['uuid'] ]);
|
|
|
274 |
}
|
|
|
275 |
if($testBoth) {
|
|
|
276 |
$item['actions']['link_report_both'] = $this->url()->fromRoute('performance-evaluation/evaluations/report-both', ['id' => $record['uuid'] ]);
|
|
|
277 |
} else{
|
|
|
278 |
$item['actions']['link_both'] = $this->url()->fromRoute('performance-evaluation/evaluations/both', ['id' => $record['uuid'] ]);
|
|
|
279 |
}
|
|
|
280 |
if($testSupervisor) {
|
|
|
281 |
$item['actions']['link_report_superviser'] = $this->url()->fromRoute('performance-evaluation/evaluations/report-superviser', ['id' => $record['uuid'] ]);
|
|
|
282 |
} else{
|
|
|
283 |
$item['actions']['link_superviser'] = $this->url()->fromRoute('performance-evaluation/evaluations/superviser', ['id' => $record['uuid'] ]);
|
|
|
284 |
}*/
|
|
|
285 |
|
|
|
286 |
array_push($items, $item);
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
$data['items'] = $items;
|
|
|
290 |
$data['total'] = $paginator->getTotalItemCount();
|
|
|
291 |
|
|
|
292 |
|
|
|
293 |
return new JsonModel([
|
|
|
294 |
'success' => true,
|
|
|
295 |
'data' => $data
|
|
|
296 |
]);
|
|
|
297 |
} else {
|
|
|
298 |
if($this->cache->hasItem('ACTIVITY_CENTER_RELATIONAL')) {
|
|
|
299 |
$search = $this->cache->getItem('ACTIVITY_CENTER_RELATIONAL');
|
|
|
300 |
$this->cache->removeItem('ACTIVITY_CENTER_RELATIONAL');
|
|
|
301 |
} else {
|
|
|
302 |
$search = '';
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
$form = new RecruitmentSelectionTakeAnTestForm();
|
|
|
309 |
|
|
|
310 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
311 |
$viewModel = new ViewModel();
|
|
|
312 |
$viewModel->setTemplate('leaders-linked/activity-center-recruitment-and-selection/index.phtml');
|
|
|
313 |
$viewModel->setVariables([
|
|
|
314 |
'search' => $search,
|
|
|
315 |
'form' => $form
|
|
|
316 |
]);
|
|
|
317 |
return $viewModel;
|
|
|
318 |
}
|
|
|
319 |
} else {
|
|
|
320 |
return new JsonModel([
|
|
|
321 |
'success' => false,
|
|
|
322 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
323 |
]);
|
|
|
324 |
|
|
|
325 |
}
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
public function takeaTestAction()
|
|
|
330 |
{
|
|
|
331 |
$request = $this->getRequest();
|
|
|
332 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
333 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
334 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
335 |
|
|
|
336 |
$request = $this->getRequest();
|
|
|
337 |
$uuid = $this->params()->fromRoute('id');
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
if (!$uuid) {
|
|
|
341 |
$data = [
|
|
|
342 |
'success' => false,
|
|
|
343 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
344 |
];
|
|
|
345 |
|
|
|
346 |
return new JsonModel($data);
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
350 |
$recruitmentSelectionInterview = $recruitmentSelectionInterviewMapper->fetchOneByUuid($uuid);
|
|
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
|
356 |
if (!$recruitmentSelectionInterview) {
|
|
|
357 |
$data = [
|
|
|
358 |
'success' => false,
|
|
|
359 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
360 |
];
|
|
|
361 |
|
|
|
362 |
return new JsonModel($data);
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
if ($recruitmentSelectionInterview->company_id == $currentCompany->id) {
|
|
|
366 |
if($recruitmentSelectionInterview->interviewer_id != $currentUser->id) {
|
|
|
367 |
return new JsonModel([
|
|
|
368 |
'success' => false,
|
|
|
369 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
370 |
]);
|
|
|
371 |
|
|
|
372 |
}
|
|
|
373 |
}
|
|
|
374 |
|
|
|
375 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
376 |
$recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
$recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
380 |
$recruitmentSelectionCandidate = $recruitmentSelectionCandidateMapper->fetchOne($recruitmentSelectionInterview->candidate_id);
|
|
|
381 |
|
|
|
382 |
|
|
|
383 |
if ($request->isPost()) {
|
|
|
384 |
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
$dataPost = $request->getPost()->toArray();
|
|
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
|
391 |
$form = new RecruitmentSelectionTakeAnTestForm($this->adapter, $currentCompany->id);
|
|
|
392 |
$form->setData($dataPost);
|
|
|
393 |
|
|
|
394 |
if ($form->isValid()) {
|
|
|
395 |
|
|
|
396 |
switch( $recruitmentSelectionInterview->type)
|
|
|
397 |
{
|
|
|
398 |
case RecruitmentSelectionInterview::TYPE_BOSS :
|
|
|
399 |
$type = 'LABEL_BOSS_INTERVIEW';
|
|
|
400 |
break;
|
|
|
401 |
|
|
|
402 |
case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
|
|
|
403 |
$type = 'LABEL_HUMAN_RESOURCE';
|
|
|
404 |
break;
|
|
|
405 |
|
|
|
406 |
default :
|
|
|
407 |
$type = 'LABEL_UNKNOWN';
|
|
|
408 |
break;
|
|
|
409 |
}
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
$type = $this->translator->translate($type);
|
|
|
413 |
$dataPost = (array) $form->getData();
|
|
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
|
417 |
$content = json_decode($recruitmentSelectionVacancy->content);
|
|
|
418 |
$content->points = $dataPost['points'];
|
|
|
419 |
$content->comment = $dataPost['comment'];
|
|
|
420 |
$content->evaluation = [];
|
|
|
421 |
|
|
|
422 |
foreach($content->competencies_selected as $competency)
|
|
|
423 |
{
|
|
|
424 |
foreach($competency->behaviors as $behavior)
|
|
|
425 |
{
|
|
|
426 |
$key_comment = $competency->uuid . '-' . $behavior->uuid . '-comment';
|
|
|
427 |
$key_points = $competency->uuid . '-' . $behavior->uuid . '-points';
|
|
|
428 |
|
|
|
429 |
|
|
|
430 |
if(!empty($_POST[$key_comment])) {
|
16766 |
efrain |
431 |
$value_comment = Functions::sanitizeFilterString($_POST[$key_comment]);
|
15461 |
efrain |
432 |
} else {
|
|
|
433 |
$value_comment = '';
|
|
|
434 |
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
if(!empty($_POST[$key_points])) {
|
|
|
438 |
$value_points = intval( filter_var($_POST[$key_points], FILTER_SANITIZE_NUMBER_INT), 10);
|
|
|
439 |
} else {
|
|
|
440 |
$value_points = 0;
|
|
|
441 |
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
array_push($content->evaluation, [
|
|
|
445 |
'competency' => $competency->uuid,
|
|
|
446 |
'behavior' => $behavior->uuid,
|
|
|
447 |
'comment' => $value_comment,
|
|
|
448 |
'points' => $value_points
|
|
|
449 |
]);
|
|
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
}
|
|
|
455 |
}
|
|
|
456 |
|
|
|
457 |
|
|
|
458 |
$recruitmentSelectionInterview->status = $dataPost['status'];
|
|
|
459 |
$recruitmentSelectionInterview->content = json_encode($content);
|
|
|
460 |
|
|
|
461 |
$result = $recruitmentSelectionInterviewMapper->update($recruitmentSelectionInterview);
|
|
|
462 |
|
|
|
463 |
if ($result) {
|
|
|
464 |
$this->logger->info('Se agrego el entrevisa de : ' . $type . ' del candidato : ' . $recruitmentSelectionCandidate->first_name . ' ' . $recruitmentSelectionCandidate->last_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
465 |
$data = [
|
|
|
466 |
'success' => true,
|
|
|
467 |
'data' => 'LABEL_RECORD_UPDATED'
|
|
|
468 |
];
|
|
|
469 |
} else {
|
|
|
470 |
$data = [
|
|
|
471 |
'success' => false,
|
|
|
472 |
'data' => $recruitmentSelectionInterviewMapper->getError()
|
|
|
473 |
];
|
|
|
474 |
}
|
|
|
475 |
|
|
|
476 |
return new JsonModel($data);
|
|
|
477 |
} else {
|
|
|
478 |
$messages = [];
|
|
|
479 |
$form_messages = (array) $form->getMessages();
|
|
|
480 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
481 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
482 |
}
|
|
|
483 |
|
|
|
484 |
return new JsonModel([
|
|
|
485 |
'success' => false,
|
|
|
486 |
'data' => $messages
|
|
|
487 |
]);
|
|
|
488 |
}
|
|
|
489 |
} else if ($request->isGet()) {
|
|
|
490 |
|
|
|
491 |
switch( $recruitmentSelectionInterview->type)
|
|
|
492 |
{
|
|
|
493 |
case RecruitmentSelectionInterview::TYPE_BOSS :
|
|
|
494 |
$type = 'LABEL_BOSS_INTERVIEW';
|
|
|
495 |
break;
|
|
|
496 |
|
|
|
497 |
case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
|
|
|
498 |
$type = 'LABEL_HUMAN_RESOURCE';
|
|
|
499 |
break;
|
|
|
500 |
|
|
|
501 |
default :
|
|
|
502 |
$type = 'LABEL_UNKNOWN';
|
|
|
503 |
break;
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
$content = json_decode($recruitmentSelectionVacancy->content);
|
|
|
508 |
foreach($content->competencies_selected as &$competency)
|
|
|
509 |
{
|
|
|
510 |
foreach($competency->behaviors as &$behavior)
|
|
|
511 |
{
|
|
|
512 |
$behavior->competency_uuid = $competency->uuid;
|
|
|
513 |
}
|
|
|
514 |
}
|
|
|
515 |
|
|
|
516 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
517 |
$recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
|
|
|
518 |
|
|
|
519 |
$dt = \DateTime::createFromFormat('Y-m-d', $recruitmentSelectionInterview->last_date);
|
|
|
520 |
if($dt) {
|
|
|
521 |
$last_date = $dt->format('d/m/Y');
|
|
|
522 |
} else {
|
|
|
523 |
$last_date = '';
|
|
|
524 |
}
|
|
|
525 |
|
|
|
526 |
|
|
|
527 |
$data = [
|
|
|
528 |
'name' => $recruitmentSelectionVacancy->name,
|
|
|
529 |
'functions' => $content->functions,
|
|
|
530 |
'objectives' => $content->objectives,
|
|
|
531 |
'type' => $type,
|
|
|
532 |
'candidate' => $recruitmentSelectionCandidate->first_name . ' ' . $recruitmentSelectionCandidate->last_name,
|
|
|
533 |
'interviewer' => $currentUser->first_name . ' ' . $currentUser->last_name,
|
|
|
534 |
'last_date' => $last_date,
|
|
|
535 |
'competency_types' => [],
|
|
|
536 |
'competencies' => [],
|
|
|
537 |
'behaviors' => [],
|
|
|
538 |
'competencies_selected' => [],
|
|
|
539 |
'subordinates_selected' => [],
|
|
|
540 |
];
|
|
|
541 |
|
|
|
542 |
foreach($content->competency_types as $record)
|
|
|
543 |
{
|
|
|
544 |
array_push($data['competency_types'], $record);
|
|
|
545 |
}
|
|
|
546 |
|
|
|
547 |
foreach($content->competencies as $record)
|
|
|
548 |
{
|
|
|
549 |
array_push($data['competencies'], $record);
|
|
|
550 |
}
|
|
|
551 |
|
|
|
552 |
foreach($content->behaviors as $record)
|
|
|
553 |
{
|
|
|
554 |
array_push($data['behaviors'], $record);
|
|
|
555 |
}
|
|
|
556 |
|
|
|
557 |
foreach($content->competencies_selected as $record)
|
|
|
558 |
{
|
|
|
559 |
array_push($data['competencies_selected'], $record);
|
|
|
560 |
}
|
|
|
561 |
|
|
|
562 |
foreach($content->subordinates_selected as $record)
|
|
|
563 |
{
|
|
|
564 |
array_push($data['subordinates_selected'], $record);
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
|
|
|
568 |
|
|
|
569 |
$data = [
|
|
|
570 |
'success' => true,
|
|
|
571 |
'data' => $data
|
|
|
572 |
];
|
|
|
573 |
|
|
|
574 |
|
|
|
575 |
return new JsonModel($data);
|
|
|
576 |
} else {
|
|
|
577 |
$data = [
|
|
|
578 |
'success' => false,
|
|
|
579 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
580 |
];
|
|
|
581 |
|
|
|
582 |
return new JsonModel($data);
|
|
|
583 |
}
|
|
|
584 |
|
|
|
585 |
return new JsonModel($data);
|
|
|
586 |
}
|
|
|
587 |
|
|
|
588 |
public function reportAction()
|
|
|
589 |
{
|
|
|
590 |
$request = $this->getRequest();
|
|
|
591 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
592 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
593 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
594 |
|
|
|
595 |
$request = $this->getRequest();
|
|
|
596 |
$uuid = $this->params()->fromRoute('id');
|
|
|
597 |
|
|
|
598 |
if (!$uuid) {
|
|
|
599 |
$data = [
|
|
|
600 |
'success' => false,
|
|
|
601 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
602 |
];
|
|
|
603 |
|
|
|
604 |
return new JsonModel($data);
|
|
|
605 |
}
|
|
|
606 |
|
|
|
607 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
608 |
$recruitmentSelectionInterview = $recruitmentSelectionInterviewMapper->fetchOneByUuid($uuid);
|
|
|
609 |
if (!$recruitmentSelectionInterview) {
|
|
|
610 |
$data = [
|
|
|
611 |
'success' => false,
|
|
|
612 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
613 |
];
|
|
|
614 |
|
|
|
615 |
return new JsonModel($data);
|
|
|
616 |
}
|
|
|
617 |
|
|
|
618 |
|
|
|
619 |
if ($recruitmentSelectionInterview->company_id != $currentCompany->id) {
|
|
|
620 |
return new JsonModel([
|
|
|
621 |
'success' => false,
|
|
|
622 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
623 |
]);
|
|
|
624 |
}
|
|
|
625 |
|
|
|
626 |
if ($recruitmentSelectionInterview->interviewer_id != $currentUser->id ) {
|
|
|
627 |
return new JsonModel([
|
|
|
628 |
'success' => false,
|
|
|
629 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
630 |
]);
|
|
|
631 |
}
|
|
|
632 |
|
|
|
633 |
if($recruitmentSelectionInterview->status == RecruitmentSelectionInterview::STATUS_PENDING) {
|
|
|
634 |
return new JsonModel([
|
|
|
635 |
'success' => false,
|
|
|
636 |
'data' => 'ERROR_RECORD_IS_PENDING'
|
|
|
637 |
]);
|
|
|
638 |
|
|
|
639 |
}
|
|
|
640 |
|
|
|
641 |
|
|
|
642 |
|
|
|
643 |
$request = $this->getRequest();
|
|
|
644 |
if ($request->isGet()) {
|
|
|
645 |
|
|
|
646 |
switch( $recruitmentSelectionInterview->type)
|
|
|
647 |
{
|
|
|
648 |
case RecruitmentSelectionInterview::TYPE_BOSS :
|
|
|
649 |
$type = $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_TYPE_BOTH');
|
|
|
650 |
break;
|
|
|
651 |
|
|
|
652 |
case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
|
|
|
653 |
$type = $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_TYPE_HUMAN_RESOURCE');
|
|
|
654 |
break;
|
|
|
655 |
|
|
|
656 |
|
|
|
657 |
|
|
|
658 |
default :
|
|
|
659 |
$type = $this->translator->translate('LABEL_UNKNOWN');
|
|
|
660 |
break;
|
|
|
661 |
}
|
|
|
662 |
|
|
|
663 |
|
|
|
664 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
665 |
$recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
|
|
|
666 |
|
|
|
667 |
|
|
|
668 |
$recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
669 |
$recruitmentSelectionCandidate = $recruitmentSelectionCandidateMapper->fetchOne($recruitmentSelectionInterview->candidate_id);
|
|
|
670 |
|
|
|
671 |
$filename = $recruitmentSelectionVacancy->name . '-' . trim($recruitmentSelectionCandidate->first_name) . '-' . trim($recruitmentSelectionCandidate->last_name) . '-' . $type . '-' . date('Y-m-d H:i a') . '.pdf';
|
|
|
672 |
|
|
|
673 |
$filename = Functions::normalizeStringFilename( $filename );
|
|
|
674 |
|
|
|
675 |
|
|
|
676 |
|
|
|
677 |
|
|
|
678 |
$content = base64_encode($this->renderPDF($recruitmentSelectionInterview));
|
|
|
679 |
$data = [
|
|
|
680 |
'success' => true,
|
|
|
681 |
'data' => [
|
|
|
682 |
'basename' => $filename,
|
|
|
683 |
'content' => $content
|
|
|
684 |
]
|
|
|
685 |
];
|
|
|
686 |
|
|
|
687 |
return new JsonModel($data);
|
|
|
688 |
|
|
|
689 |
/*
|
|
|
690 |
|
|
|
691 |
$content = $this->renderPdf($currentCompany, $jobDescription);
|
|
|
692 |
$response = new Response();
|
|
|
693 |
$response->setStatusCode(200);
|
|
|
694 |
$response->setContent($content);
|
|
|
695 |
|
|
|
696 |
|
|
|
697 |
|
|
|
698 |
$headers = $response->getHeaders();
|
|
|
699 |
$headers->clearHeaders();
|
|
|
700 |
|
|
|
701 |
$headers->addHeaderLine('Content-Description: File Transfer');
|
|
|
702 |
$headers->addHeaderLine('Content-Type: application/pdf');
|
|
|
703 |
//$headers->addHeaderLine('Content-Disposition: attachment; filename=' . $filename);
|
|
|
704 |
$headers->addHeaderLine('Content-Transfer-Encoding: binary');
|
|
|
705 |
$headers->addHeaderLine('Expires: 0');
|
|
|
706 |
$headers->addHeaderLine('Cache-Control: must-revalidate');
|
|
|
707 |
$headers->addHeaderLine('Pragma: public');
|
|
|
708 |
return $response;
|
|
|
709 |
*/
|
|
|
710 |
|
|
|
711 |
|
|
|
712 |
|
|
|
713 |
|
|
|
714 |
return ;
|
|
|
715 |
} else {
|
|
|
716 |
|
|
|
717 |
|
|
|
718 |
return new JsonModel([
|
|
|
719 |
'success' => false,
|
|
|
720 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
721 |
]);
|
|
|
722 |
}
|
|
|
723 |
}
|
|
|
724 |
|
|
|
725 |
/**
|
|
|
726 |
* Render PDF
|
|
|
727 |
* @param RecruitmentSelectionInterview $recruitmentSelectionInterview
|
|
|
728 |
|
|
|
729 |
* @return mixed
|
|
|
730 |
*/
|
|
|
731 |
private function renderPDF($recruitmentSelectionInterview)
|
|
|
732 |
{
|
|
|
733 |
$request = $this->getRequest();
|
|
|
734 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
735 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
736 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
737 |
|
|
|
738 |
|
|
|
739 |
//Generate New PDF
|
|
|
740 |
$pdf = new RecruitmentSelectionInterviewPDF();
|
|
|
741 |
|
|
|
742 |
$target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $currentCompany->uuid;
|
|
|
743 |
$header = $currentCompany->header ? $target_path . DIRECTORY_SEPARATOR . $currentCompany->header : '';
|
|
|
744 |
if (empty($header) || !file_exists($header)) {
|
|
|
745 |
$header = $this->config['leaderslinked.images_default.company_pdf_header'];
|
|
|
746 |
}
|
|
|
747 |
|
|
|
748 |
$footer = $currentCompany->footer ? $target_path . DIRECTORY_SEPARATOR . $currentCompany->footer : '';
|
|
|
749 |
if (empty($footer) || !file_exists($footer)) {
|
|
|
750 |
$footer = $this->config['leaderslinked.images_default.company_pdf_footer'];
|
|
|
751 |
}
|
|
|
752 |
|
|
|
753 |
$content = json_decode($recruitmentSelectionInterview->content);
|
|
|
754 |
|
|
|
755 |
$pdf->header = $header;
|
|
|
756 |
$pdf->footer = $footer;
|
|
|
757 |
$pdf->translator = $this->translator;
|
|
|
758 |
|
|
|
759 |
$pdf->SetMargins(10, 0, 10);
|
|
|
760 |
|
|
|
761 |
$pdf->AliasNbPages();
|
|
|
762 |
$pdf->AddPage();
|
|
|
763 |
|
|
|
764 |
switch( $recruitmentSelectionInterview->type)
|
|
|
765 |
{
|
|
|
766 |
case RecruitmentSelectionInterview::TYPE_BOSS :
|
|
|
767 |
$type = $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_TYPE_BOTH');
|
|
|
768 |
break;
|
|
|
769 |
|
|
|
770 |
case RecruitmentSelectionInterview::TYPE_HUMAN_RESOURCE :
|
|
|
771 |
$type = $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_TYPE_HUMAN_RESOURCE');
|
|
|
772 |
break;
|
|
|
773 |
|
|
|
774 |
|
|
|
775 |
|
|
|
776 |
default :
|
|
|
777 |
$type = $this->translator->translate('LABEL_UNKNOWN');
|
|
|
778 |
break;
|
|
|
779 |
}
|
|
|
780 |
|
|
|
781 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $recruitmentSelectionInterview->updated_on);
|
|
|
782 |
|
|
|
783 |
|
|
|
784 |
|
|
|
785 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
786 |
$recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
|
|
|
787 |
|
|
|
788 |
|
|
|
789 |
$recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
790 |
$recruitmentSelectionCandidate = $recruitmentSelectionCandidateMapper->fetchOne($recruitmentSelectionInterview->candidate_id);
|
|
|
791 |
|
|
|
792 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
793 |
$user = $userMapper->fetchOne($recruitmentSelectionInterview->interviewer_id);
|
|
|
794 |
if($user) {
|
|
|
795 |
$interviewer = ucwords(strtolower(trim($user->first_name . ' ' . $user->last_name)));
|
|
|
796 |
|
|
|
797 |
}
|
|
|
798 |
if($recruitmentSelectionCandidate) {
|
|
|
799 |
$candidate = ucwords(strtolower(trim($recruitmentSelectionCandidate->first_name . ' ' . $recruitmentSelectionCandidate->last_name)));
|
|
|
800 |
|
|
|
801 |
}
|
|
|
802 |
|
|
|
803 |
$rows = [
|
|
|
804 |
[
|
|
|
805 |
'title' => $this->translator->translate('LABEL_TYPE') . ' : ',
|
|
|
806 |
'content' => $type,
|
|
|
807 |
],
|
|
|
808 |
[
|
|
|
809 |
'title' => $this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_POSITION') . ' : ',
|
|
|
810 |
'content' => $recruitmentSelectionVacancy->name,
|
|
|
811 |
],
|
|
|
812 |
[
|
|
|
813 |
'title' => $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_CANDIDATE') . ' : ',
|
16768 |
efrain |
814 |
'content' => Functions::utf8_decode($candidate),
|
15461 |
efrain |
815 |
],
|
|
|
816 |
|
|
|
817 |
[
|
|
|
818 |
'title' => $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_CANDIDATE_SIGNATURE') . ' : ',
|
|
|
819 |
'content' => ''
|
|
|
820 |
],
|
|
|
821 |
[
|
|
|
822 |
'title' => $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_INTERVIEWER') . ' : ',
|
16768 |
efrain |
823 |
'content' => Functions::utf8_decode($interviewer),
|
15461 |
efrain |
824 |
],
|
|
|
825 |
[
|
|
|
826 |
'title' => $this->translator->translate('LABEL_PDF_RECRUITMENT_AND_SELECTION_INTERVIEWER_SIGNATURE') . ' : ',
|
|
|
827 |
'content' => ''
|
|
|
828 |
],
|
|
|
829 |
[
|
|
|
830 |
'title' => $this->translator->translate('LABEL_DATE'),
|
|
|
831 |
'content' => $dt->format('d/m/Y H:i a')
|
|
|
832 |
]
|
|
|
833 |
];
|
|
|
834 |
|
|
|
835 |
|
|
|
836 |
|
|
|
837 |
|
|
|
838 |
|
|
|
839 |
$pdf->borderTable($this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_TITLE'), $rows);
|
|
|
840 |
|
|
|
841 |
switch( $recruitmentSelectionInterview->status)
|
|
|
842 |
{
|
|
|
843 |
case RecruitmentSelectionInterview::STATUS_ACCEPTED :
|
|
|
844 |
$status = $this->translator->translate('LABEL_ACCEPTED');
|
|
|
845 |
break;
|
|
|
846 |
|
|
|
847 |
case RecruitmentSelectionInterview::STATUS_REJECTED :
|
|
|
848 |
$status = $this->translator->translate('LABEL_REJECTED');
|
|
|
849 |
break;
|
|
|
850 |
|
|
|
851 |
|
|
|
852 |
|
|
|
853 |
default :
|
|
|
854 |
$status = $this->translator->translate('LABEL_UNKNOWN');
|
|
|
855 |
break;
|
|
|
856 |
}
|
|
|
857 |
|
|
|
858 |
|
|
|
859 |
$pdf->evaluationTable($status, $content->comment, $content->points);
|
|
|
860 |
|
|
|
861 |
|
|
|
862 |
|
|
|
863 |
// Competencies
|
|
|
864 |
if ($content->competencies_selected) {
|
|
|
865 |
$pdf->AddPage();
|
|
|
866 |
|
|
|
867 |
$i = 0;
|
|
|
868 |
|
|
|
869 |
$max = count($content->competencies_selected);
|
|
|
870 |
for($i = 0; $i < $max; $i++)
|
|
|
871 |
{
|
|
|
872 |
$competency_selected = $content->competencies_selected[$i];
|
|
|
873 |
|
|
|
874 |
$j = $i + 1;
|
|
|
875 |
$last = $j == $max;
|
|
|
876 |
$pdf->competencyTable($i, $competency_selected, $content->competencies, $content->competency_types, $content->behaviors, $content->evaluation, $last);
|
|
|
877 |
}
|
|
|
878 |
|
|
|
879 |
}
|
|
|
880 |
|
|
|
881 |
return $pdf->Output('S');
|
|
|
882 |
}
|
|
|
883 |
}
|