| Línea 14... |
Línea 14... |
| 14 |
use Laminas\Mvc\Controller\AbstractActionController;
|
14 |
use Laminas\Mvc\Controller\AbstractActionController;
|
| 15 |
use Laminas\Log\LoggerInterface;
|
15 |
use Laminas\Log\LoggerInterface;
|
| 16 |
use Laminas\View\Model\ViewModel;
|
16 |
use Laminas\View\Model\ViewModel;
|
| 17 |
use Laminas\View\Model\JsonModel;
|
17 |
use Laminas\View\Model\JsonModel;
|
| 18 |
use LeadersLinked\Model\Notification;
|
18 |
use LeadersLinked\Model\Notification;
|
| 19 |
use LeadersLinked\Mapper\CompanySelfEvaluationTestMapper;
|
19 |
use LeadersLinked\Mapper\SelfEvaluationTestMapper;
|
| 20 |
use LeadersLinked\Mapper\NotificationMapper;
|
20 |
use LeadersLinked\Mapper\NotificationMapper;
|
| 21 |
use LeadersLinked\Mapper\QueryMapper;
|
21 |
use LeadersLinked\Mapper\QueryMapper;
|
| 22 |
use LeadersLinked\Model\CompanySelfEvaluationForm;
|
22 |
use LeadersLinked\Model\SelfEvaluationForm;
|
| 23 |
use LeadersLinked\Mapper\CompanySelfEvaluationFormMapper;
|
23 |
use LeadersLinked\Mapper\SelfEvaluationFormMapper;
|
| 24 |
use LeadersLinked\Model\CompanySelfEvaluationTest;
|
24 |
use LeadersLinked\Model\SelfEvaluationTest;
|
| 25 |
use Laminas\Db\Sql\Select;
|
25 |
use Laminas\Db\Sql\Select;
|
| 26 |
use LeadersLinked\Library\SelfEvaluationPDF;
|
26 |
use LeadersLinked\Library\SelfEvaluationPDF;
|
| 27 |
use LeadersLinked\Mapper\CompanySelfEvaluationFormUserMapper;
|
27 |
use LeadersLinked\Mapper\SelfEvaluationFormUserMapper;
|
| 28 |
use LeadersLinked\Form\SelfEvaluation\SelfEvaluationTestForm;
|
28 |
use LeadersLinked\Form\SelfEvaluation\SelfEvaluationTestForm;
|
| 29 |
use LeadersLinked\Library\Functions;
|
29 |
use LeadersLinked\Library\Functions;
|
| 30 |
use LeadersLinked\Mapper\UserMapper;
|
30 |
use LeadersLinked\Mapper\UserMapper;
|
| Línea 31... |
Línea 31... |
| 31 |
|
31 |
|
| Línea 112... |
Línea 112... |
| 112 |
|
112 |
|
| Línea 113... |
Línea 113... |
| 113 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
113 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
| 114 |
|
114 |
|
| 115 |
$select = $queryMapper->getSql()->select();
|
115 |
$select = $queryMapper->getSql()->select();
|
| 116 |
$select->columns(['uuid', 'name', 'description', 'text', 'language']);
|
116 |
$select->columns(['uuid', 'name', 'description', 'text', 'language']);
|
| 117 |
$select->from(['f' => CompanySelfEvaluationFormMapper::_TABLE]);
|
117 |
$select->from(['f' => SelfEvaluationFormMapper::_TABLE]);
|
| 118 |
$select->join(['fu' => CompanySelfEvaluationFormUserMapper::_TABLE], 'f.id = fu.form_id', []);
|
118 |
$select->join(['fu' => SelfEvaluationFormUserMapper::_TABLE], 'f.id = fu.form_id', []);
|
| 119 |
$select->join(['t' => CompanySelfEvaluationTestMapper::_TABLE], 'fu.form_id = t.form_id AND fu.user_id = t.user_id', ['status'], Select::JOIN_LEFT_OUTER);
|
119 |
$select->join(['t' => SelfEvaluationTestMapper::_TABLE], 'fu.form_id = t.form_id AND fu.user_id = t.user_id', ['status'], Select::JOIN_LEFT_OUTER);
|
| Línea 120... |
Línea 120... |
| 120 |
$select->where->equalTo('f.status', CompanySelfEvaluationForm::STATUS_ACTIVE);
|
120 |
$select->where->equalTo('f.status', SelfEvaluationForm::STATUS_ACTIVE);
|
| 121 |
$select->where->equalTo('fu.user_id', $currentUser->id);
|
121 |
$select->where->equalTo('fu.user_id', $currentUser->id);
|
| Línea 128... |
Línea 128... |
| 128 |
|
128 |
|
| 129 |
$records = $queryMapper->fetchAll($select);
|
129 |
$records = $queryMapper->fetchAll($select);
|
| 130 |
$items = [];
|
130 |
$items = [];
|
| 131 |
foreach ($records as $record) {
|
131 |
foreach ($records as $record) {
|
| 132 |
switch ($record['language']) {
|
132 |
switch ($record['language']) {
|
| 133 |
case CompanySelfEvaluationForm::LANGUAGE_ENGLISH :
|
133 |
case SelfEvaluationForm::LANGUAGE_ENGLISH :
|
| 134 |
$language = 'LABEL_ENGLISH';
|
134 |
$language = 'LABEL_ENGLISH';
|
| Línea 135... |
Línea 135... |
| 135 |
break;
|
135 |
break;
|
| 136 |
|
136 |
|
| 137 |
case CompanySelfEvaluationForm::LANGUAGE_SPANISH :
|
137 |
case SelfEvaluationForm::LANGUAGE_SPANISH :
|
| Línea 138... |
Línea 138... |
| 138 |
$language = 'LABEL_SPANISH';
|
138 |
$language = 'LABEL_SPANISH';
|
| 139 |
break;
|
139 |
break;
|
| 140 |
|
140 |
|
| 141 |
default :
|
141 |
default :
|
| Línea 142... |
Línea 142... |
| 142 |
$language = '';
|
142 |
$language = '';
|
| Línea 143... |
Línea 143... |
| 143 |
break;
|
143 |
break;
|
| 144 |
}
|
144 |
}
|
| 145 |
|
145 |
|
| Línea 146... |
Línea 146... |
| 146 |
switch ($record['status']) {
|
146 |
switch ($record['status']) {
|
| 147 |
|
147 |
|
| 148 |
case CompanySelfEvaluationTest::STATUS_DRAFT :
|
148 |
case SelfEvaluationTest::STATUS_DRAFT :
|
| Línea 149... |
Línea 149... |
| 149 |
$status = 'LABEL_DRAFT';
|
149 |
$status = 'LABEL_DRAFT';
|
| 150 |
break;
|
150 |
break;
|
| 151 |
|
151 |
|
| Línea 152... |
Línea 152... |
| 152 |
case CompanySelfEvaluationTest::STATUS_COMPLETED :
|
152 |
case SelfEvaluationTest::STATUS_COMPLETED :
|
| 153 |
$status = 'LABEL_COMPLETED';
|
153 |
$status = 'LABEL_COMPLETED';
|
| 154 |
break;
|
154 |
break;
|
| Línea 155... |
Línea 155... |
| 155 |
|
155 |
|
| Línea 172... |
Línea 172... |
| 172 |
'name' => $record['name'],
|
172 |
'name' => $record['name'],
|
| 173 |
'description' => $record['description'],
|
173 |
'description' => $record['description'],
|
| 174 |
'text' => $record['text'],
|
174 |
'text' => $record['text'],
|
| 175 |
'language' => $language,
|
175 |
'language' => $language,
|
| 176 |
'status' => $status,
|
176 |
'status' => $status,
|
| 177 |
'link_take_a_test' => $allowTakeATest && ( empty($record['status']) || $record['status'] == CompanySelfEvaluationTest::STATUS_DRAFT) ? $this->url()->fromRoute('profile/self-evaluation/take-a-test', ['id' => $record['uuid']]) : '',
|
177 |
'link_take_a_test' => $allowTakeATest && ( empty($record['status']) || $record['status'] == SelfEvaluationTest::STATUS_DRAFT) ? $this->url()->fromRoute('profile/self-evaluation/take-a-test', ['id' => $record['uuid']]) : '',
|
| 178 |
'link_report' => $allowReport && $record['status'] == CompanySelfEvaluationTest::STATUS_COMPLETED ? $this->url()->fromRoute('profile/self-evaluation/report', ['id' => $record['uuid']]) : '',
|
178 |
'link_report' => $allowReport && $record['status'] == SelfEvaluationTest::STATUS_COMPLETED ? $this->url()->fromRoute('profile/self-evaluation/report', ['id' => $record['uuid']]) : '',
|
| 179 |
];
|
179 |
];
|
| Línea 180... |
Línea 180... |
| 180 |
|
180 |
|
| Línea 214... |
Línea 214... |
| 214 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
214 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| 215 |
$currentUser = $currentUserPlugin->getUser();
|
215 |
$currentUser = $currentUserPlugin->getUser();
|
| Línea 216... |
Línea 216... |
| 216 |
|
216 |
|
| Línea 217... |
Línea 217... |
| 217 |
$uuid = $this->params()->fromRoute('id');
|
217 |
$uuid = $this->params()->fromRoute('id');
|
| 218 |
|
218 |
|
| Línea 219... |
Línea 219... |
| 219 |
$companySelfEvaluationFormMapper = CompanySelfEvaluationFormMapper::getInstance($this->adapter);
|
219 |
$companySelfEvaluationFormMapper = SelfEvaluationFormMapper::getInstance($this->adapter);
|
| 220 |
$companySelfEvaluationForm = $companySelfEvaluationFormMapper->fetchOneByUuid($uuid);
|
220 |
$companySelfEvaluationForm = $companySelfEvaluationFormMapper->fetchOneByUuid($uuid);
|
| 221 |
|
221 |
|
| 222 |
if (!$companySelfEvaluationForm) {
|
222 |
if (!$companySelfEvaluationForm) {
|
| 223 |
return new JsonModel([
|
223 |
return new JsonModel([
|
| 224 |
'success' => false,
|
224 |
'success' => false,
|
| Línea 225... |
Línea 225... |
| 225 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
225 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
| 226 |
]);
|
226 |
]);
|
| 227 |
}
|
227 |
}
|
| 228 |
|
228 |
|
| 229 |
if ($companySelfEvaluationForm->status == CompanySelfEvaluationForm::STATUS_INACTIVE) {
|
229 |
if ($companySelfEvaluationForm->status == SelfEvaluationForm::STATUS_INACTIVE) {
|
| 230 |
return new JsonModel([
|
230 |
return new JsonModel([
|
| Línea 231... |
Línea 231... |
| 231 |
'success' => false,
|
231 |
'success' => false,
|
| 232 |
'data' => 'ERROR_FORM_EVALUATION_IS_INACTIVE'
|
232 |
'data' => 'ERROR_FORM_EVALUATION_IS_INACTIVE'
|
| 233 |
]);
|
233 |
]);
|
| 234 |
}
|
234 |
}
|
| 235 |
|
235 |
|
| 236 |
|
236 |
|
| 237 |
$companySelfEvaluationFormUserMapper = CompanySelfEvaluationFormUserMapper::getInstance($this->adapter);
|
237 |
$companySelfEvaluationFormUserMapper = SelfEvaluationFormUserMapper::getInstance($this->adapter);
|
| 238 |
$companySelfEvaluationFormUser = $companySelfEvaluationFormUserMapper->fetchOneByFormIdAndUserId($companySelfEvaluationForm->id, $currentUser->id);
|
238 |
$companySelfEvaluationFormUser = $companySelfEvaluationFormUserMapper->fetchOneByFormIdAndUserId($companySelfEvaluationForm->id, $currentUser->id);
|
| Línea 239... |
Línea 239... |
| 239 |
if (!$companySelfEvaluationFormUser) {
|
239 |
if (!$companySelfEvaluationFormUser) {
|
| 240 |
return new JsonModel([
|
240 |
return new JsonModel([
|
| Línea 241... |
Línea 241... |
| 241 |
'success' => false,
|
241 |
'success' => false,
|
| 242 |
'data' => 'ERROR_FORM_EVALUATION_YOU_CAN_NOT_TAKE'
|
242 |
'data' => 'ERROR_FORM_EVALUATION_YOU_CAN_NOT_TAKE'
|
| 243 |
]);
|
243 |
]);
|
| 244 |
}
|
244 |
}
|
| 245 |
|
245 |
|
| 246 |
|
246 |
|
| Línea 261... |
Línea 261... |
| 261 |
'success' => true,
|
261 |
'success' => true,
|
| 262 |
'data' => [
|
262 |
'data' => [
|
| 263 |
'name' => $companySelfEvaluationForm->name,
|
263 |
'name' => $companySelfEvaluationForm->name,
|
| 264 |
'description' => $companySelfEvaluationForm->description,
|
264 |
'description' => $companySelfEvaluationForm->description,
|
| 265 |
'text' => $companySelfEvaluationForm->text,
|
265 |
'text' => $companySelfEvaluationForm->text,
|
| 266 |
'content' => $companySelfEvaluationTest && $companySelfEvaluationTest->status == CompanySelfEvaluationTest::STATUS_DRAFT ?
|
266 |
'content' => $companySelfEvaluationTest && $companySelfEvaluationTest->status == SelfEvaluationTest::STATUS_DRAFT ?
|
| 267 |
json_decode($companySelfEvaluationTest->content) :
|
267 |
json_decode($companySelfEvaluationTest->content) :
|
| 268 |
json_decode($companySelfEvaluationForm->content),
|
268 |
json_decode($companySelfEvaluationForm->content),
|
| 269 |
]
|
269 |
]
|
| 270 |
]);
|
270 |
]);
|
| 271 |
}
|
271 |
}
|
| Línea 277... |
Línea 277... |
| 277 |
$form->setData($dataPost);
|
277 |
$form->setData($dataPost);
|
| Línea 278... |
Línea 278... |
| 278 |
|
278 |
|
| 279 |
if ($form->isValid()) {
|
279 |
if ($form->isValid()) {
|
| Línea 280... |
Línea 280... |
| 280 |
$dataPost = (array) $form->getData();
|
280 |
$dataPost = (array) $form->getData();
|
| 281 |
|
281 |
|
| 282 |
$selfEvaluationTest = new CompanySelfEvaluationTest();
|
282 |
$selfEvaluationTest = new SelfEvaluationTest();
|
| 283 |
$selfEvaluationTest->company_id = $companySelfEvaluationForm->company_id;
|
283 |
$selfEvaluationTest->company_id = $companySelfEvaluationForm->company_id;
|
| 284 |
$selfEvaluationTest->form_id = $companySelfEvaluationForm->id;
|
284 |
$selfEvaluationTest->form_id = $companySelfEvaluationForm->id;
|
| 285 |
$selfEvaluationTest->user_id = $currentUser->id;
|
285 |
$selfEvaluationTest->user_id = $currentUser->id;
|
| Línea 336... |
Línea 336... |
| 336 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
336 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| 337 |
$currentUser = $currentUserPlugin->getUser();
|
337 |
$currentUser = $currentUserPlugin->getUser();
|
| Línea 338... |
Línea 338... |
| 338 |
|
338 |
|
| Línea 339... |
Línea 339... |
| 339 |
$uuid = $this->params()->fromRoute('id');
|
339 |
$uuid = $this->params()->fromRoute('id');
|
| 340 |
|
340 |
|
| Línea 341... |
Línea 341... |
| 341 |
$companySelfEvaluationFormMapper = CompanySelfEvaluationFormMapper::getInstance($this->adapter);
|
341 |
$companySelfEvaluationFormMapper = SelfEvaluationFormMapper::getInstance($this->adapter);
|
| 342 |
$companySelfEvaluationForm = $companySelfEvaluationFormMapper->fetchOneByUuid($uuid);
|
342 |
$companySelfEvaluationForm = $companySelfEvaluationFormMapper->fetchOneByUuid($uuid);
|
| 343 |
|
343 |
|
| 344 |
if (!$companySelfEvaluationForm) {
|
344 |
if (!$companySelfEvaluationForm) {
|
| 345 |
return new JsonModel([
|
345 |
return new JsonModel([
|
| 346 |
'success' => false,
|
346 |
'success' => false,
|
| Línea 347... |
Línea 347... |
| 347 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
347 |
'data' => 'ERROR_FORM_EVALUATION_NOT_FOUND'
|
| 348 |
]);
|
348 |
]);
|
| 349 |
}
|
349 |
}
|
| 350 |
|
350 |
|
| 351 |
if ($companySelfEvaluationForm->status == CompanySelfEvaluationForm::STATUS_INACTIVE) {
|
351 |
if ($companySelfEvaluationForm->status == SelfEvaluationForm::STATUS_INACTIVE) {
|
| 352 |
return new JsonModel([
|
352 |
return new JsonModel([
|
| Línea 353... |
Línea 353... |
| 353 |
'success' => false,
|
353 |
'success' => false,
|
| 354 |
'data' => 'ERROR_FORM_EVALUATION_IS_INACTIVE'
|
354 |
'data' => 'ERROR_FORM_EVALUATION_IS_INACTIVE'
|
| 355 |
]);
|
355 |
]);
|
| 356 |
}
|
356 |
}
|
| 357 |
|
357 |
|
| 358 |
|
358 |
|
| 359 |
$companySelfEvaluationFormUserMapper = CompanySelfEvaluationFormUserMapper::getInstance($this->adapter);
|
359 |
$companySelfEvaluationFormUserMapper = SelfEvaluationFormUserMapper::getInstance($this->adapter);
|
| 360 |
$companySelfEvaluationFormUser = $companySelfEvaluationFormUserMapper->fetchOneByFormIdAndUserId($companySelfEvaluationForm->id, $currentUser->id);
|
360 |
$companySelfEvaluationFormUser = $companySelfEvaluationFormUserMapper->fetchOneByFormIdAndUserId($companySelfEvaluationForm->id, $currentUser->id);
|
| Línea 361... |
Línea 361... |
| 361 |
if (!$companySelfEvaluationFormUser) {
|
361 |
if (!$companySelfEvaluationFormUser) {
|
| 362 |
return new JsonModel([
|
362 |
return new JsonModel([
|
| Línea 363... |
Línea 363... |
| 363 |
'success' => false,
|
363 |
'success' => false,
|
| 364 |
'data' => 'ERROR_FORM_EVALUATION_YOU_CAN_NOT_TAKE'
|
364 |
'data' => 'ERROR_FORM_EVALUATION_YOU_CAN_NOT_TAKE'
|
| 365 |
]);
|
365 |
]);
|
| 366 |
}
|
366 |
}
|
| 367 |
|
367 |
|
| 368 |
|
368 |
|
| Línea 369... |
Línea 369... |
| 369 |
$companySelfEvaluationTestMapper = CompanySelfEvaluationTestMapper::getInstance($this->adapter);
|
369 |
$companySelfEvaluationTestMapper = SelfEvaluationTestMapper::getInstance($this->adapter);
|
| 370 |
$companySelfEvaluationTest = $companySelfEvaluationTestMapper->fetchOneBy($companySelfEvaluationForm->id, $currentUser->id);
|
370 |
$companySelfEvaluationTest = $companySelfEvaluationTestMapper->fetchOneBy($companySelfEvaluationForm->id, $currentUser->id);
|
| 371 |
|
371 |
|
| 372 |
if (!$companySelfEvaluationTest) {
|
372 |
if (!$companySelfEvaluationTest) {
|
| 373 |
return new JsonModel([
|
373 |
return new JsonModel([
|
| 374 |
'success' => false,
|
374 |
'success' => false,
|
| Línea 397... |
Línea 397... |
| 397 |
]);
|
397 |
]);
|
| 398 |
}
|
398 |
}
|
| Línea 399... |
Línea 399... |
| 399 |
|
399 |
|
| 400 |
/**
|
400 |
/**
|
| 401 |
* Render Pdf document
|
401 |
* Render Pdf document
|
| 402 |
* @param CompanySelfEvaluationForm $companySelfEvaluationForm
|
402 |
* @param SelfEvaluationForm $companySelfEvaluationForm
|
| 403 |
* @param CompanySelfEvaluationTest $companySelfEvaluationTest
|
403 |
* @param SelfEvaluationTest $companySelfEvaluationTest
|
| 404 |
* @param UserMapper $userMapper
|
404 |
* @param UserMapper $userMapper
|
| 405 |
* @return mixed
|
405 |
* @return mixed
|
| 406 |
*/
|
406 |
*/
|