| 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 |
|
| 16822 |
efrain |
14 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
|
| 251 |
geraldo |
15 |
|
|
|
16 |
|
| 16822 |
efrain |
17 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
|
|
|
18 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
|
| 251 |
geraldo |
19 |
|
|
|
20 |
|
| 16822 |
efrain |
21 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
|
|
|
22 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
|
|
|
23 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));
|
| 251 |
geraldo |
24 |
|
| 16822 |
efrain |
25 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
|
|
|
26 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
|
| 251 |
geraldo |
27 |
|
| 16822 |
efrain |
28 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
|
|
|
29 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
|
|
|
30 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
|
|
|
31 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
|
| 251 |
geraldo |
32 |
|
|
|
33 |
|
| 16822 |
efrain |
34 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.min.css'));
|
|
|
35 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
|
| 251 |
geraldo |
36 |
|
| 16822 |
efrain |
37 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.full.min.js'));
|
| 251 |
geraldo |
38 |
|
| 16822 |
efrain |
39 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment-with-locales.min.js'));
|
|
|
40 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
|
|
|
41 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
|
| 251 |
geraldo |
42 |
|
|
|
43 |
|
| 16822 |
efrain |
44 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
|
|
|
45 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
|
| 251 |
geraldo |
46 |
|
| 261 |
geraldo |
47 |
|
| 16822 |
efrain |
48 |
|
|
|
49 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
|
|
|
50 |
|
| 251 |
geraldo |
51 |
// bootbox Alert //
|
| 261 |
geraldo |
52 |
|
| 16822 |
efrain |
53 |
|
| 251 |
geraldo |
54 |
// JsRender //
|
| 16822 |
efrain |
55 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.min.js'));
|
| 251 |
geraldo |
56 |
|
| 261 |
geraldo |
57 |
// Page Styles
|
|
|
58 |
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
|
| 251 |
geraldo |
59 |
|
| 306 |
geraldo |
60 |
|
| 15443 |
efrain |
61 |
$pending = \LeadersLinked\Model\SelfEvaluationTest::STATUS_PENDING;
|
|
|
62 |
$review = \LeadersLinked\Model\SelfEvaluationTest::STATUS_REVIEW;
|
|
|
63 |
$completed = \LeadersLinked\Model\SelfEvaluationTest::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();
|
| 16822 |
efrain |
245 |
|
| 251 |
geraldo |
246 |
},
|
| 339 |
geraldo |
247 |
'aoColumns': [{
|
| 294 |
geraldo |
248 |
'mDataProp': 'user'
|
| 339 |
geraldo |
249 |
}, {
|
| 251 |
geraldo |
250 |
'mDataProp': 'name'
|
|
|
251 |
},
|
|
|
252 |
{
|
|
|
253 |
'mDataProp': 'language'
|
|
|
254 |
},
|
|
|
255 |
{
|
|
|
256 |
'mDataProp': 'status'
|
|
|
257 |
},
|
|
|
258 |
{
|
| 447 |
geraldo |
259 |
'mDataProp': 'added_on'
|
|
|
260 |
},
|
|
|
261 |
{
|
| 471 |
geraldo |
262 |
'mDataProp': 'actions'
|
| 251 |
geraldo |
263 |
},
|
|
|
264 |
],
|
| 339 |
geraldo |
265 |
'columnDefs': [{
|
| 251 |
geraldo |
266 |
'targets': 0,
|
|
|
267 |
'className': 'text-vertical-middle',
|
| 339 |
geraldo |
268 |
}, {
|
| 294 |
geraldo |
269 |
'targets': 1,
|
|
|
270 |
'className': 'text-vertical-middle',
|
| 251 |
geraldo |
271 |
},
|
|
|
272 |
{
|
| 294 |
geraldo |
273 |
'targets': -1,
|
| 251 |
geraldo |
274 |
'className': 'text-vertical-middle',
|
|
|
275 |
},
|
|
|
276 |
{
|
| 447 |
geraldo |
277 |
'targets': -1,
|
| 292 |
geraldo |
278 |
'className': 'text-center',
|
| 293 |
geraldo |
279 |
'className': 'text-vertical-middle',
|
| 251 |
geraldo |
280 |
},
|
|
|
281 |
{
|
|
|
282 |
'targets': -1,
|
| 447 |
geraldo |
283 |
'className': 'text-vertical-middle',
|
|
|
284 |
},
|
|
|
285 |
{
|
|
|
286 |
'targets': -1,
|
| 251 |
geraldo |
287 |
'orderable': false,
|
|
|
288 |
'render': function(data, type, row) {
|
|
|
289 |
s = '';
|
| 469 |
geraldo |
290 |
if (allowEdit && data['link_edit']) {
|
| 941 |
geraldo |
291 |
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 |
292 |
}
|
| 469 |
geraldo |
293 |
if (allowReport && data['link_report']) {
|
| 540 |
geraldo |
294 |
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 |
295 |
}
|
| 251 |
geraldo |
296 |
return s;
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
],
|
|
|
300 |
});
|
|
|
301 |
/**
|
| 391 |
geraldo |
302 |
* Clicked edit question
|
|
|
303 |
*/
|
| 412 |
geraldo |
304 |
$('body').on('click', 'button.btn-add-review', function(e) {
|
| 391 |
geraldo |
305 |
e.preventDefault();
|
| 439 |
geraldo |
306 |
if ($('#question-value').val() == '') {
|
| 432 |
geraldo |
307 |
$.fn.showError('ERROR_ENTER_VALUE');
|
|
|
308 |
return false;
|
| 439 |
geraldo |
309 |
} else {
|
|
|
310 |
objFormGenerator.editQuestion(
|
|
|
311 |
$('#section').val(),
|
|
|
312 |
$('#question').val(),
|
|
|
313 |
$('#question-comment').val(),
|
|
|
314 |
$('#question-value').val(),
|
|
|
315 |
$('#question-status').val() == '1' ? true : false
|
|
|
316 |
);
|
|
|
317 |
renderSectionData(objFormGenerator.sections);
|
|
|
318 |
$('#form-review')[0].reset();
|
|
|
319 |
$('#modal-review').modal('hide');
|
|
|
320 |
}
|
| 391 |
geraldo |
321 |
});
|
|
|
322 |
/**
|
|
|
323 |
* Clicked edit question
|
|
|
324 |
*/
|
| 411 |
geraldo |
325 |
$('body').on('click', 'button.btn-edit-review', function(e) {
|
| 391 |
geraldo |
326 |
e.preventDefault();
|
| 411 |
geraldo |
327 |
e.preventDefault();
|
|
|
328 |
var slug_section = $(this).data('section');
|
| 412 |
geraldo |
329 |
var slug_question = $(this).data('question');
|
| 411 |
geraldo |
330 |
var showForm = false;
|
|
|
331 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
|
|
332 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
|
|
333 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
| 412 |
geraldo |
334 |
if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
|
|
|
335 |
$('#form-review #section').val(objFormGenerator.sections[i].slug_section);
|
|
|
336 |
$('#form-review #question').val(objFormGenerator.sections[i].questions[j].slug_question);
|
| 429 |
geraldo |
337 |
if (objFormGenerator.sections[i].questions[j].status) {
|
| 411 |
geraldo |
338 |
$('#form-review #question-status').val('1');
|
|
|
339 |
} else {
|
|
|
340 |
$('#form-review #question-status').val('0');
|
|
|
341 |
}
|
| 429 |
geraldo |
342 |
if (objFormGenerator.sections[i].questions[j].comment) {
|
| 419 |
geraldo |
343 |
$('#form-review #question-comment').val(objFormGenerator.sections[i].questions[j].comment);
|
| 429 |
geraldo |
344 |
} else {
|
|
|
345 |
$('#form-review #question-comment').val('');
|
| 411 |
geraldo |
346 |
}
|
| 432 |
geraldo |
347 |
if (objFormGenerator.sections[i].questions[j].question_value) {
|
|
|
348 |
$('#form-review #question-value').val(objFormGenerator.sections[i].questions[j].question_value);
|
|
|
349 |
} else {
|
| 435 |
geraldo |
350 |
$('#form-review #question-value').val(0);
|
| 432 |
geraldo |
351 |
}
|
| 412 |
geraldo |
352 |
$('#modal-review').modal('show');
|
|
|
353 |
return true;
|
| 411 |
geraldo |
354 |
}
|
|
|
355 |
}
|
|
|
356 |
}
|
|
|
357 |
}
|
| 391 |
geraldo |
358 |
});
|
|
|
359 |
/**
|
| 251 |
geraldo |
360 |
* Clicked on edit form
|
|
|
361 |
*/
|
|
|
362 |
$('body').on('click', 'button.btn-edit-form', function(e) {
|
|
|
363 |
e.preventDefault();
|
|
|
364 |
form_id = $(this).data('id')
|
|
|
365 |
var action = $(this).data('href');
|
|
|
366 |
$.ajax({
|
|
|
367 |
'dataType': 'json',
|
|
|
368 |
'accept': 'application/json',
|
|
|
369 |
'method': 'get',
|
|
|
370 |
'url': action,
|
|
|
371 |
}).done(function(response) {
|
|
|
372 |
if (response['success']) {
|
|
|
373 |
$('#form-main').attr('action', action);
|
|
|
374 |
$('#form-main #form-id').val(response['data']['id']),
|
| 855 |
geraldo |
375 |
$('#name').html(response['data']['name']);
|
| 943 |
geraldo |
376 |
$('#comments').val(response['data']['comments'] || '');
|
| 316 |
geraldo |
377 |
$('#text').html(response['data']['text']);
|
|
|
378 |
$('#user').html(response['data']['user']);
|
| 251 |
geraldo |
379 |
/*-------------Render Sections -------*/
|
|
|
380 |
objFormGenerator.clear();
|
|
|
381 |
objFormGenerator.sections = response['data']['content'] || [];
|
|
|
382 |
objFormGenerator.render();
|
|
|
383 |
renderSectionData(objFormGenerator.sections);
|
| 254 |
geraldo |
384 |
$('#row-forms').hide();
|
| 251 |
geraldo |
385 |
$('#row-edit').show();
|
|
|
386 |
} else {
|
|
|
387 |
$.fn.showError(response['message'] || 'ERROR_UNKNOWN');
|
|
|
388 |
}
|
|
|
389 |
}).fail(function(jqXHR, textStatus, errorThrown) {
|
|
|
390 |
$.fn.showError(textStatus);
|
|
|
391 |
});
|
|
|
392 |
});
|
| 351 |
geraldo |
393 |
$('button.btn-form-save-close').click(function(e) {
|
| 444 |
geraldo |
394 |
var formContinue = parseFloat($('#form-main #form-continue').val());
|
| 352 |
geraldo |
395 |
var data = {
|
| 855 |
geraldo |
396 |
'comments': $('#form-main #comments').val(),
|
| 352 |
geraldo |
397 |
'content': JSON.stringify(objFormGenerator.sections)
|
|
|
398 |
}
|
|
|
399 |
$.ajax({
|
|
|
400 |
'dataType': 'json',
|
|
|
401 |
'method': 'post',
|
|
|
402 |
'url': $('#form-main').attr('action'),
|
|
|
403 |
'data': data,
|
|
|
404 |
}).done(function(response) {
|
|
|
405 |
if (response['success']) {
|
|
|
406 |
$.fn.showSuccess(response['data']);
|
|
|
407 |
$('#row-edit').hide();
|
|
|
408 |
$('#row-forms').show();
|
|
|
409 |
/*---------- Reset Form -------- */
|
|
|
410 |
$('#form-main')[0].reset();
|
|
|
411 |
/*--------Reset Sections ----------*/
|
|
|
412 |
clearSectionData();
|
|
|
413 |
/* ------- Refresh Table -----------*/
|
|
|
414 |
tableForm.fnDraw();
|
|
|
415 |
} else {
|
|
|
416 |
$.fn.showError(response['message'] || 'ERROR_UNKNOWN');
|
|
|
417 |
}
|
|
|
418 |
}).fail(function(jqXHR, textStatus, errorThrown) {
|
|
|
419 |
$.fn.showError(textStatus);
|
|
|
420 |
});
|
|
|
421 |
return false;
|
| 351 |
geraldo |
422 |
});
|
| 251 |
geraldo |
423 |
/**
|
|
|
424 |
* Clicked cancel new/edit Form
|
|
|
425 |
*/
|
|
|
426 |
$('button.btn-edit-cancel').click(function(e) {
|
|
|
427 |
e.preventDefault();
|
|
|
428 |
$('#row-edit').hide();
|
| 254 |
geraldo |
429 |
$('#row-forms').show();
|
| 251 |
geraldo |
430 |
});
|
|
|
431 |
/**
|
| 339 |
geraldo |
432 |
* Get Answers
|
|
|
433 |
*/
|
|
|
434 |
const getAnswer = (type, options, answer) => {
|
|
|
435 |
if (type == 'open' || type == 'rating-range') {
|
| 328 |
geraldo |
436 |
return answer;
|
| 251 |
geraldo |
437 |
}
|
| 339 |
geraldo |
438 |
if (type == 'multiple') {
|
| 352 |
geraldo |
439 |
let opt = '';
|
| 339 |
geraldo |
440 |
opt += removeTags(options.filter((opt) => answer.includes(opt.slug_option))[0].text) + ' ';
|
| 332 |
geraldo |
441 |
return opt;
|
| 330 |
geraldo |
442 |
}
|
| 338 |
geraldo |
443 |
return removeTags(options.filter((opt) => opt.slug_option == answer)[0].text);
|
| 251 |
geraldo |
444 |
}
|
|
|
445 |
/**
|
| 341 |
geraldo |
446 |
* Get Status
|
|
|
447 |
*/
|
| 400 |
geraldo |
448 |
const getStatus = (options, answer, type) => {
|
| 407 |
geraldo |
449 |
let status;
|
| 409 |
geraldo |
450 |
status = type == 'multiple' ?
|
|
|
451 |
options.filter((opt) => answer.includes(opt.slug_option) && opt.correct == '1') :
|
| 410 |
geraldo |
452 |
options.filter((opt) => opt.slug_option == answer && opt.correct == '1');
|
| 409 |
geraldo |
453 |
return status.length != 0 ? '<font color="green">LABEL_CORRECT</font>' : '<font color="red">LABEL_FAIL</red>';
|
| 400 |
geraldo |
454 |
}
|
| 441 |
geraldo |
455 |
const getPtos = (options, answer, type, value, question_value) => {
|
| 429 |
geraldo |
456 |
let ptos = 0;
|
|
|
457 |
if (type == "open" || type == "rating-open" || type == "rating-range") {
|
| 441 |
geraldo |
458 |
ptos = question_value ? question_value : 0;
|
| 429 |
geraldo |
459 |
} else {
|
|
|
460 |
if (type == 'multiple') {
|
|
|
461 |
options.map((opt) => {
|
|
|
462 |
if (answer.includes(opt.slug_option)) {
|
| 444 |
geraldo |
463 |
ptos += parseFloat(opt.value);
|
| 429 |
geraldo |
464 |
}
|
|
|
465 |
})
|
|
|
466 |
} else {
|
|
|
467 |
options.map((opt) => {
|
|
|
468 |
if (opt.slug_option == answer) {
|
| 444 |
geraldo |
469 |
ptos = parseFloat(opt.value);
|
| 429 |
geraldo |
470 |
}
|
|
|
471 |
});
|
|
|
472 |
}
|
|
|
473 |
}
|
| 482 |
geraldo |
474 |
return parseFloat(ptos).toFixed(2) + '/' + parseFloat(value).toFixed(2);
|
| 429 |
geraldo |
475 |
}
|
| 341 |
geraldo |
476 |
/**
|
| 251 |
geraldo |
477 |
* Remove Html Tags
|
|
|
478 |
*/
|
| 339 |
geraldo |
479 |
const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
|
| 251 |
geraldo |
480 |
/**
|
|
|
481 |
* Render Sections data
|
|
|
482 |
*/
|
| 398 |
geraldo |
483 |
const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
|
| 323 |
geraldo |
484 |
removeTags: removeTags,
|
| 341 |
geraldo |
485 |
getAnswer: getAnswer,
|
| 429 |
geraldo |
486 |
getStatus: getStatus,
|
|
|
487 |
getPtos: getPtos
|
| 398 |
geraldo |
488 |
}));
|
| 251 |
geraldo |
489 |
/**
|
|
|
490 |
* Clear Div Section data
|
|
|
491 |
*/
|
|
|
492 |
const clearSectionData = () => $("#rows").html('');
|
|
|
493 |
/**
|
|
|
494 |
* Clicked refresh button
|
|
|
495 |
*/
|
|
|
496 |
$('button.btn-refresh').click(function(e) {
|
|
|
497 |
tableForm.fnDraw();
|
|
|
498 |
});
|
| 16822 |
efrain |
499 |
|
|
|
500 |
$('body').on('click', 'button.btn-delete', function(e) {
|
|
|
501 |
e.preventDefault();
|
|
|
502 |
var action = $(this).data('href');
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
swal.fire({
|
|
|
506 |
title: 'LABEL_ARE_YOU_SURE',
|
|
|
507 |
icon: 'question',
|
|
|
508 |
cancelButtonText: 'LABEL_NO',
|
|
|
509 |
showCancelButton: true,
|
|
|
510 |
confirmButtonText: 'LABEL_YES'
|
|
|
511 |
}).then((result) => {
|
|
|
512 |
if (result.isConfirmed) {
|
|
|
513 |
|
|
|
514 |
NProgress.start();
|
|
|
515 |
$.ajax({
|
|
|
516 |
'dataType' : 'json',
|
|
|
517 |
'accept' : 'application/json',
|
|
|
518 |
'method' : 'post',
|
|
|
519 |
'url' : action,
|
|
|
520 |
}).done(function(response) {
|
|
|
521 |
if(response['success']) {
|
|
|
522 |
$.fn.showSuccess(response['data']);
|
|
|
523 |
gridTable.api().ajax.reload(null, false);
|
|
|
524 |
} else {
|
|
|
525 |
$.fn.showError(response['data']);
|
|
|
526 |
}
|
|
|
527 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
528 |
$.fn.showError(textStatus);
|
|
|
529 |
}).always(function() {
|
|
|
530 |
NProgress.done();
|
|
|
531 |
});
|
|
|
532 |
}
|
|
|
533 |
});
|
|
|
534 |
});
|
|
|
535 |
|
| 438 |
geraldo |
536 |
/**
|
|
|
537 |
* Format input number (Form Option)
|
|
|
538 |
*/
|
|
|
539 |
$('#form-review #question-value').inputNumberFormat({
|
|
|
540 |
'decimal': 2
|
|
|
541 |
});
|
| 482 |
geraldo |
542 |
$('input[type=checkbox]').change(function() {
|
|
|
543 |
tableForm.fnDraw();
|
| 481 |
geraldo |
544 |
});
|
| 478 |
geraldo |
545 |
});
|
| 251 |
geraldo |
546 |
JS;
|
|
|
547 |
$this->inlineScript()->captureEnd();
|
|
|
548 |
?>
|
|
|
549 |
|
|
|
550 |
<!-- Content Header (Page header) -->
|
|
|
551 |
<section class="content-header">
|
| 476 |
geraldo |
552 |
<div class="container-fluid">
|
|
|
553 |
<div class="row mb-2">
|
|
|
554 |
<div class="col-sm-12">
|
|
|
555 |
<h1>LABEL_REVIEWS</h1>
|
|
|
556 |
</div>
|
|
|
557 |
</div>
|
|
|
558 |
</div>
|
|
|
559 |
<!-- /.container-fluid -->
|
| 251 |
geraldo |
560 |
</section>
|
| 314 |
geraldo |
561 |
<section class="content" style="padding: 13px;">
|
| 476 |
geraldo |
562 |
<div class="container-fluid" id="row-forms">
|
|
|
563 |
<div class="row">
|
| 16891 |
efrain |
564 |
<div class="col-12 mt-3">
|
| 476 |
geraldo |
565 |
<div class="card">
|
|
|
566 |
<div class="card-body">
|
| 16845 |
efrain |
567 |
<table id="gridTable" class="table table-bordered">
|
| 476 |
geraldo |
568 |
<thead>
|
|
|
569 |
<tr>
|
|
|
570 |
<th style="width: 16.6%;">LABEL_USER</th>
|
|
|
571 |
<th style="width: 16.6%;">LABEL_NAME</th>
|
|
|
572 |
<th style="width: 16.6%;">LABEL_LANGUAGE</th>
|
|
|
573 |
<th style="width: 16.6%;">LABEL_STATUS</th>
|
|
|
574 |
<th style="width: 16.6%;">LABEL_REGISTER</th>
|
|
|
575 |
<th style="width: 16.6%;">LABEL_ACTIONS</th>
|
|
|
576 |
</tr>
|
|
|
577 |
</thead>
|
|
|
578 |
<tbody></tbody>
|
|
|
579 |
</table>
|
|
|
580 |
</div>
|
|
|
581 |
<div class="card-footer clearfix">
|
|
|
582 |
<div class="row">
|
|
|
583 |
<div class="col-md-6 col-sm-6 col-xs-12">
|
|
|
584 |
<div class="form-check">
|
|
|
585 |
<input class="form-check-input" type="checkbox" id="only_pending" name="only_pending" value="1">
|
|
|
586 |
<label class="form-check-label">LABEL_ONLY_PENDING</label>
|
|
|
587 |
</div>
|
|
|
588 |
</div>
|
|
|
589 |
<div class="col-md-6 col-sm-6 col-xs-12">
|
|
|
590 |
<div style="float:right;">
|
| 474 |
geraldo |
591 |
<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
|
| 476 |
geraldo |
592 |
</div>
|
|
|
593 |
</div>
|
|
|
594 |
</div>
|
|
|
595 |
</div>
|
|
|
596 |
</div>
|
|
|
597 |
</div>
|
|
|
598 |
</div>
|
| 474 |
geraldo |
599 |
</div>
|
| 476 |
geraldo |
600 |
<!-- Create/Edit Form -->
|
|
|
601 |
<div class="row" id="row-edit" style="display: none">
|
|
|
602 |
<div class="col-xs-12 col-md-12">
|
|
|
603 |
<form action="#" name="form-main" id="form-main">
|
|
|
604 |
<div class="form-group">
|
|
|
605 |
<label for="form-status">LABEL_USER:</label>
|
|
|
606 |
<div id="user"></div>
|
|
|
607 |
</div>
|
|
|
608 |
<div class="form-group">
|
|
|
609 |
<label for="form-status">LABEL_FORM:</label>
|
|
|
610 |
<div id="name"></div>
|
|
|
611 |
</div>
|
|
|
612 |
<div class="form-group">
|
|
|
613 |
<label for="form-status">LABEL_DESCRIPTION:</label>
|
|
|
614 |
<div id="text"></div>
|
|
|
615 |
</div>
|
|
|
616 |
<div class="row">
|
|
|
617 |
<div class="col-xs-12 col-md-12">
|
|
|
618 |
<div class="panel-group" id="rows"></div>
|
| 251 |
geraldo |
619 |
</div>
|
| 476 |
geraldo |
620 |
</div>
|
| 855 |
geraldo |
621 |
<div class="row">
|
|
|
622 |
<div class="col-xs-12 col-md-12">
|
|
|
623 |
<div class="form-group">
|
| 944 |
geraldo |
624 |
<label >LABEL_FINAL_COMMENT</label>
|
|
|
625 |
<textarea id="comments" name="comments" class="form-control" rows="10" cols="50" ></textarea>
|
| 855 |
geraldo |
626 |
</div>
|
|
|
627 |
</div>
|
|
|
628 |
</div>
|
| 476 |
geraldo |
629 |
<div class="form-group">
|
|
|
630 |
<button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE</button>
|
| 16822 |
efrain |
631 |
<button type="button" class="btn btn-light btn-edit-cancel">LABEL_CANCEL</button>
|
| 476 |
geraldo |
632 |
</div>
|
|
|
633 |
</form>
|
|
|
634 |
</div>
|
| 434 |
geraldo |
635 |
</div>
|
| 476 |
geraldo |
636 |
<!-- Create/Edit Form-->
|
|
|
637 |
<div id="modal-review" class="modal" tabindex="-1" role="dialog">
|
|
|
638 |
<div class="modal-dialog modal-lg" role="document">
|
|
|
639 |
<form action="#" name="form-option" id="form-review">
|
|
|
640 |
<input type="hidden" name="section" id="section" value="" />
|
|
|
641 |
<input type="hidden" name="question" id="question" value="" />
|
|
|
642 |
<div class="modal-content">
|
|
|
643 |
<div class="modal-header">
|
| 16845 |
efrain |
644 |
<h6 class="modal-title">LABEL_RESPONSE_REVIEW</h6>
|
| 16864 |
efrain |
645 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
|
| 476 |
geraldo |
646 |
</div>
|
|
|
647 |
<div class="modal-body">
|
|
|
648 |
<div class="form-group">
|
|
|
649 |
<label for="option-text">LABEL_COMMENT</label>
|
|
|
650 |
<!-- ckeditor -->
|
|
|
651 |
<textarea name="question-comment" id="question-comment" rows="5" class="form-control" placeholder="LABEL_ENTER_COMMENT"></textarea>
|
|
|
652 |
</div>
|
|
|
653 |
<div class="form-group">
|
|
|
654 |
<label for="question-status">LABEL_ANSWER_CORRECT</label>
|
|
|
655 |
<select name="question-status" id="question-status" class="form-control">
|
|
|
656 |
<option value="1">LABEL_YES</option>
|
|
|
657 |
<option value="0">LABEL_NOT</option>
|
|
|
658 |
</select>
|
|
|
659 |
</div>
|
|
|
660 |
<div class="form-group">
|
|
|
661 |
<label for="question-value">LABEL_VALUE</label>
|
|
|
662 |
<input type="text" name="question-value" id="question-value" class="form-control" />
|
|
|
663 |
</div>
|
|
|
664 |
</div>
|
| 16891 |
efrain |
665 |
<div class="modal-footer text-right">
|
| 476 |
geraldo |
666 |
<button type="button" class="btn btn-primary btn-add-review">LABEL_SAVE</button>
|
| 16864 |
efrain |
667 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
|
| 476 |
geraldo |
668 |
</div>
|
|
|
669 |
</div>
|
|
|
670 |
</form>
|
|
|
671 |
</div>
|
|
|
672 |
</div>
|
| 411 |
geraldo |
673 |
|
| 251 |
geraldo |
674 |
<!---Template Sections --->
|
|
|
675 |
<script id="sectionTemplate" type="text/x-jsrender">
|
| 460 |
geraldo |
676 |
<div class="panel panel-default" id="panel-{{:slug_section}}">
|
| 369 |
geraldo |
677 |
<div class="panel-heading">
|
| 16845 |
efrain |
678 |
<h6 class="panel-title">
|
| 369 |
geraldo |
679 |
<a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
|
|
|
680 |
<span class="section-name{{:slug_section}}">
|
|
|
681 |
{{:name}}
|
|
|
682 |
</span>
|
|
|
683 |
</a>
|
| 16845 |
efrain |
684 |
</h6>
|
| 369 |
geraldo |
685 |
</div>
|
|
|
686 |
<div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
|
|
|
687 |
<div class="panel-body">
|
| 450 |
geraldo |
688 |
<div class="table-responsive">
|
| 463 |
geraldo |
689 |
<table class="table table-bordered table-review">
|
| 459 |
geraldo |
690 |
<thead>
|
| 369 |
geraldo |
691 |
<tr>
|
| 399 |
geraldo |
692 |
<th style="width: 30%;">LABEL_QUESTION</th>
|
| 428 |
geraldo |
693 |
<th style="width: 30%;">LABEL_ANSWER</th>
|
| 399 |
geraldo |
694 |
<th style="width: 10%;">LABEL_STATUS</th>
|
| 467 |
geraldo |
695 |
<th style="width: 15%;">LABEL_PTOS</th>
|
|
|
696 |
<th style="width: 15%;">LABEL_ACTIONS</th>
|
| 369 |
geraldo |
697 |
</tr>
|
| 459 |
geraldo |
698 |
</thead>
|
|
|
699 |
<tbody>
|
| 460 |
geraldo |
700 |
{{for questions}}
|
| 369 |
geraldo |
701 |
<tr class="tr-question">
|
|
|
702 |
<td class="text-left">{{:~removeTags(text)}} </td>
|
|
|
703 |
<td>{{:~getAnswer(type,options,answer)}}</td>
|
|
|
704 |
<td>
|
|
|
705 |
{{if type == 'simple' || type=='multiple' }}
|
| 429 |
geraldo |
706 |
{{:~getStatus(options,answer,type)}}
|
| 369 |
geraldo |
707 |
{{else}}
|
| 399 |
geraldo |
708 |
{{if status}}
|
| 460 |
geraldo |
709 |
<font color="green">LABEL_CORRECT</font>
|
|
|
710 |
{{else}}
|
|
|
711 |
<font color="red">LABEL_FAIL</font>
|
| 399 |
geraldo |
712 |
{{/if}}
|
| 460 |
geraldo |
713 |
{{/if}}
|
| 399 |
geraldo |
714 |
</td>
|
|
|
715 |
<td>
|
| 460 |
geraldo |
716 |
{{:~getPtos(options,answer,type, value, question_value)}}
|
|
|
717 |
</td>
|
| 429 |
geraldo |
718 |
<td>
|
| 399 |
geraldo |
719 |
{{if type != 'simple' && type !='multiple' }}
|
| 466 |
geraldo |
720 |
<button class="btn btn-default btn-edit-review" data-original-title="LABEL_EDIT" data-section="{{:slug_section}}" data-question="{{:slug_question}}">
|
| 16906 |
efrain |
721 |
<i class="fa fa-pen" aria-hidden="true"></i> LABEL_EDIT
|
| 369 |
geraldo |
722 |
</button>
|
| 413 |
geraldo |
723 |
{{/if}}
|
| 369 |
geraldo |
724 |
</td>
|
|
|
725 |
</tr>
|
| 460 |
geraldo |
726 |
{{/for}}
|
| 459 |
geraldo |
727 |
</tbody>
|
| 369 |
geraldo |
728 |
</table>
|
| 450 |
geraldo |
729 |
</div>
|
| 369 |
geraldo |
730 |
</div>
|
|
|
731 |
</div>
|
|
|
732 |
</div>
|
| 251 |
geraldo |
733 |
</script>
|
|
|
734 |
|
|
|
735 |
<!-- End Template Sections-->
|
|
|
736 |
|
|
|
737 |
</section>
|