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