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