Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 293 | Rev 303 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
251 geraldo 1
<?php
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
261 geraldo 7
$routeAdd = $this->url('self-evaluation/forms/add');
262 geraldo 8
$routeDatatable = $this->url('self-evaluation/reviews');
251 geraldo 9
$routeDashboard = $this->url('dashboard');
10
 
261 geraldo 11
$allowEdit = $acl->isAllowed($roleName, 'self-evaluation/forms/edit') ? 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
 
60
$this->inlineScript()->captureStart();
61
echo <<<JS
62
    const classFormGenerator = function() {
63
    this.id = 0,
64
        this.table = '',
65
        this.name = '',
66
        this.text = '',
67
        this.status = 'a',
68
        this.sections = [],
69
        this.clear = function() {
70
            this.sections = [];
71
            this.render();
72
        },
73
        /**
74
         * Render array sections
75
         */
76
        this.renderSection = function(slug_section) {
77
            var s = '';
78
            for (i = 0; i < this.sections.length; i++) {
79
                if (slug_section != this.sections[i].slug_section) {
80
                    continue;
81
                }
82
                for (j = 0; j < this.sections[i].questions.length; j++) {
83
                    this.sections[i].questions[j].position = j;
84
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
85
                        this.sections[i].questions[j].options.sort(function(a, b) {
86
                            if (a.position > b.position) {
87
                                return 1;
88
                            }
89
                            if (a.position < b.position) {
90
                                return -1;
91
                            }
92
                            return 0;
93
                        });
94
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
95
                            this.sections[i].questions[j].options[k].position = j;
96
                        }
97
                    }
98
                }
99
            }
100
            $('[data-toggle="tooltip"]').tooltip();
101
        },
102
        this.render = function() {
103
            this.sections.sort(function(a, b) {
104
                if (a.position > b.position) {
105
                    return 1;
106
                }
107
                if (a.position < b.position) {
108
                    return -1;
109
                }
110
                return 0;
111
            });
112
            var s = '';
113
            for (i = 0; i < this.sections.length; i++) {
114
                this.sections[i].position = i;
115
                this.sections[i].questions.sort(function(a, b) {
116
                    if (a.position > b.position) {
117
                        return 1;
118
                    }
119
                    if (a.position < b.position) {
120
                        return -1;
121
                    }
122
                    return 0;
123
                });
124
                for (j = 0; j < this.sections[i].questions.length; j++) {
125
                    this.sections[i].questions[j].position = j;
126
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
127
                        this.sections[i].questions[j].options.sort(function(a, b) {
128
                            if (a.position > b.position) {
129
                                return 1;
130
                            }
131
                            if (a.position < b.position) {
132
                                return -1;
133
                            }
134
                            return 0;
135
                        });
136
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
137
                            this.sections[i].questions[j].options[k].position = j;
138
                        }
139
                    }
140
                }
141
            }
142
            $('[data-toggle="tooltip"]').tooltip();
266 geraldo 143
        };
144
    }
264 geraldo 145
 
146
 
251 geraldo 147
 
148
function htmlEntities(str) {
149
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
150
}
151
jQuery(document).ready(function($) {
152
    var objFormGenerator = new classFormGenerator();
153
    objFormGenerator.render();
154
    var allowEdit = $allowEdit;
155
    /**
156
     * Get rows and set data table
157
     */
158
    var tableForm = $('#gridTable').dataTable({
159
        'processing': true,
160
        'serverSide': true,
161
        'searching': true,
162
        'order': [
163
            [0, 'asc']
164
        ],
165
        'ordering': true,
166
        'ordenable': true,
167
        'responsive': true,
168
        'select': false,
169
        'paging': true,
170
        'pagingType': 'simple_numbers',
171
        'ajax': {
172
            'url': '$routeDatatable',
173
            'type': 'get',
174
            'beforeSend': function(request) {
175
                NProgress.start();
176
            },
177
            'dataFilter': function(response) {
178
                var response = jQuery.parseJSON(response);
179
                var json = {};
180
                json.recordsTotal = 0;
181
                json.recordsFiltered = 0;
182
                json.data = [];
183
                if (response.success) {
184
                    json.recordsTotal = response.data.total;
185
                    json.recordsFiltered = response.data.total;
186
                    json.data = response.data.items;
187
                } else {
188
                    $.fn.showError(response.data)
189
                }
190
                return JSON.stringify(json);
191
            }
192
        },
193
        'language': {
194
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
195
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
196
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
197
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
198
            'sInfo': 'LABEL_DATATABLE_SINFO',
199
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
200
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
201
            'sInfoPostFix': '',
202
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
203
            'sUrl': '',
204
            'sInfoThousands': ',',
205
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
206
            'oPaginate': {
207
                'sFirst': 'LABEL_DATATABLE_SFIRST',
208
                'sLast': 'LABEL_DATATABLE_SLAST',
209
                'sNext': 'LABEL_DATATABLE_SNEXT',
210
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
211
            },
212
            'oAria': {
213
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
214
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
215
            },
216
        },
217
        'drawCallback': function(settings) {
218
            NProgress.done();
219
            $('button.btn-delete').confirmation({
220
                rootSelector: 'button.btn-delete',
221
                title: 'LABEL_ARE_YOU_SURE',
222
                singleton: true,
223
                btnOkLabel: 'LABEL_YES',
224
                btnCancelLabel: 'LABEL_NO',
225
                onConfirm: function(value) {
226
                    action = $(this).data('href');
227
                    NProgress.start();
228
                    $.ajax({
229
                        'dataType': 'json',
230
                        'accept': 'application/json',
231
                        'method': 'post',
232
                        'url': action,
233
                    }).done(function(response) {
234
                        if (response['success']) {
235
                            $.fn.showSuccess(response['data']);
236
                            tableForm.fnDraw();
237
                        } else {
238
                            $.fn.showError(response['data']);
239
                        }
240
                    }).fail(function(jqXHR, textStatus, errorThrown) {
241
                        $.fn.showError(textStatus);
242
                    }).always(function() {
243
                        NProgress.done();
244
                    });
245
                },
246
            });
247
        },
294 geraldo 248
        'aoColumns': [
249
            {
250
                'mDataProp': 'user'
251
            },{
251 geraldo 252
                'mDataProp': 'name'
253
            },
254
            {
255
                'mDataProp': 'language'
256
            },
257
            {
258
                'mDataProp': 'status'
259
            },
260
            {
294 geraldo 261
                'mDataProp': 'link_edit'
251 geraldo 262
            },
263
        ],
294 geraldo 264
        'columnDefs': [
265
            {
251 geraldo 266
                'targets': 0,
267
                'className': 'text-vertical-middle',
294 geraldo 268
            },{
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
            {
292 geraldo 277
                'targets': -2,
278
                'orderable': false,
279
                'className': 'text-center',
293 geraldo 280
                'className': 'text-vertical-middle',
251 geraldo 281
            },
282
            {
283
                'targets': -1,
284
                'orderable': false,
285
                'render': function(data, type, row) {
286
                    s = '';
287
                    if (allowEdit) {
293 geraldo 288
                        s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
251 geraldo 289
                    }
290
                    return s;
291
                }
292
            }
293
        ],
294
    });
295
    /**
296
     * Clicked on edit form
297
     */
298
    $('body').on('click', 'button.btn-edit-form', function(e) {
299
        e.preventDefault();
300
        form_id = $(this).data('id')
301
        var action = $(this).data('href');
302
        $.ajax({
303
            'dataType': 'json',
304
            'accept': 'application/json',
305
            'method': 'get',
306
            'url': action,
307
        }).done(function(response) {
308
            if (response['success']) {
309
                validatorForm.resetForm();
310
                $('#form-main').attr('action', action);
311
                $('#form-main #form-id').val(response['data']['id']),
312
                $('#form-main #form-continue').val('0');
313
                $('#form-main #form-name').val(response['data']['name']),
314
 
315
                /*----------Set Ckeditor ------------*/
316
                CKEDITOR.instances['form-description'].setData(response['data']['description']);
317
                CKEDITOR.instances['form-text'].setData(response['data']['text']);
318
 
319
                $('#form-main #form-language').val(response['data']['language']),
320
                $('#form-main #form-status').val(response['data']['status']);
321
 
322
                /*-------------Render Sections -------*/
323
 
324
                objFormGenerator.clear();
325
                objFormGenerator.sections = response['data']['content'] || [];
326
                objFormGenerator.render();
327
                renderSectionData(objFormGenerator.sections);
328
 
254 geraldo 329
                $('#row-forms').hide();
251 geraldo 330
                $('#row-edit').show();
331
                $('#form-main #form-name').focus();
332
 
333
            } else {
334
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
335
            }
336
        }).fail(function(jqXHR, textStatus, errorThrown) {
337
            $.fn.showError(textStatus);
338
        });
339
    });
340
    $(document).on('click', '[data-type="select_all"]', function() {
341
        if ($('input[name="select_all"]:checked').val() == 'all') {
342
            $('[data-type="select"]').prop('checked', true);
343
            $('[data-action="delete"]').removeClass('hide');
344
        } else {
345
            $('[data-type="select"]').prop('checked', false);
346
            $('[data-action="delete"]').addClass('hide');
347
        }
348
    });
349
 
264 geraldo 350
 
251 geraldo 351
 
352
    function currentSelected() {
353
        var selected = [];
354
        $.each($("input[name='select[]']:checked"), function() {
355
            selected.push($(this).val());
356
        });
357
        return selected;
358
    }
359
    $(document).on('change', "input[name='select[]']", function() {
360
        var c = currentSelected();
361
        var cc = getLength();
362
        if (c.length == cc) {
363
            if ($('[data-action="delete"]').hasClass('hide')) {
364
                $('[data-action="delete"]').removeClass('hide');
365
            }
366
            return true;
367
        } else {
368
            $('input[name="select_all"]').prop('checked', false);
369
        }
370
        if (c.length > 0) {
371
            if ($('[data-action="delete"]').hasClass('hide')) {
372
                $('[data-action="delete"]').removeClass('hide');
373
            }
374
        } else {
375
            if (!$('[data-action="delete"]').hasClass('hide')) {
376
                $('[data-action="delete"]').addClass('hide');
377
            }
378
        }
379
    });
380
    var form3 = $('#form_sample_3');
381
    var error3 = $('.alert-danger', form3);
382
    var success3 = $('.alert-success', form3);
383
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
384
    $("#form-main").on('submit', function() {
385
        for (var instanceName in CKEDITOR.instances) {
386
            CKEDITOR.instances[instanceName].updateElement();
387
        }
388
    })
389
    /**
390
     * Validate rules form
391
     */
392
    var validatorForm = $("#form-main").validate({
393
        ignore: [],
394
        errorClass: 'help-block',
395
        errorElement: 'span',
396
        rules: {
397
            'form-name': {
398
                required: true,
399
                minlength: 2,
400
                maxlength: 50
401
            },
402
            'form-description': {
403
                required: true,
404
            },
405
            'form-text': {
406
                required: true,
407
            },
408
            'form-language': {
409
                required: true,
410
            },
411
            'forrm-status': {
412
                required: true,
413
            },
414
        },
415
        highlight: function(element) {
416
            $(element).closest('.form-group').addClass('has-error');
417
        },
418
        unhighlight: function(element) {
419
            $(element).closest('.form-group').removeClass('has-error');
420
        },
421
        errorPlacement: function(error, element) {
422
            if (element.attr("data-error-container")) {
423
                error.appendTo(element.attr("data-error-container"));
424
            } else {
425
                error.insertAfter(element);
426
            }
427
        },
428
        invalidHandler: function(form, validator) {
429
            if (!validator.numberOfInvalids())
430
                return;
431
            $('html, body').animate({
432
                scrollTop: $(validator.errorList[0].element).offset().top - 100
433
            }, 1000);
434
        },
435
        submitHandler: function(form) {
436
            var error = false;
437
            if (objFormGenerator.sections.length == 0) {
438
                $.fn.showError('ERROR_SECCTIONS');
439
                return false;
440
            } else {
441
                for (i = 0; i < objFormGenerator.sections.length; i++) {
442
                    if (objFormGenerator.sections[i].questions.length == 0) {
443
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
444
                        return false;
445
                    }
446
                    var valueSection = parseInt(objFormGenerator.sections[i].value);
447
                    var totalValueQuestion = 0;
448
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
449
                        valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
450
                        totalValueQuestion = totalValueQuestion + valueQuestion;
451
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
452
                            objFormGenerator.sections[i].questions[j].type == 'multiple' ||
453
                            objFormGenerator.sections[i].questions[j].type == 'rating-open') {
454
                            var questionNumber = j + 1;
455
                            var numberCorrect = 0;
456
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
457
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
458
                                return false;
459
                            }
460
                            var totalOption = 0;
461
                            var maxOption = 0;
462
                            for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
463
                                if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
464
                                    if (objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
465
                                        numberCorrect++;
466
                                    }
467
                                }
468
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
469
                                    totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
470
                                }
471
                                if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
472
                                    if (parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
473
                                        maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
474
                                    }
475
                                }
476
                            }
477
                            if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
478
                                if (numberCorrect == 0) {
479
                                    $.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
480
                                    return false;
481
                                }
482
                                if (
483
                                    objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
484
                                    $.fn.showError('ERROR_OPTIONS_DUPLICATE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
485
                                    return false;
486
                                }
487
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
488
                                    $.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
489
                                    return false;
490
                                }
491
                            }
492
                            if (objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption != valueQuestion) {
493
                                $.fn.showError('ERROR_OPTIONS_SUM_VALUES'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
494
                                return false;
495
                            }
496
                            if (objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion) {
497
                                $.fn.showError('ERROR_OPTIONS_MAX_OPTION'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
498
                                return false;
499
                            }
500
                        }
501
                    }
502
                    if (valueSection != totalValueQuestion) {
503
                        $.fn.showError('ERROR_VALUE_SECTIONS'.replace('%s', objFormGenerator.sections[i].name));
504
                        return false;
505
                    }
506
                }
507
                var formId = parseInt($('#form-main #form-id').val());
508
                var formContinue = parseInt($('#form-main #form-continue').val());
509
                var data = {
510
                    'id': formId,
511
                    'name': $('#form-main #form-name').val(),
512
                    'description': $('#form-main #form-description').val(),
513
                    'text': $('#form-main #form-text').val(),
514
                    'language': $('#form-main #form-language').val(),
515
                    'status': $('#form-main #form-status').val(),
516
                    'content': JSON.stringify(objFormGenerator.sections)
517
                }
518
                $.ajax({
519
                    'dataType': 'json',
520
                    'method': 'post',
521
                    'url': $('#form-main').attr('action'),
522
                    'data': data,
523
                }).done(function(response) {
524
                    if (response['success']) {
525
                        $.fn.showSuccess(response['data']);
526
                        if (formContinue == 1) {
527
                            $('#form-main').attr('action',response['action_edit']);
528
                            $('#form-main #form-id').val(response['id']);
529
                            $('#form-main #form-continue').val(0);
530
                        } else {
531
                            $('#row-edit').hide();
254 geraldo 532
                            $('#row-forms').show();
251 geraldo 533
                        /*---------- Reset Form -------- */
534
                        $('#form-main')[0].reset();
535
                        /*--------Reset Ckeditor ----------*/
536
                        CKEDITOR.instances['form-text'].setData('');
537
                        CKEDITOR.instances['form-description'].setData('');
538
                        /*--------Reset Sections ----------*/
539
                        clearSectionData();
540
                        /* ------- Refresh Table -----------*/
541
 
542
                        }
543
                        tableForm.fnDraw();
544
                    } else {
545
                        $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
546
                    }
547
                }).fail(function(jqXHR, textStatus, errorThrown) {
548
                    $.fn.showError(textStatus);
549
                });
550
                return false;
551
            }
552
        }
553
    });
264 geraldo 554
 
251 geraldo 555
    /**
556
     * Clicked cancel new/edit Form
557
     */
558
    $('button.btn-edit-cancel').click(function(e) {
559
        e.preventDefault();
560
        $('#row-edit').hide();
254 geraldo 561
        $('#row-forms').show();
251 geraldo 562
    });
563
    /**
564
     * Clicked save and continue new Form
565
     */
566
    $('button.btn-form-save-continue').click(function(e) {
567
        e.preventDefault();
568
        $('#form-main #form-continue').val('1')
569
        $('#form-main').submit();
570
    });
571
    /**
572
     * Clicked save and close new/edit Form
573
     */
574
    $('button.btn-form-save-close').click(function(e) {
575
        e.preventDefault();
576
        $('#form-main #form-continue').val('0')
577
        $('#form-main').submit();
578
    });
579
    /**
580
     * Modal Settings
581
     */
582
    $('#modal-section, #modal-question, #modal-option').modal({
583
        backdrop: 'static',
584
        keyboard: false,
585
        show: false
586
    });
587
    /**
588
     * Get Question type
589
     */
590
    const getQuestionTypeBySlug = (slug_section, slug_question) => {
591
        for (i = 0; i < objFormGenerator.sections.length; i++) {
592
            if (slug_section == objFormGenerator.sections[i].slug_section) {
593
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
594
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
595
                        return objFormGenerator.sections[i].questions[j].type;
596
                    }
597
                }
598
            }
599
        }
600
    }
601
    /**
602
     * Remove Html Tags
603
     */
604
    const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
605
    /**
606
     * Render Sections data
607
     */
608
    const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
609
        getType: getQuestionTypeBySlug,
610
        removeTags: removeTags
611
    }));
612
 
613
 
614
    /**
615
     * Clear Div Section data
616
     */
617
    const clearSectionData = () => $("#rows").html('');
618
    /**
619
     * Clicked refresh button
620
     */
621
    $('button.btn-refresh').click(function(e) {
622
        tableForm.fnDraw();
623
    });
624
 
625
});
626
JS;
627
$this->inlineScript()->captureEnd();
628
?>
629
 
630
<!-- Content Header (Page header) -->
631
<section class="content-header">
632
    <div class="container-fluid">
633
        <div class="row mb-2">
634
            <div class="col-sm-12">
264 geraldo 635
                <h1>LABEL_REVIEWS</h1>
251 geraldo 636
            </div>
637
        </div>
638
    </div>
639
    <!-- /.container-fluid -->
640
</section>
641
<section class="content">
254 geraldo 642
    <div class="container-fluid" id="row-forms">
251 geraldo 643
        <div class="row">
644
            <div class="col-12">
645
                <div class="card">
646
                    <div class="card-body">
647
                        <table id="gridTable" class="table   table-hover">
648
                            <thead>
649
                                <tr>
294 geraldo 650
                                <th>LABEL_USER</th>
251 geraldo 651
                                    <th>LABEL_NAME</th>
652
                                    <th>LABEL_LANGUAGE</th>
294 geraldo 653
                                    <th>LABEL_STATUS</th>
251 geraldo 654
                                    <th>LABEL_ACTIONS</th>
655
                                </tr>
656
                            </thead>
657
                            <tbody></tbody>
658
                        </table>
659
                    </div>
660
                    <div class="card-footer clearfix">
661
                        <div style="float:right;">
662
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
663
                        </div>
664
                    </div>
665
                </div>
666
            </div>
667
        </div>
668
    </div>
669
 
670
    <!-- Create/Edit Form -->
671
 
672
    <div class="row" id="row-edit" style="display: none">
673
        <div class="col-xs-12 col-md-12">
674
            <form action="#" name="form-main" id="form-main">
261 geraldo 675
                <input type="hidden" name="form-id" id="form-id" value="0" />
676
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
251 geraldo 677
                <div class="form-group">
261 geraldo 678
                    <label for="form-name">LABEL_FIRST_NAME</label>
679
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
680
                </div>
681
                <div class="form-group">
682
                    <label for="form-description">LABEL_DESCRIPTION</label>
683
                    <!--  ckeditor -->
684
                    <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
685
                </div>
686
                <div class="form-group">
687
                    <label for="form-text">LABEL_TEXT</label>
688
                    <!--  ckeditor -->
689
                    <textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
690
                </div>
691
                <div class="form-group">
692
                    <label for="form-language">LABEL_LANGUAGES</label>
693
                    <select name="form-language" id="form-language" class="form-control">
694
                        <option value="<?php echo $lang_en; ?>">LABEL_ENGLISH</option>
695
                        <option value="<?php echo $lang_es; ?>">LABEL_SPANISH</option>
696
                    </select>
697
                </div>
698
                <div class="form-group">
699
                    <label for="form-status">LABEL_STATUS</label>
700
                    <select name="form-status" id="form-status" class="form-control">
701
                        <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
702
                        <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
703
                    </select>
704
                </div>
705
                <br/>
706
                <div class="row">
707
                    <div class="col-xs-12 col-md-12 text-right">
708
                        <button class="btn btn-primary" id="btn-add-section" data-toggle="tooltip" title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION</button>
709
                    </div>
710
                </div>
711
                <br />
712
                <div class="row">
713
                    <div class="col-xs-12 col-md-12">
714
                        <div class="panel-group" id="rows"></div>
715
                    </div>
716
                </div>
717
                <div class="form-group">
251 geraldo 718
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
719
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
720
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
721
                </div>
722
            </form>
723
        </div>
724
    </div>
725
 
261 geraldo 726
    <!-- Create/Edit Form-->
251 geraldo 727
 
264 geraldo 728
 
261 geraldo 729
 
251 geraldo 730
    <!---Template Sections --->
731
    <script id="sectionTemplate" type="text/x-jsrender">
732
    <div class="panel panel-default" id="panel-{{:slug_section}}">
733
        <div class="panel-heading">
734
            <h4 class="panel-title">
735
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
736
                    <span class="section-name{{:slug_section}}">
737
                        {{:name}}
738
                    </span>
739
                </a>
740
            </h4>
741
        </div>
742
        <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
743
            <div class="panel-body">
744
                <div class="table-responsive">
745
                    <table class="table table-bordered">
746
                        <thead>
747
                            <tr>
748
                                <th style="width: 10%;">LABEL_ELEMENT</th>
749
                                <th style="width: 50%;">LABEL_TEXT</th>
750
                                <th style="width: 10%;">LABEL_VALUE</th>
751
                                <th style="width: 10%;">LABEL_TYPE</th>
752
                                <th style="width: 20%;">LABEL_ACTIONS</th>
753
                            </tr>
754
                        </thead>
755
                        <tbody>
756
                            <tr class="tr-section">
757
                                <td class="text-left">LABEL_SECTION</td>
758
                                <td class="text-left">{{:name}}</td>
759
                                <td>{{:value}}</td>
760
                                <td></td>
761
                                <td>
762
                                    <button class="btn btn-default btn-edit-section" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>
763
                                    <button class="btn btn-default btn-delete-section" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>
764
                                    <button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_QUESTION </button>
765
                                </td>
766
                            </tr>
767
                            {{for questions}}
768
                            <tr class="tr-question">
769
                                <td class="text-left">--LABEL_QUESTION</td>
770
                                <td class="text-left">
771
                                    {{:~removeTags(text)}}
772
                                </td>
773
                                <td><font color="red">{{:value}}</font></td>
774
                                <td class="text-capitalize">
775
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
776
                                    {{if type == 'simple'}} Simple {{/if}}
777
                                    {{if type == 'multiple'}} Multiple {{/if}}
778
                                    {{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
779
                                    {{if type == 'rating-range'}} LABEL_RATING_RANGE {{/if}}
780
                                </td>
781
                                <td>
782
                                    <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
783
                                    <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
784
 
785
                                    {{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
786
                                    <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
787
                                    {{/if}}
788
 
789
                                </td>
790
                            </tr>
791
                            {{for options}}
792
                            <tr class="tr-option">
793
                                <td class="text-left">---LABEL_OPTION</td>
794
                                <td class="text-left">
795
                                    {{:~removeTags(text)}}
796
                                </td>
797
                                <td>
798
 
799
                                    {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
800
                                    {{:value}}
801
                                    {{/if}}
802
                                </td>
803
                                <td class="text-left">
804
                                    {{if ~getType( slug_section, slug_question) != 'rating-open'}}
805
                                    {{if correct == 1}}
806
                                    <font color="green">LABEL_CORRECT</font>
807
                                    {{/if}}
808
                                    {{if correct == 0}}
809
                                    <font color="red">LABEL_FAIL</font>
810
                                    {{/if}}
811
                                    {{/if}}
812
                                </td>
813
                                <td>
814
                                    <button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
815
                                    <button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
816
                                </td>
817
                            </tr>
818
                            {{/for}}
819
                            {{/for}}
820
                        </tbody>
821
                    </table>
822
                </div>
823
            </div>
824
        </div>
825
    </div>
826
    </script>
827
 
828
    <!-- End Template Sections-->
829
 
830
</section>