| 251 |
geraldo |
1 |
<?php
|
|
|
2 |
$acl = $this->viewModel()->getRoot()->getVariable('acl');
|
|
|
3 |
$currentUser = $this->currentUserHelper();
|
|
|
4 |
|
|
|
5 |
$roleName = $currentUser->getUserTypeId();
|
|
|
6 |
|
| 262 |
geraldo |
7 |
$routeDatatable = $this->url('self-evaluation/reviews');
|
| 251 |
geraldo |
8 |
$routeDashboard = $this->url('dashboard');
|
|
|
9 |
|
| 469 |
geraldo |
10 |
$allowEdit = $acl->isAllowed($roleName, 'self-evaluation/reviews/edit') ? 1 : 0;
|
|
|
11 |
$allowReport = $acl->isAllowed($roleName, 'self-evaluation/reviews/report') ? 1 : 0;
|
| 251 |
geraldo |
12 |
|
|
|
13 |
|
|
|
14 |
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
|
|
|
18 |
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
|
|
|
22 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
|
|
|
23 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
|
|
|
24 |
|
|
|
25 |
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
|
|
|
26 |
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
|
|
|
27 |
|
|
|
28 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
|
|
|
29 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
|
|
|
30 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
|
|
|
31 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
|
|
|
35 |
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
|
|
|
36 |
|
|
|
37 |
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
|
|
|
38 |
|
|
|
39 |
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
|
|
|
40 |
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
|
|
|
41 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
|
|
|
45 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
|
|
|
46 |
|
|
|
47 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
|
|
|
48 |
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
|
|
|
49 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
|
| 261 |
geraldo |
50 |
|
| 251 |
geraldo |
51 |
// bootbox Alert //
|
|
|
52 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
|
| 261 |
geraldo |
53 |
|
| 251 |
geraldo |
54 |
// JsRender //
|
|
|
55 |
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
|
|
|
56 |
|
| 261 |
geraldo |
57 |
// Page Styles
|
|
|
58 |
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
|
| 251 |
geraldo |
59 |
|
| 306 |
geraldo |
60 |
|
| 307 |
geraldo |
61 |
$pending = \LeadersLinked\Model\CompanySelfEvaluationTest::STATUS_PENDING;
|
| 308 |
geraldo |
62 |
$review = \LeadersLinked\Model\CompanySelfEvaluationTest::STATUS_REVIEW;
|
| 307 |
geraldo |
63 |
$completed = \LeadersLinked\Model\CompanySelfEvaluationTest::STATUS_COMPLETED;
|
| 306 |
geraldo |
64 |
|
| 251 |
geraldo |
65 |
$this->inlineScript()->captureStart();
|
|
|
66 |
echo <<<JS
|
| 339 |
geraldo |
67 |
const classFormGenerator = function() {
|
| 251 |
geraldo |
68 |
this.id = 0,
|
|
|
69 |
this.table = '',
|
|
|
70 |
this.name = '',
|
|
|
71 |
this.text = '',
|
|
|
72 |
this.status = 'a',
|
|
|
73 |
this.sections = [],
|
|
|
74 |
this.clear = function() {
|
|
|
75 |
this.sections = [];
|
|
|
76 |
this.render();
|
|
|
77 |
},
|
|
|
78 |
/**
|
|
|
79 |
* Render array sections
|
|
|
80 |
*/
|
|
|
81 |
this.renderSection = function(slug_section) {
|
|
|
82 |
var s = '';
|
|
|
83 |
for (i = 0; i < this.sections.length; i++) {
|
|
|
84 |
if (slug_section != this.sections[i].slug_section) {
|
|
|
85 |
continue;
|
|
|
86 |
}
|
|
|
87 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
|
|
88 |
this.sections[i].questions[j].position = j;
|
|
|
89 |
if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
|
|
|
90 |
this.sections[i].questions[j].options.sort(function(a, b) {
|
|
|
91 |
if (a.position > b.position) {
|
|
|
92 |
return 1;
|
|
|
93 |
}
|
|
|
94 |
if (a.position < b.position) {
|
|
|
95 |
return -1;
|
|
|
96 |
}
|
|
|
97 |
return 0;
|
|
|
98 |
});
|
|
|
99 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
|
|
100 |
this.sections[i].questions[j].options[k].position = j;
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
$('[data-toggle="tooltip"]').tooltip();
|
|
|
106 |
},
|
|
|
107 |
this.render = function() {
|
|
|
108 |
this.sections.sort(function(a, b) {
|
|
|
109 |
if (a.position > b.position) {
|
|
|
110 |
return 1;
|
|
|
111 |
}
|
|
|
112 |
if (a.position < b.position) {
|
|
|
113 |
return -1;
|
|
|
114 |
}
|
|
|
115 |
return 0;
|
|
|
116 |
});
|
|
|
117 |
var s = '';
|
|
|
118 |
for (i = 0; i < this.sections.length; i++) {
|
|
|
119 |
this.sections[i].position = i;
|
|
|
120 |
this.sections[i].questions.sort(function(a, b) {
|
|
|
121 |
if (a.position > b.position) {
|
|
|
122 |
return 1;
|
|
|
123 |
}
|
|
|
124 |
if (a.position < b.position) {
|
|
|
125 |
return -1;
|
|
|
126 |
}
|
|
|
127 |
return 0;
|
|
|
128 |
});
|
|
|
129 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
|
|
130 |
this.sections[i].questions[j].position = j;
|
|
|
131 |
if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
|
|
|
132 |
this.sections[i].questions[j].options.sort(function(a, b) {
|
|
|
133 |
if (a.position > b.position) {
|
|
|
134 |
return 1;
|
|
|
135 |
}
|
|
|
136 |
if (a.position < b.position) {
|
|
|
137 |
return -1;
|
|
|
138 |
}
|
|
|
139 |
return 0;
|
|
|
140 |
});
|
|
|
141 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
|
|
142 |
this.sections[i].questions[j].options[k].position = j;
|
|
|
143 |
}
|
|
|
144 |
}
|
|
|
145 |
}
|
|
|
146 |
}
|
|
|
147 |
$('[data-toggle="tooltip"]').tooltip();
|
| 266 |
geraldo |
148 |
};
|
| 352 |
geraldo |
149 |
/**
|
|
|
150 |
* Add element to question array
|
|
|
151 |
*/
|
| 439 |
geraldo |
152 |
this.editQuestion = function(slug_section, slug_question, comment, question_value, status) {
|
| 352 |
geraldo |
153 |
var renderTable = false;
|
|
|
154 |
for (i = 0; i < this.sections.length; i++) {
|
|
|
155 |
if (slug_section == this.sections[i].slug_section) {
|
|
|
156 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
|
|
157 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
|
|
158 |
this.sections[i].questions[j].status = status;
|
| 417 |
geraldo |
159 |
this.sections[i].questions[j].comment = comment;
|
| 432 |
geraldo |
160 |
this.sections[i].questions[j].question_value = question_value;
|
| 395 |
geraldo |
161 |
this.renderSection(slug_section);
|
| 394 |
geraldo |
162 |
return true;
|
| 345 |
geraldo |
163 |
}
|
|
|
164 |
}
|
|
|
165 |
}
|
| 352 |
geraldo |
166 |
}
|
|
|
167 |
};
|
| 339 |
geraldo |
168 |
}
|
| 251 |
geraldo |
169 |
jQuery(document).ready(function($) {
|
|
|
170 |
var objFormGenerator = new classFormGenerator();
|
|
|
171 |
objFormGenerator.render();
|
|
|
172 |
var allowEdit = $allowEdit;
|
| 469 |
geraldo |
173 |
var allowReport = $allowReport;
|
| 251 |
geraldo |
174 |
/**
|
|
|
175 |
* Get rows and set data table
|
|
|
176 |
*/
|
|
|
177 |
var tableForm = $('#gridTable').dataTable({
|
|
|
178 |
'processing': true,
|
|
|
179 |
'serverSide': true,
|
|
|
180 |
'searching': true,
|
|
|
181 |
'order': [
|
|
|
182 |
[0, 'asc']
|
|
|
183 |
],
|
|
|
184 |
'ordering': true,
|
|
|
185 |
'ordenable': true,
|
|
|
186 |
'responsive': true,
|
|
|
187 |
'select': false,
|
|
|
188 |
'paging': true,
|
|
|
189 |
'pagingType': 'simple_numbers',
|
|
|
190 |
'ajax': {
|
|
|
191 |
'url': '$routeDatatable',
|
|
|
192 |
'type': 'get',
|
|
|
193 |
'beforeSend': function(request) {
|
|
|
194 |
NProgress.start();
|
|
|
195 |
},
|
|
|
196 |
'dataFilter': function(response) {
|
|
|
197 |
var response = jQuery.parseJSON(response);
|
|
|
198 |
var json = {};
|
|
|
199 |
json.recordsTotal = 0;
|
|
|
200 |
json.recordsFiltered = 0;
|
|
|
201 |
json.data = [];
|
|
|
202 |
if (response.success) {
|
| 482 |
geraldo |
203 |
if ($('#only_pending').is(':checked')) {
|
|
|
204 |
let items = response.data.items.filter((item) => item.status == 'Pendiente');
|
| 481 |
geraldo |
205 |
json.recordsTotal = items.length;
|
| 482 |
geraldo |
206 |
json.recordsFiltered = items.length;
|
|
|
207 |
json.data = items;
|
|
|
208 |
} else {
|
|
|
209 |
json.recordsTotal = response.data.total;
|
|
|
210 |
json.recordsFiltered = response.data.total;
|
|
|
211 |
json.data = response.data.items;
|
|
|
212 |
}
|
| 251 |
geraldo |
213 |
} else {
|
|
|
214 |
$.fn.showError(response.data)
|
|
|
215 |
}
|
|
|
216 |
return JSON.stringify(json);
|
|
|
217 |
}
|
|
|
218 |
},
|
|
|
219 |
'language': {
|
|
|
220 |
'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
|
|
|
221 |
'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
|
|
|
222 |
'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
|
|
|
223 |
'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
|
|
|
224 |
'sInfo': 'LABEL_DATATABLE_SINFO',
|
|
|
225 |
'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
|
|
|
226 |
'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
|
|
|
227 |
'sInfoPostFix': '',
|
|
|
228 |
'sSearch': 'LABEL_DATATABLE_SSEARCH',
|
|
|
229 |
'sUrl': '',
|
|
|
230 |
'sInfoThousands': ',',
|
|
|
231 |
'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
|
|
|
232 |
'oPaginate': {
|
|
|
233 |
'sFirst': 'LABEL_DATATABLE_SFIRST',
|
|
|
234 |
'sLast': 'LABEL_DATATABLE_SLAST',
|
|
|
235 |
'sNext': 'LABEL_DATATABLE_SNEXT',
|
|
|
236 |
'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
|
|
|
237 |
},
|
|
|
238 |
'oAria': {
|
|
|
239 |
'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
|
|
|
240 |
'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
|
|
|
241 |
},
|
|
|
242 |
},
|
|
|
243 |
'drawCallback': function(settings) {
|
|
|
244 |
NProgress.done();
|
|
|
245 |
$('button.btn-delete').confirmation({
|
|
|
246 |
rootSelector: 'button.btn-delete',
|
|
|
247 |
title: 'LABEL_ARE_YOU_SURE',
|
|
|
248 |
singleton: true,
|
|
|
249 |
btnOkLabel: 'LABEL_YES',
|
|
|
250 |
btnCancelLabel: 'LABEL_NO',
|
|
|
251 |
onConfirm: function(value) {
|
|
|
252 |
action = $(this).data('href');
|
|
|
253 |
NProgress.start();
|
|
|
254 |
$.ajax({
|
|
|
255 |
'dataType': 'json',
|
|
|
256 |
'accept': 'application/json',
|
|
|
257 |
'method': 'post',
|
|
|
258 |
'url': action,
|
|
|
259 |
}).done(function(response) {
|
|
|
260 |
if (response['success']) {
|
|
|
261 |
$.fn.showSuccess(response['data']);
|
|
|
262 |
tableForm.fnDraw();
|
|
|
263 |
} else {
|
|
|
264 |
$.fn.showError(response['data']);
|
|
|
265 |
}
|
|
|
266 |
}).fail(function(jqXHR, textStatus, errorThrown) {
|
|
|
267 |
$.fn.showError(textStatus);
|
|
|
268 |
}).always(function() {
|
|
|
269 |
NProgress.done();
|
|
|
270 |
});
|
|
|
271 |
},
|
|
|
272 |
});
|
|
|
273 |
},
|
| 339 |
geraldo |
274 |
'aoColumns': [{
|
| 294 |
geraldo |
275 |
'mDataProp': 'user'
|
| 339 |
geraldo |
276 |
}, {
|
| 251 |
geraldo |
277 |
'mDataProp': 'name'
|
|
|
278 |
},
|
|
|
279 |
{
|
|
|
280 |
'mDataProp': 'language'
|
|
|
281 |
},
|
|
|
282 |
{
|
|
|
283 |
'mDataProp': 'status'
|
|
|
284 |
},
|
|
|
285 |
{
|
| 447 |
geraldo |
286 |
'mDataProp': 'added_on'
|
|
|
287 |
},
|
|
|
288 |
{
|
| 471 |
geraldo |
289 |
'mDataProp': 'actions'
|
| 251 |
geraldo |
290 |
},
|
|
|
291 |
],
|
| 339 |
geraldo |
292 |
'columnDefs': [{
|
| 251 |
geraldo |
293 |
'targets': 0,
|
|
|
294 |
'className': 'text-vertical-middle',
|
| 339 |
geraldo |
295 |
}, {
|
| 294 |
geraldo |
296 |
'targets': 1,
|
|
|
297 |
'className': 'text-vertical-middle',
|
| 251 |
geraldo |
298 |
},
|
|
|
299 |
{
|
| 294 |
geraldo |
300 |
'targets': -1,
|
| 251 |
geraldo |
301 |
'className': 'text-vertical-middle',
|
|
|
302 |
},
|
|
|
303 |
{
|
| 447 |
geraldo |
304 |
'targets': -1,
|
| 292 |
geraldo |
305 |
'className': 'text-center',
|
| 293 |
geraldo |
306 |
'className': 'text-vertical-middle',
|
| 251 |
geraldo |
307 |
},
|
|
|
308 |
{
|
|
|
309 |
'targets': -1,
|
| 447 |
geraldo |
310 |
'className': 'text-vertical-middle',
|
|
|
311 |
},
|
|
|
312 |
{
|
|
|
313 |
'targets': -1,
|
| 251 |
geraldo |
314 |
'orderable': false,
|
|
|
315 |
'render': function(data, type, row) {
|
|
|
316 |
s = '';
|
| 469 |
geraldo |
317 |
if (allowEdit && data['link_edit']) {
|
| 941 |
geraldo |
318 |
s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_MAKE_CHECK">LABEL_MAKE_CHECK</button> ';
|
| 251 |
geraldo |
319 |
}
|
| 469 |
geraldo |
320 |
if (allowReport && data['link_report']) {
|
| 540 |
geraldo |
321 |
s = s + '<a class="btn btn-primary btn-edit-form" href="' + data['link_report'] + '" target="_blank" data-toggle="tooltip" title="LABEL_VIEW_REPORT">LABEL_VIEW_REPORT</a> ';
|
| 469 |
geraldo |
322 |
}
|
| 251 |
geraldo |
323 |
return s;
|
|
|
324 |
}
|
|
|
325 |
}
|
|
|
326 |
],
|
|
|
327 |
});
|
|
|
328 |
/**
|
| 391 |
geraldo |
329 |
* Clicked edit question
|
|
|
330 |
*/
|
| 412 |
geraldo |
331 |
$('body').on('click', 'button.btn-add-review', function(e) {
|
| 391 |
geraldo |
332 |
e.preventDefault();
|
| 439 |
geraldo |
333 |
if ($('#question-value').val() == '') {
|
| 432 |
geraldo |
334 |
$.fn.showError('ERROR_ENTER_VALUE');
|
|
|
335 |
return false;
|
| 439 |
geraldo |
336 |
} else {
|
|
|
337 |
objFormGenerator.editQuestion(
|
|
|
338 |
$('#section').val(),
|
|
|
339 |
$('#question').val(),
|
|
|
340 |
$('#question-comment').val(),
|
|
|
341 |
$('#question-value').val(),
|
|
|
342 |
$('#question-status').val() == '1' ? true : false
|
|
|
343 |
);
|
|
|
344 |
renderSectionData(objFormGenerator.sections);
|
|
|
345 |
$('#form-review')[0].reset();
|
|
|
346 |
$('#modal-review').modal('hide');
|
|
|
347 |
}
|
| 391 |
geraldo |
348 |
});
|
|
|
349 |
/**
|
|
|
350 |
* Clicked edit question
|
|
|
351 |
*/
|
| 411 |
geraldo |
352 |
$('body').on('click', 'button.btn-edit-review', function(e) {
|
| 391 |
geraldo |
353 |
e.preventDefault();
|
| 411 |
geraldo |
354 |
e.preventDefault();
|
|
|
355 |
var slug_section = $(this).data('section');
|
| 412 |
geraldo |
356 |
var slug_question = $(this).data('question');
|
| 411 |
geraldo |
357 |
var showForm = false;
|
|
|
358 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
|
|
359 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
|
|
360 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
| 412 |
geraldo |
361 |
if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
|
|
|
362 |
$('#form-review #section').val(objFormGenerator.sections[i].slug_section);
|
|
|
363 |
$('#form-review #question').val(objFormGenerator.sections[i].questions[j].slug_question);
|
| 429 |
geraldo |
364 |
if (objFormGenerator.sections[i].questions[j].status) {
|
| 411 |
geraldo |
365 |
$('#form-review #question-status').val('1');
|
|
|
366 |
} else {
|
|
|
367 |
$('#form-review #question-status').val('0');
|
|
|
368 |
}
|
| 429 |
geraldo |
369 |
if (objFormGenerator.sections[i].questions[j].comment) {
|
| 419 |
geraldo |
370 |
$('#form-review #question-comment').val(objFormGenerator.sections[i].questions[j].comment);
|
| 429 |
geraldo |
371 |
} else {
|
|
|
372 |
$('#form-review #question-comment').val('');
|
| 411 |
geraldo |
373 |
}
|
| 432 |
geraldo |
374 |
if (objFormGenerator.sections[i].questions[j].question_value) {
|
|
|
375 |
$('#form-review #question-value').val(objFormGenerator.sections[i].questions[j].question_value);
|
|
|
376 |
} else {
|
| 435 |
geraldo |
377 |
$('#form-review #question-value').val(0);
|
| 432 |
geraldo |
378 |
}
|
| 412 |
geraldo |
379 |
$('#modal-review').modal('show');
|
|
|
380 |
return true;
|
| 411 |
geraldo |
381 |
}
|
|
|
382 |
}
|
|
|
383 |
}
|
|
|
384 |
}
|
| 391 |
geraldo |
385 |
});
|
|
|
386 |
/**
|
| 251 |
geraldo |
387 |
* Clicked on edit form
|
|
|
388 |
*/
|
|
|
389 |
$('body').on('click', 'button.btn-edit-form', function(e) {
|
|
|
390 |
e.preventDefault();
|
|
|
391 |
form_id = $(this).data('id')
|
|
|
392 |
var action = $(this).data('href');
|
|
|
393 |
$.ajax({
|
|
|
394 |
'dataType': 'json',
|
|
|
395 |
'accept': 'application/json',
|
|
|
396 |
'method': 'get',
|
|
|
397 |
'url': action,
|
|
|
398 |
}).done(function(response) {
|
|
|
399 |
if (response['success']) {
|
|
|
400 |
$('#form-main').attr('action', action);
|
|
|
401 |
$('#form-main #form-id').val(response['data']['id']),
|
| 855 |
geraldo |
402 |
$('#name').html(response['data']['name']);
|
| 943 |
geraldo |
403 |
$('#comments').val(response['data']['comments'] || '');
|
| 316 |
geraldo |
404 |
$('#text').html(response['data']['text']);
|
|
|
405 |
$('#user').html(response['data']['user']);
|
| 251 |
geraldo |
406 |
/*-------------Render Sections -------*/
|
|
|
407 |
objFormGenerator.clear();
|
|
|
408 |
objFormGenerator.sections = response['data']['content'] || [];
|
|
|
409 |
objFormGenerator.render();
|
|
|
410 |
renderSectionData(objFormGenerator.sections);
|
| 254 |
geraldo |
411 |
$('#row-forms').hide();
|
| 251 |
geraldo |
412 |
$('#row-edit').show();
|
|
|
413 |
} else {
|
|
|
414 |
$.fn.showError(response['message'] || 'ERROR_UNKNOWN');
|
|
|
415 |
}
|
|
|
416 |
}).fail(function(jqXHR, textStatus, errorThrown) {
|
|
|
417 |
$.fn.showError(textStatus);
|
|
|
418 |
});
|
|
|
419 |
});
|
| 351 |
geraldo |
420 |
$('button.btn-form-save-close').click(function(e) {
|
| 444 |
geraldo |
421 |
var formContinue = parseFloat($('#form-main #form-continue').val());
|
| 352 |
geraldo |
422 |
var data = {
|
| 855 |
geraldo |
423 |
'comments': $('#form-main #comments').val(),
|
| 352 |
geraldo |
424 |
'content': JSON.stringify(objFormGenerator.sections)
|
|
|
425 |
}
|
|
|
426 |
$.ajax({
|
|
|
427 |
'dataType': 'json',
|
|
|
428 |
'method': 'post',
|
|
|
429 |
'url': $('#form-main').attr('action'),
|
|
|
430 |
'data': data,
|
|
|
431 |
}).done(function(response) {
|
|
|
432 |
if (response['success']) {
|
|
|
433 |
$.fn.showSuccess(response['data']);
|
|
|
434 |
$('#row-edit').hide();
|
|
|
435 |
$('#row-forms').show();
|
|
|
436 |
/*---------- Reset Form -------- */
|
|
|
437 |
$('#form-main')[0].reset();
|
|
|
438 |
/*--------Reset Sections ----------*/
|
|
|
439 |
clearSectionData();
|
|
|
440 |
/* ------- Refresh Table -----------*/
|
|
|
441 |
tableForm.fnDraw();
|
|
|
442 |
} else {
|
|
|
443 |
$.fn.showError(response['message'] || 'ERROR_UNKNOWN');
|
|
|
444 |
}
|
|
|
445 |
}).fail(function(jqXHR, textStatus, errorThrown) {
|
|
|
446 |
$.fn.showError(textStatus);
|
|
|
447 |
});
|
|
|
448 |
return false;
|
| 351 |
geraldo |
449 |
});
|
| 251 |
geraldo |
450 |
/**
|
|
|
451 |
* Clicked cancel new/edit Form
|
|
|
452 |
*/
|
|
|
453 |
$('button.btn-edit-cancel').click(function(e) {
|
|
|
454 |
e.preventDefault();
|
|
|
455 |
$('#row-edit').hide();
|
| 254 |
geraldo |
456 |
$('#row-forms').show();
|
| 251 |
geraldo |
457 |
});
|
|
|
458 |
/**
|
| 339 |
geraldo |
459 |
* Get Answers
|
|
|
460 |
*/
|
|
|
461 |
const getAnswer = (type, options, answer) => {
|
|
|
462 |
if (type == 'open' || type == 'rating-range') {
|
| 328 |
geraldo |
463 |
return answer;
|
| 251 |
geraldo |
464 |
}
|
| 339 |
geraldo |
465 |
if (type == 'multiple') {
|
| 352 |
geraldo |
466 |
let opt = '';
|
| 339 |
geraldo |
467 |
opt += removeTags(options.filter((opt) => answer.includes(opt.slug_option))[0].text) + ' ';
|
| 332 |
geraldo |
468 |
return opt;
|
| 330 |
geraldo |
469 |
}
|
| 338 |
geraldo |
470 |
return removeTags(options.filter((opt) => opt.slug_option == answer)[0].text);
|
| 251 |
geraldo |
471 |
}
|
|
|
472 |
/**
|
| 341 |
geraldo |
473 |
* Get Status
|
|
|
474 |
*/
|
| 400 |
geraldo |
475 |
const getStatus = (options, answer, type) => {
|
| 407 |
geraldo |
476 |
let status;
|
| 409 |
geraldo |
477 |
status = type == 'multiple' ?
|
|
|
478 |
options.filter((opt) => answer.includes(opt.slug_option) && opt.correct == '1') :
|
| 410 |
geraldo |
479 |
options.filter((opt) => opt.slug_option == answer && opt.correct == '1');
|
| 409 |
geraldo |
480 |
return status.length != 0 ? '<font color="green">LABEL_CORRECT</font>' : '<font color="red">LABEL_FAIL</red>';
|
| 400 |
geraldo |
481 |
}
|
| 441 |
geraldo |
482 |
const getPtos = (options, answer, type, value, question_value) => {
|
| 429 |
geraldo |
483 |
let ptos = 0;
|
|
|
484 |
if (type == "open" || type == "rating-open" || type == "rating-range") {
|
| 441 |
geraldo |
485 |
ptos = question_value ? question_value : 0;
|
| 429 |
geraldo |
486 |
} else {
|
|
|
487 |
if (type == 'multiple') {
|
|
|
488 |
options.map((opt) => {
|
|
|
489 |
if (answer.includes(opt.slug_option)) {
|
| 444 |
geraldo |
490 |
ptos += parseFloat(opt.value);
|
| 429 |
geraldo |
491 |
}
|
|
|
492 |
})
|
|
|
493 |
} else {
|
|
|
494 |
options.map((opt) => {
|
|
|
495 |
if (opt.slug_option == answer) {
|
| 444 |
geraldo |
496 |
ptos = parseFloat(opt.value);
|
| 429 |
geraldo |
497 |
}
|
|
|
498 |
});
|
|
|
499 |
}
|
|
|
500 |
}
|
| 482 |
geraldo |
501 |
return parseFloat(ptos).toFixed(2) + '/' + parseFloat(value).toFixed(2);
|
| 429 |
geraldo |
502 |
}
|
| 341 |
geraldo |
503 |
/**
|
| 251 |
geraldo |
504 |
* Remove Html Tags
|
|
|
505 |
*/
|
| 339 |
geraldo |
506 |
const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
|
| 251 |
geraldo |
507 |
/**
|
|
|
508 |
* Render Sections data
|
|
|
509 |
*/
|
| 398 |
geraldo |
510 |
const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
|
| 323 |
geraldo |
511 |
removeTags: removeTags,
|
| 341 |
geraldo |
512 |
getAnswer: getAnswer,
|
| 429 |
geraldo |
513 |
getStatus: getStatus,
|
|
|
514 |
getPtos: getPtos
|
| 398 |
geraldo |
515 |
}));
|
| 251 |
geraldo |
516 |
/**
|
|
|
517 |
* Clear Div Section data
|
|
|
518 |
*/
|
|
|
519 |
const clearSectionData = () => $("#rows").html('');
|
|
|
520 |
/**
|
|
|
521 |
* Clicked refresh button
|
|
|
522 |
*/
|
|
|
523 |
$('button.btn-refresh').click(function(e) {
|
|
|
524 |
tableForm.fnDraw();
|
|
|
525 |
});
|
| 438 |
geraldo |
526 |
/**
|
|
|
527 |
* Format input number (Form Option)
|
|
|
528 |
*/
|
|
|
529 |
$('#form-review #question-value').inputNumberFormat({
|
|
|
530 |
'decimal': 2
|
|
|
531 |
});
|
| 482 |
geraldo |
532 |
$('input[type=checkbox]').change(function() {
|
|
|
533 |
tableForm.fnDraw();
|
| 481 |
geraldo |
534 |
});
|
| 478 |
geraldo |
535 |
});
|
| 251 |
geraldo |
536 |
JS;
|
|
|
537 |
$this->inlineScript()->captureEnd();
|
|
|
538 |
?>
|
|
|
539 |
|
|
|
540 |
<!-- Content Header (Page header) -->
|
|
|
541 |
<section class="content-header">
|
| 476 |
geraldo |
542 |
<div class="container-fluid">
|
|
|
543 |
<div class="row mb-2">
|
|
|
544 |
<div class="col-sm-12">
|
|
|
545 |
<h1>LABEL_REVIEWS</h1>
|
|
|
546 |
</div>
|
|
|
547 |
</div>
|
|
|
548 |
</div>
|
|
|
549 |
<!-- /.container-fluid -->
|
| 251 |
geraldo |
550 |
</section>
|
| 314 |
geraldo |
551 |
<section class="content" style="padding: 13px;">
|
| 476 |
geraldo |
552 |
<div class="container-fluid" id="row-forms">
|
|
|
553 |
<div class="row">
|
|
|
554 |
<div class="col-12">
|
|
|
555 |
<div class="card">
|
|
|
556 |
<div class="card-body">
|
|
|
557 |
<table id="gridTable" class="table table-hover">
|
|
|
558 |
<thead>
|
|
|
559 |
<tr>
|
|
|
560 |
<th style="width: 16.6%;">LABEL_USER</th>
|
|
|
561 |
<th style="width: 16.6%;">LABEL_NAME</th>
|
|
|
562 |
<th style="width: 16.6%;">LABEL_LANGUAGE</th>
|
|
|
563 |
<th style="width: 16.6%;">LABEL_STATUS</th>
|
|
|
564 |
<th style="width: 16.6%;">LABEL_REGISTER</th>
|
|
|
565 |
<th style="width: 16.6%;">LABEL_ACTIONS</th>
|
|
|
566 |
</tr>
|
|
|
567 |
</thead>
|
|
|
568 |
<tbody></tbody>
|
|
|
569 |
</table>
|
|
|
570 |
</div>
|
|
|
571 |
<div class="card-footer clearfix">
|
|
|
572 |
<div class="row">
|
|
|
573 |
<div class="col-md-6 col-sm-6 col-xs-12">
|
|
|
574 |
<div class="form-check">
|
|
|
575 |
<input class="form-check-input" type="checkbox" id="only_pending" name="only_pending" value="1">
|
|
|
576 |
<label class="form-check-label">LABEL_ONLY_PENDING</label>
|
|
|
577 |
</div>
|
|
|
578 |
</div>
|
|
|
579 |
<div class="col-md-6 col-sm-6 col-xs-12">
|
|
|
580 |
<div style="float:right;">
|
| 474 |
geraldo |
581 |
<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
|
| 476 |
geraldo |
582 |
</div>
|
|
|
583 |
</div>
|
|
|
584 |
</div>
|
|
|
585 |
</div>
|
|
|
586 |
</div>
|
|
|
587 |
</div>
|
|
|
588 |
</div>
|
| 474 |
geraldo |
589 |
</div>
|
| 476 |
geraldo |
590 |
<!-- Create/Edit Form -->
|
|
|
591 |
<div class="row" id="row-edit" style="display: none">
|
|
|
592 |
<div class="col-xs-12 col-md-12">
|
|
|
593 |
<form action="#" name="form-main" id="form-main">
|
|
|
594 |
<div class="form-group">
|
|
|
595 |
<label for="form-status">LABEL_USER:</label>
|
|
|
596 |
<div id="user"></div>
|
|
|
597 |
</div>
|
|
|
598 |
<div class="form-group">
|
|
|
599 |
<label for="form-status">LABEL_FORM:</label>
|
|
|
600 |
<div id="name"></div>
|
|
|
601 |
</div>
|
|
|
602 |
<div class="form-group">
|
|
|
603 |
<label for="form-status">LABEL_DESCRIPTION:</label>
|
|
|
604 |
<div id="text"></div>
|
|
|
605 |
</div>
|
|
|
606 |
<div class="row">
|
|
|
607 |
<div class="col-xs-12 col-md-12">
|
|
|
608 |
<div class="panel-group" id="rows"></div>
|
| 251 |
geraldo |
609 |
</div>
|
| 476 |
geraldo |
610 |
</div>
|
| 855 |
geraldo |
611 |
<div class="row">
|
|
|
612 |
<div class="col-xs-12 col-md-12">
|
|
|
613 |
<div class="form-group">
|
| 944 |
geraldo |
614 |
<label >LABEL_FINAL_COMMENT</label>
|
|
|
615 |
<textarea id="comments" name="comments" class="form-control" rows="10" cols="50" ></textarea>
|
| 855 |
geraldo |
616 |
</div>
|
|
|
617 |
</div>
|
|
|
618 |
</div>
|
| 476 |
geraldo |
619 |
<div class="form-group">
|
|
|
620 |
<button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE</button>
|
|
|
621 |
<button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
|
|
|
622 |
</div>
|
|
|
623 |
</form>
|
|
|
624 |
</div>
|
| 434 |
geraldo |
625 |
</div>
|
| 476 |
geraldo |
626 |
<!-- Create/Edit Form-->
|
|
|
627 |
<div id="modal-review" class="modal" tabindex="-1" role="dialog">
|
|
|
628 |
<div class="modal-dialog modal-lg" role="document">
|
|
|
629 |
<form action="#" name="form-option" id="form-review">
|
|
|
630 |
<input type="hidden" name="section" id="section" value="" />
|
|
|
631 |
<input type="hidden" name="question" id="question" value="" />
|
|
|
632 |
<div class="modal-content">
|
|
|
633 |
<div class="modal-header">
|
|
|
634 |
<h4 class="modal-title">LABEL_RESPONSE_REVIEW</h4>
|
|
|
635 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
636 |
<span aria-hidden="true">×</span>
|
|
|
637 |
</button>
|
|
|
638 |
</div>
|
|
|
639 |
<div class="modal-body">
|
|
|
640 |
<div class="form-group">
|
|
|
641 |
<label for="option-text">LABEL_COMMENT</label>
|
|
|
642 |
<!-- ckeditor -->
|
|
|
643 |
<textarea name="question-comment" id="question-comment" rows="5" class="form-control" placeholder="LABEL_ENTER_COMMENT"></textarea>
|
|
|
644 |
</div>
|
|
|
645 |
<div class="form-group">
|
|
|
646 |
<label for="question-status">LABEL_ANSWER_CORRECT</label>
|
|
|
647 |
<select name="question-status" id="question-status" class="form-control">
|
|
|
648 |
<option value="1">LABEL_YES</option>
|
|
|
649 |
<option value="0">LABEL_NOT</option>
|
|
|
650 |
</select>
|
|
|
651 |
</div>
|
|
|
652 |
<div class="form-group">
|
|
|
653 |
<label for="question-value">LABEL_VALUE</label>
|
|
|
654 |
<input type="text" name="question-value" id="question-value" class="form-control" />
|
|
|
655 |
</div>
|
|
|
656 |
</div>
|
|
|
657 |
<div class="modal-footer">
|
|
|
658 |
<button type="button" class="btn btn-primary btn-add-review">LABEL_SAVE</button>
|
|
|
659 |
<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
|
|
|
660 |
</div>
|
|
|
661 |
</div>
|
|
|
662 |
</form>
|
|
|
663 |
</div>
|
|
|
664 |
</div>
|
| 411 |
geraldo |
665 |
|
| 251 |
geraldo |
666 |
<!---Template Sections --->
|
|
|
667 |
<script id="sectionTemplate" type="text/x-jsrender">
|
| 460 |
geraldo |
668 |
<div class="panel panel-default" id="panel-{{:slug_section}}">
|
| 369 |
geraldo |
669 |
<div class="panel-heading">
|
|
|
670 |
<h4 class="panel-title">
|
|
|
671 |
<a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
|
|
|
672 |
<span class="section-name{{:slug_section}}">
|
|
|
673 |
{{:name}}
|
|
|
674 |
</span>
|
|
|
675 |
</a>
|
|
|
676 |
</h4>
|
|
|
677 |
</div>
|
|
|
678 |
<div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
|
|
|
679 |
<div class="panel-body">
|
| 450 |
geraldo |
680 |
<div class="table-responsive">
|
| 463 |
geraldo |
681 |
<table class="table table-bordered table-review">
|
| 459 |
geraldo |
682 |
<thead>
|
| 369 |
geraldo |
683 |
<tr>
|
| 399 |
geraldo |
684 |
<th style="width: 30%;">LABEL_QUESTION</th>
|
| 428 |
geraldo |
685 |
<th style="width: 30%;">LABEL_ANSWER</th>
|
| 399 |
geraldo |
686 |
<th style="width: 10%;">LABEL_STATUS</th>
|
| 467 |
geraldo |
687 |
<th style="width: 15%;">LABEL_PTOS</th>
|
|
|
688 |
<th style="width: 15%;">LABEL_ACTIONS</th>
|
| 369 |
geraldo |
689 |
</tr>
|
| 459 |
geraldo |
690 |
</thead>
|
|
|
691 |
<tbody>
|
| 460 |
geraldo |
692 |
{{for questions}}
|
| 369 |
geraldo |
693 |
<tr class="tr-question">
|
|
|
694 |
<td class="text-left">{{:~removeTags(text)}} </td>
|
|
|
695 |
<td>{{:~getAnswer(type,options,answer)}}</td>
|
|
|
696 |
<td>
|
|
|
697 |
{{if type == 'simple' || type=='multiple' }}
|
| 429 |
geraldo |
698 |
{{:~getStatus(options,answer,type)}}
|
| 369 |
geraldo |
699 |
{{else}}
|
| 399 |
geraldo |
700 |
{{if status}}
|
| 460 |
geraldo |
701 |
<font color="green">LABEL_CORRECT</font>
|
|
|
702 |
{{else}}
|
|
|
703 |
<font color="red">LABEL_FAIL</font>
|
| 399 |
geraldo |
704 |
{{/if}}
|
| 460 |
geraldo |
705 |
{{/if}}
|
| 399 |
geraldo |
706 |
</td>
|
|
|
707 |
<td>
|
| 460 |
geraldo |
708 |
{{:~getPtos(options,answer,type, value, question_value)}}
|
|
|
709 |
</td>
|
| 429 |
geraldo |
710 |
<td>
|
| 399 |
geraldo |
711 |
{{if type != 'simple' && type !='multiple' }}
|
| 466 |
geraldo |
712 |
<button class="btn btn-default btn-edit-review" data-original-title="LABEL_EDIT" data-section="{{:slug_section}}" data-question="{{:slug_question}}">
|
|
|
713 |
<i class="fa fa-pencil" aria-hidden="true"></i> LABEL_EDIT
|
| 369 |
geraldo |
714 |
</button>
|
| 413 |
geraldo |
715 |
{{/if}}
|
| 369 |
geraldo |
716 |
</td>
|
|
|
717 |
</tr>
|
| 460 |
geraldo |
718 |
{{/for}}
|
| 459 |
geraldo |
719 |
</tbody>
|
| 369 |
geraldo |
720 |
</table>
|
| 450 |
geraldo |
721 |
</div>
|
| 369 |
geraldo |
722 |
</div>
|
|
|
723 |
</div>
|
|
|
724 |
</div>
|
| 251 |
geraldo |
725 |
</script>
|
|
|
726 |
|
|
|
727 |
<!-- End Template Sections-->
|
|
|
728 |
|
|
|
729 |
</section>
|