1709 |
eleazar |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
2667 |
eleazar |
8 |
use LeadersLinked\Library\InterviewPDF;
|
1709 |
eleazar |
9 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
10 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
11 |
use Laminas\Log\LoggerInterface;
|
|
|
12 |
use Laminas\View\Model\JsonModel;
|
|
|
13 |
use LeadersLinked\Form\RecruitmentSelectionInterviewFormForm;
|
8758 |
eleazar |
14 |
use LeadersLinked\Form\InterviewFileForm;
|
1828 |
eleazar |
15 |
use LeadersLinked\Form\JobDescriptionForm;
|
1829 |
eleazar |
16 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
|
|
17 |
use LeadersLinked\Library\Functions;
|
|
|
18 |
use LeadersLinked\Mapper\CompanyMapper;
|
|
|
19 |
use LeadersLinked\Mapper\CompetencyTypeMapper;
|
|
|
20 |
use LeadersLinked\Model\JobDescription;
|
|
|
21 |
use LeadersLinked\Mapper\CompetencyMapper;
|
4029 |
eleazar |
22 |
use LeadersLinked\Mapper\BehaviorCompetencyMapper;
|
|
|
23 |
use LeadersLinked\Model\BehaviorCompetency;
|
1829 |
eleazar |
24 |
use LeadersLinked\Library\JobPdf;
|
|
|
25 |
use LeadersLinked\Mapper\JobDescriptionCompetencyMapper;
|
|
|
26 |
use LeadersLinked\Mapper\JobDescriptionSubordinateMapper;
|
|
|
27 |
use LeadersLinked\Model\JobDescriptionCompetency;
|
|
|
28 |
use LeadersLinked\Model\JobDescriptionBehaviorCompetency;
|
|
|
29 |
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
|
|
|
30 |
use LeadersLinked\Model\JobDescriptionSubordinate;
|
|
|
31 |
use LeadersLinked\Mapper\BehaviorMapper;
|
|
|
32 |
use LeadersLinked\Model\Behavior;
|
|
|
33 |
use LeadersLinked\Model\Company;
|
1713 |
eleazar |
34 |
use LeadersLinked\Mapper\RecruitmentSelectionInterviewMapper;
|
8779 |
eleazar |
35 |
use LeadersLinked\Mapper\RecruitmentSelectionInterviewFileMapper;
|
1713 |
eleazar |
36 |
use LeadersLinked\Model\RecruitmentSelectionInterview;
|
8779 |
eleazar |
37 |
use LeadersLinked\Model\RecruitmentSelectionInterviewFile;
|
1713 |
eleazar |
38 |
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
|
|
|
39 |
use LeadersLinked\Model\RecruitmentSelectionVacancy;
|
|
|
40 |
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
|
|
|
41 |
use LeadersLinked\Model\RecruitmentSelectionCandidate;
|
|
|
42 |
use LeadersLinked\Mapper\JobDescriptionMapper;
|
1717 |
eleazar |
43 |
use Laminas\View\Model\ViewModel;
|
|
|
44 |
use LeadersLinked\Form\RecruitmentSelectionCandidateFormForm;
|
|
|
45 |
use Laminas\Hydrator\ArraySerializableHydrator;
|
|
|
46 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
47 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
48 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
49 |
use Laminas\Paginator\Paginator;
|
15030 |
efrain |
50 |
use LeadersLinked\Mapper\CompetencyBehaviorMapper;
|
1709 |
eleazar |
51 |
|
|
|
52 |
class RecruitmentSelectionInterviewFormController extends AbstractActionController {
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
*
|
|
|
56 |
* @var AdapterInterface
|
|
|
57 |
*/
|
|
|
58 |
private $adapter;
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
*
|
|
|
62 |
* @var AbstractAdapter
|
|
|
63 |
*/
|
|
|
64 |
private $cache;
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
*
|
|
|
68 |
* @var LoggerInterface
|
|
|
69 |
*/
|
|
|
70 |
private $logger;
|
|
|
71 |
|
|
|
72 |
/**
|
|
|
73 |
*
|
|
|
74 |
* @var array
|
|
|
75 |
*/
|
|
|
76 |
private $config;
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
*
|
|
|
80 |
* @param AdapterInterface $adapter
|
|
|
81 |
* @param AbstractAdapter $cache
|
|
|
82 |
* @param LoggerInterface $logger
|
|
|
83 |
* @param array $config
|
|
|
84 |
*/
|
|
|
85 |
public function __construct($adapter, $cache, $logger, $config) {
|
|
|
86 |
$this->adapter = $adapter;
|
|
|
87 |
$this->cache = $cache;
|
|
|
88 |
$this->logger = $logger;
|
|
|
89 |
$this->config = $config;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
public function indexAction() {
|
|
|
93 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
94 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
95 |
$currentCompany = $currentUserPlugin->getCompany();
|
3458 |
eleazar |
96 |
|
1709 |
eleazar |
97 |
$request = $this->getRequest();
|
3458 |
eleazar |
98 |
|
1709 |
eleazar |
99 |
if($request->isGet())
|
|
|
100 |
{
|
|
|
101 |
$headers = $request->getHeaders();
|
3458 |
eleazar |
102 |
|
1709 |
eleazar |
103 |
$isJson = false;
|
|
|
104 |
if($headers->has('Accept')) {
|
|
|
105 |
$accept = $headers->get('Accept');
|
3458 |
eleazar |
106 |
|
1709 |
eleazar |
107 |
$prioritized = $accept->getPrioritized();
|
3458 |
eleazar |
108 |
|
1709 |
eleazar |
109 |
foreach($prioritized as $key => $value) {
|
|
|
110 |
$raw = trim($value->getRaw());
|
3458 |
eleazar |
111 |
|
1709 |
eleazar |
112 |
if(!$isJson) {
|
|
|
113 |
$isJson = strpos($raw, 'json');
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
}
|
3458 |
eleazar |
117 |
|
2021 |
eleazar |
118 |
if ($isJson) {
|
4350 |
eleazar |
119 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
|
|
|
120 |
|
3458 |
eleazar |
121 |
$search = $this->params()->fromQuery('search', []);
|
|
|
122 |
$search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
|
|
|
123 |
|
15371 |
efrain |
124 |
$start = intval($this->params()->fromQuery('start', 0), 10);
|
3458 |
eleazar |
125 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
15371 |
efrain |
126 |
$page = intval($start / $records_x_page);
|
|
|
127 |
$page++;
|
|
|
128 |
|
3458 |
eleazar |
129 |
$order = $this->params()->fromQuery('order', []);
|
|
|
130 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
131 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
132 |
|
|
|
133 |
$fields = ['uuid', 'first_name', 'last_name', 'email'];
|
|
|
134 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
|
|
|
135 |
|
|
|
136 |
if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
137 |
$order_direction = 'ASC';
|
|
|
138 |
}
|
|
|
139 |
|
3536 |
eleazar |
140 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
|
|
141 |
$allowEdit = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/interview/form/edit');
|
|
|
142 |
$allowDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/interview/form/delete');
|
|
|
143 |
$allowReport = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/interview/report');
|
8781 |
eleazar |
144 |
$allowFile = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/interview/file');
|
3536 |
eleazar |
145 |
|
3484 |
eleazar |
146 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
147 |
$sql = $queryMapper->getSql();
|
3515 |
eleazar |
148 |
$select = $sql->select();
|
8884 |
eleazar |
149 |
$select->columns(['uuid', 'company_id', 'status', 'type', 'vacancy_id', 'points']);
|
3516 |
eleazar |
150 |
$select->from(['i' => RecruitmentSelectionInterviewMapper::_TABLE]);
|
3526 |
eleazar |
151 |
$select->join(['c' => RecruitmentSelectionCandidateMapper::_TABLE], "i.candidate_id = c.id", ['first_name', 'last_name', 'email']);
|
4361 |
eleazar |
152 |
$select->join(['v' => RecruitmentSelectionVacancyMapper::_TABLE],"c.vacancy_id = v.id", ['name', 'last_date']);
|
4360 |
eleazar |
153 |
$select->where->equalTo('i.company_id', $currentCompany->id);
|
4361 |
eleazar |
154 |
$select->where->equalTo('v.uuid', $vacancy_uuid);
|
12656 |
eleazar |
155 |
|
3887 |
eleazar |
156 |
// echo $select->getSqlString($this->adapter->platform); exit;
|
3458 |
eleazar |
157 |
|
3484 |
eleazar |
158 |
if($search) {
|
|
|
159 |
$select->where->nest()
|
|
|
160 |
->like('first_name', '%' . $search . '%')
|
|
|
161 |
->unnest();
|
|
|
162 |
}
|
3458 |
eleazar |
163 |
|
3484 |
eleazar |
164 |
$select->order($order_field . ' ' . $order_direction);
|
3458 |
eleazar |
165 |
|
3484 |
eleazar |
166 |
$hydrator = new ArraySerializableHydrator();
|
|
|
167 |
$resultset = new HydratingResultSet($hydrator);
|
|
|
168 |
|
4359 |
eleazar |
169 |
$adapter = new DbSelect($select, $sql, $resultset);
|
|
|
170 |
$paginator = new Paginator($adapter);
|
12658 |
eleazar |
171 |
|
|
|
172 |
$paginator->setItemCountPerPage($records_x_page);
|
|
|
173 |
$paginator->setCurrentPageNumber($page);
|
12660 |
eleazar |
174 |
$items = [];
|
|
|
175 |
$records = $paginator->getCurrentItems();
|
12662 |
eleazar |
176 |
|
3484 |
eleazar |
177 |
foreach ($records as $record) {
|
|
|
178 |
$params = [
|
7966 |
eleazar |
179 |
'vacancy_uuid' => $vacancy_uuid,
|
3537 |
eleazar |
180 |
'interview_uuid' => $record['uuid'],
|
3484 |
eleazar |
181 |
];
|
3536 |
eleazar |
182 |
|
|
|
183 |
$link_delete = $this->url()->fromRoute('recruitment-and-selection/interview/form/delete', $params);
|
|
|
184 |
|
|
|
185 |
$link_edit = $this->url()->fromRoute('recruitment-and-selection/interview/form/edit', $params);
|
3710 |
eleazar |
186 |
|
|
|
187 |
$link_report = $this->url()->fromRoute('recruitment-and-selection/interview/report', $params);
|
3536 |
eleazar |
188 |
|
8781 |
eleazar |
189 |
$link_file = $this->url()->fromRoute('recruitment-and-selection/interview/file', $params);
|
3484 |
eleazar |
190 |
|
|
|
191 |
$item = [
|
|
|
192 |
'uuid' => $record['uuid'],
|
|
|
193 |
'first_name' => $record['first_name'],
|
|
|
194 |
'last_name' => $record['last_name'],
|
|
|
195 |
'email' => $record['email'],
|
3882 |
eleazar |
196 |
'vacancy' =>$record['name'],
|
8886 |
eleazar |
197 |
'points' =>$record['points'],
|
3953 |
eleazar |
198 |
'last_date' =>$record['last_date'],
|
3543 |
eleazar |
199 |
'status' => $record['status'],
|
3561 |
eleazar |
200 |
'type' => $record['type'],
|
3484 |
eleazar |
201 |
// 'file' => $this->url()->fromRoute('storage', ['type' => 'recruitment_selection', 'code' => $record['uuid'], 'filename' => $record['file']]),
|
3536 |
eleazar |
202 |
'actions' => [
|
|
|
203 |
'link_edit' => $allowEdit ? $link_edit : '',
|
|
|
204 |
'link_delete' => $allowDelete ? $link_delete : '',
|
3710 |
eleazar |
205 |
'link_report' => $allowReport ? $link_report : '',
|
9395 |
eleazar |
206 |
'link_file' => $allowFile ? $link_file : '',
|
3536 |
eleazar |
207 |
]
|
3484 |
eleazar |
208 |
];
|
|
|
209 |
|
9414 |
eleazar |
210 |
if($record['type'] == 'r'){
|
|
|
211 |
$item['actions']['link_file'] = $allowFile ? $link_file : '';
|
|
|
212 |
} else{
|
|
|
213 |
$item['actions']['link_file'] = null;
|
|
|
214 |
}
|
|
|
215 |
|
3484 |
eleazar |
216 |
array_push($items, $item);
|
|
|
217 |
}
|
|
|
218 |
|
2029 |
eleazar |
219 |
return new JsonModel([
|
|
|
220 |
'success' => true,
|
2033 |
eleazar |
221 |
'data' => [
|
3528 |
eleazar |
222 |
'items' => $items,
|
|
|
223 |
'total' => $paginator->getTotalItemCount()
|
2033 |
eleazar |
224 |
],
|
2029 |
eleazar |
225 |
]);
|
1709 |
eleazar |
226 |
} else {
|
2199 |
eleazar |
227 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
2203 |
eleazar |
228 |
$vacancies = $vacancyMapper->fetchAllByCompanyId($currentCompany->id);
|
2211 |
eleazar |
229 |
|
|
|
230 |
$form = new RecruitmentSelectionInterviewFormForm($this->adapter, $currentCompany ? $currentCompany->id : null);
|
8757 |
eleazar |
231 |
$formFile = new InterviewFileForm($this->adapter, $currentCompany ? $currentCompany->id : null);
|
3458 |
eleazar |
232 |
|
1709 |
eleazar |
233 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
234 |
$viewModel = new ViewModel();
|
1718 |
eleazar |
235 |
$viewModel->setTemplate('leaders-linked/recruitment-and-selection-interview/index.phtml');
|
1709 |
eleazar |
236 |
$viewModel->setVariables([
|
2211 |
eleazar |
237 |
'form' => $form,
|
8757 |
eleazar |
238 |
'vacancies' => $vacancies,
|
|
|
239 |
'formFile' => $formFile
|
1709 |
eleazar |
240 |
]);
|
3458 |
eleazar |
241 |
|
1709 |
eleazar |
242 |
return $viewModel ;
|
|
|
243 |
}
|
3458 |
eleazar |
244 |
|
1709 |
eleazar |
245 |
} else {
|
|
|
246 |
return new JsonModel([
|
|
|
247 |
'success' => false,
|
|
|
248 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
249 |
]);
|
|
|
250 |
}
|
|
|
251 |
}
|
|
|
252 |
|
3571 |
eleazar |
253 |
public function addAction(){
|
1827 |
eleazar |
254 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
255 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
256 |
$currentCompany = $currentUserPlugin->getCompany();
|
1709 |
eleazar |
257 |
|
7964 |
eleazar |
258 |
$request = $this->getRequest();
|
7962 |
eleazar |
259 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
|
|
|
260 |
|
7961 |
eleazar |
261 |
if ($request->isPost()) {
|
2578 |
eleazar |
262 |
$dataPost = $request->getPost()->toArray();
|
7965 |
eleazar |
263 |
$dataPost['vacancy_uuid'] = $vacancy_uuid;
|
3458 |
eleazar |
264 |
|
2578 |
eleazar |
265 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
7962 |
eleazar |
266 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
2606 |
eleazar |
267 |
|
|
|
268 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
269 |
$candidate = $candidateMapper->fetchOneByUuid($dataPost['candidate_uuid']);
|
3458 |
eleazar |
270 |
|
2578 |
eleazar |
271 |
$form = new RecruitmentSelectionInterviewFormForm($this->adapter, $currentCompany->id, $vacancy->id);
|
1827 |
eleazar |
272 |
|
2574 |
eleazar |
273 |
$dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionInterview::STATUS_REJECTED;
|
3911 |
eleazar |
274 |
$dataPost['type'] = RecruitmentSelectionInterview::STATUS_HUMAN_RESOURCE;
|
2573 |
eleazar |
275 |
|
2572 |
eleazar |
276 |
$form->setData($dataPost);
|
|
|
277 |
|
1827 |
eleazar |
278 |
if ($form->isValid()) {
|
|
|
279 |
$dataPost = (array) $form->getData();
|
2603 |
eleazar |
280 |
|
2596 |
eleazar |
281 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
282 |
$recruitmentSelectionInterview = new RecruitmentSelectionInterview();
|
|
|
283 |
$hydrator->hydrate($dataPost, $recruitmentSelectionInterview);
|
1827 |
eleazar |
284 |
|
2597 |
eleazar |
285 |
if (!$recruitmentSelectionInterview->status) {
|
|
|
286 |
$recruitmentSelectionInterview->status = RecruitmentSelectionInterview::STATUS_REJECTED;
|
|
|
287 |
}
|
3458 |
eleazar |
288 |
|
2598 |
eleazar |
289 |
$recruitmentSelectionInterview->company_id = $currentCompany->id;
|
3458 |
eleazar |
290 |
$recruitmentSelectionInterview->vacancy_id = $vacancy->id;
|
|
|
291 |
$recruitmentSelectionInterview->candidate_id = $candidate->id;
|
2613 |
eleazar |
292 |
$recruitmentSelectionInterview->user_id = $currentUser->id;
|
3458 |
eleazar |
293 |
|
2599 |
eleazar |
294 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
3626 |
eleazar |
295 |
|
|
|
296 |
$interviews = $recruitmentSelectionInterviewMapper->fetchAllByCandidateIdAndVacancyId($candidate->id, $vacancy->id);
|
|
|
297 |
|
|
|
298 |
if (count($interviews) > 0) {
|
|
|
299 |
$hasHumanResourcesInterview = false;
|
|
|
300 |
|
|
|
301 |
foreach($interviews as $interview) {
|
|
|
302 |
if ($interview->type === RecruitmentSelectionInterview::STATUS_HUMAN_RESOURCE) {
|
|
|
303 |
$hasHumanResourcesInterview = true;
|
|
|
304 |
}
|
4199 |
eleazar |
305 |
if ($interview->type === RecruitmentSelectionInterview::STATUS_BOSS){
|
|
|
306 |
return new JsonModel([
|
|
|
307 |
'success' => false,
|
4202 |
eleazar |
308 |
'data' => 'LABEL_BOSS_DONE'
|
4199 |
eleazar |
309 |
]);
|
|
|
310 |
}
|
3626 |
eleazar |
311 |
}
|
|
|
312 |
|
|
|
313 |
$recruitmentSelectionInterview->type = $hasHumanResourcesInterview
|
|
|
314 |
? RecruitmentSelectionInterview::STATUS_BOSS
|
|
|
315 |
: RecruitmentSelectionInterview::STATUS_HUMAN_RESOURCE;
|
|
|
316 |
}
|
|
|
317 |
|
2600 |
eleazar |
318 |
$result = $recruitmentSelectionInterviewMapper->insert($recruitmentSelectionInterview);
|
7952 |
eleazar |
319 |
|
2588 |
eleazar |
320 |
|
1827 |
eleazar |
321 |
if ($result) {
|
2621 |
eleazar |
322 |
$this->logger->info('Se agrego la entrevista ' . $recruitmentSelectionInterview->id, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
3458 |
eleazar |
323 |
|
2622 |
eleazar |
324 |
// Get record by id
|
|
|
325 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
326 |
$record = $recruitmentSelectionInterviewMapper->fetchOne($recruitmentSelectionInterview->id);
|
|
|
327 |
|
3458 |
eleazar |
328 |
|
2504 |
eleazar |
329 |
if ($record) {
|
1827 |
eleazar |
330 |
|
2504 |
eleazar |
331 |
$data = [
|
|
|
332 |
'success' => true,
|
|
|
333 |
'id' => $record->id,
|
|
|
334 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
335 |
];
|
|
|
336 |
} else {
|
1827 |
eleazar |
337 |
|
2504 |
eleazar |
338 |
$data = [
|
|
|
339 |
'success' => false,
|
|
|
340 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
341 |
];
|
1827 |
eleazar |
342 |
}
|
|
|
343 |
} else {
|
|
|
344 |
$data = [
|
|
|
345 |
'success' => false,
|
2504 |
eleazar |
346 |
'data' => $recruitmentSelectionInterviewMapper->getError()
|
1827 |
eleazar |
347 |
];
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
return new JsonModel($data);
|
|
|
351 |
} else {
|
|
|
352 |
$messages = [];
|
|
|
353 |
$form_messages = (array) $form->getMessages();
|
|
|
354 |
foreach ($form_messages as $fieldname => $field_messages) {
|
1906 |
eleazar |
355 |
|
1827 |
eleazar |
356 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
return new JsonModel([
|
|
|
360 |
'success' => false,
|
|
|
361 |
'data' => $messages
|
|
|
362 |
]);
|
|
|
363 |
}
|
|
|
364 |
} else {
|
|
|
365 |
$data = [
|
|
|
366 |
'success' => false,
|
|
|
367 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
368 |
];
|
|
|
369 |
|
|
|
370 |
return new JsonModel($data);
|
|
|
371 |
}
|
|
|
372 |
|
|
|
373 |
return new JsonModel($data);
|
|
|
374 |
}
|
3458 |
eleazar |
375 |
|
3580 |
eleazar |
376 |
public function vacancyAction() {
|
3571 |
eleazar |
377 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
378 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
379 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
380 |
|
|
|
381 |
$request = $this->getRequest();
|
|
|
382 |
|
|
|
383 |
$vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
|
|
|
384 |
|
|
|
385 |
if ($request->isGet()) {
|
|
|
386 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
387 |
$vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
|
|
|
388 |
|
|
|
389 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
390 |
$jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
|
|
|
391 |
|
|
|
392 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
393 |
$jobDescriptionCompetencies = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($jobDescription->id);
|
|
|
394 |
|
|
|
395 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
15087 |
efrain |
396 |
$activeCandidates = $candidateMapper->fetchAllActive($vacancy->id);
|
3947 |
eleazar |
397 |
|
3571 |
eleazar |
398 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
399 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
15030 |
efrain |
400 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
3571 |
eleazar |
401 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
4342 |
eleazar |
402 |
|
3571 |
eleazar |
403 |
$data = [
|
4030 |
eleazar |
404 |
'candidates' => $activeCandidates,
|
3571 |
eleazar |
405 |
'job_description' => [
|
|
|
406 |
'uuid' => $jobDescription->uuid,
|
|
|
407 |
'name' => $jobDescription->name,
|
|
|
408 |
'functions' => $jobDescription->functions,
|
|
|
409 |
'objectives' => $jobDescription->objectives,
|
|
|
410 |
'competencies' => []
|
|
|
411 |
],
|
4341 |
eleazar |
412 |
'interview' => [
|
|
|
413 |
'type' => RecruitmentSelectionInterview::STATUS_HUMAN_RESOURCE,
|
|
|
414 |
'status' => RecruitmentSelectionInterview::STATUS_ACCEPTED,
|
|
|
415 |
'points' => 0,
|
|
|
416 |
'comment' => '',
|
|
|
417 |
],
|
3598 |
eleazar |
418 |
'vacancy' => $vacancy,
|
3571 |
eleazar |
419 |
];
|
|
|
420 |
|
|
|
421 |
foreach ($jobDescriptionCompetencies as $jobDescriptionCompetency) {
|
|
|
422 |
$competency = $competencyMapper->fetchOne($jobDescriptionCompetency->competency_id);
|
|
|
423 |
$competencyType = $competencyTypeMapper->fetchOne($competency->competency_type_id);
|
15030 |
efrain |
424 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
3571 |
eleazar |
425 |
|
|
|
426 |
$behaviors = [];
|
|
|
427 |
|
|
|
428 |
foreach ($behaviorCompetencies as $behaviorCompetency) {
|
|
|
429 |
$behavior = $behaviorMapper->fetchOne($behaviorCompetency->behavior_id);
|
|
|
430 |
|
|
|
431 |
$behaviors []= [
|
|
|
432 |
'uuid' => $behavior->uuid,
|
|
|
433 |
'description' => $behavior->description,
|
|
|
434 |
'points' => 0,
|
|
|
435 |
'comment' => '',
|
|
|
436 |
'competency_uuid' => $competency->uuid,
|
|
|
437 |
];
|
|
|
438 |
}
|
|
|
439 |
|
|
|
440 |
array_push($data['job_description']['competencies'], [
|
|
|
441 |
'competency_uuid' => $competency->uuid,
|
|
|
442 |
'competency_name' => $competency->name,
|
|
|
443 |
'competency_type_uuid' => $competencyType->uuid,
|
|
|
444 |
'competency_type_name' => $competencyType->name,
|
|
|
445 |
'behaviors' => $behaviors,
|
|
|
446 |
]);
|
|
|
447 |
}
|
|
|
448 |
|
|
|
449 |
return new JsonModel([
|
|
|
450 |
'success' => true,
|
|
|
451 |
'data' => $data
|
|
|
452 |
]);
|
|
|
453 |
|
|
|
454 |
} else {
|
|
|
455 |
return new JsonModel([
|
|
|
456 |
'success' => true,
|
|
|
457 |
'data' => 'ERROR_METHOD_NOT_ALLOWED',
|
|
|
458 |
]);
|
|
|
459 |
}
|
|
|
460 |
}
|
|
|
461 |
|
4367 |
eleazar |
462 |
public function typeAction(){
|
4365 |
eleazar |
463 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
464 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
465 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
466 |
|
|
|
467 |
$request = $this->getRequest();
|
|
|
468 |
|
|
|
469 |
$candidate_uuid = $this->params()->fromRoute('candidate_uuid');
|
|
|
470 |
|
4368 |
eleazar |
471 |
if(!$request->isGet()){
|
4365 |
eleazar |
472 |
return new JsonModel([
|
|
|
473 |
'success' => false,
|
|
|
474 |
'data' => 'ERROR_METHOD_NOT_ALLOWED',
|
|
|
475 |
]);
|
|
|
476 |
}
|
|
|
477 |
|
|
|
478 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
479 |
$candidate = $candidateMapper->fetchOneByUuid($candidate_uuid);
|
|
|
480 |
|
|
|
481 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
482 |
$vacancy = $vacancyMapper->fetchOne($candidate->vacancy_id);
|
|
|
483 |
|
|
|
484 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
485 |
$interviews = $recruitmentSelectionInterviewMapper->fetchAllByCandidateIdAndVacancyId($candidate->id, $vacancy->id);
|
8741 |
eleazar |
486 |
if (count($interviews) === 2){
|
8658 |
eleazar |
487 |
return new JsonModel([
|
|
|
488 |
'success' => true,
|
|
|
489 |
'data' => 'Este candidato completo su ciclo de entrevistas'
|
|
|
490 |
]);
|
8741 |
eleazar |
491 |
} else if(count($interviews) === 1){
|
8660 |
eleazar |
492 |
return new JsonModel([
|
|
|
493 |
'success' => true,
|
|
|
494 |
'data' => 'Entrevista por el Jefe' ,
|
|
|
495 |
]);
|
|
|
496 |
} else{
|
|
|
497 |
return new JsonModel([
|
|
|
498 |
'success' => true,
|
|
|
499 |
'data' => 'Entrevista por Recursos Humanos',
|
|
|
500 |
]);
|
8658 |
eleazar |
501 |
}
|
8654 |
eleazar |
502 |
|
4365 |
eleazar |
503 |
}
|
|
|
504 |
|
2126 |
efrain |
505 |
public function editAction() {
|
2757 |
eleazar |
506 |
$request = $this->getRequest();
|
|
|
507 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
508 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
509 |
$currentUser = $currentUserPlugin->getUser();
|
3458 |
eleazar |
510 |
|
2757 |
eleazar |
511 |
$request = $this->getRequest();
|
2668 |
eleazar |
512 |
$interview_uuid = $this->params()->fromRoute('interview_uuid');
|
2757 |
eleazar |
513 |
|
|
|
514 |
if (!$interview_uuid) {
|
|
|
515 |
$data = [
|
|
|
516 |
'success' => false,
|
|
|
517 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
518 |
];
|
|
|
519 |
|
|
|
520 |
return new JsonModel($data);
|
|
|
521 |
}
|
|
|
522 |
|
|
|
523 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
524 |
$interview = $recruitmentSelectionInterviewMapper->fetchOneByUuid($interview_uuid);
|
|
|
525 |
|
2838 |
eleazar |
526 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
527 |
$vacancy = $vacancyMapper->fetchOne($interview->vacancy_id);
|
|
|
528 |
|
2757 |
eleazar |
529 |
if(!$interview){
|
|
|
530 |
$data = [
|
|
|
531 |
'success' => false,
|
|
|
532 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
533 |
];
|
|
|
534 |
|
|
|
535 |
return new JsonModel($data);
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
if ($interview->company_id != $currentCompany->id) {
|
|
|
539 |
return new JsonModel([
|
|
|
540 |
'success' => false,
|
|
|
541 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
542 |
]);
|
|
|
543 |
}
|
|
|
544 |
|
|
|
545 |
if ($request->isPost()) {
|
2838 |
eleazar |
546 |
$form = new RecruitmentSelectionInterviewFormForm($this->adapter, $currentCompany->id, $vacancy->id);
|
2757 |
eleazar |
547 |
$dataPost = $request->getPost()->toArray();
|
8894 |
efrain |
548 |
$dataPost['vacancy_uuid'] = $vacancy->uuid;
|
2757 |
eleazar |
549 |
$dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionInterview::STATUS_REJECTED;
|
3632 |
eleazar |
550 |
$dataPost['type'] = $interview->type;
|
2757 |
eleazar |
551 |
|
|
|
552 |
$form->setData($dataPost);
|
|
|
553 |
|
|
|
554 |
if ($form->isValid()) {
|
|
|
555 |
$dataPost = (array) $form->getData();
|
|
|
556 |
|
|
|
557 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
558 |
$hydrator->hydrate($dataPost, $interview);
|
|
|
559 |
|
|
|
560 |
if (!$interview->status) {
|
|
|
561 |
$interview->status = RecruitmentSelectionInterview::STATUS_REJECTED;
|
|
|
562 |
}
|
|
|
563 |
|
2831 |
eleazar |
564 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
2837 |
eleazar |
565 |
$candidate = $candidateMapper->fetchOneByUuid($dataPost['candidate_uuid']);
|
3458 |
eleazar |
566 |
|
2831 |
eleazar |
567 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
2837 |
eleazar |
568 |
$vacancy = $vacancyMapper->fetchOneByUuid($dataPost['vacancy_uuid']);
|
2831 |
eleazar |
569 |
|
2757 |
eleazar |
570 |
$interview->company_id = $currentCompany->id;
|
3458 |
eleazar |
571 |
$interview->vacancy_id = $vacancy->id;
|
|
|
572 |
$interview->candidate_id = $candidate->id;
|
2757 |
eleazar |
573 |
$interview->user_id = $currentUser->id;
|
|
|
574 |
|
|
|
575 |
$result = $recruitmentSelectionInterviewMapper->update($interview);
|
|
|
576 |
|
3458 |
eleazar |
577 |
|
2757 |
eleazar |
578 |
if ($result) {
|
|
|
579 |
$this->logger->info('Se edito correctamente la entrevista' . $interview->id, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
580 |
$data = [
|
|
|
581 |
'success' => true,
|
|
|
582 |
'data' => 'LABEL_RECORD_UPDATED'
|
|
|
583 |
];
|
|
|
584 |
} else {
|
|
|
585 |
$data = [
|
|
|
586 |
'success' => false,
|
|
|
587 |
'data' => $recruitmentSelectionInterviewMapper->getError()
|
|
|
588 |
];
|
|
|
589 |
}
|
|
|
590 |
|
|
|
591 |
return new JsonModel($data);
|
|
|
592 |
} else {
|
|
|
593 |
$messages = [];
|
|
|
594 |
$form_messages = (array) $form->getMessages();
|
|
|
595 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
596 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
597 |
}
|
|
|
598 |
|
|
|
599 |
return new JsonModel([
|
|
|
600 |
'success' => false,
|
|
|
601 |
'data' => $messages
|
|
|
602 |
]);
|
|
|
603 |
}
|
|
|
604 |
} else if ($request->isGet()) {
|
|
|
605 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
606 |
|
2793 |
eleazar |
607 |
$candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
608 |
$candidate = $candidateMapper->fetchOne($interview->candidate_id);
|
3458 |
eleazar |
609 |
|
2793 |
eleazar |
610 |
$vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
611 |
$vacancy = $vacancyMapper->fetchOne($candidate->vacancy_id);
|
3458 |
eleazar |
612 |
|
2793 |
eleazar |
613 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
614 |
$jobDescription = $jobDescriptionMapper->fetchOne($vacancy->job_description_id);
|
3458 |
eleazar |
615 |
|
2793 |
eleazar |
616 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
617 |
$jobDescriptionCompetencies = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($jobDescription->id);
|
3458 |
eleazar |
618 |
|
2793 |
eleazar |
619 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
620 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
15030 |
efrain |
621 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
2793 |
eleazar |
622 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
623 |
|
2757 |
eleazar |
624 |
$data = [
|
2793 |
eleazar |
625 |
'candidate' => [
|
|
|
626 |
'uuid' => $candidate->uuid,
|
|
|
627 |
'first_name' => $candidate->first_name,
|
|
|
628 |
'last_name' => $candidate->last_name,
|
|
|
629 |
'email' => $candidate->email
|
3458 |
eleazar |
630 |
],
|
2793 |
eleazar |
631 |
'job_description' => [
|
|
|
632 |
'uuid' => $jobDescription->uuid,
|
|
|
633 |
'name' => $jobDescription->name,
|
3458 |
eleazar |
634 |
'functions' => $jobDescription->functions,
|
2793 |
eleazar |
635 |
'objectives' => $jobDescription->objectives,
|
|
|
636 |
'competencies' => []
|
3458 |
eleazar |
637 |
],
|
2793 |
eleazar |
638 |
'interview' => [
|
2757 |
eleazar |
639 |
'id' => $interview->uuid,
|
|
|
640 |
'status' => $interview->status,
|
|
|
641 |
'content' => $interview->content ? json_decode($interview->content) : [],
|
3458 |
eleazar |
642 |
'type' => $interview->type,
|
|
|
643 |
'status' => $interview->status,
|
|
|
644 |
'points' => $interview->points,
|
2757 |
eleazar |
645 |
'comment' => $interview->comment,
|
3634 |
eleazar |
646 |
],
|
|
|
647 |
'vacancy' => $vacancy,
|
2757 |
eleazar |
648 |
];
|
|
|
649 |
|
2793 |
eleazar |
650 |
foreach ($jobDescriptionCompetencies as $jobDescriptionCompetency) {
|
|
|
651 |
$competency = $competencyMapper->fetchOne($jobDescriptionCompetency->competency_id);
|
|
|
652 |
$competencyType = $competencyTypeMapper->fetchOne($competency->competency_type_id);
|
15030 |
efrain |
653 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
2793 |
eleazar |
654 |
|
|
|
655 |
$behaviors = [];
|
|
|
656 |
|
|
|
657 |
foreach ($behaviorCompetencies as $behaviorCompetency) {
|
|
|
658 |
$behavior = $behaviorMapper->fetchOne($behaviorCompetency->behavior_id);
|
3458 |
eleazar |
659 |
|
2853 |
eleazar |
660 |
$behaviors []= [
|
2793 |
eleazar |
661 |
'uuid' => $behavior->uuid,
|
|
|
662 |
'description' => $behavior->description,
|
|
|
663 |
'points' => 0,
|
2853 |
eleazar |
664 |
'comment' => '',
|
|
|
665 |
'competency_uuid' => $competency->uuid,
|
|
|
666 |
];
|
2793 |
eleazar |
667 |
}
|
|
|
668 |
|
|
|
669 |
array_push($data['job_description']['competencies'], [
|
|
|
670 |
'competency_uuid' => $competency->uuid,
|
|
|
671 |
'competency_name' => $competency->name,
|
|
|
672 |
'competency_type_uuid' => $competencyType->uuid,
|
|
|
673 |
'competency_type_name' => $competencyType->name,
|
|
|
674 |
'behaviors' => $behaviors,
|
|
|
675 |
]);
|
|
|
676 |
}
|
2830 |
eleazar |
677 |
|
2796 |
eleazar |
678 |
return new JsonModel([
|
|
|
679 |
'success' => true,
|
|
|
680 |
'data' => $data
|
|
|
681 |
]);
|
2757 |
eleazar |
682 |
} else {
|
|
|
683 |
$data = [
|
|
|
684 |
'success' => false,
|
|
|
685 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
686 |
];
|
|
|
687 |
|
|
|
688 |
return new JsonModel($data);
|
|
|
689 |
}
|
|
|
690 |
|
|
|
691 |
return new JsonModel($data);
|
2126 |
efrain |
692 |
}
|
1827 |
eleazar |
693 |
|
2747 |
eleazar |
694 |
public function deleteAction() {
|
2667 |
eleazar |
695 |
$request = $this->getRequest();
|
|
|
696 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
697 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
698 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
699 |
|
|
|
700 |
$request = $this->getRequest();
|
2789 |
eleazar |
701 |
$uuid = $this->params()->fromRoute('interview_uuid');
|
2667 |
eleazar |
702 |
|
|
|
703 |
if (!$uuid) {
|
|
|
704 |
$data = [
|
|
|
705 |
'success' => false,
|
|
|
706 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
707 |
];
|
|
|
708 |
|
|
|
709 |
return new JsonModel($data);
|
|
|
710 |
}
|
|
|
711 |
|
2754 |
eleazar |
712 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
713 |
$recruitmentSelectionInterview = $recruitmentSelectionInterviewMapper->fetchOneByUuid($uuid);
|
|
|
714 |
if (!$recruitmentSelectionInterview) {
|
2667 |
eleazar |
715 |
$data = [
|
|
|
716 |
'success' => false,
|
|
|
717 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
718 |
];
|
|
|
719 |
|
|
|
720 |
return new JsonModel($data);
|
|
|
721 |
}
|
|
|
722 |
|
2754 |
eleazar |
723 |
if ($recruitmentSelectionInterview->company_id != $currentCompany->id) {
|
2667 |
eleazar |
724 |
return new JsonModel([
|
|
|
725 |
'success' => false,
|
|
|
726 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
727 |
]);
|
|
|
728 |
}
|
|
|
729 |
|
|
|
730 |
if ($request->isPost()) {
|
|
|
731 |
|
2754 |
eleazar |
732 |
$result = $recruitmentSelectionInterviewMapper->delete($recruitmentSelectionInterview->id);
|
2667 |
eleazar |
733 |
if ($result) {
|
2755 |
eleazar |
734 |
$this->logger->info('Se borro la entrevista ' . $recruitmentSelectionInterview->uuid, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
2667 |
eleazar |
735 |
|
|
|
736 |
$data = [
|
|
|
737 |
'success' => true,
|
|
|
738 |
'data' => 'LABEL_RECORD_DELETED'
|
|
|
739 |
];
|
|
|
740 |
} else {
|
|
|
741 |
|
|
|
742 |
$data = [
|
|
|
743 |
'success' => false,
|
2754 |
eleazar |
744 |
'data' => $recruitmentSelectionInterviewMapper->getError()
|
2667 |
eleazar |
745 |
];
|
|
|
746 |
|
|
|
747 |
return new JsonModel($data);
|
|
|
748 |
}
|
|
|
749 |
} else {
|
|
|
750 |
$data = [
|
|
|
751 |
'success' => false,
|
|
|
752 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
753 |
];
|
|
|
754 |
|
|
|
755 |
return new JsonModel($data);
|
|
|
756 |
}
|
|
|
757 |
|
|
|
758 |
return new JsonModel($data);
|
|
|
759 |
}
|
2864 |
eleazar |
760 |
|
2667 |
eleazar |
761 |
public function reportAction() {
|
|
|
762 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
763 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
764 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
765 |
|
2880 |
eleazar |
766 |
$uuid = $this->params()->fromRoute('interview_uuid');
|
2667 |
eleazar |
767 |
|
2747 |
eleazar |
768 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
769 |
$recruitmentSelectionInterview = $recruitmentSelectionInterviewMapper->fetchOneByUuid($uuid);
|
2667 |
eleazar |
770 |
|
2747 |
eleazar |
771 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionvacancyMapper::getInstance($this->adapter);
|
|
|
772 |
$recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
|
|
|
773 |
|
|
|
774 |
|
|
|
775 |
if (!$recruitmentSelectionInterview) {
|
2667 |
eleazar |
776 |
return new JsonModel([
|
|
|
777 |
'success' => false,
|
|
|
778 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
|
|
779 |
]);
|
|
|
780 |
}
|
|
|
781 |
|
|
|
782 |
$request = $this->getRequest();
|
|
|
783 |
if ($request->isGet()) {
|
|
|
784 |
//Competencies
|
|
|
785 |
|
|
|
786 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
787 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
|
|
788 |
$competenceTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
15030 |
efrain |
789 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
2667 |
eleazar |
790 |
$jobDescriptionBehaviorCompetencyMapper = JobDescriptionBehaviorCompetencyMapper::getInstance($this->adapter);
|
|
|
791 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
792 |
|
|
|
793 |
$competencies = [];
|
|
|
794 |
|
2747 |
eleazar |
795 |
$jobDescriptionCompetency = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($recruitmentSelectionVacancy->job_description_id);
|
2667 |
eleazar |
796 |
|
3458 |
eleazar |
797 |
$content = json_decode($recruitmentSelectionInterview->content, true);
|
2898 |
eleazar |
798 |
|
2667 |
eleazar |
799 |
foreach ($jobDescriptionCompetency as $record) {
|
|
|
800 |
|
|
|
801 |
$competency = $competencyMapper->fetchOne($record->competency_id);
|
|
|
802 |
$competenceType = $competenceTypeMapper->fetchOne($competency->competency_type_id);
|
|
|
803 |
|
|
|
804 |
if ($competency && $competenceType) {
|
|
|
805 |
|
15030 |
efrain |
806 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
2667 |
eleazar |
807 |
$behaviors = [];
|
|
|
808 |
|
|
|
809 |
foreach ($behaviorCompetencies as $rows) {
|
|
|
810 |
|
|
|
811 |
$behavior = $behaviorMapper->fetchOne($rows->behavior_id);
|
2747 |
eleazar |
812 |
$jobDescriptionBehaviorCompetency = $jobDescriptionBehaviorCompetencyMapper->fetchOneByBehavior($recruitmentSelectionVacancy->job_description_id, $record->competency_id, $rows->behavior_id);
|
2667 |
eleazar |
813 |
|
|
|
814 |
if ($behavior && $jobDescriptionBehaviorCompetency) {
|
2898 |
eleazar |
815 |
$rowData = [
|
2667 |
eleazar |
816 |
'description' => $behavior->description,
|
|
|
817 |
'level' => $jobDescriptionBehaviorCompetency->level,
|
2898 |
eleazar |
818 |
'comment' => '',
|
4077 |
eleazar |
819 |
'evaluation' => '',
|
4040 |
eleazar |
820 |
|
2898 |
eleazar |
821 |
];
|
|
|
822 |
|
|
|
823 |
foreach($content as $eval) {
|
|
|
824 |
if ($eval['competencyUuid'] == $competency->uuid &&
|
|
|
825 |
$eval['behaviorUuid'] == $behavior->uuid) {
|
3458 |
eleazar |
826 |
|
2898 |
eleazar |
827 |
$rowData['comment'] = $eval['comment'];
|
4077 |
eleazar |
828 |
$rowData['evaluation'] = $eval['evaluation'];
|
4040 |
eleazar |
829 |
|
3458 |
eleazar |
830 |
|
2898 |
eleazar |
831 |
break;
|
|
|
832 |
}
|
|
|
833 |
}
|
|
|
834 |
|
|
|
835 |
$behaviors []= $rowData;
|
2667 |
eleazar |
836 |
}
|
|
|
837 |
}
|
|
|
838 |
|
|
|
839 |
array_push($competencies, [
|
|
|
840 |
'name' => $competency->name,
|
|
|
841 |
'description' => $competency->description,
|
|
|
842 |
'type' => $competenceType->name,
|
|
|
843 |
'behaviors' => $behaviors
|
|
|
844 |
]);
|
|
|
845 |
}
|
|
|
846 |
}
|
|
|
847 |
|
2747 |
eleazar |
848 |
return $this->renderPDF($currentCompany, $recruitmentSelectionInterview, $competencies);
|
2667 |
eleazar |
849 |
}
|
|
|
850 |
|
|
|
851 |
return new JsonModel([
|
|
|
852 |
'success' => false,
|
|
|
853 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
854 |
]);
|
2747 |
eleazar |
855 |
}
|
2667 |
eleazar |
856 |
|
|
|
857 |
/**
|
|
|
858 |
* Render PDF
|
|
|
859 |
* @param Company $currentCompany
|
2747 |
eleazar |
860 |
* @param recruitmentSelectionInterview $interviewEvaluation
|
2667 |
eleazar |
861 |
* @param array $competencies
|
|
|
862 |
* @return mixed
|
|
|
863 |
*/
|
15087 |
efrain |
864 |
public function renderPDF($company, $interviewEvaluation, $competencies) {
|
2667 |
eleazar |
865 |
|
3458 |
eleazar |
866 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
867 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
868 |
|
2667 |
eleazar |
869 |
//Generate New PDF
|
|
|
870 |
$pdf = new InterviewPDF();
|
|
|
871 |
|
15087 |
efrain |
872 |
$target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
|
|
|
873 |
|
|
|
874 |
$header = $company->header ? $target_path . DIRECTORY_SEPARATOR . $company->header : '';
|
|
|
875 |
if(empty($header) || !file_exists($header)) {
|
|
|
876 |
$header = $this->config['leaderslinked.images_default.company_pdf_header'];
|
2667 |
eleazar |
877 |
}
|
15087 |
efrain |
878 |
|
|
|
879 |
$footer = $company->footer ? $target_path . DIRECTORY_SEPARATOR . $company->footer : '';
|
|
|
880 |
if(empty($footer) || !file_exists($footer)) {
|
|
|
881 |
$footer = $this->config['leaderslinked.images_default.company_pdf_footer'];
|
|
|
882 |
}
|
|
|
883 |
|
|
|
884 |
$pdf->header = $header;
|
|
|
885 |
$pdf->footer = $footer;
|
|
|
886 |
|
2667 |
eleazar |
887 |
|
|
|
888 |
$pdf->SetMargins(10, 0, 10);
|
|
|
889 |
|
|
|
890 |
$pdf->AliasNbPages();
|
|
|
891 |
$pdf->AddPage();
|
|
|
892 |
|
2894 |
eleazar |
893 |
$recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
894 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
2747 |
eleazar |
895 |
$vacancy = $recruitmentSelectionVacancyMapper->fetchOne($interviewEvaluation->vacancy_id);
|
2894 |
eleazar |
896 |
$candidate = $recruitmentSelectionCandidateMapper->fetchOne($interviewEvaluation->candidate_id);
|
2667 |
eleazar |
897 |
|
4037 |
eleazar |
898 |
switch ($interviewEvaluation->type) {
|
4036 |
eleazar |
899 |
case "r":
|
4046 |
eleazar |
900 |
$type = "Recursos Humanos";
|
4036 |
eleazar |
901 |
break;
|
|
|
902 |
case "b":
|
4038 |
eleazar |
903 |
$type = "Jefe";
|
4036 |
eleazar |
904 |
break;
|
|
|
905 |
default :
|
|
|
906 |
$type = "ERROR";
|
|
|
907 |
break;
|
|
|
908 |
}
|
|
|
909 |
|
4247 |
eleazar |
910 |
switch ($interviewEvaluation->points) {
|
|
|
911 |
case "0":
|
|
|
912 |
$points = "Sugerir otro cargo";
|
|
|
913 |
break;
|
|
|
914 |
case "1":
|
|
|
915 |
$points = "25%";
|
|
|
916 |
break;
|
|
|
917 |
case "2":
|
|
|
918 |
$points = "50%";
|
|
|
919 |
break;
|
|
|
920 |
case "3":
|
|
|
921 |
$points = "75%";
|
|
|
922 |
break;
|
|
|
923 |
case "4":
|
|
|
924 |
$points = "100%";
|
|
|
925 |
break;
|
|
|
926 |
default :
|
|
|
927 |
$points = "ERROR";
|
|
|
928 |
break;
|
|
|
929 |
}
|
|
|
930 |
|
2667 |
eleazar |
931 |
$rows = [
|
|
|
932 |
array(
|
|
|
933 |
'title' => 'Nombre Evaluado: ',
|
3458 |
eleazar |
934 |
'content' => $candidate ? ' ' . $candidate->first_name . ' ' . $candidate->last_name : 'No Aplica'
|
2667 |
eleazar |
935 |
),
|
|
|
936 |
array(
|
|
|
937 |
'title' => 'Cargo: ',
|
2747 |
eleazar |
938 |
'content' => $vacancy ? ' ' . $vacancy->name : ' No aplica'
|
2667 |
eleazar |
939 |
),
|
|
|
940 |
array(
|
3458 |
eleazar |
941 |
'title' => 'Entrevistado por: ',
|
|
|
942 |
'content' => $currentUser ? ' ' . $currentUser->first_name . ' ' . $currentUser->last_name : ' No Aplica '
|
2667 |
eleazar |
943 |
),
|
|
|
944 |
array(
|
3458 |
eleazar |
945 |
'title' => 'Estatus del candidato: ',
|
4036 |
eleazar |
946 |
'content' => $type
|
2667 |
eleazar |
947 |
),
|
|
|
948 |
array(
|
3458 |
eleazar |
949 |
'title' => 'Comentarios del entrevistador: ',
|
|
|
950 |
'content' => $interviewEvaluation ? ' ' . $interviewEvaluation->comment : 'No Aplica'
|
2667 |
eleazar |
951 |
),
|
|
|
952 |
array(
|
3458 |
eleazar |
953 |
'title' => 'Porcentage de adaptibilidad ',
|
4247 |
eleazar |
954 |
'content' => $points
|
2667 |
eleazar |
955 |
)
|
|
|
956 |
];
|
|
|
957 |
|
2922 |
eleazar |
958 |
$pdf->borderTable('DATOS DE LA ENTREVISTA', $rows);
|
4050 |
eleazar |
959 |
|
|
|
960 |
$sections = json_decode($interviewEvaluation->content, true);
|
4052 |
eleazar |
961 |
/*
|
4050 |
eleazar |
962 |
for ($s = 0; $s < count($sections); $s++) {
|
|
|
963 |
|
|
|
964 |
$pdf->singleTable($sections[$s]['title'], [
|
|
|
965 |
array(
|
|
|
966 |
'content' => $sections[$s]['type'] != 'multiple' ? $sections[$s]['text'] : ''
|
|
|
967 |
)]);
|
|
|
968 |
|
|
|
969 |
if ($sections[$s]['type'] == 'multiple') {
|
|
|
970 |
|
|
|
971 |
$pdf->titleOptionTable($sections[$s]['text']);
|
|
|
972 |
|
|
|
973 |
for ($o = 0; $o < count($sections[$s]['options']); $o++) {
|
|
|
974 |
|
|
|
975 |
$pdf->optionTable($sections[$s]['options'][$o]['title']);
|
|
|
976 |
}
|
|
|
977 |
$pdf->Ln();
|
|
|
978 |
}
|
|
|
979 |
if ($s % 2 == 0 && $s > 1) {
|
|
|
980 |
$pdf->AddPage();
|
|
|
981 |
}
|
4052 |
eleazar |
982 |
}*/
|
4050 |
eleazar |
983 |
|
3458 |
eleazar |
984 |
// Competencies
|
2667 |
eleazar |
985 |
if (count($competencies) != 0) {
|
|
|
986 |
|
4053 |
eleazar |
987 |
// add new page
|
2667 |
eleazar |
988 |
|
|
|
989 |
$pdf->AddPage();
|
|
|
990 |
|
|
|
991 |
$competencies_header[] = array('content' => 'Indique el nivel de desempeño del evaluado en relación a sus conductas y actitudes frente a cada valor, según la clasificación siguiente:');
|
|
|
992 |
|
|
|
993 |
$pdf->singleTable('Anexo de valores:', $competencies_header);
|
|
|
994 |
|
|
|
995 |
|
|
|
996 |
// Add scale section
|
|
|
997 |
$pdf->sectionScale();
|
|
|
998 |
|
|
|
999 |
$i = 0;
|
4053 |
eleazar |
1000 |
|
|
|
1001 |
foreach ($competencies as $record) {
|
|
|
1002 |
|
|
|
1003 |
$i = $i + 1;
|
|
|
1004 |
|
|
|
1005 |
$pdf->competencyTable($i, $record);
|
|
|
1006 |
|
|
|
1007 |
if ($i % 3 == 0 && $i < count($competencies)) {
|
|
|
1008 |
$pdf->AddPage();
|
|
|
1009 |
}
|
|
|
1010 |
}
|
4029 |
eleazar |
1011 |
|
2893 |
eleazar |
1012 |
}
|
4027 |
eleazar |
1013 |
|
2667 |
eleazar |
1014 |
return $pdf->Output();
|
4027 |
eleazar |
1015 |
|
2864 |
eleazar |
1016 |
}
|
1709 |
eleazar |
1017 |
}
|