| 977 |
geraldo |
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;
|
| 15444 |
efrain |
13 |
use Laminas\Mvc\I18n\Translator;
|
|
|
14 |
|
| 977 |
geraldo |
15 |
use LeadersLinked\Library\Functions;
|
| 15444 |
efrain |
16 |
use LeadersLinked\Mapper\PerformanceEvaluationFormMapper;
|
|
|
17 |
use LeadersLinked\Form\PerformanceEvaluation\PerformanceEvaluationFormForm;
|
|
|
18 |
use LeadersLinked\Model\PerformanceEvaluationForm;
|
| 977 |
geraldo |
19 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
| 1052 |
geraldo |
20 |
use LeadersLinked\Mapper\JobDescriptionMapper;
|
| 1271 |
geraldo |
21 |
use LeadersLinked\Mapper\JobDescriptionCompetencyMapper;
|
| 1272 |
geraldo |
22 |
use LeadersLinked\Mapper\CompetencyMapper;
|
| 1337 |
efrain |
23 |
use LeadersLinked\Library\PerformanceEvaluationPdf;
|
| 1273 |
geraldo |
24 |
use LeadersLinked\Mapper\CompetencyTypeMapper;
|
| 15030 |
efrain |
25 |
use LeadersLinked\Mapper\CompetencyBehaviorMapper;
|
| 1320 |
efrain |
26 |
use LeadersLinked\Mapper\BehaviorMapper;
|
| 1275 |
geraldo |
27 |
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
|
| 15444 |
efrain |
28 |
use LeadersLinked\Mapper\JobDescriptionCompetencyBehaviorMapper;
|
|
|
29 |
|
| 15253 |
stevensc |
30 |
use LeadersLinked\Mapper\JobDescriptionSubordinateMapper;
|
| 1336 |
efrain |
31 |
use LeadersLinked\Model\Company;
|
| 15444 |
efrain |
32 |
use LeadersLinked\Model\JobDescription;
|
| 977 |
geraldo |
33 |
|
| 15253 |
stevensc |
34 |
class PerformanceEvaluationFormController extends AbstractActionController
|
|
|
35 |
{
|
| 977 |
geraldo |
36 |
|
|
|
37 |
/**
|
|
|
38 |
*
|
|
|
39 |
* @var AdapterInterface
|
|
|
40 |
*/
|
|
|
41 |
private $adapter;
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
*
|
|
|
45 |
* @var AbstractAdapter
|
|
|
46 |
*/
|
|
|
47 |
private $cache;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
*
|
|
|
51 |
* @var LoggerInterface
|
|
|
52 |
*/
|
|
|
53 |
private $logger;
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
*
|
|
|
57 |
* @var array
|
|
|
58 |
*/
|
|
|
59 |
private $config;
|
| 15444 |
efrain |
60 |
|
|
|
61 |
/**
|
|
|
62 |
*
|
|
|
63 |
* @var Translator
|
|
|
64 |
*/
|
|
|
65 |
private $translator;
|
| 977 |
geraldo |
66 |
|
|
|
67 |
/**
|
|
|
68 |
*
|
|
|
69 |
* @param AdapterInterface $adapter
|
|
|
70 |
* @param AbstractAdapter $cache
|
|
|
71 |
* @param LoggerInterface $logger
|
|
|
72 |
* @param array $config
|
| 15444 |
efrain |
73 |
* @param Translator $translator
|
| 977 |
geraldo |
74 |
*/
|
| 15444 |
efrain |
75 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
| 15253 |
stevensc |
76 |
{
|
| 977 |
geraldo |
77 |
$this->adapter = $adapter;
|
|
|
78 |
$this->cache = $cache;
|
|
|
79 |
$this->logger = $logger;
|
|
|
80 |
$this->config = $config;
|
| 15444 |
efrain |
81 |
$this->translator = $translator;
|
| 977 |
geraldo |
82 |
}
|
|
|
83 |
|
| 15253 |
stevensc |
84 |
public function indexAction()
|
|
|
85 |
{
|
| 977 |
geraldo |
86 |
$request = $this->getRequest();
|
|
|
87 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
88 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
89 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
$request = $this->getRequest();
|
|
|
93 |
if ($request->isGet()) {
|
|
|
94 |
|
|
|
95 |
$headers = $request->getHeaders();
|
|
|
96 |
|
|
|
97 |
$isJson = false;
|
|
|
98 |
if ($headers->has('Accept')) {
|
|
|
99 |
$accept = $headers->get('Accept');
|
|
|
100 |
|
|
|
101 |
$prioritized = $accept->getPrioritized();
|
|
|
102 |
|
|
|
103 |
foreach ($prioritized as $key => $value) {
|
|
|
104 |
$raw = trim($value->getRaw());
|
|
|
105 |
|
|
|
106 |
if (!$isJson) {
|
|
|
107 |
$isJson = strpos($raw, 'json');
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
}
|
|
|
111 |
|
| 1336 |
efrain |
112 |
//$isJson = true;
|
| 977 |
geraldo |
113 |
if ($isJson) {
|
| 15253 |
stevensc |
114 |
$search = $this->params()->fromQuery('search');
|
|
|
115 |
$search = empty($search) ? '' : filter_var($search, FILTER_SANITIZE_STRING);
|
| 977 |
geraldo |
116 |
|
| 15371 |
efrain |
117 |
$start = intval($this->params()->fromQuery('start', 0), 10);
|
| 977 |
geraldo |
118 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
| 15371 |
efrain |
119 |
$page = intval($start / $records_x_page);
|
|
|
120 |
$page++;
|
|
|
121 |
|
| 977 |
geraldo |
122 |
$order = $this->params()->fromQuery('order', []);
|
|
|
123 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
124 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
125 |
|
|
|
126 |
$fields = ['name'];
|
|
|
127 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'name';
|
|
|
128 |
|
|
|
129 |
if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
130 |
$order_direction = 'ASC';
|
|
|
131 |
}
|
|
|
132 |
|
| 15444 |
efrain |
133 |
$performanceEvaluationMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
134 |
$paginator = $performanceEvaluationMapper->fetchAllDataTableByCompanyId($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
|
| 977 |
geraldo |
135 |
|
| 1078 |
geraldo |
136 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
| 15444 |
efrain |
137 |
$jobsDescription = [];
|
|
|
138 |
|
|
|
139 |
|
| 1078 |
geraldo |
140 |
|
| 977 |
geraldo |
141 |
$items = [];
|
|
|
142 |
$records = $paginator->getCurrentItems();
|
|
|
143 |
foreach ($records as $record) {
|
|
|
144 |
|
| 1078 |
geraldo |
145 |
|
| 15444 |
efrain |
146 |
if(!isset($jobsDescription[$record->job_description_id])) {
|
|
|
147 |
$jobDescription = $jobDescriptionMapper->fetchOne($record->job_description_id);
|
|
|
148 |
|
|
|
149 |
if($jobDescription) {
|
|
|
150 |
$jobsDescription[ $record->job_description_id ] = $jobDescription;
|
|
|
151 |
}
|
|
|
152 |
} else {
|
|
|
153 |
$jobDescription = $jobsDescription[$record->job_description_id];
|
|
|
154 |
}
|
|
|
155 |
|
| 1078 |
geraldo |
156 |
|
| 15444 |
efrain |
157 |
|
| 1098 |
geraldo |
158 |
if ($jobDescription) {
|
| 977 |
geraldo |
159 |
|
| 15444 |
efrain |
160 |
|
|
|
161 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->updated_on);
|
|
|
162 |
|
|
|
163 |
if($record->tests) {
|
|
|
164 |
$actions = [
|
|
|
165 |
'link_report' => $this->url()->fromRoute('performance-evaluation/forms/report', ['id' => $record->uuid]),
|
|
|
166 |
'link_active' => $record->status == PerformanceEvaluationForm::STATUS_ACTIVE ? '' : $this->url()->fromRoute('performance-evaluation/forms/active', ['id' => $record->uuid]),
|
|
|
167 |
'link_inactive' => $record->status == PerformanceEvaluationForm::STATUS_INACTIVE ? '' : $this->url()->fromRoute('performance-evaluation/forms/inactive', ['id' => $record->uuid])
|
|
|
168 |
];
|
|
|
169 |
} else {
|
|
|
170 |
|
|
|
171 |
$actions = [
|
|
|
172 |
'link_report' => $this->url()->fromRoute('performance-evaluation/forms/report', ['id' => $record->uuid]),
|
|
|
173 |
'link_edit' => $this->url()->fromRoute('performance-evaluation/forms/edit', ['id' => $record->uuid]),
|
|
|
174 |
'link_delete' => $this->url()->fromRoute('performance-evaluation/forms/delete', ['id' => $record->uuid])
|
|
|
175 |
];
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
|
| 1098 |
geraldo |
179 |
$item = [
|
|
|
180 |
'id' => $record->id,
|
|
|
181 |
'name' => $record->name,
|
|
|
182 |
'job_description' => $jobDescription->name,
|
| 15444 |
efrain |
183 |
'tests' => $record->tests,
|
|
|
184 |
'date' => $dt->format('d/m/Y H:i a'),
|
| 1098 |
geraldo |
185 |
'status' => $record->status,
|
| 15444 |
efrain |
186 |
'actions' => $actions
|
| 1098 |
geraldo |
187 |
];
|
|
|
188 |
}
|
|
|
189 |
|
| 977 |
geraldo |
190 |
array_push($items, $item);
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
return new JsonModel([
|
|
|
194 |
'success' => true,
|
|
|
195 |
'data' => [
|
|
|
196 |
'items' => $items,
|
|
|
197 |
'total' => $paginator->getTotalItemCount(),
|
|
|
198 |
]
|
|
|
199 |
]);
|
|
|
200 |
} else {
|
|
|
201 |
|
| 15444 |
efrain |
202 |
$form = new PerformanceEvaluationFormForm($this->adapter, $currentCompany->id);
|
| 977 |
geraldo |
203 |
|
| 15444 |
efrain |
204 |
$jobsDescription = [];
|
| 1051 |
geraldo |
205 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
| 15444 |
efrain |
206 |
$records = $jobDescriptionMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
207 |
foreach($records as $record)
|
|
|
208 |
{
|
|
|
209 |
$jobsDescription[ $record->uuid ] = $this->url()->fromRoute('performance-evaluation/forms/job-description', ['id' => $record->uuid]);
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
}
|
| 1051 |
geraldo |
213 |
|
| 977 |
geraldo |
214 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
215 |
$viewModel = new ViewModel();
|
|
|
216 |
$viewModel->setTemplate('leaders-linked/performance-evaluation-forms/index.phtml');
|
| 15444 |
efrain |
217 |
$viewModel->setVariables([
|
|
|
218 |
'jobsDescription' => $jobsDescription,
|
|
|
219 |
'form' => $form,
|
|
|
220 |
]);
|
| 977 |
geraldo |
221 |
return $viewModel;
|
|
|
222 |
}
|
|
|
223 |
} else {
|
|
|
224 |
return new JsonModel([
|
|
|
225 |
'success' => false,
|
|
|
226 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
| 15253 |
stevensc |
227 |
]);;
|
| 977 |
geraldo |
228 |
}
|
|
|
229 |
}
|
|
|
230 |
|
| 15253 |
stevensc |
231 |
public function addAction()
|
|
|
232 |
{
|
| 977 |
geraldo |
233 |
$request = $this->getRequest();
|
|
|
234 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
235 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
236 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
237 |
|
|
|
238 |
$request = $this->getRequest();
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
if ($request->isPost()) {
|
|
|
242 |
$dataPost = $request->getPost()->toArray();
|
| 15444 |
efrain |
243 |
$dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : PerformanceEvaluationForm::STATUS_INACTIVE;
|
| 1059 |
geraldo |
244 |
|
| 15444 |
efrain |
245 |
$form = new PerformanceEvaluationFormForm($this->adapter, $currentCompany->id);
|
| 977 |
geraldo |
246 |
$form->setData($dataPost);
|
|
|
247 |
|
|
|
248 |
if ($form->isValid()) {
|
| 1058 |
geraldo |
249 |
|
|
|
250 |
|
| 977 |
geraldo |
251 |
$dataPost = (array) $form->getData();
|
|
|
252 |
|
|
|
253 |
$hydrator = new ObjectPropertyHydrator();
|
| 15444 |
efrain |
254 |
$performanceEvaluation = new PerformanceEvaluationForm();
|
|
|
255 |
$hydrator->hydrate($dataPost, $performanceEvaluation);
|
| 977 |
geraldo |
256 |
|
| 1075 |
geraldo |
257 |
|
| 15444 |
efrain |
258 |
$performanceEvaluation->company_id = $currentCompany->id;
|
|
|
259 |
|
|
|
260 |
|
| 1075 |
geraldo |
261 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
262 |
$jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
|
| 15444 |
efrain |
263 |
$performanceEvaluation->job_description_id = $jobDescription->id;
|
|
|
264 |
$performanceEvaluation->content = $this->serialize($jobDescription);
|
| 1075 |
geraldo |
265 |
|
| 15444 |
efrain |
266 |
$performanceEvaluationMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
267 |
|
|
|
268 |
|
|
|
269 |
$result = $performanceEvaluationMapper->insert($performanceEvaluation);
|
| 1076 |
geraldo |
270 |
|
| 977 |
geraldo |
271 |
|
|
|
272 |
if ($result) {
|
| 15444 |
efrain |
273 |
$this->logger->info('Se agrego el Formulario de Evaluación de Desempeño : ' . $performanceEvaluation->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
| 977 |
geraldo |
274 |
|
|
|
275 |
// Get record by id
|
| 15444 |
efrain |
276 |
$record = $performanceEvaluationMapper->fetchOne($performanceEvaluation->id);
|
| 977 |
geraldo |
277 |
|
|
|
278 |
if ($record) {
|
| 1098 |
geraldo |
279 |
|
| 977 |
geraldo |
280 |
$data = [
|
|
|
281 |
'success' => true,
|
|
|
282 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
283 |
];
|
|
|
284 |
} else {
|
| 1098 |
geraldo |
285 |
|
| 977 |
geraldo |
286 |
$data = [
|
|
|
287 |
'success' => false,
|
|
|
288 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
289 |
];
|
|
|
290 |
}
|
|
|
291 |
} else {
|
|
|
292 |
$data = [
|
|
|
293 |
'success' => false,
|
| 15444 |
efrain |
294 |
'data' => $performanceEvaluationMapper->getError()
|
| 977 |
geraldo |
295 |
];
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
return new JsonModel($data);
|
|
|
299 |
} else {
|
|
|
300 |
$messages = [];
|
|
|
301 |
$form_messages = (array) $form->getMessages();
|
|
|
302 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
303 |
|
|
|
304 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
return new JsonModel([
|
|
|
308 |
'success' => false,
|
|
|
309 |
'data' => $messages
|
|
|
310 |
]);
|
|
|
311 |
}
|
|
|
312 |
} else {
|
|
|
313 |
$data = [
|
|
|
314 |
'success' => false,
|
|
|
315 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
316 |
];
|
|
|
317 |
|
|
|
318 |
return new JsonModel($data);
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
return new JsonModel($data);
|
|
|
322 |
}
|
|
|
323 |
|
| 15253 |
stevensc |
324 |
public function editAction()
|
|
|
325 |
{
|
| 977 |
geraldo |
326 |
$request = $this->getRequest();
|
|
|
327 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
328 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
329 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
330 |
|
|
|
331 |
$request = $this->getRequest();
|
|
|
332 |
$uuid = $this->params()->fromRoute('id');
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
if (!$uuid) {
|
|
|
336 |
$data = [
|
|
|
337 |
'success' => false,
|
|
|
338 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
339 |
];
|
|
|
340 |
|
|
|
341 |
return new JsonModel($data);
|
|
|
342 |
}
|
|
|
343 |
|
| 15444 |
efrain |
344 |
$performanceEvaluationMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
345 |
$performanceEvaluation = $performanceEvaluationMapper->fetchOneByUuid($uuid);
|
|
|
346 |
if (!$performanceEvaluation) {
|
| 977 |
geraldo |
347 |
$data = [
|
|
|
348 |
'success' => false,
|
|
|
349 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
350 |
];
|
|
|
351 |
|
|
|
352 |
return new JsonModel($data);
|
|
|
353 |
}
|
|
|
354 |
|
| 15444 |
efrain |
355 |
if ($performanceEvaluation->company_id != $currentCompany->id) {
|
| 977 |
geraldo |
356 |
return new JsonModel([
|
|
|
357 |
'success' => false,
|
|
|
358 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
359 |
]);
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
if ($request->isPost()) {
|
|
|
364 |
$dataPost = $request->getPost()->toArray();
|
| 15444 |
efrain |
365 |
$dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : PerformanceEvaluationForm::STATUS_INACTIVE;
|
|
|
366 |
|
|
|
367 |
$form = new PerformanceEvaluationFormForm($this->adapter, $currentCompany->id);
|
| 977 |
geraldo |
368 |
$form->setData($dataPost);
|
|
|
369 |
|
|
|
370 |
if ($form->isValid()) {
|
|
|
371 |
$dataPost = (array) $form->getData();
|
|
|
372 |
|
|
|
373 |
$hydrator = new ObjectPropertyHydrator();
|
| 15444 |
efrain |
374 |
$hydrator->hydrate($dataPost, $performanceEvaluation);
|
| 977 |
geraldo |
375 |
|
| 15444 |
efrain |
376 |
if (!$performanceEvaluation->status) {
|
|
|
377 |
$performanceEvaluation->status = PerformanceEvaluationForm::STATUS_INACTIVE;
|
| 977 |
geraldo |
378 |
}
|
|
|
379 |
|
| 1080 |
geraldo |
380 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
381 |
$jobDescription = $jobDescriptionMapper->fetchOneByUuid($dataPost['job_description_id']);
|
| 15444 |
efrain |
382 |
|
|
|
383 |
$performanceEvaluation->job_description_id = $jobDescription->id;
|
|
|
384 |
$performanceEvaluation->content = $this->serialize($jobDescription);
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
$result = $performanceEvaluationMapper->update($performanceEvaluation);
|
| 1080 |
geraldo |
388 |
|
| 977 |
geraldo |
389 |
if ($result) {
|
| 15444 |
efrain |
390 |
$this->logger->info('Se actualizo el Formulario de Evaluación de Desempeño : ' . $performanceEvaluation->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
| 977 |
geraldo |
391 |
$data = [
|
|
|
392 |
'success' => true,
|
|
|
393 |
'data' => 'LABEL_RECORD_UPDATED'
|
|
|
394 |
];
|
|
|
395 |
} else {
|
|
|
396 |
$data = [
|
|
|
397 |
'success' => false,
|
| 15444 |
efrain |
398 |
'data' => $performanceEvaluationMapper->getError()
|
| 977 |
geraldo |
399 |
];
|
|
|
400 |
}
|
|
|
401 |
|
|
|
402 |
return new JsonModel($data);
|
|
|
403 |
} else {
|
|
|
404 |
$messages = [];
|
|
|
405 |
$form_messages = (array) $form->getMessages();
|
|
|
406 |
foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
407 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
408 |
}
|
|
|
409 |
|
|
|
410 |
return new JsonModel([
|
|
|
411 |
'success' => false,
|
|
|
412 |
'data' => $messages
|
|
|
413 |
]);
|
|
|
414 |
}
|
|
|
415 |
} else if ($request->isGet()) {
|
|
|
416 |
|
| 1098 |
geraldo |
417 |
|
| 15444 |
efrain |
418 |
$content = json_decode($performanceEvaluation->content);
|
|
|
419 |
|
| 977 |
geraldo |
420 |
$data = [
|
|
|
421 |
'success' => true,
|
|
|
422 |
'data' => [
|
| 15444 |
efrain |
423 |
'name' => $performanceEvaluation->name,
|
|
|
424 |
'description' => $performanceEvaluation->description,
|
|
|
425 |
'job_description_id' => $content->uuid,
|
|
|
426 |
'status' => $performanceEvaluation->status,
|
|
|
427 |
'content' => $content,
|
|
|
428 |
|
| 977 |
geraldo |
429 |
]
|
|
|
430 |
];
|
|
|
431 |
|
|
|
432 |
return new JsonModel($data);
|
|
|
433 |
} else {
|
|
|
434 |
$data = [
|
|
|
435 |
'success' => false,
|
|
|
436 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
437 |
];
|
|
|
438 |
|
|
|
439 |
return new JsonModel($data);
|
|
|
440 |
}
|
|
|
441 |
|
|
|
442 |
return new JsonModel($data);
|
|
|
443 |
}
|
|
|
444 |
|
| 15253 |
stevensc |
445 |
public function deleteAction()
|
|
|
446 |
{
|
| 977 |
geraldo |
447 |
$request = $this->getRequest();
|
|
|
448 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
449 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
450 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
451 |
|
|
|
452 |
$request = $this->getRequest();
|
|
|
453 |
$uuid = $this->params()->fromRoute('id');
|
|
|
454 |
|
|
|
455 |
if (!$uuid) {
|
|
|
456 |
$data = [
|
|
|
457 |
'success' => false,
|
|
|
458 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
459 |
];
|
|
|
460 |
|
|
|
461 |
return new JsonModel($data);
|
|
|
462 |
}
|
|
|
463 |
|
| 15444 |
efrain |
464 |
$performanceEvaluationMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
465 |
$performanceEvaluation = $performanceEvaluationMapper->fetchOneByUuid($uuid);
|
|
|
466 |
if (!$performanceEvaluation) {
|
| 977 |
geraldo |
467 |
$data = [
|
|
|
468 |
'success' => false,
|
|
|
469 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
470 |
];
|
|
|
471 |
|
|
|
472 |
return new JsonModel($data);
|
|
|
473 |
}
|
|
|
474 |
|
| 15444 |
efrain |
475 |
if ($performanceEvaluation->company_id != $currentCompany->id) {
|
| 977 |
geraldo |
476 |
return new JsonModel([
|
|
|
477 |
'success' => false,
|
|
|
478 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
479 |
]);
|
|
|
480 |
}
|
|
|
481 |
|
|
|
482 |
if ($request->isPost()) {
|
|
|
483 |
|
|
|
484 |
|
| 15444 |
efrain |
485 |
$result = $performanceEvaluationMapper->delete($performanceEvaluation->id);
|
| 977 |
geraldo |
486 |
if ($result) {
|
| 15444 |
efrain |
487 |
$this->logger->info('Se borro el Formulario de Evaluación de Desempeño : ' . $performanceEvaluation->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
| 977 |
geraldo |
488 |
|
|
|
489 |
$data = [
|
|
|
490 |
'success' => true,
|
|
|
491 |
'data' => 'LABEL_RECORD_DELETED'
|
|
|
492 |
];
|
|
|
493 |
} else {
|
|
|
494 |
|
|
|
495 |
$data = [
|
|
|
496 |
'success' => false,
|
| 15444 |
efrain |
497 |
'data' => $performanceEvaluationMapper->getError()
|
| 977 |
geraldo |
498 |
];
|
|
|
499 |
|
|
|
500 |
return new JsonModel($data);
|
|
|
501 |
}
|
|
|
502 |
} else {
|
|
|
503 |
$data = [
|
|
|
504 |
'success' => false,
|
|
|
505 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
506 |
];
|
|
|
507 |
|
|
|
508 |
return new JsonModel($data);
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
return new JsonModel($data);
|
|
|
512 |
}
|
| 15444 |
efrain |
513 |
|
|
|
514 |
public function activeAction()
|
| 15253 |
stevensc |
515 |
{
|
| 15444 |
efrain |
516 |
$request = $this->getRequest();
|
| 1263 |
geraldo |
517 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| 15444 |
efrain |
518 |
$currentCompany = $currentUserPlugin->getCompany();
|
| 1263 |
geraldo |
519 |
$currentUser = $currentUserPlugin->getUser();
|
| 15444 |
efrain |
520 |
|
|
|
521 |
$request = $this->getRequest();
|
|
|
522 |
$uuid = $this->params()->fromRoute('id');
|
|
|
523 |
|
|
|
524 |
if (!$uuid) {
|
|
|
525 |
$data = [
|
|
|
526 |
'success' => false,
|
|
|
527 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
528 |
];
|
|
|
529 |
|
|
|
530 |
return new JsonModel($data);
|
|
|
531 |
}
|
|
|
532 |
|
|
|
533 |
$performanceEvaluationMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
534 |
$performanceEvaluation = $performanceEvaluationMapper->fetchOneByUuid($uuid);
|
|
|
535 |
if (!$performanceEvaluation) {
|
|
|
536 |
$data = [
|
|
|
537 |
'success' => false,
|
|
|
538 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
539 |
];
|
|
|
540 |
|
|
|
541 |
return new JsonModel($data);
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
if ($performanceEvaluation->company_id != $currentCompany->id) {
|
|
|
545 |
return new JsonModel([
|
|
|
546 |
'success' => false,
|
|
|
547 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
548 |
]);
|
|
|
549 |
}
|
|
|
550 |
|
|
|
551 |
if($performanceEvaluation->status == PerformanceEvaluationForm::STATUS_ACTIVE) {
|
|
|
552 |
return new JsonModel([
|
|
|
553 |
'success' => false,
|
|
|
554 |
'data' => 'ERROR_RECORD_IS_CURRENTLY_ACTIVE'
|
|
|
555 |
]);
|
|
|
556 |
|
|
|
557 |
}
|
|
|
558 |
|
|
|
559 |
if ($request->isPost()) {
|
|
|
560 |
|
|
|
561 |
|
|
|
562 |
$result = $performanceEvaluationMapper->active($performanceEvaluation);
|
|
|
563 |
if ($result) {
|
|
|
564 |
$this->logger->info('Se activo el Formulario de Evaluación de Desempeño : ' . $performanceEvaluation->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
565 |
|
|
|
566 |
$data = [
|
|
|
567 |
'success' => true,
|
|
|
568 |
'data' => 'LABEL_RECORD_ACTIVED'
|
|
|
569 |
];
|
|
|
570 |
} else {
|
|
|
571 |
|
|
|
572 |
$data = [
|
|
|
573 |
'success' => false,
|
|
|
574 |
'data' => $performanceEvaluationMapper->getError()
|
|
|
575 |
];
|
|
|
576 |
|
|
|
577 |
return new JsonModel($data);
|
|
|
578 |
}
|
|
|
579 |
} else {
|
|
|
580 |
$data = [
|
|
|
581 |
'success' => false,
|
|
|
582 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
583 |
];
|
|
|
584 |
|
|
|
585 |
return new JsonModel($data);
|
|
|
586 |
}
|
|
|
587 |
|
|
|
588 |
return new JsonModel($data);
|
|
|
589 |
}
|
|
|
590 |
|
|
|
591 |
public function inactiveAction()
|
|
|
592 |
{
|
|
|
593 |
$request = $this->getRequest();
|
|
|
594 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| 1277 |
geraldo |
595 |
$currentCompany = $currentUserPlugin->getCompany();
|
| 15444 |
efrain |
596 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
597 |
|
|
|
598 |
$request = $this->getRequest();
|
| 1263 |
geraldo |
599 |
$uuid = $this->params()->fromRoute('id');
|
| 15444 |
efrain |
600 |
|
|
|
601 |
if (!$uuid) {
|
|
|
602 |
$data = [
|
|
|
603 |
'success' => false,
|
|
|
604 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
605 |
];
|
|
|
606 |
|
|
|
607 |
return new JsonModel($data);
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
$performanceEvaluationMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
611 |
$performanceEvaluation = $performanceEvaluationMapper->fetchOneByUuid($uuid);
|
|
|
612 |
if (!$performanceEvaluation) {
|
|
|
613 |
$data = [
|
|
|
614 |
'success' => false,
|
|
|
615 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
616 |
];
|
|
|
617 |
|
|
|
618 |
return new JsonModel($data);
|
|
|
619 |
}
|
|
|
620 |
|
|
|
621 |
if ($performanceEvaluation->company_id != $currentCompany->id) {
|
| 1263 |
geraldo |
622 |
return new JsonModel([
|
|
|
623 |
'success' => false,
|
| 15444 |
efrain |
624 |
'data' => 'ERROR_UNAUTHORIZED'
|
| 1263 |
geraldo |
625 |
]);
|
|
|
626 |
}
|
| 15444 |
efrain |
627 |
|
|
|
628 |
if($performanceEvaluation->status == PerformanceEvaluationForm::STATUS_INACTIVE) {
|
| 1263 |
geraldo |
629 |
return new JsonModel([
|
|
|
630 |
'success' => false,
|
| 15444 |
efrain |
631 |
'data' => 'ERROR_RECORD_IS_CURRENTLY_INACTIVE'
|
| 1263 |
geraldo |
632 |
]);
|
| 15444 |
efrain |
633 |
|
| 1263 |
geraldo |
634 |
}
|
| 15444 |
efrain |
635 |
|
|
|
636 |
if ($request->isPost()) {
|
|
|
637 |
|
|
|
638 |
|
|
|
639 |
$result = $performanceEvaluationMapper->inactive($performanceEvaluation);
|
|
|
640 |
if ($result) {
|
|
|
641 |
$this->logger->info('Se inactivo el Formulario de Evaluación de Desempeño : ' . $performanceEvaluation->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
642 |
|
|
|
643 |
$data = [
|
|
|
644 |
'success' => true,
|
|
|
645 |
'data' => 'LABEL_RECORD_ACTIVED'
|
|
|
646 |
];
|
|
|
647 |
} else {
|
|
|
648 |
|
|
|
649 |
$data = [
|
|
|
650 |
'success' => false,
|
|
|
651 |
'data' => $performanceEvaluationMapper->getError()
|
|
|
652 |
];
|
|
|
653 |
|
|
|
654 |
return new JsonModel($data);
|
|
|
655 |
}
|
|
|
656 |
} else {
|
|
|
657 |
$data = [
|
|
|
658 |
'success' => false,
|
|
|
659 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
660 |
];
|
|
|
661 |
|
|
|
662 |
return new JsonModel($data);
|
|
|
663 |
}
|
|
|
664 |
|
|
|
665 |
return new JsonModel($data);
|
|
|
666 |
}
|
| 1263 |
geraldo |
667 |
|
| 15444 |
efrain |
668 |
public function reportAction()
|
|
|
669 |
{
|
|
|
670 |
$request = $this->getRequest();
|
|
|
671 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
672 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
673 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
674 |
|
|
|
675 |
$request = $this->getRequest();
|
|
|
676 |
$uuid = $this->params()->fromRoute('id');
|
|
|
677 |
|
|
|
678 |
if (!$uuid) {
|
|
|
679 |
$data = [
|
|
|
680 |
'success' => false,
|
|
|
681 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
682 |
];
|
|
|
683 |
|
|
|
684 |
return new JsonModel($data);
|
|
|
685 |
}
|
|
|
686 |
|
|
|
687 |
$performanceEvaluationMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
688 |
$performanceEvaluation = $performanceEvaluationMapper->fetchOneByUuid($uuid);
|
|
|
689 |
if (!$performanceEvaluation) {
|
|
|
690 |
$data = [
|
|
|
691 |
'success' => false,
|
|
|
692 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
693 |
];
|
|
|
694 |
|
|
|
695 |
return new JsonModel($data);
|
|
|
696 |
}
|
|
|
697 |
|
|
|
698 |
if ($performanceEvaluation->company_id != $currentCompany->id) {
|
| 1263 |
geraldo |
699 |
return new JsonModel([
|
|
|
700 |
'success' => false,
|
| 15444 |
efrain |
701 |
'data' => 'ERROR_UNAUTHORIZED'
|
| 1263 |
geraldo |
702 |
]);
|
|
|
703 |
}
|
| 15444 |
efrain |
704 |
|
|
|
705 |
if($performanceEvaluation->status == PerformanceEvaluationForm::STATUS_INACTIVE) {
|
| 1263 |
geraldo |
706 |
return new JsonModel([
|
|
|
707 |
'success' => false,
|
| 15444 |
efrain |
708 |
'data' => 'ERROR_RECORD_IS_CURRENTLY_INACTIVE'
|
| 1263 |
geraldo |
709 |
]);
|
| 15444 |
efrain |
710 |
|
| 1263 |
geraldo |
711 |
}
|
|
|
712 |
|
|
|
713 |
$request = $this->getRequest();
|
|
|
714 |
if ($request->isGet()) {
|
| 15444 |
efrain |
715 |
|
|
|
716 |
$filename = Functions::normalizeStringFilename($performanceEvaluation->name . '-' . date('Y-m-d H:i a') . '.pdf');
|
|
|
717 |
|
|
|
718 |
|
|
|
719 |
|
|
|
720 |
|
|
|
721 |
$content = base64_encode($this->renderPDF($performanceEvaluation));
|
|
|
722 |
$data = [
|
|
|
723 |
'success' => true,
|
|
|
724 |
'data' => [
|
|
|
725 |
'basename' => $filename,
|
|
|
726 |
'content' => $content
|
|
|
727 |
]
|
|
|
728 |
];
|
|
|
729 |
|
|
|
730 |
return new JsonModel($data);
|
|
|
731 |
|
|
|
732 |
/*
|
|
|
733 |
|
|
|
734 |
$content = $this->renderPdf($currentCompany, $jobDescription);
|
|
|
735 |
$response = new Response();
|
|
|
736 |
$response->setStatusCode(200);
|
|
|
737 |
$response->setContent($content);
|
|
|
738 |
|
|
|
739 |
|
|
|
740 |
|
|
|
741 |
$headers = $response->getHeaders();
|
|
|
742 |
$headers->clearHeaders();
|
|
|
743 |
|
|
|
744 |
$headers->addHeaderLine('Content-Description: File Transfer');
|
|
|
745 |
$headers->addHeaderLine('Content-Type: application/pdf');
|
|
|
746 |
//$headers->addHeaderLine('Content-Disposition: attachment; filename=' . $filename);
|
|
|
747 |
$headers->addHeaderLine('Content-Transfer-Encoding: binary');
|
|
|
748 |
$headers->addHeaderLine('Expires: 0');
|
|
|
749 |
$headers->addHeaderLine('Cache-Control: must-revalidate');
|
|
|
750 |
$headers->addHeaderLine('Pragma: public');
|
|
|
751 |
return $response;
|
|
|
752 |
*/
|
|
|
753 |
|
| 1263 |
geraldo |
754 |
|
|
|
755 |
|
|
|
756 |
|
| 15444 |
efrain |
757 |
return ;
|
|
|
758 |
} else {
|
| 1263 |
geraldo |
759 |
|
|
|
760 |
|
| 15444 |
efrain |
761 |
return new JsonModel([
|
|
|
762 |
'success' => false,
|
|
|
763 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
764 |
]);
|
| 1263 |
geraldo |
765 |
}
|
|
|
766 |
}
|
| 1292 |
geraldo |
767 |
|
| 1277 |
geraldo |
768 |
/**
|
|
|
769 |
* Render PDF
|
| 15444 |
efrain |
770 |
* @param PerformanceEvaluationForm $performanceEvaluation
|
|
|
771 |
|
| 1336 |
efrain |
772 |
* @return mixed
|
| 1277 |
geraldo |
773 |
*/
|
| 15444 |
efrain |
774 |
private function renderPDF($performanceEvaluation)
|
| 15253 |
stevensc |
775 |
{
|
| 15444 |
efrain |
776 |
$request = $this->getRequest();
|
|
|
777 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
778 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
779 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
780 |
|
| 1263 |
geraldo |
781 |
|
| 1277 |
geraldo |
782 |
//Generate New PDF
|
|
|
783 |
$pdf = new PerformanceEvaluationPdf();
|
|
|
784 |
|
| 15444 |
efrain |
785 |
$target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $currentCompany->uuid;
|
|
|
786 |
$header = $currentCompany->header ? $target_path . DIRECTORY_SEPARATOR . $currentCompany->header : '';
|
| 15253 |
stevensc |
787 |
if (empty($header) || !file_exists($header)) {
|
| 15079 |
efrain |
788 |
$header = $this->config['leaderslinked.images_default.company_pdf_header'];
|
| 1277 |
geraldo |
789 |
}
|
| 15253 |
stevensc |
790 |
|
| 15444 |
efrain |
791 |
$footer = $currentCompany->footer ? $target_path . DIRECTORY_SEPARATOR . $currentCompany->footer : '';
|
| 15253 |
stevensc |
792 |
if (empty($footer) || !file_exists($footer)) {
|
| 15079 |
efrain |
793 |
$footer = $this->config['leaderslinked.images_default.company_pdf_footer'];
|
|
|
794 |
}
|
| 15444 |
efrain |
795 |
|
|
|
796 |
$content = json_decode($performanceEvaluation->content);
|
| 15253 |
stevensc |
797 |
|
| 15079 |
efrain |
798 |
$pdf->header = $header;
|
|
|
799 |
$pdf->footer = $footer;
|
| 15444 |
efrain |
800 |
$pdf->translator = $this->translator;
|
| 1277 |
geraldo |
801 |
|
|
|
802 |
$pdf->SetMargins(10, 0, 10);
|
|
|
803 |
|
|
|
804 |
$pdf->AliasNbPages();
|
|
|
805 |
$pdf->AddPage();
|
| 15444 |
efrain |
806 |
|
|
|
807 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $performanceEvaluation->updated_on);
|
| 1277 |
geraldo |
808 |
|
|
|
809 |
|
|
|
810 |
$rows = [
|
| 15444 |
efrain |
811 |
[
|
|
|
812 |
'title' => $this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_POSITION') . ' : ',
|
|
|
813 |
'content' => $content->name,
|
|
|
814 |
],
|
|
|
815 |
[
|
|
|
816 |
'title' => $this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_EVALUATED') . ' : ',
|
| 1277 |
geraldo |
817 |
'content' => ''
|
| 15444 |
efrain |
818 |
],
|
|
|
819 |
|
|
|
820 |
[
|
|
|
821 |
'title' => $this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_EVALUATE_SIGNATURE') . ' : ',
|
| 1277 |
geraldo |
822 |
'content' => ''
|
| 15444 |
efrain |
823 |
],
|
|
|
824 |
[
|
|
|
825 |
'title' => $this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_EVALUATOR') . ' : ',
|
| 1277 |
geraldo |
826 |
'content' => ''
|
| 15444 |
efrain |
827 |
],
|
|
|
828 |
[
|
|
|
829 |
'title' => $this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_EVALUATOR_SIGNATURE') . ' : ',
|
| 1277 |
geraldo |
830 |
'content' => ''
|
| 15444 |
efrain |
831 |
],
|
|
|
832 |
[
|
|
|
833 |
'title' => $this->translator->translate( 'LABEL_PDF_PERFORMANCE_EVALUATION_MANAGER_SIGNATURE') . ' : ',
|
|
|
834 |
'content' => ''
|
|
|
835 |
],
|
|
|
836 |
[
|
|
|
837 |
'title' => $this->translator->translate('LABEL_DATE'),
|
|
|
838 |
'content' => $dt->format('d/m/Y H:i a')
|
|
|
839 |
]
|
| 1277 |
geraldo |
840 |
];
|
| 15444 |
efrain |
841 |
|
| 1277 |
geraldo |
842 |
|
| 1292 |
geraldo |
843 |
|
| 15444 |
efrain |
844 |
$pdf->borderTable($this->translator->translate('LABEL_PDF_PERFORMANCE_EVALUATION_TITLE'), $rows);
|
|
|
845 |
|
|
|
846 |
$pdf->evaluationTable();
|
|
|
847 |
|
|
|
848 |
|
| 1292 |
geraldo |
849 |
//Sections
|
| 15444 |
efrain |
850 |
/*
|
| 1282 |
geraldo |
851 |
$sections = json_decode($performanceEvaluation->content, true);
|
| 1277 |
geraldo |
852 |
|
| 1309 |
geraldo |
853 |
for ($s = 0; $s < count($sections); $s++) {
|
| 1277 |
geraldo |
854 |
|
| 1317 |
geraldo |
855 |
$pdf->singleTable($sections[$s]['title'], [
|
|
|
856 |
array(
|
|
|
857 |
'content' => $sections[$s]['type'] != 'multiple' ? $sections[$s]['text'] : ''
|
| 15253 |
stevensc |
858 |
)
|
|
|
859 |
]);
|
| 1277 |
geraldo |
860 |
|
| 1310 |
geraldo |
861 |
if ($sections[$s]['type'] == 'multiple') {
|
| 15253 |
stevensc |
862 |
|
| 1318 |
geraldo |
863 |
$pdf->titleOptionTable($sections[$s]['text']);
|
| 1288 |
geraldo |
864 |
|
| 1309 |
geraldo |
865 |
for ($o = 0; $o < count($sections[$s]['options']); $o++) {
|
| 1292 |
geraldo |
866 |
|
| 1309 |
geraldo |
867 |
$pdf->optionTable($sections[$s]['options'][$o]['title']);
|
| 1292 |
geraldo |
868 |
}
|
| 1307 |
geraldo |
869 |
$pdf->Ln();
|
| 1292 |
geraldo |
870 |
}
|
| 1312 |
geraldo |
871 |
if ($s % 2 == 0 && $s > 1) {
|
| 1317 |
geraldo |
872 |
$pdf->AddPage();
|
| 1308 |
geraldo |
873 |
}
|
| 15444 |
efrain |
874 |
}*/
|
| 1292 |
geraldo |
875 |
// Competencies
|
| 15444 |
efrain |
876 |
if ($content->competencies_selected) {
|
| 1292 |
geraldo |
877 |
|
|
|
878 |
// add new page
|
|
|
879 |
|
|
|
880 |
$pdf->AddPage();
|
| 15444 |
efrain |
881 |
/*
|
|
|
882 |
$competencies_header[] = [
|
|
|
883 |
'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:'
|
|
|
884 |
|
|
|
885 |
];
|
| 1292 |
geraldo |
886 |
|
|
|
887 |
$pdf->singleTable('Anexo de valores:', $competencies_header);
|
|
|
888 |
|
|
|
889 |
|
|
|
890 |
// Add scale section
|
|
|
891 |
$pdf->sectionScale();
|
| 15444 |
efrain |
892 |
*/
|
|
|
893 |
|
| 1292 |
geraldo |
894 |
$i = 0;
|
|
|
895 |
|
| 15444 |
efrain |
896 |
$max = count($content->competencies_selected);
|
|
|
897 |
for($i = 0; $i < $max; $i++)
|
|
|
898 |
{
|
| 1305 |
geraldo |
899 |
|
| 15444 |
efrain |
900 |
$competency_selected = $content->competencies_selected[$i];
|
| 1292 |
geraldo |
901 |
|
| 15444 |
efrain |
902 |
$j = $i + 1;
|
|
|
903 |
$last = $j == $max;
|
|
|
904 |
$pdf->competencyTable($i, $competency_selected, $content->competencies, $content->competency_types, $content->behaviors, $last);
|
| 1317 |
geraldo |
905 |
|
| 15444 |
efrain |
906 |
/*
|
| 1305 |
geraldo |
907 |
$pdf->singleTable('Comentarios Finales :', [array('content' => '')]);
|
| 1292 |
geraldo |
908 |
|
| 15444 |
efrain |
909 |
if ($i % 3 == 0 && $i < $max) {
|
| 1292 |
geraldo |
910 |
$pdf->AddPage();
|
| 15444 |
efrain |
911 |
}*/
|
| 1292 |
geraldo |
912 |
}
|
| 15444 |
efrain |
913 |
|
| 1292 |
geraldo |
914 |
}
|
|
|
915 |
|
| 15444 |
efrain |
916 |
return $pdf->Output('S');
|
| 1277 |
geraldo |
917 |
}
|
| 15253 |
stevensc |
918 |
|
| 15079 |
efrain |
919 |
public function jobDescriptionAction()
|
|
|
920 |
{
|
| 15253 |
stevensc |
921 |
|
|
|
922 |
|
| 15079 |
efrain |
923 |
$request = $this->getRequest();
|
|
|
924 |
if ($request->isGet()) {
|
| 15253 |
stevensc |
925 |
|
| 15079 |
efrain |
926 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
927 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
928 |
$currentCompany = $currentUserPlugin->getCompany();
|
| 15253 |
stevensc |
929 |
|
|
|
930 |
|
| 15444 |
efrain |
931 |
$id = $this->params()->fromRoute('id');
|
|
|
932 |
if (!$id) {
|
| 15079 |
efrain |
933 |
$data = [
|
|
|
934 |
'success' => false,
|
|
|
935 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
936 |
];
|
| 15253 |
stevensc |
937 |
|
| 15079 |
efrain |
938 |
return new JsonModel($data);
|
|
|
939 |
}
|
| 15253 |
stevensc |
940 |
|
| 15079 |
efrain |
941 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
| 15444 |
efrain |
942 |
$jobDescription = $jobDescriptionMapper->fetchOneByUuid($id);
|
| 15079 |
efrain |
943 |
if (!$jobDescription) {
|
|
|
944 |
$data = [
|
|
|
945 |
'success' => false,
|
|
|
946 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
947 |
];
|
| 15253 |
stevensc |
948 |
|
| 15079 |
efrain |
949 |
return new JsonModel($data);
|
|
|
950 |
}
|
| 15253 |
stevensc |
951 |
|
| 15079 |
efrain |
952 |
if ($currentCompany && $jobDescription->company_id != $currentCompany->id) {
|
|
|
953 |
$data = [
|
|
|
954 |
'success' => false,
|
|
|
955 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
956 |
];
|
| 15253 |
stevensc |
957 |
|
| 15079 |
efrain |
958 |
return new JsonModel($data);
|
|
|
959 |
}
|
| 15253 |
stevensc |
960 |
|
| 15444 |
efrain |
961 |
if ($jobDescription->job_description_id_boss) {
|
|
|
962 |
|
|
|
963 |
$jobDescriptionBoss = $jobDescriptionMapper->fetchOne($jobDescription->job_description_id_boss);
|
| 15079 |
efrain |
964 |
if ($jobDescriptionBoss) {
|
| 15444 |
efrain |
965 |
$job_description_uuid_boss = $jobDescriptionBoss->uuid;
|
| 15079 |
efrain |
966 |
} else {
|
| 15444 |
efrain |
967 |
$job_description_uuid_boss = '';
|
| 15079 |
efrain |
968 |
}
|
|
|
969 |
} else {
|
| 15444 |
efrain |
970 |
$job_description_uuid_boss = '';
|
| 15079 |
efrain |
971 |
}
|
| 15444 |
efrain |
972 |
|
|
|
973 |
if($currentCompany) {
|
|
|
974 |
$records = $jobDescriptionMapper->fetchAllActiveByCompanyId($currentCompany->id);
|
|
|
975 |
} else {
|
| 15253 |
stevensc |
976 |
$jobDescriptionMapper->fetchAllActiveByDefault();
|
| 15444 |
efrain |
977 |
}
|
|
|
978 |
|
|
|
979 |
$jobsDescription = [];
|
|
|
980 |
|
|
|
981 |
foreach ($records as $record)
|
|
|
982 |
{
|
|
|
983 |
|
|
|
984 |
if($jobDescription->id != $record->id) {
|
|
|
985 |
|
|
|
986 |
$jobsDescription[ $record->uuid ] = $record->name;
|
|
|
987 |
}
|
|
|
988 |
}
|
|
|
989 |
|
|
|
990 |
$behaviors = [];
|
|
|
991 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
992 |
|
|
|
993 |
|
|
|
994 |
if($currentCompany) {
|
|
|
995 |
$records = $behaviorMapper->fetchAllActiveByCompanyId($currentCompany->id);
|
|
|
996 |
} else {
|
|
|
997 |
$records = $behaviorMapper->fetchAllActiveByDefault();
|
|
|
998 |
}
|
|
|
999 |
|
|
|
1000 |
$behaviorIds = [];
|
|
|
1001 |
foreach($records as $record)
|
|
|
1002 |
{
|
|
|
1003 |
|
|
|
1004 |
$behaviorIds[ $record->id ] = $record->uuid;
|
|
|
1005 |
|
|
|
1006 |
array_push($behaviors, [
|
|
|
1007 |
'uuid' => $record->uuid,
|
|
|
1008 |
'description' => $record->description
|
| 15079 |
efrain |
1009 |
]);
|
|
|
1010 |
}
|
| 15444 |
efrain |
1011 |
|
|
|
1012 |
|
|
|
1013 |
$competencyTypes = [];
|
|
|
1014 |
|
|
|
1015 |
|
|
|
1016 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
1017 |
|
|
|
1018 |
if($currentCompany) {
|
|
|
1019 |
$records = $competencyTypeMapper->fetchAllActiveByCompanyId($currentCompany->id);
|
|
|
1020 |
} else {
|
|
|
1021 |
$records = $competencyTypeMapper->fetchAllActiveByDefault();
|
|
|
1022 |
}
|
|
|
1023 |
|
|
|
1024 |
|
|
|
1025 |
$competencyTypeIds = [];
|
|
|
1026 |
foreach($records as $record)
|
|
|
1027 |
{
|
|
|
1028 |
$competencyTypeIds[ $record->id ] = $record->uuid;
|
|
|
1029 |
|
|
|
1030 |
|
|
|
1031 |
array_push($competencyTypes, [
|
|
|
1032 |
'uuid' => $record->uuid,
|
|
|
1033 |
'name' => $record->name,
|
|
|
1034 |
]);
|
|
|
1035 |
}
|
|
|
1036 |
|
|
|
1037 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
|
|
1038 |
if($currentCompany) {
|
|
|
1039 |
$records = $competencyMapper->fetchAllActiveByCompanyId($currentCompany->id);
|
|
|
1040 |
} else {
|
|
|
1041 |
$records = $competencyMapper->fetchAllActiveByDefault();
|
|
|
1042 |
}
|
|
|
1043 |
|
| 15079 |
efrain |
1044 |
$competencyBehaviorMapper = CompetencyBehaviorMapper::getInstance($this->adapter);
|
| 15444 |
efrain |
1045 |
|
|
|
1046 |
|
|
|
1047 |
|
|
|
1048 |
$competencies = [];
|
|
|
1049 |
|
|
|
1050 |
foreach($records as $record)
|
|
|
1051 |
{
|
|
|
1052 |
if(!isset($competencyTypeIds[ $record->competency_type_id ])) {
|
|
|
1053 |
continue;
|
|
|
1054 |
}
|
|
|
1055 |
|
|
|
1056 |
$behaviors_by_competency = [];
|
|
|
1057 |
|
|
|
1058 |
$competencyBehaviors = $competencyBehaviorMapper->fetchAllByCompetencyId($record->id);
|
|
|
1059 |
foreach($competencyBehaviors as $competencyBehavior)
|
|
|
1060 |
{
|
|
|
1061 |
if(!isset($behaviorIds[ $competencyBehavior->behavior_id ])) {
|
|
|
1062 |
continue;
|
| 15079 |
efrain |
1063 |
}
|
| 15444 |
efrain |
1064 |
|
|
|
1065 |
array_push($behaviors_by_competency, $behaviorIds[ $competencyBehavior->behavior_id ]);
|
|
|
1066 |
}
|
|
|
1067 |
|
|
|
1068 |
|
|
|
1069 |
if($behaviors_by_competency) {
|
|
|
1070 |
array_push($competencies, [
|
|
|
1071 |
'competency_type_uuid' => $competencyTypeIds[ $record->competency_type_id ],
|
|
|
1072 |
'uuid' => $record->uuid,
|
| 15079 |
efrain |
1073 |
'name' => $record->name,
|
| 15444 |
efrain |
1074 |
'behaviors' => $behaviors_by_competency,
|
| 15079 |
efrain |
1075 |
]);
|
|
|
1076 |
}
|
| 15444 |
efrain |
1077 |
|
|
|
1078 |
|
| 15079 |
efrain |
1079 |
}
|
| 15444 |
efrain |
1080 |
|
|
|
1081 |
|
|
|
1082 |
|
|
|
1083 |
|
|
|
1084 |
|
| 15079 |
efrain |
1085 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
| 15444 |
efrain |
1086 |
if($currentCompany) {
|
|
|
1087 |
$records = $jobDescriptionMapper->fetchAllActiveByCompanyId($currentCompany->id);
|
|
|
1088 |
} else {
|
|
|
1089 |
$jobDescriptionMapper->fetchAllActiveByDefault();
|
|
|
1090 |
}
|
|
|
1091 |
|
|
|
1092 |
$jobsDescription = [];
|
|
|
1093 |
|
|
|
1094 |
foreach ($records as $record)
|
|
|
1095 |
{
|
|
|
1096 |
$jobsDescription[ $record->uuid ] = $record->name;
|
|
|
1097 |
}
|
|
|
1098 |
|
|
|
1099 |
|
|
|
1100 |
$data = [
|
|
|
1101 |
'name' => $jobDescription->name,
|
|
|
1102 |
'functions' => $jobDescription->functions,
|
|
|
1103 |
'objectives' => $jobDescription->objectives,
|
|
|
1104 |
'status' => $jobDescription->status,
|
|
|
1105 |
'job_description_id_boss' => $job_description_uuid_boss,
|
|
|
1106 |
'jobs_description' => $jobsDescription,
|
|
|
1107 |
'subordinates_selected' => [],
|
|
|
1108 |
'competencies_selected' => [],
|
|
|
1109 |
'behaviors' => $behaviors,
|
|
|
1110 |
'competency_types' => $competencyTypes,
|
|
|
1111 |
'competencies' => $competencies,
|
|
|
1112 |
];
|
|
|
1113 |
|
|
|
1114 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
1115 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
|
|
1116 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
1117 |
|
|
|
1118 |
$competencyTypes = [];
|
|
|
1119 |
|
|
|
1120 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
1121 |
$jobDescriptionCompetencyBehaviorMapper = JobDescriptionCompetencyBehaviorMapper::getInstance($this->adapter);
|
|
|
1122 |
|
|
|
1123 |
$jobDescriptionCompetencies = $jobDescriptionCompetencyMapper->fetchAllByJobDescriptionId($jobDescription->id);
|
|
|
1124 |
foreach($jobDescriptionCompetencies as $jobDescriptionCompetency)
|
|
|
1125 |
{
|
|
|
1126 |
|
|
|
1127 |
|
|
|
1128 |
|
|
|
1129 |
$competency = $competencyMapper->fetchOne($jobDescriptionCompetency->competency_id);
|
|
|
1130 |
if(!$competency) {
|
|
|
1131 |
continue;
|
| 15079 |
efrain |
1132 |
}
|
| 15444 |
efrain |
1133 |
|
|
|
1134 |
if(isset($competencyTypes[$competency->competency_type_id])) {
|
|
|
1135 |
$competencyType = $competencyTypes[$competency->competency_type_id];
|
|
|
1136 |
} else {
|
|
|
1137 |
|
|
|
1138 |
$competencyType = $competencyTypeMapper->fetchOne($competency->competency_type_id);
|
|
|
1139 |
if(!$competencyType) {
|
|
|
1140 |
continue;
|
|
|
1141 |
}
|
|
|
1142 |
|
|
|
1143 |
$competencyTypes[$competency->competency_type_id] = $competencyType;
|
|
|
1144 |
}
|
|
|
1145 |
|
|
|
1146 |
$competency_selected = [
|
|
|
1147 |
'uuid' => $competency->uuid,
|
|
|
1148 |
'competency_type_uuid' => $competencyType->uuid,
|
|
|
1149 |
'behaviors' => []
|
|
|
1150 |
];
|
|
|
1151 |
|
|
|
1152 |
|
|
|
1153 |
$jobDescriptionCompetencyBehaviors = $jobDescriptionCompetencyBehaviorMapper->fetchAllByJobDescriptionIdAndCompetencyId($jobDescriptionCompetency->job_description_id, $jobDescriptionCompetency->competency_id);
|
|
|
1154 |
foreach($jobDescriptionCompetencyBehaviors as $jobDescriptionCompetencyBehavior)
|
|
|
1155 |
{
|
|
|
1156 |
$behavior = $behaviorMapper->fetchOne($jobDescriptionCompetencyBehavior->behavior_id);
|
|
|
1157 |
if($behavior) {
|
|
|
1158 |
array_push($competency_selected['behaviors'], ['uuid' => $behavior->uuid, 'level' => $jobDescriptionCompetencyBehavior->level]);
|
|
|
1159 |
|
|
|
1160 |
}
|
|
|
1161 |
|
|
|
1162 |
}
|
|
|
1163 |
|
|
|
1164 |
array_push($data['competencies_selected'], $competency_selected);
|
|
|
1165 |
|
|
|
1166 |
|
|
|
1167 |
|
| 15079 |
efrain |
1168 |
}
|
| 15444 |
efrain |
1169 |
|
| 15079 |
efrain |
1170 |
$jobDescriptionSubordinateMapper = JobDescriptionSubordinateMapper::getInstance($this->adapter);
|
| 15444 |
efrain |
1171 |
$jobDescriptionSubordinates = $jobDescriptionSubordinateMapper->fetchAllByJobDescriptionIdTopLevel($jobDescription->id);
|
|
|
1172 |
|
|
|
1173 |
foreach($jobDescriptionSubordinates as $jobDescriptionSubordinate)
|
|
|
1174 |
{
|
|
|
1175 |
$jobDescriptionForSubordinate = $jobDescriptionMapper->fetchOne($jobDescriptionSubordinate->job_description_id_low_level);
|
|
|
1176 |
if($jobDescriptionForSubordinate) {
|
|
|
1177 |
array_push($data['subordinates_selected'], ['uuid' => $jobDescriptionForSubordinate->uuid ]);
|
| 15079 |
efrain |
1178 |
}
|
|
|
1179 |
}
|
| 15444 |
efrain |
1180 |
|
|
|
1181 |
|
|
|
1182 |
|
| 15079 |
efrain |
1183 |
$response = [
|
|
|
1184 |
'success' => true,
|
|
|
1185 |
'data' => $data
|
|
|
1186 |
];
|
| 15253 |
stevensc |
1187 |
|
| 15079 |
efrain |
1188 |
return new JsonModel($response);
|
|
|
1189 |
} else {
|
|
|
1190 |
$data = [
|
|
|
1191 |
'success' => false,
|
|
|
1192 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1193 |
];
|
| 15253 |
stevensc |
1194 |
|
| 15079 |
efrain |
1195 |
return new JsonModel($data);
|
|
|
1196 |
}
|
|
|
1197 |
}
|
| 15444 |
efrain |
1198 |
|
|
|
1199 |
/**
|
|
|
1200 |
*
|
|
|
1201 |
* @param JobDescription $jobDescription
|
|
|
1202 |
* @return String
|
|
|
1203 |
*/
|
|
|
1204 |
public function serialize($jobDescription)
|
|
|
1205 |
{
|
|
|
1206 |
|
|
|
1207 |
|
|
|
1208 |
|
|
|
1209 |
|
|
|
1210 |
$behaviorMapper = BehaviorMapper::getInstance($this->adapter);
|
|
|
1211 |
$competencyMapper = CompetencyMapper::getInstance($this->adapter);
|
|
|
1212 |
$competencyTypeMapper = CompetencyTypeMapper::getInstance($this->adapter);
|
|
|
1213 |
|
|
|
1214 |
$competencyTypes = [];
|
|
|
1215 |
$competencies = [];
|
|
|
1216 |
$behaviors = [];
|
|
|
1217 |
$competencies_selected = [];
|
|
|
1218 |
$subordinates_selected = [];
|
|
|
1219 |
|
|
|
1220 |
$jobDescriptionCompetencyMapper = JobDescriptionCompetencyMapper::getInstance($this->adapter);
|
|
|
1221 |
$jobDescriptionCompetencyBehaviorMapper = JobDescriptionCompetencyBehaviorMapper::getInstance($this->adapter);
|
|
|
1222 |
|
|
|
1223 |
$jobDescriptionCompetencies = $jobDescriptionCompetencyMapper->fetchAllByJobDescriptionId($jobDescription->id);
|
|
|
1224 |
foreach($jobDescriptionCompetencies as $jobDescriptionCompetency)
|
|
|
1225 |
{
|
|
|
1226 |
|
|
|
1227 |
if(isset($competencies[$jobDescriptionCompetency->competency_id])) {
|
|
|
1228 |
$competency = $competencies[$jobDescriptionCompetency->competency_id];
|
|
|
1229 |
} else {
|
|
|
1230 |
|
|
|
1231 |
$competency = $competencyMapper->fetchOne($jobDescriptionCompetency->competency_id);
|
|
|
1232 |
if(!$competency) {
|
|
|
1233 |
continue;
|
|
|
1234 |
}
|
|
|
1235 |
|
|
|
1236 |
|
|
|
1237 |
|
|
|
1238 |
$competencies[$jobDescriptionCompetency->competency_id] = new \stdClass();
|
|
|
1239 |
$competencies[$jobDescriptionCompetency->competency_id]->uuid = $competency->uuid;
|
|
|
1240 |
$competencies[$jobDescriptionCompetency->competency_id]->name = $competency->name;
|
|
|
1241 |
$competencies[$jobDescriptionCompetency->competency_id]->description = $competency->description;
|
|
|
1242 |
|
|
|
1243 |
}
|
|
|
1244 |
|
|
|
1245 |
|
|
|
1246 |
if(isset($competencyTypes[$competency->competency_type_id])) {
|
|
|
1247 |
$competencyType = $competencyTypes[$competency->competency_type_id];
|
|
|
1248 |
} else {
|
|
|
1249 |
|
|
|
1250 |
$competencyType = $competencyTypeMapper->fetchOne($competency->competency_type_id);
|
|
|
1251 |
if(!$competencyType) {
|
|
|
1252 |
continue;
|
|
|
1253 |
}
|
|
|
1254 |
|
|
|
1255 |
$competencyTypes[$competency->competency_type_id] = new \stdClass();
|
|
|
1256 |
$competencyTypes[$competency->competency_type_id]->uuid = $competencyType->uuid;
|
|
|
1257 |
$competencyTypes[$competency->competency_type_id]->name = $competencyType->name;
|
|
|
1258 |
$competencyTypes[$competency->competency_type_id]->description = $competencyType->description;
|
|
|
1259 |
|
|
|
1260 |
}
|
|
|
1261 |
|
|
|
1262 |
$competency_selected = [
|
|
|
1263 |
'uuid' => $competency->uuid,
|
|
|
1264 |
'competency_type_uuid' => $competencyType->uuid,
|
|
|
1265 |
'behaviors' => []
|
|
|
1266 |
];
|
|
|
1267 |
|
|
|
1268 |
|
|
|
1269 |
$jobDescriptionCompetencyBehaviors = $jobDescriptionCompetencyBehaviorMapper->fetchAllByJobDescriptionIdAndCompetencyId($jobDescriptionCompetency->job_description_id, $jobDescriptionCompetency->competency_id);
|
|
|
1270 |
foreach($jobDescriptionCompetencyBehaviors as $jobDescriptionCompetencyBehavior)
|
|
|
1271 |
{
|
|
|
1272 |
|
|
|
1273 |
|
|
|
1274 |
if(isset($behaviors[$jobDescriptionCompetencyBehavior->behavior_id])) {
|
|
|
1275 |
$behavior = $behaviors[$jobDescriptionCompetencyBehavior->behavior_id];
|
|
|
1276 |
} else {
|
|
|
1277 |
|
|
|
1278 |
$behavior = $behaviorMapper->fetchOne($jobDescriptionCompetencyBehavior->behavior_id);
|
|
|
1279 |
if(!$behavior) {
|
|
|
1280 |
|
|
|
1281 |
continue;
|
|
|
1282 |
}
|
|
|
1283 |
|
|
|
1284 |
$behaviors[$jobDescriptionCompetencyBehavior->behavior_id] = new \stdClass();
|
|
|
1285 |
$behaviors[$jobDescriptionCompetencyBehavior->behavior_id]->uuid = $behavior->uuid;
|
|
|
1286 |
$behaviors[$jobDescriptionCompetencyBehavior->behavior_id]->description = $behavior->description;
|
|
|
1287 |
|
|
|
1288 |
}
|
|
|
1289 |
|
|
|
1290 |
|
|
|
1291 |
|
|
|
1292 |
|
|
|
1293 |
array_push($competency_selected['behaviors'], ['uuid' => $behavior->uuid, 'level' => $jobDescriptionCompetencyBehavior->level]);
|
|
|
1294 |
|
|
|
1295 |
|
|
|
1296 |
}
|
|
|
1297 |
|
|
|
1298 |
array_push($competencies_selected, $competency_selected);
|
|
|
1299 |
|
|
|
1300 |
|
|
|
1301 |
|
|
|
1302 |
}
|
|
|
1303 |
|
|
|
1304 |
|
|
|
1305 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
1306 |
|
|
|
1307 |
$jobDescriptionSubordinateMapper = JobDescriptionSubordinateMapper::getInstance($this->adapter);
|
|
|
1308 |
$jobDescriptionSubordinates = $jobDescriptionSubordinateMapper->fetchAllByJobDescriptionIdTopLevel($jobDescription->id);
|
|
|
1309 |
|
|
|
1310 |
foreach($jobDescriptionSubordinates as $jobDescriptionSubordinate)
|
|
|
1311 |
{
|
|
|
1312 |
$jobDescriptionForSubordinate = $jobDescriptionMapper->fetchOne($jobDescriptionSubordinate->job_description_id_low_level);
|
|
|
1313 |
if($jobDescriptionForSubordinate) {
|
|
|
1314 |
array_push($subordinates_selected, ['uuid' => $jobDescriptionForSubordinate->uuid ]);
|
|
|
1315 |
}
|
|
|
1316 |
|
|
|
1317 |
|
|
|
1318 |
|
|
|
1319 |
}
|
|
|
1320 |
|
|
|
1321 |
if($jobDescription->job_description_id_boss) {
|
|
|
1322 |
|
|
|
1323 |
$jobDescriptionBoss = $jobDescriptionMapper->fetchOne($jobDescription->job_description_id_boss);
|
|
|
1324 |
if($jobDescriptionBoss) {
|
|
|
1325 |
$job_description_id_boss = $jobDescriptionBoss->uuid;
|
|
|
1326 |
}
|
|
|
1327 |
} else {
|
|
|
1328 |
$job_description_id_boss = '';
|
|
|
1329 |
}
|
|
|
1330 |
|
|
|
1331 |
$content = [
|
|
|
1332 |
'uuid' => $jobDescription->uuid,
|
|
|
1333 |
'name' => $jobDescription->name,
|
|
|
1334 |
'functions' => $jobDescription->functions,
|
|
|
1335 |
'objectives' => $jobDescription->objectives,
|
|
|
1336 |
'job_description_id_boss' => $job_description_id_boss,
|
|
|
1337 |
'competency_types' => $competencyTypes,
|
|
|
1338 |
'competencies' => $competencies,
|
|
|
1339 |
'behaviors' => $behaviors,
|
|
|
1340 |
'competencies_selected' => $competencies_selected,
|
|
|
1341 |
'subordinates_selected' => $subordinates_selected,
|
|
|
1342 |
|
|
|
1343 |
];
|
|
|
1344 |
|
|
|
1345 |
return json_encode($content);
|
|
|
1346 |
}
|
| 977 |
geraldo |
1347 |
}
|