1384 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
8 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
9 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
10 |
use Laminas\Log\LoggerInterface;
|
|
|
11 |
use Laminas\View\Model\ViewModel;
|
|
|
12 |
use Laminas\View\Model\JsonModel;
|
7778 |
eleazar |
13 |
use LeadersLinked\Library\Functions;
|
1384 |
efrain |
14 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
15 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
16 |
use Laminas\Hydrator\ArraySerializableHydrator;
|
|
|
17 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
18 |
use Laminas\Paginator\Adapter\DbSelect;
|
8169 |
eleazar |
19 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
1384 |
efrain |
20 |
use Laminas\Paginator\Paginator;
|
|
|
21 |
use LeadersLinked\Mapper\CompanyPerformanceEvaluationFormMapper;
|
|
|
22 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
8100 |
eleazar |
23 |
use LeadersLinked\Mapper\JobDescriptionMapper;
|
8101 |
eleazar |
24 |
use LeadersLinked\Mapper\CompetencyTypeMapper;
|
|
|
25 |
use LeadersLinked\Mapper\CompetencyMapper;
|
|
|
26 |
use LeadersLinked\Mapper\JobDescriptionCompetencyMapper;
|
|
|
27 |
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
|
|
|
28 |
use LeadersLinked\Mapper\BehaviorMapper;
|
8190 |
eleazar |
29 |
use LeadersLinked\Library\InterviewPDF;
|
1384 |
efrain |
30 |
use LeadersLinked\Form\PerformanceEvaluationEvaluationForm;
|
8087 |
eleazar |
31 |
use LeadersLinked\Form\PerformanceEvaluationEvaluationSelfForm;
|
1384 |
efrain |
32 |
use LeadersLinked\Mapper\CompanyPerformanceEvaluationTestMapper;
|
8170 |
eleazar |
33 |
use LeadersLinked\Mapper\CompanyPerformanceEvaluationTestSelfMapper;
|
8179 |
eleazar |
34 |
use LeadersLinked\Mapper\CompanyPerformanceEvaluationTestBothMapper;
|
|
|
35 |
use LeadersLinked\Mapper\CompanyPerformanceEvaluationTestSupervisorMapper;
|
15254 |
stevensc |
36 |
use LeadersLinked\Model\Company;
|
1384 |
efrain |
37 |
use LeadersLinked\Model\CompanyPerformanceEvaluationTest;
|
8087 |
eleazar |
38 |
use LeadersLinked\Model\CompanyPerformanceEvaluationTestSelf;
|
8179 |
eleazar |
39 |
use LeadersLinked\Model\CompanyPerformanceEvaluationTestBoth;
|
|
|
40 |
use LeadersLinked\Model\CompanyPerformanceEvaluationTestSupervisor;
|
15032 |
efrain |
41 |
use LeadersLinked\Mapper\CompetencyBehaviorMapper;
|
1384 |
efrain |
42 |
|
|
|
43 |
class PerformanceEvaluationEvaluationController extends AbstractActionController {
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
*
|
|
|
47 |
* @var AdapterInterface
|
|
|
48 |
*/
|
|
|
49 |
private $adapter;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
*
|
|
|
53 |
* @var AbstractAdapter
|
|
|
54 |
*/
|
|
|
55 |
private $cache;
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
*
|
|
|
59 |
* @var LoggerInterface
|
|
|
60 |
*/
|
|
|
61 |
private $logger;
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
*
|
|
|
65 |
* @var array
|
|
|
66 |
*/
|
|
|
67 |
private $config;
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
*
|
|
|
71 |
* @param AdapterInterface $adapter
|
|
|
72 |
* @param AbstractAdapter $cache
|
|
|
73 |
* @param LoggerInterface $logger
|
|
|
74 |
* @param array $config
|
|
|
75 |
*/
|
|
|
76 |
public function __construct($adapter, $cache, $logger, $config) {
|
|
|
77 |
$this->adapter = $adapter;
|
|
|
78 |
$this->cache = $cache;
|
|
|
79 |
$this->logger = $logger;
|
|
|
80 |
$this->config = $config;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public function indexAction() {
|
|
|
84 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
85 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
86 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
87 |
|
7897 |
eleazar |
88 |
try{
|
1384 |
efrain |
89 |
$request = $this->getRequest();
|
|
|
90 |
|
|
|
91 |
if ($request->isGet()) {
|
|
|
92 |
|
|
|
93 |
$headers = $request->getHeaders();
|
|
|
94 |
|
|
|
95 |
$isJson = false;
|
|
|
96 |
if ($headers->has('Accept')) {
|
|
|
97 |
$accept = $headers->get('Accept');
|
|
|
98 |
|
|
|
99 |
$prioritized = $accept->getPrioritized();
|
|
|
100 |
|
|
|
101 |
foreach ($prioritized as $key => $value) {
|
|
|
102 |
$raw = trim($value->getRaw());
|
|
|
103 |
|
|
|
104 |
if (!$isJson) {
|
|
|
105 |
$isJson = strpos($raw, 'json');
|
|
|
106 |
}
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
//$isJson = true;
|
|
|
111 |
if ($isJson) {
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
$data = [
|
|
|
115 |
'items' => [],
|
|
|
116 |
'total' => 0,
|
|
|
117 |
];
|
|
|
118 |
|
|
|
119 |
|
15254 |
stevensc |
120 |
$search = $this->params()->fromQuery('search');
|
|
|
121 |
$search = empty($search) ? '' : filter_var($search, FILTER_SANITIZE_STRING);
|
1384 |
efrain |
122 |
|
15371 |
efrain |
123 |
$start = intval($this->params()->fromQuery('start', 0), 10);
|
1384 |
efrain |
124 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
15371 |
efrain |
125 |
$page = intval($start / $records_x_page);
|
|
|
126 |
$page++;
|
|
|
127 |
|
1384 |
efrain |
128 |
$order = $this->params()->fromQuery('order', []);
|
|
|
129 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
130 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
131 |
|
|
|
132 |
$fields = ['max_date'];
|
|
|
133 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
|
|
|
134 |
|
|
|
135 |
if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
136 |
$order_direction = 'ASC';
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
|
|
141 |
$allowDelete = $acl->isAllowed($currentUser->usertype_id, 'performance-evaluation/evaluations/delete');
|
7913 |
eleazar |
142 |
|
1384 |
efrain |
143 |
|
7906 |
eleazar |
144 |
|
1384 |
efrain |
145 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
146 |
$sql = $queryMapper->getSql();
|
|
|
147 |
$select = $sql->select();
|
8082 |
eleazar |
148 |
$select->columns(['uuid', 'last_date', 'form_id']);
|
1384 |
efrain |
149 |
$select->from(['tb1' => CompanyPerformanceEvaluationTestMapper::_TABLE]);
|
|
|
150 |
$select->join(['tb2' => CompanyPerformanceEvaluationFormMapper::_TABLE], 'tb1.form_id = tb2.id ', ['form' =>'name']);
|
|
|
151 |
$select->join(['tb3' => UserMapper::_TABLE], 'tb1.supervisor_id = tb3.id ', ['first_name', 'last_name', 'email']);
|
|
|
152 |
$select->where->equalTo('tb1.company_id', $currentCompany->id);
|
12140 |
eleazar |
153 |
$select->where->notEqualTo('tb1.status', CompanyPerformanceEvaluationTest::STATUS_DELETED);
|
1384 |
efrain |
154 |
|
|
|
155 |
if ($search) {
|
|
|
156 |
$select->where->nest()
|
|
|
157 |
->like('tb1.last_date', '%' . $search . '%')
|
|
|
158 |
->like('tb2.name', '%' . $search . '%')
|
|
|
159 |
->like('tb3.first_name', '%' . $search . '%')
|
|
|
160 |
->or->like('tb3.last_name', '%' . $search . '%')
|
|
|
161 |
->or->like('tb3.email', '%' . $search . '%')
|
|
|
162 |
->unnest();
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
$select->order($order_field . ' ' . $order_direction);
|
|
|
167 |
|
|
|
168 |
$hydrator = new ArraySerializableHydrator();
|
|
|
169 |
$resultset = new HydratingResultSet($hydrator);
|
|
|
170 |
|
|
|
171 |
$adapter = new DbSelect($select, $sql, $resultset);
|
|
|
172 |
$paginator = new Paginator($adapter);
|
|
|
173 |
$paginator->setItemCountPerPage($records_x_page);
|
|
|
174 |
$paginator->setCurrentPageNumber($page);
|
|
|
175 |
|
|
|
176 |
$items = [];
|
|
|
177 |
$records = $paginator->getCurrentItems();
|
8175 |
eleazar |
178 |
$testSelfMapper = CompanyPerformanceEvaluationTestSelfMapper::getInstance($this->adapter);
|
8188 |
eleazar |
179 |
$testBothMapper = CompanyPerformanceEvaluationTestBothMapper::getInstance($this->adapter);
|
|
|
180 |
$testSupervisorMapper = CompanyPerformanceEvaluationTestSupervisorMapper::getInstance($this->adapter);
|
1384 |
efrain |
181 |
foreach ($records as $record)
|
|
|
182 |
{
|
8082 |
eleazar |
183 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
184 |
$test = $testMapper->fetchOneByUuid($record['uuid']);
|
8083 |
eleazar |
185 |
|
1384 |
efrain |
186 |
$dt = \DateTime::createFromFormat('Y-m-d', $record['last_date']);
|
|
|
187 |
$last_date = $dt->format('d/m/Y');
|
|
|
188 |
|
8175 |
eleazar |
189 |
$testSelf = $testSelfMapper->fetchOneByTestId($test->id);
|
8188 |
eleazar |
190 |
$testBoth = $testBothMapper->fetchOneByTestId($test->id);
|
|
|
191 |
$testSupervisor = $testSupervisorMapper->fetchOneByTestId($test->id);
|
7778 |
eleazar |
192 |
$link_delete = $this->url()->fromRoute('performance-evaluation/evaluations/delete', ['id' => $record['uuid'] ]);
|
8182 |
eleazar |
193 |
|
7897 |
eleazar |
194 |
$item = [
|
1384 |
efrain |
195 |
'last_date' => $last_date,
|
|
|
196 |
'form' => $record['form'],
|
8083 |
eleazar |
197 |
'first_name' => $test->first_name,
|
|
|
198 |
'last_name' => $test->last_name,
|
1384 |
efrain |
199 |
'supervisor' => trim(trim($record['first_name']) . ' ' . trim($record['last_name'])) . ' (' . trim($record['email']) . ')',
|
|
|
200 |
'actions' => [
|
|
|
201 |
'link_delete' => $allowDelete ? $link_delete : '',
|
|
|
202 |
]
|
|
|
203 |
];
|
8184 |
eleazar |
204 |
if($testSelf) {
|
8220 |
eleazar |
205 |
$item['actions']['link_report_self'] = $this->url()->fromRoute('performance-evaluation/evaluations/report-self', ['id' => $record['uuid'] ]);
|
8182 |
eleazar |
206 |
} else{
|
8184 |
eleazar |
207 |
$item['actions']['link_self'] = $this->url()->fromRoute('performance-evaluation/evaluations/self', ['id' => $record['uuid'] ]);
|
8182 |
eleazar |
208 |
}
|
8188 |
eleazar |
209 |
if($testBoth) {
|
8220 |
eleazar |
210 |
$item['actions']['link_report_both'] = $this->url()->fromRoute('performance-evaluation/evaluations/report-both', ['id' => $record['uuid'] ]);
|
8188 |
eleazar |
211 |
} else{
|
|
|
212 |
$item['actions']['link_both'] = $this->url()->fromRoute('performance-evaluation/evaluations/both', ['id' => $record['uuid'] ]);
|
|
|
213 |
}
|
|
|
214 |
if($testSupervisor) {
|
8220 |
eleazar |
215 |
$item['actions']['link_report_superviser'] = $this->url()->fromRoute('performance-evaluation/evaluations/report-superviser', ['id' => $record['uuid'] ]);
|
8188 |
eleazar |
216 |
} else{
|
|
|
217 |
$item['actions']['link_superviser'] = $this->url()->fromRoute('performance-evaluation/evaluations/superviser', ['id' => $record['uuid'] ]);
|
|
|
218 |
}
|
1384 |
efrain |
219 |
|
|
|
220 |
array_push($items, $item);
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
$data['items'] = $items;
|
|
|
224 |
$data['total'] = $paginator->getTotalItemCount();
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
return new JsonModel([
|
7890 |
eleazar |
228 |
'success' => true,
|
1384 |
efrain |
229 |
'data' => $data
|
|
|
230 |
]);
|
|
|
231 |
} else {
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
$form = new PerformanceEvaluationEvaluationForm($this->adapter, $currentCompany->id);
|
8088 |
eleazar |
235 |
$formSelf = new PerformanceEvaluationEvaluationSelfForm($this->adapter, $currentCompany->id);
|
1384 |
efrain |
236 |
|
|
|
237 |
|
|
|
238 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
239 |
$viewModel = new ViewModel();
|
|
|
240 |
$viewModel->setTemplate('leaders-linked/performance-evaluation-evaluations/index.phtml');
|
|
|
241 |
$viewModel->setVariables([
|
|
|
242 |
'form' => $form,
|
8088 |
eleazar |
243 |
'formSelf' => $formSelf,
|
1384 |
efrain |
244 |
]);
|
|
|
245 |
|
|
|
246 |
return $viewModel;
|
|
|
247 |
}
|
|
|
248 |
} else {
|
|
|
249 |
return new JsonModel([
|
|
|
250 |
'success' => false,
|
|
|
251 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
252 |
]);
|
7897 |
eleazar |
253 |
|
1384 |
efrain |
254 |
}
|
7897 |
eleazar |
255 |
} catch (\Throwable $e) {
|
|
|
256 |
$e->getMessage();
|
|
|
257 |
return new JsonModel([
|
|
|
258 |
'success' => false,
|
|
|
259 |
'data' => $e
|
|
|
260 |
]);
|
|
|
261 |
}
|
1384 |
efrain |
262 |
}
|
|
|
263 |
|
8068 |
eleazar |
264 |
|
|
|
265 |
public function emailAction() {
|
|
|
266 |
$request = $this->getRequest();
|
|
|
267 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
268 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
269 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
270 |
|
|
|
271 |
$email = $request->getQuery('email');
|
|
|
272 |
|
|
|
273 |
if(!$email){
|
|
|
274 |
$data = [
|
|
|
275 |
'success' => false,
|
|
|
276 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
277 |
];
|
|
|
278 |
|
|
|
279 |
return new JsonModel($data);
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
283 |
$user = $userMapper->fetchOneByEmail($email);
|
|
|
284 |
|
|
|
285 |
if (!$user) {
|
|
|
286 |
return new JsonModel([
|
|
|
287 |
'success' => false,
|
|
|
288 |
'data' => 'ERROR_USER_NOT_FOUND',
|
|
|
289 |
]);
|
|
|
290 |
} else if($request->isGet()){
|
|
|
291 |
$data = [
|
|
|
292 |
'success' => true,
|
|
|
293 |
'data' => [
|
|
|
294 |
'user_id' => $user->id,
|
|
|
295 |
'first_name' => $user->first_name,
|
|
|
296 |
'last_name' => $user->last_name,
|
|
|
297 |
|
|
|
298 |
]
|
|
|
299 |
];
|
|
|
300 |
return new JsonModel($data);
|
|
|
301 |
|
|
|
302 |
}else {
|
|
|
303 |
$data = [
|
|
|
304 |
'success' => false,
|
|
|
305 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
306 |
];
|
|
|
307 |
|
|
|
308 |
return new JsonModel($data);
|
|
|
309 |
}
|
|
|
310 |
}
|
|
|
311 |
|
1384 |
efrain |
312 |
public function addAction() {
|
|
|
313 |
$request = $this->getRequest();
|
|
|
314 |
|
|
|
315 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
316 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
317 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
318 |
|
|
|
319 |
$request = $this->getRequest();
|
12094 |
eleazar |
320 |
|
1384 |
efrain |
321 |
|
|
|
322 |
if ($request->isPost()) {
|
|
|
323 |
$dataPost = $request->getPost()->toArray();
|
|
|
324 |
$form = new PerformanceEvaluationEvaluationForm($this->adapter, $currentCompany->id);
|
12094 |
eleazar |
325 |
$actual_date = time();
|
12118 |
eleazar |
326 |
$actual_dt = date('Y-m-d', $actual_date);
|
12094 |
eleazar |
327 |
$last_dt = strtotime($dataPost['last_date']);
|
12105 |
eleazar |
328 |
// return new JsonModel([
|
|
|
329 |
// 'success' => false,
|
|
|
330 |
// 'data' => $last_dt
|
|
|
331 |
// ]);
|
12118 |
eleazar |
332 |
if($actual_dt > $last_dt){
|
12105 |
eleazar |
333 |
return new JsonModel([
|
|
|
334 |
'success' => false,
|
|
|
335 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
336 |
]);
|
|
|
337 |
}
|
12091 |
eleazar |
338 |
|
12087 |
eleazar |
339 |
$form->setData($dataPost);
|
12088 |
eleazar |
340 |
|
1384 |
efrain |
341 |
if($form->isValid()) {
|
|
|
342 |
$dataPost = (array) $form->getData();
|
12094 |
eleazar |
343 |
|
1384 |
efrain |
344 |
$form_id = $dataPost['form_id'];
|
8072 |
eleazar |
345 |
$supervisor_id = $dataPost['supervisor_id'];
|
|
|
346 |
$first_name= $dataPost['first_name'];
|
|
|
347 |
$last_name= $dataPost['last_name'];
|
|
|
348 |
$email= $dataPost['email'];
|
|
|
349 |
$user_id= $dataPost['user_id'];
|
12107 |
eleazar |
350 |
$dt = $dataPost['last_date'];
|
12105 |
eleazar |
351 |
|
1384 |
efrain |
352 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
353 |
$form = $formMapper->fetchOneByUuid($form_id);
|
|
|
354 |
if (!$form) {
|
|
|
355 |
return new JsonModel([
|
|
|
356 |
'success' => true,
|
|
|
357 |
'data' => 'ERROR_FORM_NOT_FOUND'
|
|
|
358 |
]);
|
|
|
359 |
}
|
|
|
360 |
|
|
|
361 |
if ($form->company_id != $currentCompany->id) {
|
|
|
362 |
return new JsonModel([
|
|
|
363 |
'success' => true,
|
|
|
364 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
365 |
]);
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
|
|
|
369 |
$userMapper = UserMapper::getInstance($this->adapter);
|
8073 |
eleazar |
370 |
$supervisor = $userMapper->fetchOneByUuid($supervisor_id);
|
1384 |
efrain |
371 |
|
8072 |
eleazar |
372 |
if (!$supervisor) {
|
1384 |
efrain |
373 |
return new JsonModel([
|
|
|
374 |
'success' => false,
|
|
|
375 |
'data' => 'ERROR_USER_NOT_FOUND'
|
|
|
376 |
]);
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
|
381 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
8074 |
eleazar |
382 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($form->company_id, $supervisor->id);
|
1384 |
efrain |
383 |
if (!$companyUser) {
|
|
|
384 |
return new JsonModel([
|
|
|
385 |
'success' => false,
|
|
|
386 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
387 |
]);
|
|
|
388 |
}
|
|
|
389 |
|
|
|
390 |
|
|
|
391 |
$test = new CompanyPerformanceEvaluationTest();
|
|
|
392 |
$test->company_id = $form->company_id;
|
|
|
393 |
$test->form_id = $form->id;
|
8072 |
eleazar |
394 |
$test->supervisor_id = $supervisor->id;
|
12107 |
eleazar |
395 |
$test->last_date = $dt;
|
8072 |
eleazar |
396 |
$test->first_name = $first_name;
|
|
|
397 |
$test->last_name = $last_name;
|
|
|
398 |
$test->email = $email;
|
8078 |
eleazar |
399 |
//$tst->user_id = $user_id;
|
1384 |
efrain |
400 |
|
|
|
401 |
|
|
|
402 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
403 |
$result = $testMapper->insert($test);
|
|
|
404 |
|
|
|
405 |
if($result) {
|
|
|
406 |
$this->logger->info('Se agrego el Test de Performance ' . $form->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
407 |
|
|
|
408 |
$data = [
|
|
|
409 |
'success' => true,
|
|
|
410 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
411 |
];
|
|
|
412 |
} else {
|
|
|
413 |
$data = [
|
|
|
414 |
'success' => false,
|
|
|
415 |
'data' => $testMapper->getError()
|
|
|
416 |
];
|
|
|
417 |
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
return new JsonModel($data);
|
|
|
421 |
|
|
|
422 |
} else {
|
|
|
423 |
$messages = [];
|
|
|
424 |
$form_messages = (array) $form->getMessages();
|
|
|
425 |
foreach($form_messages as $fieldname => $field_messages)
|
|
|
426 |
{
|
|
|
427 |
|
|
|
428 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
return new JsonModel([
|
|
|
432 |
'success' => false,
|
|
|
433 |
'data' => $messages
|
|
|
434 |
]);
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
|
|
|
438 |
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
return new JsonModel([
|
|
|
442 |
'success' => false,
|
|
|
443 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
444 |
]);
|
|
|
445 |
}
|
8087 |
eleazar |
446 |
|
|
|
447 |
public function selfAction() {
|
|
|
448 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
449 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
450 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
451 |
|
|
|
452 |
$request = $this->getRequest();
|
|
|
453 |
|
|
|
454 |
$uuid = $this->params()->fromRoute('id');
|
|
|
455 |
|
|
|
456 |
if ($request->isGet()) {
|
|
|
457 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
458 |
$test = $testMapper->fetchOneByUuid($uuid);
|
8094 |
eleazar |
459 |
|
|
|
460 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
8097 |
eleazar |
461 |
$form = $formMapper->fetchOne($test->form_id);
|
8099 |
eleazar |
462 |
|
8087 |
eleazar |
463 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
464 |
$jobDescription = $jobDescriptionMapper->fetchOne($form->job_description_id);
|
8101 |
eleazar |
465 |
|
|
|
466 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
467 |
$jobDescriptionCompetencies = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($jobDescription->id);
|
8102 |
eleazar |
468 |
// return new JsonModel([
|
|
|
469 |
// 'success' => false,
|
|
|
470 |
// 'data' => $jobDescriptionCompetencies
|
|
|
471 |
// ]);
|
8087 |
eleazar |
472 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
473 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
15032 |
efrain |
474 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
8087 |
eleazar |
475 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
1384 |
efrain |
476 |
|
8087 |
eleazar |
477 |
$data = [
|
|
|
478 |
'job_description' => [
|
|
|
479 |
'uuid' => $jobDescription->uuid,
|
|
|
480 |
'name' => $jobDescription->name,
|
|
|
481 |
'functions' => $jobDescription->functions,
|
|
|
482 |
'objectives' => $jobDescription->objectives,
|
|
|
483 |
'competencies' => []
|
|
|
484 |
],
|
|
|
485 |
'self' => [
|
|
|
486 |
'points' => 0,
|
|
|
487 |
'comment' => '',
|
|
|
488 |
],
|
|
|
489 |
'test' => $test,
|
|
|
490 |
];
|
|
|
491 |
|
|
|
492 |
foreach ($jobDescriptionCompetencies as $jobDescriptionCompetency) {
|
|
|
493 |
$competency = $competencyMapper->fetchOne($jobDescriptionCompetency->competency_id);
|
|
|
494 |
$competencyType = $competencyTypeMapper->fetchOne($competency->competency_type_id);
|
15032 |
efrain |
495 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
8087 |
eleazar |
496 |
|
|
|
497 |
$behaviors = [];
|
|
|
498 |
|
|
|
499 |
foreach ($behaviorCompetencies as $behaviorCompetency) {
|
|
|
500 |
$behavior = $behaviorMapper->fetchOne($behaviorCompetency->behavior_id);
|
|
|
501 |
|
|
|
502 |
$behaviors []= [
|
|
|
503 |
'uuid' => $behavior->uuid,
|
|
|
504 |
'description' => $behavior->description,
|
|
|
505 |
'points' => 0,
|
|
|
506 |
'comment' => '',
|
|
|
507 |
'competency_uuid' => $competency->uuid,
|
|
|
508 |
];
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
array_push($data['job_description']['competencies'], [
|
|
|
512 |
'competency_uuid' => $competency->uuid,
|
|
|
513 |
'competency_name' => $competency->name,
|
|
|
514 |
'competency_type_uuid' => $competencyType->uuid,
|
|
|
515 |
'competency_type_name' => $competencyType->name,
|
|
|
516 |
'behaviors' => $behaviors,
|
|
|
517 |
]);
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
return new JsonModel([
|
|
|
521 |
'success' => true,
|
|
|
522 |
'data' => $data
|
|
|
523 |
]);
|
|
|
524 |
|
|
|
525 |
} else if($request->isPost()){
|
8168 |
eleazar |
526 |
try{
|
8087 |
eleazar |
527 |
$dataPost = $request->getPost()->toArray();
|
|
|
528 |
|
|
|
529 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
8162 |
eleazar |
530 |
$test = $testMapper->fetchOneByUuid($uuid);
|
8166 |
eleazar |
531 |
|
8088 |
eleazar |
532 |
$formSelf = new PerformanceEvaluationEvaluationSelfForm($this->adapter, $currentCompany->id);
|
8167 |
eleazar |
533 |
$dataPost['first_name'] = $test->first_name;
|
|
|
534 |
$dataPost['last_name'] = $test->last_name;
|
|
|
535 |
$dataPost['email'] = $test->email;
|
8091 |
eleazar |
536 |
$formSelf->setData($dataPost);
|
8087 |
eleazar |
537 |
|
8091 |
eleazar |
538 |
if ($formSelf->isValid()) {
|
|
|
539 |
$dataPost = (array) $formSelf->getData();
|
8087 |
eleazar |
540 |
|
|
|
541 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
542 |
$performanceEvaluationTestSelf = new CompanyPerformanceEvaluationTestSelf();
|
|
|
543 |
$hydrator->hydrate($dataPost, $performanceEvaluationTestSelf);
|
|
|
544 |
|
|
|
545 |
$performanceEvaluationTestSelf->company_id = $currentCompany->id;
|
|
|
546 |
$performanceEvaluationTestSelf->test_id = $test->id;
|
8171 |
eleazar |
547 |
$performanceEvaluationTestSelf->form_id = $test->form_id;
|
8173 |
eleazar |
548 |
$performanceEvaluationTestSelf->supervisor_id = $test->supervisor_id;
|
8087 |
eleazar |
549 |
|
|
|
550 |
$performanceEvaluationTestSelfMapper = CompanyPerformanceEvaluationTestSelfMapper::getInstance($this->adapter);
|
|
|
551 |
|
|
|
552 |
$result = $performanceEvaluationTestSelfMapper->insert($performanceEvaluationTestSelf);
|
|
|
553 |
|
|
|
554 |
|
|
|
555 |
if ($result) {
|
8174 |
eleazar |
556 |
$this->logger->info('Se agrego la entrevista ' . $performanceEvaluationTestSelf->id, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
8087 |
eleazar |
557 |
|
|
|
558 |
// Get record by id
|
|
|
559 |
$performanceEvaluationTestSelfMapper = CompanyPerformanceEvaluationTestSelfMapper::getInstance($this->adapter);
|
|
|
560 |
$record = $performanceEvaluationTestSelfMapper->fetchOne($performanceEvaluationTestSelf->id);
|
|
|
561 |
|
|
|
562 |
|
|
|
563 |
if ($record) {
|
|
|
564 |
|
|
|
565 |
$data = [
|
|
|
566 |
'success' => true,
|
|
|
567 |
'id' => $record->id,
|
|
|
568 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
569 |
];
|
|
|
570 |
} else {
|
|
|
571 |
|
|
|
572 |
$data = [
|
|
|
573 |
'success' => false,
|
|
|
574 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
575 |
];
|
|
|
576 |
}
|
|
|
577 |
} else {
|
|
|
578 |
$data = [
|
|
|
579 |
'success' => false,
|
|
|
580 |
'data' => $performanceEvaluationTestSelfMapper->getError()
|
|
|
581 |
];
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
return new JsonModel($data);
|
|
|
585 |
} else {
|
|
|
586 |
$messages = [];
|
8163 |
eleazar |
587 |
$form_messages = (array) $formSelf->getMessages();
|
8087 |
eleazar |
588 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
589 |
|
|
|
590 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
591 |
}
|
|
|
592 |
|
|
|
593 |
return new JsonModel([
|
|
|
594 |
'success' => false,
|
|
|
595 |
'data' => $messages
|
|
|
596 |
]);
|
8168 |
eleazar |
597 |
}}catch (\Throwable $e) {
|
|
|
598 |
$e->getMessage();
|
|
|
599 |
return new JsonModel([
|
|
|
600 |
'success' => false,
|
|
|
601 |
'data' => $e
|
|
|
602 |
]);
|
8087 |
eleazar |
603 |
}
|
|
|
604 |
} else {
|
|
|
605 |
$data = [
|
|
|
606 |
'success' => false,
|
|
|
607 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
608 |
];
|
|
|
609 |
|
|
|
610 |
return new JsonModel($data);
|
|
|
611 |
}
|
|
|
612 |
|
|
|
613 |
return new JsonModel($data);
|
|
|
614 |
}
|
8179 |
eleazar |
615 |
|
|
|
616 |
public function bothAction() {
|
|
|
617 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
618 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
619 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
620 |
|
|
|
621 |
$request = $this->getRequest();
|
|
|
622 |
|
|
|
623 |
$uuid = $this->params()->fromRoute('id');
|
|
|
624 |
|
|
|
625 |
if ($request->isGet()) {
|
|
|
626 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
627 |
$test = $testMapper->fetchOneByUuid($uuid);
|
|
|
628 |
|
|
|
629 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
630 |
$form = $formMapper->fetchOne($test->form_id);
|
|
|
631 |
|
|
|
632 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
633 |
$jobDescription = $jobDescriptionMapper->fetchOne($form->job_description_id);
|
|
|
634 |
|
|
|
635 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
636 |
$jobDescriptionCompetencies = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($jobDescription->id);
|
|
|
637 |
// return new JsonModel([
|
|
|
638 |
// 'success' => false,
|
|
|
639 |
// 'data' => $jobDescriptionCompetencies
|
|
|
640 |
// ]);
|
|
|
641 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
642 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
15032 |
efrain |
643 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
8179 |
eleazar |
644 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
8087 |
eleazar |
645 |
|
8179 |
eleazar |
646 |
$data = [
|
|
|
647 |
'job_description' => [
|
|
|
648 |
'uuid' => $jobDescription->uuid,
|
|
|
649 |
'name' => $jobDescription->name,
|
|
|
650 |
'functions' => $jobDescription->functions,
|
|
|
651 |
'objectives' => $jobDescription->objectives,
|
|
|
652 |
'competencies' => []
|
|
|
653 |
],
|
|
|
654 |
'both' => [
|
|
|
655 |
'points' => 0,
|
|
|
656 |
'comment' => '',
|
|
|
657 |
],
|
|
|
658 |
'test' => $test,
|
|
|
659 |
];
|
|
|
660 |
|
|
|
661 |
foreach ($jobDescriptionCompetencies as $jobDescriptionCompetency) {
|
|
|
662 |
$competency = $competencyMapper->fetchOne($jobDescriptionCompetency->competency_id);
|
|
|
663 |
$competencyType = $competencyTypeMapper->fetchOne($competency->competency_type_id);
|
15032 |
efrain |
664 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
8179 |
eleazar |
665 |
|
|
|
666 |
$behaviors = [];
|
|
|
667 |
|
|
|
668 |
foreach ($behaviorCompetencies as $behaviorCompetency) {
|
|
|
669 |
$behavior = $behaviorMapper->fetchOne($behaviorCompetency->behavior_id);
|
|
|
670 |
|
|
|
671 |
$behaviors []= [
|
|
|
672 |
'uuid' => $behavior->uuid,
|
|
|
673 |
'description' => $behavior->description,
|
|
|
674 |
'points' => 0,
|
|
|
675 |
'comment' => '',
|
|
|
676 |
'competency_uuid' => $competency->uuid,
|
|
|
677 |
];
|
|
|
678 |
}
|
|
|
679 |
|
|
|
680 |
array_push($data['job_description']['competencies'], [
|
|
|
681 |
'competency_uuid' => $competency->uuid,
|
|
|
682 |
'competency_name' => $competency->name,
|
|
|
683 |
'competency_type_uuid' => $competencyType->uuid,
|
|
|
684 |
'competency_type_name' => $competencyType->name,
|
|
|
685 |
'behaviors' => $behaviors,
|
|
|
686 |
]);
|
|
|
687 |
}
|
|
|
688 |
|
|
|
689 |
return new JsonModel([
|
|
|
690 |
'success' => true,
|
|
|
691 |
'data' => $data
|
|
|
692 |
]);
|
|
|
693 |
|
|
|
694 |
} else if($request->isPost()){
|
|
|
695 |
try{
|
|
|
696 |
$dataPost = $request->getPost()->toArray();
|
|
|
697 |
|
|
|
698 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
699 |
$test = $testMapper->fetchOneByUuid($uuid);
|
|
|
700 |
|
|
|
701 |
$formSelf = new PerformanceEvaluationEvaluationSelfForm($this->adapter, $currentCompany->id);
|
|
|
702 |
$dataPost['first_name'] = $test->first_name;
|
|
|
703 |
$dataPost['last_name'] = $test->last_name;
|
|
|
704 |
$dataPost['email'] = $test->email;
|
|
|
705 |
$formSelf->setData($dataPost);
|
|
|
706 |
|
|
|
707 |
if ($formSelf->isValid()) {
|
|
|
708 |
$dataPost = (array) $formSelf->getData();
|
|
|
709 |
|
|
|
710 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
711 |
$performanceEvaluationTestBoth = new CompanyPerformanceEvaluationTestBoth();
|
|
|
712 |
$hydrator->hydrate($dataPost, $performanceEvaluationTestBoth);
|
|
|
713 |
|
|
|
714 |
$performanceEvaluationTestBoth->company_id = $currentCompany->id;
|
|
|
715 |
$performanceEvaluationTestBoth->test_id = $test->id;
|
|
|
716 |
$performanceEvaluationTestBoth->form_id = $test->form_id;
|
|
|
717 |
$performanceEvaluationTestBoth->supervisor_id = $test->supervisor_id;
|
|
|
718 |
|
|
|
719 |
$performanceEvaluationTestBothMapper = CompanyPerformanceEvaluationTestBothMapper::getInstance($this->adapter);
|
|
|
720 |
|
|
|
721 |
$result = $performanceEvaluationTestBothMapper->insert($performanceEvaluationTestBoth);
|
|
|
722 |
|
|
|
723 |
|
|
|
724 |
if ($result) {
|
|
|
725 |
$this->logger->info('Se agrego la entrevista ' . $performanceEvaluationTestBoth->id, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
726 |
|
|
|
727 |
// Get record by id
|
|
|
728 |
$performanceEvaluationTestBothMapper = CompanyPerformanceEvaluationTestBothMapper::getInstance($this->adapter);
|
|
|
729 |
$record = $performanceEvaluationTestBothMapper->fetchOne($performanceEvaluationTestBoth->id);
|
|
|
730 |
|
|
|
731 |
|
|
|
732 |
if ($record) {
|
|
|
733 |
|
|
|
734 |
$data = [
|
|
|
735 |
'success' => true,
|
|
|
736 |
'id' => $record->id,
|
|
|
737 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
738 |
];
|
|
|
739 |
} else {
|
|
|
740 |
|
|
|
741 |
$data = [
|
|
|
742 |
'success' => false,
|
|
|
743 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
744 |
];
|
|
|
745 |
}
|
|
|
746 |
} else {
|
|
|
747 |
$data = [
|
|
|
748 |
'success' => false,
|
|
|
749 |
'data' => $performanceEvaluationTestBothMapper->getError()
|
|
|
750 |
];
|
|
|
751 |
}
|
|
|
752 |
|
|
|
753 |
return new JsonModel($data);
|
|
|
754 |
} else {
|
|
|
755 |
$messages = [];
|
|
|
756 |
$form_messages = (array) $formSelf->getMessages();
|
|
|
757 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
758 |
|
|
|
759 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
760 |
}
|
|
|
761 |
|
|
|
762 |
return new JsonModel([
|
|
|
763 |
'success' => false,
|
|
|
764 |
'data' => $messages
|
|
|
765 |
]);
|
|
|
766 |
}}catch (\Throwable $e) {
|
|
|
767 |
$e->getMessage();
|
|
|
768 |
return new JsonModel([
|
|
|
769 |
'success' => false,
|
|
|
770 |
'data' => $e
|
|
|
771 |
]);
|
|
|
772 |
}
|
|
|
773 |
} else {
|
|
|
774 |
$data = [
|
|
|
775 |
'success' => false,
|
|
|
776 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
777 |
];
|
|
|
778 |
|
|
|
779 |
return new JsonModel($data);
|
|
|
780 |
}
|
|
|
781 |
|
|
|
782 |
return new JsonModel($data);
|
|
|
783 |
}
|
|
|
784 |
|
8181 |
eleazar |
785 |
public function superviserAction() {
|
8179 |
eleazar |
786 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
787 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
788 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
789 |
|
|
|
790 |
$request = $this->getRequest();
|
|
|
791 |
|
|
|
792 |
$uuid = $this->params()->fromRoute('id');
|
|
|
793 |
|
|
|
794 |
if ($request->isGet()) {
|
|
|
795 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
796 |
$test = $testMapper->fetchOneByUuid($uuid);
|
|
|
797 |
|
|
|
798 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
799 |
$form = $formMapper->fetchOne($test->form_id);
|
|
|
800 |
|
|
|
801 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
802 |
$jobDescription = $jobDescriptionMapper->fetchOne($form->job_description_id);
|
|
|
803 |
|
|
|
804 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
805 |
$jobDescriptionCompetencies = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($jobDescription->id);
|
|
|
806 |
// return new JsonModel([
|
|
|
807 |
// 'success' => false,
|
|
|
808 |
// 'data' => $jobDescriptionCompetencies
|
|
|
809 |
// ]);
|
|
|
810 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
811 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
15032 |
efrain |
812 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
8179 |
eleazar |
813 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
814 |
|
|
|
815 |
$data = [
|
|
|
816 |
'job_description' => [
|
|
|
817 |
'uuid' => $jobDescription->uuid,
|
|
|
818 |
'name' => $jobDescription->name,
|
|
|
819 |
'functions' => $jobDescription->functions,
|
|
|
820 |
'objectives' => $jobDescription->objectives,
|
|
|
821 |
'competencies' => []
|
|
|
822 |
],
|
|
|
823 |
'supervisor' => [
|
|
|
824 |
'points' => 0,
|
|
|
825 |
'comment' => '',
|
|
|
826 |
],
|
|
|
827 |
'test' => $test,
|
|
|
828 |
];
|
|
|
829 |
|
|
|
830 |
foreach ($jobDescriptionCompetencies as $jobDescriptionCompetency) {
|
|
|
831 |
$competency = $competencyMapper->fetchOne($jobDescriptionCompetency->competency_id);
|
|
|
832 |
$competencyType = $competencyTypeMapper->fetchOne($competency->competency_type_id);
|
15032 |
efrain |
833 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
8179 |
eleazar |
834 |
|
|
|
835 |
$behaviors = [];
|
|
|
836 |
|
|
|
837 |
foreach ($behaviorCompetencies as $behaviorCompetency) {
|
|
|
838 |
$behavior = $behaviorMapper->fetchOne($behaviorCompetency->behavior_id);
|
|
|
839 |
|
|
|
840 |
$behaviors []= [
|
|
|
841 |
'uuid' => $behavior->uuid,
|
|
|
842 |
'description' => $behavior->description,
|
|
|
843 |
'points' => 0,
|
|
|
844 |
'comment' => '',
|
|
|
845 |
'competency_uuid' => $competency->uuid,
|
|
|
846 |
];
|
|
|
847 |
}
|
|
|
848 |
|
|
|
849 |
array_push($data['job_description']['competencies'], [
|
|
|
850 |
'competency_uuid' => $competency->uuid,
|
|
|
851 |
'competency_name' => $competency->name,
|
|
|
852 |
'competency_type_uuid' => $competencyType->uuid,
|
|
|
853 |
'competency_type_name' => $competencyType->name,
|
|
|
854 |
'behaviors' => $behaviors,
|
|
|
855 |
]);
|
|
|
856 |
}
|
|
|
857 |
|
|
|
858 |
return new JsonModel([
|
|
|
859 |
'success' => true,
|
|
|
860 |
'data' => $data
|
|
|
861 |
]);
|
|
|
862 |
|
|
|
863 |
} else if($request->isPost()){
|
|
|
864 |
try{
|
|
|
865 |
$dataPost = $request->getPost()->toArray();
|
|
|
866 |
|
|
|
867 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
868 |
$test = $testMapper->fetchOneByUuid($uuid);
|
|
|
869 |
|
|
|
870 |
$formSelf = new PerformanceEvaluationEvaluationSelfForm($this->adapter, $currentCompany->id);
|
|
|
871 |
$dataPost['first_name'] = $test->first_name;
|
|
|
872 |
$dataPost['last_name'] = $test->last_name;
|
|
|
873 |
$dataPost['email'] = $test->email;
|
|
|
874 |
$formSelf->setData($dataPost);
|
|
|
875 |
|
|
|
876 |
if ($formSelf->isValid()) {
|
|
|
877 |
$dataPost = (array) $formSelf->getData();
|
|
|
878 |
|
|
|
879 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
880 |
$performanceEvaluationTestSupervisor = new CompanyPerformanceEvaluationTestSupervisor();
|
|
|
881 |
$hydrator->hydrate($dataPost, $performanceEvaluationTestSupervisor);
|
|
|
882 |
|
|
|
883 |
$performanceEvaluationTestSupervisor->company_id = $currentCompany->id;
|
|
|
884 |
$performanceEvaluationTestSupervisor->test_id = $test->id;
|
|
|
885 |
$performanceEvaluationTestSupervisor->form_id = $test->form_id;
|
|
|
886 |
$performanceEvaluationTestSupervisor->supervisor_id = $test->supervisor_id;
|
|
|
887 |
|
|
|
888 |
$performanceEvaluationTestSupervisorMapper = CompanyPerformanceEvaluationTestSupervisorMapper::getInstance($this->adapter);
|
|
|
889 |
|
|
|
890 |
$result = $performanceEvaluationTestSupervisorMapper->insert($performanceEvaluationTestSupervisor);
|
|
|
891 |
|
|
|
892 |
|
|
|
893 |
if ($result) {
|
|
|
894 |
$this->logger->info('Se agrego la entrevista ' . $performanceEvaluationTestSupervisor->id, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
895 |
|
|
|
896 |
// Get record by id
|
|
|
897 |
$performanceEvaluationTestSupervisorMapper = CompanyPerformanceEvaluationTestSupervisorMapper::getInstance($this->adapter);
|
|
|
898 |
$record = $performanceEvaluationTestSupervisorMapper->fetchOne($performanceEvaluationTestSupervisor->id);
|
|
|
899 |
|
|
|
900 |
|
|
|
901 |
if ($record) {
|
|
|
902 |
|
|
|
903 |
$data = [
|
|
|
904 |
'success' => true,
|
|
|
905 |
'id' => $record->id,
|
|
|
906 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
907 |
];
|
|
|
908 |
} else {
|
|
|
909 |
|
|
|
910 |
$data = [
|
|
|
911 |
'success' => false,
|
|
|
912 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
913 |
];
|
|
|
914 |
}
|
|
|
915 |
} else {
|
|
|
916 |
$data = [
|
|
|
917 |
'success' => false,
|
|
|
918 |
'data' => $performanceEvaluationTestSupervisorMapper->getError()
|
|
|
919 |
];
|
|
|
920 |
}
|
|
|
921 |
|
|
|
922 |
return new JsonModel($data);
|
|
|
923 |
} else {
|
|
|
924 |
$messages = [];
|
|
|
925 |
$form_messages = (array) $formSelf->getMessages();
|
|
|
926 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
927 |
|
|
|
928 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
929 |
}
|
|
|
930 |
|
|
|
931 |
return new JsonModel([
|
|
|
932 |
'success' => false,
|
|
|
933 |
'data' => $messages
|
|
|
934 |
]);
|
|
|
935 |
}}catch (\Throwable $e) {
|
|
|
936 |
$e->getMessage();
|
|
|
937 |
return new JsonModel([
|
|
|
938 |
'success' => false,
|
|
|
939 |
'data' => $e
|
|
|
940 |
]);
|
|
|
941 |
}
|
|
|
942 |
} else {
|
|
|
943 |
$data = [
|
|
|
944 |
'success' => false,
|
|
|
945 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
946 |
];
|
|
|
947 |
|
|
|
948 |
return new JsonModel($data);
|
|
|
949 |
}
|
|
|
950 |
|
|
|
951 |
return new JsonModel($data);
|
|
|
952 |
}
|
|
|
953 |
|
1384 |
efrain |
954 |
public function editAction() {
|
|
|
955 |
$request = $this->getRequest();
|
|
|
956 |
|
|
|
957 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
958 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
959 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
960 |
|
|
|
961 |
$request = $this->getRequest();
|
|
|
962 |
$id = $this->params()->fromRoute('id');
|
|
|
963 |
|
|
|
964 |
$formTestMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
965 |
$formTest = $formTestMapper->fetchOneByUuid($id);
|
8080 |
eleazar |
966 |
|
1384 |
efrain |
967 |
if (!$formTest) {
|
|
|
968 |
return new JsonModel([
|
|
|
969 |
'success' => true,
|
|
|
970 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
971 |
]);
|
|
|
972 |
}
|
|
|
973 |
|
|
|
974 |
if ($formTest->company_id != $currentCompany->id) {
|
|
|
975 |
return new JsonModel([
|
|
|
976 |
'success' => true,
|
|
|
977 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
978 |
]);
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
|
|
|
982 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
983 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($formTest->company_id, $currentUser->id);
|
|
|
984 |
if (!$companyUser) {
|
|
|
985 |
return new JsonModel([
|
|
|
986 |
'success' => false,
|
|
|
987 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
988 |
]);
|
|
|
989 |
}
|
|
|
990 |
|
|
|
991 |
if ($request->isGet()) {
|
|
|
992 |
|
|
|
993 |
$dt = \DateTime::createFromFormat('Y-m-d', $formTest->last_date);
|
|
|
994 |
|
|
|
995 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
996 |
$form = $formMapper->fetchOne($formTest->form_id);
|
|
|
997 |
|
|
|
998 |
$userMapper = UserMapper::getInstance($this->adapter);
|
7785 |
eleazar |
999 |
$user = $userMapper->fetchOne($formTest->supervisor_id);
|
1384 |
efrain |
1000 |
|
|
|
1001 |
$data = [
|
|
|
1002 |
'success' => true,
|
|
|
1003 |
'data' => [
|
|
|
1004 |
'last_date' => $dt->format('d/m/Y'),
|
|
|
1005 |
'form' => $form->uuid,
|
|
|
1006 |
'supervisor' => $user->uuid,
|
|
|
1007 |
]
|
|
|
1008 |
];
|
|
|
1009 |
|
|
|
1010 |
return new JsonModel($data);
|
|
|
1011 |
|
|
|
1012 |
|
|
|
1013 |
|
|
|
1014 |
} else if ($request->isPost()) {
|
|
|
1015 |
|
|
|
1016 |
|
|
|
1017 |
$dataPost = $request->getPost()->toArray();
|
|
|
1018 |
$form = new PerformanceEvaluationEvaluationForm($this->adapter, $currentCompany->id);
|
|
|
1019 |
$form->setData($dataPost);
|
|
|
1020 |
|
|
|
1021 |
if($form->isValid()) {
|
|
|
1022 |
$dataPost = (array) $form->getData();
|
|
|
1023 |
|
|
|
1024 |
$form_id = $dataPost['form_id'];
|
|
|
1025 |
$user_id = $dataPost['supervisor_id'];
|
|
|
1026 |
$dt = \DateTime::createFromFormat('d/m/Y', $dataPost['last_date']);
|
|
|
1027 |
$last_date = $dt->format('Y-m-d');
|
|
|
1028 |
|
|
|
1029 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
1030 |
$form = $formMapper->fetchOneByUuid($form_id);
|
|
|
1031 |
if (!$form) {
|
|
|
1032 |
return new JsonModel([
|
|
|
1033 |
'success' => true,
|
|
|
1034 |
'data' => 'ERROR_FORM_NOT_FOUND'
|
|
|
1035 |
]);
|
|
|
1036 |
}
|
|
|
1037 |
|
|
|
1038 |
if ($form->company_id != $currentCompany->id) {
|
|
|
1039 |
return new JsonModel([
|
|
|
1040 |
'success' => true,
|
|
|
1041 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1042 |
]);
|
|
|
1043 |
}
|
|
|
1044 |
|
|
|
1045 |
|
|
|
1046 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1047 |
$user = $userMapper->fetchOneByUuid($user_id);
|
|
|
1048 |
|
|
|
1049 |
if (!$user) {
|
|
|
1050 |
return new JsonModel([
|
|
|
1051 |
'success' => false,
|
|
|
1052 |
'data' => 'ERROR_USER_NOT_FOUND'
|
|
|
1053 |
]);
|
|
|
1054 |
}
|
|
|
1055 |
|
|
|
1056 |
|
|
|
1057 |
|
|
|
1058 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
1059 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($form->company_id, $user->id);
|
|
|
1060 |
if (!$companyUser) {
|
|
|
1061 |
return new JsonModel([
|
|
|
1062 |
'success' => false,
|
|
|
1063 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1064 |
]);
|
|
|
1065 |
}
|
|
|
1066 |
|
|
|
1067 |
$formTest->supervisor_id = $user->id;
|
|
|
1068 |
$formTest->last_date = $last_date;
|
|
|
1069 |
|
|
|
1070 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1071 |
$result = $testMapper->update($formTest);
|
|
|
1072 |
|
|
|
1073 |
if($result) {
|
|
|
1074 |
$this->logger->info('Se actualizo el Test de Performance ' . $form->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
1075 |
|
|
|
1076 |
$data = [
|
|
|
1077 |
'success' => true,
|
|
|
1078 |
'data' => 'LABEL_RECORD_UPDATED'
|
|
|
1079 |
];
|
|
|
1080 |
} else {
|
|
|
1081 |
$data = [
|
|
|
1082 |
'success' => false,
|
|
|
1083 |
'data' => $testMapper->getError()
|
|
|
1084 |
];
|
|
|
1085 |
|
|
|
1086 |
}
|
|
|
1087 |
|
|
|
1088 |
return new JsonModel($data);
|
|
|
1089 |
|
|
|
1090 |
} else {
|
|
|
1091 |
$messages = [];
|
|
|
1092 |
$form_messages = (array) $form->getMessages();
|
|
|
1093 |
foreach($form_messages as $fieldname => $field_messages)
|
|
|
1094 |
{
|
|
|
1095 |
|
|
|
1096 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
1097 |
}
|
|
|
1098 |
|
|
|
1099 |
return new JsonModel([
|
|
|
1100 |
'success' => false,
|
|
|
1101 |
'data' => $messages
|
|
|
1102 |
]);
|
|
|
1103 |
}
|
|
|
1104 |
}
|
|
|
1105 |
|
|
|
1106 |
return new JsonModel([
|
|
|
1107 |
'success' => false,
|
|
|
1108 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1109 |
]);
|
|
|
1110 |
}
|
|
|
1111 |
|
|
|
1112 |
public function deleteAction() {
|
|
|
1113 |
$request = $this->getRequest();
|
|
|
1114 |
|
|
|
1115 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1116 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1117 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1118 |
|
|
|
1119 |
$request = $this->getRequest();
|
|
|
1120 |
$id = $this->params()->fromRoute('id');
|
|
|
1121 |
|
|
|
1122 |
$formTestMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1123 |
$formTest = $formTestMapper->fetchOneByUuid($id);
|
|
|
1124 |
if (!$formTest) {
|
|
|
1125 |
return new JsonModel([
|
|
|
1126 |
'success' => true,
|
|
|
1127 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
1128 |
]);
|
|
|
1129 |
}
|
|
|
1130 |
|
|
|
1131 |
if ($formTest->company_id != $currentCompany->id) {
|
|
|
1132 |
return new JsonModel([
|
|
|
1133 |
'success' => true,
|
|
|
1134 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1135 |
]);
|
|
|
1136 |
}
|
|
|
1137 |
|
|
|
1138 |
|
|
|
1139 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
1140 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($formTest->company_id, $currentUser->id);
|
|
|
1141 |
if (!$companyUser) {
|
|
|
1142 |
return new JsonModel([
|
|
|
1143 |
'success' => false,
|
|
|
1144 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1145 |
]);
|
|
|
1146 |
}
|
|
|
1147 |
|
|
|
1148 |
if ($request->isPost()) {
|
12143 |
eleazar |
1149 |
|
|
|
1150 |
$formTestMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
12142 |
eleazar |
1151 |
$formTest->status = CompanyPerformanceEvaluationTest::STATUS_DELETED;
|
|
|
1152 |
if($formTestMapper->update($formTest)) {
|
12144 |
eleazar |
1153 |
return new JsonModel([
|
1384 |
efrain |
1154 |
'success' => true,
|
12142 |
eleazar |
1155 |
'data' => 'LABEL_PERFORMANCE_TEST_DELETED'
|
12144 |
eleazar |
1156 |
]);
|
12142 |
eleazar |
1157 |
|
1384 |
efrain |
1158 |
} else {
|
12144 |
eleazar |
1159 |
return new JsonModel([
|
1384 |
efrain |
1160 |
'success' => false,
|
12142 |
eleazar |
1161 |
'data' => $feedMapper->getError()
|
12144 |
eleazar |
1162 |
]);
|
1384 |
efrain |
1163 |
}
|
12142 |
eleazar |
1164 |
|
1384 |
efrain |
1165 |
}
|
|
|
1166 |
|
|
|
1167 |
return new JsonModel([
|
|
|
1168 |
'success' => false,
|
|
|
1169 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1170 |
]);
|
|
|
1171 |
}
|
|
|
1172 |
|
8179 |
eleazar |
1173 |
public function reportSelfAction() {
|
8167 |
eleazar |
1174 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1175 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1176 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1177 |
|
|
|
1178 |
$uuid = $this->params()->fromRoute('id');
|
|
|
1179 |
|
|
|
1180 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1181 |
$test = $testMapper->fetchOneByUuid($uuid);
|
8194 |
eleazar |
1182 |
|
|
|
1183 |
$testSelfMapper = CompanyPerformanceEvaluationTestSelfMapper::getInstance($this->adapter);
|
|
|
1184 |
$testSelf = $testSelfMapper->fetchOneByTestId($test->id);
|
8207 |
eleazar |
1185 |
|
8196 |
eleazar |
1186 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
1187 |
$form = $formMapper->fetchOne($test->form_id);
|
8199 |
eleazar |
1188 |
|
8167 |
eleazar |
1189 |
if (!$form) {
|
|
|
1190 |
return new JsonModel([
|
|
|
1191 |
'success' => false,
|
|
|
1192 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
|
|
1193 |
]);
|
|
|
1194 |
}
|
|
|
1195 |
|
|
|
1196 |
$request = $this->getRequest();
|
|
|
1197 |
if ($request->isGet()) {
|
|
|
1198 |
//Competencies
|
|
|
1199 |
|
|
|
1200 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
1201 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
|
|
1202 |
$competenceTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
15032 |
efrain |
1203 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
8167 |
eleazar |
1204 |
$jobDescriptionBehaviorCompetencyMapper = JobDescriptionBehaviorCompetencyMapper::getInstance($this->adapter);
|
|
|
1205 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
1206 |
|
|
|
1207 |
$competencies = [];
|
|
|
1208 |
|
|
|
1209 |
$jobDescriptionCompetency = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($form->job_description_id);
|
|
|
1210 |
|
8179 |
eleazar |
1211 |
$content = json_decode($testSelf->content, true);
|
8167 |
eleazar |
1212 |
|
|
|
1213 |
foreach ($jobDescriptionCompetency as $record) {
|
|
|
1214 |
|
|
|
1215 |
$competency = $competencyMapper->fetchOne($record->competency_id);
|
|
|
1216 |
$competenceType = $competenceTypeMapper->fetchOne($competency->competency_type_id);
|
|
|
1217 |
|
|
|
1218 |
if ($competency && $competenceType) {
|
|
|
1219 |
|
15032 |
efrain |
1220 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
8167 |
eleazar |
1221 |
$behaviors = [];
|
|
|
1222 |
|
|
|
1223 |
foreach ($behaviorCompetencies as $rows) {
|
|
|
1224 |
|
|
|
1225 |
$behavior = $behaviorMapper->fetchOne($rows->behavior_id);
|
8179 |
eleazar |
1226 |
$jobDescriptionBehaviorCompetency = $jobDescriptionBehaviorCompetencyMapper->fetchOneByBehavior($form->job_description_id, $record->competency_id, $rows->behavior_id);
|
8167 |
eleazar |
1227 |
|
|
|
1228 |
if ($behavior && $jobDescriptionBehaviorCompetency) {
|
|
|
1229 |
$rowData = [
|
|
|
1230 |
'description' => $behavior->description,
|
|
|
1231 |
'level' => $jobDescriptionBehaviorCompetency->level,
|
|
|
1232 |
'comment' => '',
|
|
|
1233 |
'evaluation' => '',
|
|
|
1234 |
|
|
|
1235 |
];
|
|
|
1236 |
|
|
|
1237 |
foreach($content as $eval) {
|
|
|
1238 |
if ($eval['competencyUuid'] == $competency->uuid &&
|
|
|
1239 |
$eval['behaviorUuid'] == $behavior->uuid) {
|
|
|
1240 |
|
|
|
1241 |
$rowData['comment'] = $eval['comment'];
|
|
|
1242 |
$rowData['evaluation'] = $eval['evaluation'];
|
|
|
1243 |
|
|
|
1244 |
|
|
|
1245 |
break;
|
|
|
1246 |
}
|
|
|
1247 |
}
|
|
|
1248 |
|
|
|
1249 |
$behaviors []= $rowData;
|
|
|
1250 |
}
|
|
|
1251 |
}
|
|
|
1252 |
|
|
|
1253 |
array_push($competencies, [
|
|
|
1254 |
'name' => $competency->name,
|
|
|
1255 |
'description' => $competency->description,
|
|
|
1256 |
'type' => $competenceType->name,
|
|
|
1257 |
'behaviors' => $behaviors
|
|
|
1258 |
]);
|
|
|
1259 |
}
|
|
|
1260 |
}
|
|
|
1261 |
|
8230 |
eleazar |
1262 |
return $this->renderSelfPDF($currentCompany, $testSelf, $competencies);
|
8167 |
eleazar |
1263 |
}
|
|
|
1264 |
|
|
|
1265 |
return new JsonModel([
|
|
|
1266 |
'success' => false,
|
|
|
1267 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1268 |
]);
|
|
|
1269 |
}
|
|
|
1270 |
|
8179 |
eleazar |
1271 |
/**
|
|
|
1272 |
* Render PDF
|
15079 |
efrain |
1273 |
* @param Company $company
|
|
|
1274 |
* @param CompanyPerformanceEvaluationTestSelf $interviewEvaluation
|
8179 |
eleazar |
1275 |
* @param array $competencies
|
|
|
1276 |
* @return mixed
|
|
|
1277 |
*/
|
15079 |
efrain |
1278 |
public function renderSelfPDF($company, $testSelf, $competencies)
|
|
|
1279 |
{
|
8179 |
eleazar |
1280 |
|
|
|
1281 |
|
15079 |
efrain |
1282 |
|
8179 |
eleazar |
1283 |
//Generate New PDF
|
|
|
1284 |
$pdf = new InterviewPDF();
|
|
|
1285 |
|
|
|
1286 |
|
15079 |
efrain |
1287 |
$target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
|
|
|
1288 |
|
|
|
1289 |
$header = $company->header ? $target_path . DIRECTORY_SEPARATOR . $company->header : '';
|
|
|
1290 |
if(empty($header) || !file_exists($header)) {
|
|
|
1291 |
$header = $this->config['leaderslinked.images_default.company_pdf_header'];
|
8179 |
eleazar |
1292 |
}
|
15079 |
efrain |
1293 |
|
|
|
1294 |
$footer = $company->footer ? $target_path . DIRECTORY_SEPARATOR . $company->footer : '';
|
|
|
1295 |
if(empty($footer) || !file_exists($footer)) {
|
|
|
1296 |
$footer = $this->config['leaderslinked.images_default.company_pdf_footer'];
|
|
|
1297 |
}
|
|
|
1298 |
|
|
|
1299 |
$pdf->header = $header;
|
|
|
1300 |
$pdf->footer = $footer;
|
8179 |
eleazar |
1301 |
|
|
|
1302 |
$pdf->SetMargins(10, 0, 10);
|
|
|
1303 |
|
|
|
1304 |
$pdf->AliasNbPages();
|
|
|
1305 |
$pdf->AddPage();
|
|
|
1306 |
|
|
|
1307 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1308 |
$test = $testMapper->fetchOne($testSelf->test_id);
|
|
|
1309 |
|
|
|
1310 |
$userMapper = UserMapper::getInstance($this->adapter);
|
8206 |
eleazar |
1311 |
$supervisor = $userMapper->fetchOne($testSelf->supervisor_id);
|
8179 |
eleazar |
1312 |
|
|
|
1313 |
switch ($testSelf->points) {
|
|
|
1314 |
case "0":
|
|
|
1315 |
$points = "Sugerir otro cargo";
|
|
|
1316 |
break;
|
|
|
1317 |
case "1":
|
|
|
1318 |
$points = "25%";
|
|
|
1319 |
break;
|
|
|
1320 |
case "2":
|
|
|
1321 |
$points = "50%";
|
|
|
1322 |
break;
|
|
|
1323 |
case "3":
|
|
|
1324 |
$points = "75%";
|
|
|
1325 |
break;
|
|
|
1326 |
case "4":
|
|
|
1327 |
$points = "100%";
|
|
|
1328 |
break;
|
|
|
1329 |
default :
|
|
|
1330 |
$points = "ERROR";
|
|
|
1331 |
break;
|
|
|
1332 |
}
|
|
|
1333 |
|
|
|
1334 |
$rows = [
|
|
|
1335 |
array(
|
|
|
1336 |
'title' => 'Nombre Evaluado: ',
|
|
|
1337 |
'content' => $testSelf ? ' ' . $testSelf->first_name . ' ' . $testSelf->last_name : 'No Aplica'
|
|
|
1338 |
),
|
|
|
1339 |
array(
|
|
|
1340 |
'title' => 'Supervisado por: ',
|
|
|
1341 |
'content' => $supervisor ? ' ' . $supervisor->first_name . ' ' . $supervisor->last_name : ' No Aplica '
|
|
|
1342 |
),
|
|
|
1343 |
array(
|
|
|
1344 |
'title' => 'Comentarios del supervisor: ',
|
|
|
1345 |
'content' => $testSelf ? ' ' . $testSelf->comment : 'No Aplica'
|
|
|
1346 |
),
|
|
|
1347 |
array(
|
9429 |
eleazar |
1348 |
'title' => 'Porcentage',
|
8179 |
eleazar |
1349 |
'content' => $points
|
|
|
1350 |
)
|
|
|
1351 |
];
|
|
|
1352 |
|
|
|
1353 |
$pdf->borderTable('DATOS DE LA ENTREVISTA', $rows);
|
|
|
1354 |
|
|
|
1355 |
$sections = json_decode($testSelf->content, true);
|
|
|
1356 |
/*
|
|
|
1357 |
for ($s = 0; $s < count($sections); $s++) {
|
|
|
1358 |
|
|
|
1359 |
$pdf->singleTable($sections[$s]['title'], [
|
|
|
1360 |
array(
|
|
|
1361 |
'content' => $sections[$s]['type'] != 'multiple' ? $sections[$s]['text'] : ''
|
|
|
1362 |
)]);
|
|
|
1363 |
|
|
|
1364 |
if ($sections[$s]['type'] == 'multiple') {
|
|
|
1365 |
|
|
|
1366 |
$pdf->titleOptionTable($sections[$s]['text']);
|
|
|
1367 |
|
|
|
1368 |
for ($o = 0; $o < count($sections[$s]['options']); $o++) {
|
|
|
1369 |
|
|
|
1370 |
$pdf->optionTable($sections[$s]['options'][$o]['title']);
|
|
|
1371 |
}
|
|
|
1372 |
$pdf->Ln();
|
|
|
1373 |
}
|
|
|
1374 |
if ($s % 2 == 0 && $s > 1) {
|
|
|
1375 |
$pdf->AddPage();
|
|
|
1376 |
}
|
|
|
1377 |
}*/
|
|
|
1378 |
|
|
|
1379 |
// Competencies
|
|
|
1380 |
if (count($competencies) != 0) {
|
|
|
1381 |
|
|
|
1382 |
// add new page
|
|
|
1383 |
|
|
|
1384 |
$pdf->AddPage();
|
|
|
1385 |
|
|
|
1386 |
$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:');
|
|
|
1387 |
|
|
|
1388 |
$pdf->singleTable('Anexo de valores:', $competencies_header);
|
|
|
1389 |
|
|
|
1390 |
|
|
|
1391 |
// Add scale section
|
|
|
1392 |
$pdf->sectionScale();
|
|
|
1393 |
|
|
|
1394 |
$i = 0;
|
|
|
1395 |
|
|
|
1396 |
foreach ($competencies as $record) {
|
|
|
1397 |
|
|
|
1398 |
$i = $i + 1;
|
|
|
1399 |
|
|
|
1400 |
$pdf->competencyTable($i, $record);
|
|
|
1401 |
|
|
|
1402 |
if ($i % 3 == 0 && $i < count($competencies)) {
|
|
|
1403 |
$pdf->AddPage();
|
|
|
1404 |
}
|
|
|
1405 |
}
|
|
|
1406 |
|
|
|
1407 |
}
|
|
|
1408 |
|
|
|
1409 |
return $pdf->Output();
|
|
|
1410 |
|
|
|
1411 |
}
|
|
|
1412 |
|
8230 |
eleazar |
1413 |
public function reportBothAction() {
|
|
|
1414 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1415 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1416 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1417 |
|
|
|
1418 |
$uuid = $this->params()->fromRoute('id');
|
|
|
1419 |
|
|
|
1420 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1421 |
$test = $testMapper->fetchOneByUuid($uuid);
|
|
|
1422 |
|
|
|
1423 |
$testBothMapper = CompanyPerformanceEvaluationTestBothMapper::getInstance($this->adapter);
|
|
|
1424 |
$testBoth = $testBothMapper->fetchOneByTestId($test->id);
|
|
|
1425 |
|
|
|
1426 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
1427 |
$form = $formMapper->fetchOne($test->form_id);
|
|
|
1428 |
|
|
|
1429 |
if (!$form) {
|
|
|
1430 |
return new JsonModel([
|
|
|
1431 |
'success' => false,
|
|
|
1432 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
|
|
1433 |
]);
|
|
|
1434 |
}
|
|
|
1435 |
|
|
|
1436 |
$request = $this->getRequest();
|
|
|
1437 |
if ($request->isGet()) {
|
|
|
1438 |
//Competencies
|
|
|
1439 |
|
|
|
1440 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
1441 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
|
|
1442 |
$competenceTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
15032 |
efrain |
1443 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
8230 |
eleazar |
1444 |
$jobDescriptionBehaviorCompetencyMapper = JobDescriptionBehaviorCompetencyMapper::getInstance($this->adapter);
|
|
|
1445 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
1446 |
|
|
|
1447 |
$competencies = [];
|
|
|
1448 |
|
|
|
1449 |
$jobDescriptionCompetency = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($form->job_description_id);
|
|
|
1450 |
|
|
|
1451 |
$content = json_decode($testBoth->content, true);
|
|
|
1452 |
|
|
|
1453 |
foreach ($jobDescriptionCompetency as $record) {
|
|
|
1454 |
|
|
|
1455 |
$competency = $competencyMapper->fetchOne($record->competency_id);
|
|
|
1456 |
$competenceType = $competenceTypeMapper->fetchOne($competency->competency_type_id);
|
|
|
1457 |
|
|
|
1458 |
if ($competency && $competenceType) {
|
|
|
1459 |
|
15032 |
efrain |
1460 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
8230 |
eleazar |
1461 |
$behaviors = [];
|
|
|
1462 |
|
|
|
1463 |
foreach ($behaviorCompetencies as $rows) {
|
|
|
1464 |
|
|
|
1465 |
$behavior = $behaviorMapper->fetchOne($rows->behavior_id);
|
|
|
1466 |
$jobDescriptionBehaviorCompetency = $jobDescriptionBehaviorCompetencyMapper->fetchOneByBehavior($form->job_description_id, $record->competency_id, $rows->behavior_id);
|
|
|
1467 |
|
|
|
1468 |
if ($behavior && $jobDescriptionBehaviorCompetency) {
|
|
|
1469 |
$rowData = [
|
|
|
1470 |
'description' => $behavior->description,
|
|
|
1471 |
'level' => $jobDescriptionBehaviorCompetency->level,
|
|
|
1472 |
'comment' => '',
|
|
|
1473 |
'evaluation' => '',
|
|
|
1474 |
|
|
|
1475 |
];
|
|
|
1476 |
|
|
|
1477 |
foreach($content as $eval) {
|
|
|
1478 |
if ($eval['competencyUuid'] == $competency->uuid &&
|
|
|
1479 |
$eval['behaviorUuid'] == $behavior->uuid) {
|
|
|
1480 |
|
|
|
1481 |
$rowData['comment'] = $eval['comment'];
|
|
|
1482 |
$rowData['evaluation'] = $eval['evaluation'];
|
|
|
1483 |
|
|
|
1484 |
|
|
|
1485 |
break;
|
|
|
1486 |
}
|
|
|
1487 |
}
|
|
|
1488 |
|
|
|
1489 |
$behaviors []= $rowData;
|
|
|
1490 |
}
|
|
|
1491 |
}
|
|
|
1492 |
|
|
|
1493 |
array_push($competencies, [
|
|
|
1494 |
'name' => $competency->name,
|
|
|
1495 |
'description' => $competency->description,
|
|
|
1496 |
'type' => $competenceType->name,
|
|
|
1497 |
'behaviors' => $behaviors
|
|
|
1498 |
]);
|
|
|
1499 |
}
|
|
|
1500 |
}
|
|
|
1501 |
|
|
|
1502 |
return $this->renderBothPDF($currentCompany, $testBoth, $competencies);
|
|
|
1503 |
}
|
|
|
1504 |
|
|
|
1505 |
return new JsonModel([
|
|
|
1506 |
'success' => false,
|
|
|
1507 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1508 |
]);
|
|
|
1509 |
}
|
|
|
1510 |
|
15079 |
efrain |
1511 |
public function renderBothPDF($company, $testBoth, $competencies) {
|
8230 |
eleazar |
1512 |
|
|
|
1513 |
|
15079 |
efrain |
1514 |
|
8230 |
eleazar |
1515 |
//Generate New PDF
|
|
|
1516 |
$pdf = new InterviewPDF();
|
|
|
1517 |
|
|
|
1518 |
|
|
|
1519 |
|
|
|
1520 |
|
15079 |
efrain |
1521 |
$target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
|
|
|
1522 |
|
|
|
1523 |
$header = $company->header ? $target_path . DIRECTORY_SEPARATOR . $company->header : '';
|
|
|
1524 |
if(empty($header) || !file_exists($header)) {
|
|
|
1525 |
$header = $this->config['leaderslinked.images_default.company_pdf_header'];
|
8230 |
eleazar |
1526 |
}
|
15079 |
efrain |
1527 |
|
|
|
1528 |
$footer = $company->footer ? $target_path . DIRECTORY_SEPARATOR . $company->footer : '';
|
|
|
1529 |
if(empty($footer) || !file_exists($footer)) {
|
|
|
1530 |
$footer = $this->config['leaderslinked.images_default.company_pdf_footer'];
|
|
|
1531 |
}
|
8230 |
eleazar |
1532 |
|
15079 |
efrain |
1533 |
$pdf->header = $header;
|
|
|
1534 |
$pdf->footer = $footer;
|
|
|
1535 |
|
|
|
1536 |
|
8230 |
eleazar |
1537 |
$pdf->SetMargins(10, 0, 10);
|
|
|
1538 |
|
|
|
1539 |
$pdf->AliasNbPages();
|
|
|
1540 |
$pdf->AddPage();
|
|
|
1541 |
|
|
|
1542 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1543 |
$test = $testMapper->fetchOne($testBoth->test_id);
|
|
|
1544 |
|
|
|
1545 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1546 |
$supervisor = $userMapper->fetchOne($testBoth->supervisor_id);
|
|
|
1547 |
|
|
|
1548 |
switch ($testBoth->points) {
|
|
|
1549 |
case "0":
|
15079 |
efrain |
1550 |
$points = "N/A";
|
8230 |
eleazar |
1551 |
break;
|
|
|
1552 |
case "1":
|
|
|
1553 |
$points = "25%";
|
|
|
1554 |
break;
|
|
|
1555 |
case "2":
|
|
|
1556 |
$points = "50%";
|
|
|
1557 |
break;
|
|
|
1558 |
case "3":
|
|
|
1559 |
$points = "75%";
|
|
|
1560 |
break;
|
|
|
1561 |
case "4":
|
|
|
1562 |
$points = "100%";
|
|
|
1563 |
break;
|
|
|
1564 |
default :
|
|
|
1565 |
$points = "ERROR";
|
|
|
1566 |
break;
|
|
|
1567 |
}
|
|
|
1568 |
|
|
|
1569 |
$rows = [
|
|
|
1570 |
array(
|
|
|
1571 |
'title' => 'Nombre Evaluado: ',
|
|
|
1572 |
'content' => $testBoth ? ' ' . $testBoth->first_name . ' ' . $testBoth->last_name : 'No Aplica'
|
|
|
1573 |
),
|
|
|
1574 |
array(
|
|
|
1575 |
'title' => 'Supervisado por: ',
|
|
|
1576 |
'content' => $supervisor ? ' ' . $supervisor->first_name . ' ' . $supervisor->last_name : ' No Aplica '
|
|
|
1577 |
),
|
|
|
1578 |
array(
|
|
|
1579 |
'title' => 'Comentarios del supervisor: ',
|
|
|
1580 |
'content' => $testBoth ? ' ' . $testBoth->comment : 'No Aplica'
|
|
|
1581 |
),
|
|
|
1582 |
array(
|
|
|
1583 |
'title' => 'Porcentage de adaptibilidad ',
|
|
|
1584 |
'content' => $points
|
|
|
1585 |
)
|
|
|
1586 |
];
|
|
|
1587 |
|
|
|
1588 |
$pdf->borderTable('DATOS DE LA ENTREVISTA', $rows);
|
|
|
1589 |
|
|
|
1590 |
$sections = json_decode($testBoth->content, true);
|
|
|
1591 |
/*
|
|
|
1592 |
for ($s = 0; $s < count($sections); $s++) {
|
|
|
1593 |
|
|
|
1594 |
$pdf->singleTable($sections[$s]['title'], [
|
|
|
1595 |
array(
|
|
|
1596 |
'content' => $sections[$s]['type'] != 'multiple' ? $sections[$s]['text'] : ''
|
|
|
1597 |
)]);
|
|
|
1598 |
|
|
|
1599 |
if ($sections[$s]['type'] == 'multiple') {
|
|
|
1600 |
|
|
|
1601 |
$pdf->titleOptionTable($sections[$s]['text']);
|
|
|
1602 |
|
|
|
1603 |
for ($o = 0; $o < count($sections[$s]['options']); $o++) {
|
|
|
1604 |
|
|
|
1605 |
$pdf->optionTable($sections[$s]['options'][$o]['title']);
|
|
|
1606 |
}
|
|
|
1607 |
$pdf->Ln();
|
|
|
1608 |
}
|
|
|
1609 |
if ($s % 2 == 0 && $s > 1) {
|
|
|
1610 |
$pdf->AddPage();
|
|
|
1611 |
}
|
|
|
1612 |
}*/
|
|
|
1613 |
|
|
|
1614 |
// Competencies
|
|
|
1615 |
if (count($competencies) != 0) {
|
|
|
1616 |
|
|
|
1617 |
// add new page
|
|
|
1618 |
|
|
|
1619 |
$pdf->AddPage();
|
|
|
1620 |
|
|
|
1621 |
$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:');
|
|
|
1622 |
|
|
|
1623 |
$pdf->singleTable('Anexo de valores:', $competencies_header);
|
|
|
1624 |
|
|
|
1625 |
|
|
|
1626 |
// Add scale section
|
|
|
1627 |
$pdf->sectionScale();
|
|
|
1628 |
|
|
|
1629 |
$i = 0;
|
|
|
1630 |
|
|
|
1631 |
foreach ($competencies as $record) {
|
|
|
1632 |
|
|
|
1633 |
$i = $i + 1;
|
|
|
1634 |
|
|
|
1635 |
$pdf->competencyTable($i, $record);
|
|
|
1636 |
|
|
|
1637 |
if ($i % 3 == 0 && $i < count($competencies)) {
|
|
|
1638 |
$pdf->AddPage();
|
|
|
1639 |
}
|
|
|
1640 |
}
|
|
|
1641 |
|
|
|
1642 |
}
|
|
|
1643 |
|
|
|
1644 |
return $pdf->Output();
|
|
|
1645 |
|
|
|
1646 |
}
|
|
|
1647 |
|
|
|
1648 |
public function reportSupervisorAction() {
|
|
|
1649 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1650 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1651 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1652 |
|
|
|
1653 |
$uuid = $this->params()->fromRoute('id');
|
|
|
1654 |
|
|
|
1655 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1656 |
$test = $testMapper->fetchOneByUuid($uuid);
|
|
|
1657 |
|
|
|
1658 |
$testSupervisorMapper = CompanyPerformanceEvaluationTestSupervisorMapper::getInstance($this->adapter);
|
|
|
1659 |
$testSupervisor = $testSupervisorMapper->fetchOneByTestId($test->id);
|
|
|
1660 |
|
|
|
1661 |
$formMapper = CompanyPerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
1662 |
$form = $formMapper->fetchOne($test->form_id);
|
|
|
1663 |
|
|
|
1664 |
if (!$form) {
|
|
|
1665 |
return new JsonModel([
|
|
|
1666 |
'success' => false,
|
|
|
1667 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
|
|
1668 |
]);
|
|
|
1669 |
}
|
|
|
1670 |
|
|
|
1671 |
$request = $this->getRequest();
|
|
|
1672 |
if ($request->isGet()) {
|
|
|
1673 |
//Competencies
|
|
|
1674 |
|
|
|
1675 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
1676 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
|
|
1677 |
$competenceTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
15032 |
efrain |
1678 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
8230 |
eleazar |
1679 |
$jobDescriptionBehaviorCompetencyMapper = JobDescriptionBehaviorCompetencyMapper::getInstance($this->adapter);
|
|
|
1680 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
1681 |
|
|
|
1682 |
$competencies = [];
|
|
|
1683 |
|
|
|
1684 |
$jobDescriptionCompetency = $jobDescriptionCompetencyMapper->fetchByJobDescriptionId($form->job_description_id);
|
|
|
1685 |
|
|
|
1686 |
$content = json_decode($testSupervisor->content, true);
|
|
|
1687 |
|
|
|
1688 |
foreach ($jobDescriptionCompetency as $record) {
|
|
|
1689 |
|
|
|
1690 |
$competency = $competencyMapper->fetchOne($record->competency_id);
|
|
|
1691 |
$competenceType = $competenceTypeMapper->fetchOne($competency->competency_type_id);
|
|
|
1692 |
|
|
|
1693 |
if ($competency && $competenceType) {
|
|
|
1694 |
|
15032 |
efrain |
1695 |
$behaviorCompetencies = $competencyBehaviorMapper->fetchAllByCompetencyId($competency->id);
|
8230 |
eleazar |
1696 |
$behaviors = [];
|
|
|
1697 |
|
|
|
1698 |
foreach ($behaviorCompetencies as $rows) {
|
|
|
1699 |
|
|
|
1700 |
$behavior = $behaviorMapper->fetchOne($rows->behavior_id);
|
|
|
1701 |
$jobDescriptionBehaviorCompetency = $jobDescriptionBehaviorCompetencyMapper->fetchOneByBehavior($form->job_description_id, $record->competency_id, $rows->behavior_id);
|
|
|
1702 |
|
|
|
1703 |
if ($behavior && $jobDescriptionBehaviorCompetency) {
|
|
|
1704 |
$rowData = [
|
|
|
1705 |
'description' => $behavior->description,
|
|
|
1706 |
'level' => $jobDescriptionBehaviorCompetency->level,
|
|
|
1707 |
'comment' => '',
|
|
|
1708 |
'evaluation' => '',
|
|
|
1709 |
|
|
|
1710 |
];
|
|
|
1711 |
|
|
|
1712 |
foreach($content as $eval) {
|
|
|
1713 |
if ($eval['competencyUuid'] == $competency->uuid &&
|
|
|
1714 |
$eval['behaviorUuid'] == $behavior->uuid) {
|
|
|
1715 |
|
|
|
1716 |
$rowData['comment'] = $eval['comment'];
|
|
|
1717 |
$rowData['evaluation'] = $eval['evaluation'];
|
|
|
1718 |
|
|
|
1719 |
|
|
|
1720 |
break;
|
|
|
1721 |
}
|
|
|
1722 |
}
|
|
|
1723 |
|
|
|
1724 |
$behaviors []= $rowData;
|
|
|
1725 |
}
|
|
|
1726 |
}
|
|
|
1727 |
|
|
|
1728 |
array_push($competencies, [
|
|
|
1729 |
'name' => $competency->name,
|
|
|
1730 |
'description' => $competency->description,
|
|
|
1731 |
'type' => $competenceType->name,
|
|
|
1732 |
'behaviors' => $behaviors
|
|
|
1733 |
]);
|
|
|
1734 |
}
|
|
|
1735 |
}
|
|
|
1736 |
|
|
|
1737 |
return $this->renderSupervisorPDF($currentCompany, $testSupervisor, $competencies);
|
|
|
1738 |
}
|
|
|
1739 |
|
|
|
1740 |
return new JsonModel([
|
|
|
1741 |
'success' => false,
|
|
|
1742 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1743 |
]);
|
|
|
1744 |
}
|
|
|
1745 |
|
|
|
1746 |
/**
|
|
|
1747 |
* Render PDF
|
15079 |
efrain |
1748 |
* @param Company $company
|
|
|
1749 |
* @param CompanyPerformanceEvaluationTestSelf $interviewEvaluation
|
8230 |
eleazar |
1750 |
* @param array $competencies
|
|
|
1751 |
* @return mixed
|
|
|
1752 |
*/
|
15079 |
efrain |
1753 |
public function renderSupervisorPDF($company, $testSupervisor, $competencies)
|
|
|
1754 |
{
|
8230 |
eleazar |
1755 |
|
|
|
1756 |
//Generate New PDF
|
|
|
1757 |
$pdf = new InterviewPDF();
|
|
|
1758 |
|
|
|
1759 |
$pdf->header = '';
|
|
|
1760 |
$pdf->footer = '';
|
|
|
1761 |
|
15079 |
efrain |
1762 |
$target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
|
|
|
1763 |
|
|
|
1764 |
$header = $company->header ? $target_path . DIRECTORY_SEPARATOR . $company->header : '';
|
|
|
1765 |
if(empty($header) || !file_exists($header)) {
|
|
|
1766 |
$header = $this->config['leaderslinked.images_default.company_pdf_header'];
|
8230 |
eleazar |
1767 |
}
|
15079 |
efrain |
1768 |
|
|
|
1769 |
$footer = $company->footer ? $target_path . DIRECTORY_SEPARATOR . $company->footer : '';
|
|
|
1770 |
if(empty($footer) || !file_exists($footer)) {
|
|
|
1771 |
$footer = $this->config['leaderslinked.images_default.company_pdf_footer'];
|
|
|
1772 |
}
|
|
|
1773 |
|
|
|
1774 |
$pdf->header = $header;
|
|
|
1775 |
$pdf->footer = $footer;
|
8230 |
eleazar |
1776 |
|
|
|
1777 |
$pdf->SetMargins(10, 0, 10);
|
|
|
1778 |
|
|
|
1779 |
$pdf->AliasNbPages();
|
|
|
1780 |
$pdf->AddPage();
|
|
|
1781 |
|
|
|
1782 |
$testMapper = CompanyPerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1783 |
$test = $testMapper->fetchOne($testSupervisor->test_id);
|
|
|
1784 |
|
|
|
1785 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1786 |
$supervisor = $userMapper->fetchOne($testSupervisor->supervisor_id);
|
|
|
1787 |
|
|
|
1788 |
switch ($testSupervisor->points) {
|
|
|
1789 |
case "0":
|
|
|
1790 |
$points = "Sugerir otro cargo";
|
|
|
1791 |
break;
|
|
|
1792 |
case "1":
|
|
|
1793 |
$points = "25%";
|
|
|
1794 |
break;
|
|
|
1795 |
case "2":
|
|
|
1796 |
$points = "50%";
|
|
|
1797 |
break;
|
|
|
1798 |
case "3":
|
|
|
1799 |
$points = "75%";
|
|
|
1800 |
break;
|
|
|
1801 |
case "4":
|
|
|
1802 |
$points = "100%";
|
|
|
1803 |
break;
|
|
|
1804 |
default :
|
|
|
1805 |
$points = "ERROR";
|
|
|
1806 |
break;
|
|
|
1807 |
}
|
|
|
1808 |
|
|
|
1809 |
$rows = [
|
|
|
1810 |
array(
|
|
|
1811 |
'title' => 'Nombre Evaluado: ',
|
|
|
1812 |
'content' => $testSupervisor ? ' ' . $testSupervisor->first_name . ' ' . $testSupervisor->last_name : 'No Aplica'
|
|
|
1813 |
),
|
|
|
1814 |
array(
|
|
|
1815 |
'title' => 'Supervisado por: ',
|
|
|
1816 |
'content' => $supervisor ? ' ' . $supervisor->first_name . ' ' . $supervisor->last_name : ' No Aplica '
|
|
|
1817 |
),
|
|
|
1818 |
array(
|
|
|
1819 |
'title' => 'Comentarios del supervisor: ',
|
|
|
1820 |
'content' => $testSupervisor ? ' ' . $testSupervisor->comment : 'No Aplica'
|
|
|
1821 |
),
|
|
|
1822 |
array(
|
|
|
1823 |
'title' => 'Porcentage de adaptibilidad ',
|
|
|
1824 |
'content' => $points
|
|
|
1825 |
)
|
|
|
1826 |
];
|
|
|
1827 |
|
|
|
1828 |
$pdf->borderTable('DATOS DE LA ENTREVISTA', $rows);
|
|
|
1829 |
|
|
|
1830 |
$sections = json_decode($testSupervisor->content, true);
|
|
|
1831 |
/*
|
|
|
1832 |
for ($s = 0; $s < count($sections); $s++) {
|
|
|
1833 |
|
|
|
1834 |
$pdf->singleTable($sections[$s]['title'], [
|
|
|
1835 |
array(
|
|
|
1836 |
'content' => $sections[$s]['type'] != 'multiple' ? $sections[$s]['text'] : ''
|
|
|
1837 |
)]);
|
|
|
1838 |
|
|
|
1839 |
if ($sections[$s]['type'] == 'multiple') {
|
|
|
1840 |
|
|
|
1841 |
$pdf->titleOptionTable($sections[$s]['text']);
|
|
|
1842 |
|
|
|
1843 |
for ($o = 0; $o < count($sections[$s]['options']); $o++) {
|
|
|
1844 |
|
|
|
1845 |
$pdf->optionTable($sections[$s]['options'][$o]['title']);
|
|
|
1846 |
}
|
|
|
1847 |
$pdf->Ln();
|
|
|
1848 |
}
|
|
|
1849 |
if ($s % 2 == 0 && $s > 1) {
|
|
|
1850 |
$pdf->AddPage();
|
|
|
1851 |
}
|
|
|
1852 |
}*/
|
|
|
1853 |
|
|
|
1854 |
// Competencies
|
|
|
1855 |
if (count($competencies) != 0) {
|
|
|
1856 |
|
|
|
1857 |
// add new page
|
|
|
1858 |
|
|
|
1859 |
$pdf->AddPage();
|
|
|
1860 |
|
|
|
1861 |
$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:');
|
|
|
1862 |
|
|
|
1863 |
$pdf->singleTable('Anexo de valores:', $competencies_header);
|
|
|
1864 |
|
|
|
1865 |
|
|
|
1866 |
// Add scale section
|
|
|
1867 |
$pdf->sectionScale();
|
|
|
1868 |
|
|
|
1869 |
$i = 0;
|
|
|
1870 |
|
|
|
1871 |
foreach ($competencies as $record) {
|
|
|
1872 |
|
|
|
1873 |
$i = $i + 1;
|
|
|
1874 |
|
|
|
1875 |
$pdf->competencyTable($i, $record);
|
|
|
1876 |
|
|
|
1877 |
if ($i % 3 == 0 && $i < count($competencies)) {
|
|
|
1878 |
$pdf->AddPage();
|
|
|
1879 |
}
|
|
|
1880 |
}
|
|
|
1881 |
|
|
|
1882 |
}
|
|
|
1883 |
|
|
|
1884 |
return $pdf->Output();
|
|
|
1885 |
|
|
|
1886 |
}
|
1384 |
efrain |
1887 |
}
|