Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
977 geraldo 1
<?php
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
985 geraldo 7
$routeAdd = $this->url('performance-evaluation/forms/add');
8
$routeDatatable = $this->url('performance-evaluation/forms');
977 geraldo 9
$routeDashboard = $this->url('dashboard');
10
 
985 geraldo 11
$allowAdd = $acl->isAllowed($roleName, 'performance-evaluation/forms/add') ? 1 : 0;
12
$allowEdit = $acl->isAllowed($roleName, 'performance-evaluation/forms/edit') ? 1 : 0;
13
$allowDelete = $acl->isAllowed($roleName, 'performance-evaluation/forms/delete') ? 1 : 0;
977 geraldo 14
 
15
 
16
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
17
 
18
 
19
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
21
 
22
 
23
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
24
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
26
 
27
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
28
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
29
 
30
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
34
 
35
 
36
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
38
 
39
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
40
 
41
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
42
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
44
 
45
 
46
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
47
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
48
 
49
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
50
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
51
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
52
 
53
// bootbox Alert //
54
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
55
 
56
// JsRender //
57
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
58
 
59
$this->inlineScript()->captureStart();
60
echo <<<JS
61
    const classFormGenerator = function() {
62
    this.id = 0,
63
        this.table = '',
64
        this.name = '',
65
        this.text = '',
66
        this.status = 'a',
67
        this.sections = [],
68
        this.clear = function() {
69
            this.sections = [];
70
            this.render();
71
        },
72
        /**
73
         * Render array sections
74
         */
75
        this.renderSection = function(slug_section) {
76
            var s = '';
77
            for (i = 0; i < this.sections.length; i++) {
78
                if (slug_section != this.sections[i].slug_section) {
79
                    continue;
80
                }
997 geraldo 81
                for (j = 0; j < this.sections[i].sections.length; j++) {
82
                    this.sections[i].sections[j].position = j;
83
                    if (this.sections[i].sections[j].type == 'simple' || this.sections[i].sections[j].type == 'multiple' || this.sections[i].sections[j].type == 'rating-open') {
84
                        this.sections[i].sections[j].options.sort(function(a, b) {
977 geraldo 85
                            if (a.position > b.position) {
86
                                return 1;
87
                            }
88
                            if (a.position < b.position) {
89
                                return -1;
90
                            }
91
                            return 0;
92
                        });
997 geraldo 93
                        for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
94
                            this.sections[i].sections[j].options[k].position = j;
977 geraldo 95
                        }
96
                    }
97
                }
98
            }
99
            $('[data-toggle="tooltip"]').tooltip();
100
        },
101
        this.render = function() {
102
            this.sections.sort(function(a, b) {
103
                if (a.position > b.position) {
104
                    return 1;
105
                }
106
                if (a.position < b.position) {
107
                    return -1;
108
                }
109
                return 0;
110
            });
111
            var s = '';
112
            for (i = 0; i < this.sections.length; i++) {
113
                this.sections[i].position = i;
997 geraldo 114
                this.sections[i].sections.sort(function(a, b) {
977 geraldo 115
                    if (a.position > b.position) {
116
                        return 1;
117
                    }
118
                    if (a.position < b.position) {
119
                        return -1;
120
                    }
121
                    return 0;
122
                });
997 geraldo 123
                for (j = 0; j < this.sections[i].sections.length; j++) {
124
                    this.sections[i].sections[j].position = j;
125
                    if (this.sections[i].sections[j].type == 'simple' || this.sections[i].sections[j].type == 'multiple' || this.sections[i].sections[j].type == 'rating-open') {
126
                        this.sections[i].sections[j].options.sort(function(a, b) {
977 geraldo 127
                            if (a.position > b.position) {
128
                                return 1;
129
                            }
130
                            if (a.position < b.position) {
131
                                return -1;
132
                            }
133
                            return 0;
134
                        });
997 geraldo 135
                        for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
136
                            this.sections[i].sections[j].options[k].position = j;
977 geraldo 137
                        }
138
                    }
139
                }
140
            }
141
            $('[data-toggle="tooltip"]').tooltip();
142
        },
143
        /**
144
         * Add element to section array
145
         */
146
        this.addSection = function(name, text, value) {
147
            var d = new Date();
148
            var slug = 'section' + d.getTime();
149
            var position = 0;
150
            $.each(this.sections, function(index, section) {
151
                if (position < section.position) {
152
                    position = section.position;
153
                }
154
            });
155
            position++;
156
            var section = {
157
                'slug_section': slug,
158
                'name': name,
159
                'text': text,
160
                'value': value,
161
                'position': position,
997 geraldo 162
                'sections': [],
977 geraldo 163
                'status': 0
164
            }
165
            this.sections.push(section);
166
        },
167
         /**
168
         * Edit element to section array
169
         */
170
        this.editSection = function(slug, name, text, value) {
171
            var renderTable = false;
172
            for (i = 0; i < this.sections.length; i++) {
173
                if (slug == this.sections[i].slug_section) {
174
                    this.sections[i].name = name;
175
                    this.sections[i].text = text;
176
                    this.sections[i].value = value;
177
                    renderTable = true;
178
                    break;
179
                }
180
            }
181
            if (renderTable) {
182
                this.renderSection(slug);
183
            }
184
        },
185
         /**
186
         * Remove element to section array
187
         */
188
        this.deleteSection = function(slug) {
189
            var renderTable = false;
190
            for (i = 0; i < this.sections.length; i++) {
191
                if (slug == this.sections[i].slug_section) {
192
                    this.sections.splice(i, 1);
193
                    renderTable = true;
194
                    break;
195
                }
196
            }
197
            if (renderTable) {
198
                $('#panel' + slug).remove();
199
            }
200
        },
201
         /**
997 geraldo 202
         * Add element to section array
977 geraldo 203
         */
997 geraldo 204
        this.addsection = function(slug_section, text, value, type, maxlength, multiline, range) {
977 geraldo 205
            var d = new Date();
997 geraldo 206
            var slug_section = 'section' + d.getTime();
977 geraldo 207
            var position = 0;
208
            var renderTable = false;
209
            for (i = 0; i < this.sections.length; i++) {
210
                if (slug_section == this.sections[i].slug_section) {
997 geraldo 211
                    $.each(this.sections[i].sections, function(index, section) {
212
                        if (position < section.position) {
213
                            position = section.position;
977 geraldo 214
                        }
215
                    });
216
                    position++;
997 geraldo 217
                    var section = {
977 geraldo 218
                        'slug_section': slug_section,
997 geraldo 219
                        'slug_section': slug_section,
977 geraldo 220
                        'text': text,
221
                        'value': value,
222
                        'type': type,
223
                        'position': position,
224
                        'maxlength': maxlength,
225
                        'multiline': multiline,
226
                        'range': range,
227
                        'options': [],
228
                        'answer': type=='multiple' ? [] : ''
229
                    }
997 geraldo 230
                    this.sections[i].sections.push(section);
977 geraldo 231
                    renderTable = true;
232
                    break;
233
                }
234
            }
235
            if (renderTable) {
236
                this.renderSection(slug_section);
237
            }
238
        },
239
         /**
997 geraldo 240
         * Add element to section array
977 geraldo 241
         */
997 geraldo 242
        this.editsection = function(slug_section, slug_section, text, value, type, maxlength, multiline, range) {
977 geraldo 243
            var renderTable = false;
244
            for (i = 0; i < this.sections.length; i++) {
245
                if (slug_section == this.sections[i].slug_section) {
997 geraldo 246
                    for (j = 0; j < this.sections[i].sections.length; j++) {
247
                        if (slug_section == this.sections[i].sections[j].slug_section) {
248
                            this.sections[i].sections[j].text = text,
249
                                this.sections[i].sections[j].value = value,
250
                                this.sections[i].sections[j].type = type;
977 geraldo 251
                            if (type == 'open') {
997 geraldo 252
                                this.sections[i].sections[j].maxlength = maxlength;
253
                                this.sections[i].sections[j].multiline = multiline;
254
                                this.sections[i].sections[j].options = [];
977 geraldo 255
                            } else {
997 geraldo 256
                                this.sections[i].sections[j].maxlength = 0;
257
                                this.sections[i].sections[j].multiline = 0;
977 geraldo 258
                            }
259
                            if (type == 'rating-range') {
997 geraldo 260
                                this.sections[i].sections[j].range = range;
977 geraldo 261
                            } else {
997 geraldo 262
                                this.sections[i].sections[j].range = 0;
977 geraldo 263
                            }
264
 
265
                            if(type=='multiple'){
997 geraldo 266
                                this.sections[i].sections[j].answer = [];
977 geraldo 267
                            }else{
997 geraldo 268
                                this.sections[i].sections[j].answer = '';
977 geraldo 269
                            }
270
 
271
                            renderTable = true;
272
                            break;
273
                        }
274
                    }
275
                }
276
                if (renderTable) {
277
                    break;
278
                }
279
            }
280
            if (renderTable) {
281
                this.renderSection(slug_section);
282
            }
283
        },
284
        /**
997 geraldo 285
         * Remove element to section array
977 geraldo 286
         */
997 geraldo 287
        this.deletesection = function(slug_section, slug_section) {
977 geraldo 288
            var renderTable = false;
289
            for (i = 0; i < this.sections.length; i++) {
290
                if (slug_section == this.sections[i].slug_section) {
997 geraldo 291
                    for (j = 0; j < this.sections[i].sections.length; j++) {
292
                        if (slug_section == this.sections[i].sections[j].slug_section) {
293
                            this.sections[i].sections.splice(j, 1);
977 geraldo 294
                            renderTable = true;
295
                            break;
296
                        }
297
                    }
298
                }
299
                if (renderTable) {
300
                    break;
301
                }
302
            }
303
            if (renderTable) {
304
                this.renderSection(slug_section);
305
            }
306
        },
307
        /**
308
         * Add element to option array
309
         */
997 geraldo 310
        this.addOption = function(slug_section, slug_section, text, correct, value) {
977 geraldo 311
            var d = new Date();
312
            var slug_option = 'option' + d.getTime();
313
            var position = 0;
314
            var renderTable = false;
315
            for (i = 0; i < this.sections.length; i++) {
316
                if (slug_section == this.sections[i].slug_section) {
997 geraldo 317
                    for (j = 0; j < this.sections[i].sections.length; j++) {
318
                        if (slug_section == this.sections[i].sections[j].slug_section) {
319
                            $.each(this.sections[i].sections[j].options, function(index, option) {
977 geraldo 320
                                if (position < option.position) {
321
                                    position = option.position;
322
                                }
323
                            });
324
                            position++;
325
                            var option = {
326
                                'slug_section': slug_section,
997 geraldo 327
                                'slug_section': slug_section,
977 geraldo 328
                                'slug_option': slug_option,
329
                                'text': text,
330
                                'correct': correct,
331
                                'value': value,
332
                                'checked': false
333
                            }
997 geraldo 334
                            this.sections[i].sections[j].options.push(option);
977 geraldo 335
                            renderTable = true;
336
                            break;
337
                        }
338
                        if (renderTable) {
339
                            break;
340
                        }
341
                    }
342
                }
343
            }
344
            if (renderTable) {
345
                this.renderSection(slug_section);
346
            }
347
        },
348
        /**
349
         * Edit element to option array
350
         */
997 geraldo 351
        this.editOption = function(slug_section, slug_section, option_slug, text, correct, value) {
977 geraldo 352
            var renderTable = false;
353
            for (i = 0; i < this.sections.length; i++) {
354
                if (slug_section == this.sections[i].slug_section) {
997 geraldo 355
                    for (j = 0; j < this.sections[i].sections.length; j++) {
356
                        if (slug_section == this.sections[i].sections[j].slug_section) {
357
                            for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
358
                                if (option_slug == this.sections[i].sections[j].options[k].slug_option) {
359
                                    this.sections[i].sections[j].options[k].text = text;
360
                                    this.sections[i].sections[j].options[k].correct = correct;
361
                                    this.sections[i].sections[j].options[k].value = value;
977 geraldo 362
                                    renderTable = true;
363
                                    break;
364
                                }
365
                            }
366
                        }
367
                        if (renderTable) {
368
                            break;
369
                        }
370
                    }
371
                }
372
                if (renderTable) {
373
                    break;
374
                }
375
            }
376
            if (renderTable) {
377
                this.renderSection(slug_section);
378
            }
379
        },
380
        /**
381
         * Remove element to option array
382
         */
997 geraldo 383
        this.deleteOption = function(slug_section, slug_section, option_slug) {
977 geraldo 384
            var renderTable = false;
385
            for (i = 0; i < this.sections.length; i++) {
386
                if (slug_section == this.sections[i].slug_section) {
997 geraldo 387
                    for (j = 0; j < this.sections[i].sections.length; j++) {
388
                        if (slug_section == this.sections[i].sections[j].slug_section) {
389
                            for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
390
                                if (option_slug == this.sections[i].sections[j].options[k].slug_option) {
391
                                    this.sections[i].sections[j].options.splice(k, 1);
977 geraldo 392
                                    renderTable = true;
393
                                    break;
394
                                }
395
                            }
396
                        }
397
                        if (renderTable) {
398
                            break;
399
                        }
400
                    }
401
                }
402
                if (renderTable) {
403
                    break;
404
                }
405
            }
406
            if (renderTable) {
407
                this.renderSection(slug_section);
408
            }
409
        }
410
}
411
 
412
function htmlEntities(str) {
413
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
414
}
415
jQuery(document).ready(function($) {
416
    var objFormGenerator = new classFormGenerator();
417
    objFormGenerator.render();
418
    var allowEdit = $allowEdit;
419
    var allowDelete = $allowDelete;
420
    /**
421
     * Get rows and set data table
422
     */
423
    var tableForm = $('#gridTable').dataTable({
424
        'processing': true,
425
        'serverSide': true,
426
        'searching': true,
427
        'order': [
428
            [0, 'asc']
429
        ],
430
        'ordering': true,
431
        'ordenable': true,
432
        'responsive': true,
433
        'select': false,
434
        'paging': true,
435
        'pagingType': 'simple_numbers',
436
        'ajax': {
437
            'url': '$routeDatatable',
438
            'type': 'get',
439
            'beforeSend': function(request) {
440
                NProgress.start();
441
            },
442
            'dataFilter': function(response) {
443
                var response = jQuery.parseJSON(response);
444
                var json = {};
445
                json.recordsTotal = 0;
446
                json.recordsFiltered = 0;
447
                json.data = [];
448
                if (response.success) {
449
                    json.recordsTotal = response.data.total;
450
                    json.recordsFiltered = response.data.total;
451
                    json.data = response.data.items;
452
                } else {
453
                    $.fn.showError(response.data)
454
                }
455
                return JSON.stringify(json);
456
            }
457
        },
458
        'language': {
459
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
460
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
461
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
462
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
463
            'sInfo': 'LABEL_DATATABLE_SINFO',
464
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
465
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
466
            'sInfoPostFix': '',
467
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
468
            'sUrl': '',
469
            'sInfoThousands': ',',
470
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
471
            'oPaginate': {
472
                'sFirst': 'LABEL_DATATABLE_SFIRST',
473
                'sLast': 'LABEL_DATATABLE_SLAST',
474
                'sNext': 'LABEL_DATATABLE_SNEXT',
475
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
476
            },
477
            'oAria': {
478
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
479
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
480
            },
481
        },
482
        'drawCallback': function(settings) {
483
            NProgress.done();
484
            $('button.btn-delete').confirmation({
485
                rootSelector: 'button.btn-delete',
486
                title: 'LABEL_ARE_YOU_SURE',
487
                singleton: true,
488
                btnOkLabel: 'LABEL_YES',
489
                btnCancelLabel: 'LABEL_NO',
490
                onConfirm: function(value) {
491
                    action = $(this).data('href');
492
                    NProgress.start();
493
                    $.ajax({
494
                        'dataType': 'json',
495
                        'accept': 'application/json',
496
                        'method': 'post',
497
                        'url': action,
498
                    }).done(function(response) {
499
                        if (response['success']) {
500
                            $.fn.showSuccess(response['data']);
501
                            tableForm.fnDraw();
502
                        } else {
503
                            $.fn.showError(response['data']);
504
                        }
505
                    }).fail(function(jqXHR, textStatus, errorThrown) {
506
                        $.fn.showError(textStatus);
507
                    }).always(function() {
508
                        NProgress.done();
509
                    });
510
                },
511
            });
512
        },
513
        'aoColumns': [{
514
                'mDataProp': 'name'
515
            },
516
            {
517
                'mDataProp': 'language'
518
            },
519
            {
520
                'mDataProp': 'status'
521
            },
522
            {
523
                'mDataProp': 'actions'
524
            },
525
        ],
526
        'columnDefs': [{
527
                'targets': 0,
528
                'className': 'text-vertical-middle',
529
            },
530
            {
531
                'targets': 1,
532
                'className': 'text-vertical-middle',
533
            },
534
            {
535
                'targets': -2,
536
                'orderable': false,
537
                'className': 'text-center',
538
                'render': function(data, type, row) {
539
                    checked = data == 'a' ? ' checked="checked" ' : '';
540
                    return '<div class="checkbox checkbox-success">' +
541
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
542
                        '<label ></label></div>';
543
                }
544
            },
545
            {
546
                'targets': -1,
547
                'orderable': false,
548
                'render': function(data, type, row) {
549
                    s = '';
550
                    if (allowEdit) {
551
                        s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
552
                    }
553
                    if (allowDelete) {
554
                        s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete'] + '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>&nbsp;';
555
                    }
556
                    return s;
557
                }
558
            }
559
        ],
560
    });
561
    /**
562
     * Clicked on edit form
563
     */
564
    $('body').on('click', 'button.btn-edit-form', function(e) {
565
        e.preventDefault();
566
        form_id = $(this).data('id')
567
        var action = $(this).data('href');
568
        $.ajax({
569
            'dataType': 'json',
570
            'accept': 'application/json',
571
            'method': 'get',
572
            'url': action,
573
        }).done(function(response) {
574
            if (response['success']) {
575
                validatorForm.resetForm();
576
                $('#form-main').attr('action', action);
577
                $('#form-main #form-id').val(response['data']['id']),
578
                $('#form-main #form-continue').val('0');
579
                $('#form-main #form-name').val(response['data']['name']),
580
 
581
                /*----------Set Ckeditor ------------*/
582
                CKEDITOR.instances['form-description'].setData(response['data']['description']);
583
                CKEDITOR.instances['form-text'].setData(response['data']['text']);
584
 
585
                $('#form-main #form-language').val(response['data']['language']),
586
                $('#form-main #form-status').val(response['data']['status']);
587
 
588
                /*-------------Render Sections -------*/
589
 
590
                objFormGenerator.clear();
591
                objFormGenerator.sections = response['data']['content'] || [];
592
                objFormGenerator.render();
593
                renderSectionData(objFormGenerator.sections);
594
 
595
                $('#row-forms').hide();
596
                $('#row-edit').show();
597
                $('#form-main #form-name').focus();
598
 
599
            } else {
600
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
601
            }
602
        }).fail(function(jqXHR, textStatus, errorThrown) {
603
            $.fn.showError(textStatus);
604
        });
605
    });
606
    $(document).on('click', '[data-type="select_all"]', function() {
607
        if ($('input[name="select_all"]:checked').val() == 'all') {
608
            $('[data-type="select"]').prop('checked', true);
609
            $('[data-action="delete"]').removeClass('hide');
610
        } else {
611
            $('[data-type="select"]').prop('checked', false);
612
            $('[data-action="delete"]').addClass('hide');
613
        }
614
    });
615
 
616
    function getLength() {
617
        return $('[data-type="select"]').length;
618
    }
619
 
620
    function currentSelected() {
621
        var selected = [];
622
        $.each($("input[name='select[]']:checked"), function() {
623
            selected.push($(this).val());
624
        });
625
        return selected;
626
    }
627
    $(document).on('change', "input[name='select[]']", function() {
628
        var c = currentSelected();
629
        var cc = getLength();
630
        if (c.length == cc) {
631
            if ($('[data-action="delete"]').hasClass('hide')) {
632
                $('[data-action="delete"]').removeClass('hide');
633
            }
634
            return true;
635
        } else {
636
            $('input[name="select_all"]').prop('checked', false);
637
        }
638
        if (c.length > 0) {
639
            if ($('[data-action="delete"]').hasClass('hide')) {
640
                $('[data-action="delete"]').removeClass('hide');
641
            }
642
        } else {
643
            if (!$('[data-action="delete"]').hasClass('hide')) {
644
                $('[data-action="delete"]').addClass('hide');
645
            }
646
        }
647
    });
648
    var form3 = $('#form_sample_3');
649
    var error3 = $('.alert-danger', form3);
650
    var success3 = $('.alert-success', form3);
651
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
652
    $("#form-main").on('submit', function() {
653
        for (var instanceName in CKEDITOR.instances) {
654
            CKEDITOR.instances[instanceName].updateElement();
655
        }
656
    })
657
    /**
658
     * Validate rules form
659
     */
660
    var validatorForm = $("#form-main").validate({
661
        ignore: [],
662
        errorClass: 'help-block',
663
        errorElement: 'span',
664
        rules: {
665
            'form-name': {
666
                required: true,
667
                minlength: 2,
668
                maxlength: 50
669
            },
670
            'form-description': {
671
                required: true,
672
            },
673
            'form-text': {
674
                required: true,
675
            },
676
            'form-language': {
677
                required: true,
678
            },
679
            'forrm-status': {
680
                required: true,
681
            },
682
        },
683
        highlight: function(element) {
684
            $(element).closest('.form-group').addClass('has-error');
685
        },
686
        unhighlight: function(element) {
687
            $(element).closest('.form-group').removeClass('has-error');
688
        },
689
        errorPlacement: function(error, element) {
690
            if (element.attr("data-error-container")) {
691
                error.appendTo(element.attr("data-error-container"));
692
            } else {
693
                error.insertAfter(element);
694
            }
695
        },
696
        invalidHandler: function(form, validator) {
697
            if (!validator.numberOfInvalids())
698
                return;
699
            $('html, body').animate({
700
                scrollTop: $(validator.errorList[0].element).offset().top - 100
701
            }, 1000);
702
        },
703
        submitHandler: function(form) {
704
            var error = false;
705
            if (objFormGenerator.sections.length == 0) {
706
                $.fn.showError('ERROR_SECCTIONS');
707
                return false;
708
            } else {
709
                for (i = 0; i < objFormGenerator.sections.length; i++) {
997 geraldo 710
                    if (objFormGenerator.sections[i].sections.length == 0) {
711
                        $.fn.showError('ERROR_sectionS'.replace('%s', objFormGenerator.sections[i].name));
977 geraldo 712
                        return false;
713
                    }
714
                    var valueSection = parseInt(objFormGenerator.sections[i].value);
997 geraldo 715
                    var totalValuesection = 0;
716
                    for (j = 0; j < objFormGenerator.sections[i].sections.length; j++) {
717
                        valuesection = parseInt(objFormGenerator.sections[i].sections[j].value);
718
                        totalValuesection = totalValuesection + valuesection;
719
                        if (objFormGenerator.sections[i].sections[j].type == 'simple' ||
720
                            objFormGenerator.sections[i].sections[j].type == 'multiple' ||
721
                            objFormGenerator.sections[i].sections[j].type == 'rating-open') {
722
                            var sectionNumber = j + 1;
977 geraldo 723
                            var numberCorrect = 0;
997 geraldo 724
                            if (objFormGenerator.sections[i].sections[j].options.length == 0) {
725
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
977 geraldo 726
                                return false;
727
                            }
728
                            var totalOption = 0;
729
                            var maxOption = 0;
997 geraldo 730
                            for (k = 0; k < objFormGenerator.sections[i].sections[j].options.length; k++) {
731
                                if (objFormGenerator.sections[i].sections[j].type == 'simple' || objFormGenerator.sections[i].sections[j].type == 'multiple') {
732
                                    if (objFormGenerator.sections[i].sections[j].options[k].correct == 1) {
977 geraldo 733
                                        numberCorrect++;
734
                                    }
735
                                }
997 geraldo 736
                                if (objFormGenerator.sections[i].sections[j].type == 'multiple' && objFormGenerator.sections[i].sections[j].options[k].correct == 1) {
737
                                    totalOption = totalOption + parseInt(objFormGenerator.sections[i].sections[j].options[k].value);
977 geraldo 738
                                }
997 geraldo 739
                                if (objFormGenerator.sections[i].sections[j].type == 'rating-open') {
740
                                    if (parseInt(objFormGenerator.sections[i].sections[j].options[k].value) > maxOption) {
741
                                        maxOption = parseInt(objFormGenerator.sections[i].sections[j].options[k].value);
977 geraldo 742
                                    }
743
                                }
744
                            }
997 geraldo 745
                            if (objFormGenerator.sections[i].sections[j].type == 'simple' || objFormGenerator.sections[i].sections[j].type == 'multiple') {
977 geraldo 746
                                if (numberCorrect == 0) {
997 geraldo 747
                                    $.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
977 geraldo 748
                                    return false;
749
                                }
750
                                if (
997 geraldo 751
                                    objFormGenerator.sections[i].sections[j].type == 'simple' && numberCorrect > 1) {
752
                                    $.fn.showError('ERROR_OPTIONS_DUPLICATE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
977 geraldo 753
                                    return false;
754
                                }
997 geraldo 755
                                if (objFormGenerator.sections[i].sections[j].type == 'multiple' && numberCorrect == 1) {
756
                                    $.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
977 geraldo 757
                                    return false;
758
                                }
759
                            }
997 geraldo 760
                            if (objFormGenerator.sections[i].sections[j].type == 'multiple' && totalOption != valuesection) {
761
                                $.fn.showError('ERROR_OPTIONS_SUM_VALUES'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
977 geraldo 762
                                return false;
763
                            }
997 geraldo 764
                            if (objFormGenerator.sections[i].sections[j].type == 'rating-open' && maxOption > valuesection) {
765
                                $.fn.showError('ERROR_OPTIONS_MAX_OPTION'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
977 geraldo 766
                                return false;
767
                            }
768
                        }
769
                    }
997 geraldo 770
                    if (valueSection != totalValuesection) {
977 geraldo 771
                        $.fn.showError('ERROR_VALUE_SECTIONS'.replace('%s', objFormGenerator.sections[i].name));
772
                        return false;
773
                    }
774
                }
775
                var formId = parseInt($('#form-main #form-id').val());
776
                var formContinue = parseInt($('#form-main #form-continue').val());
777
                var data = {
778
                    'id': formId,
779
                    'name': $('#form-main #form-name').val(),
780
                    'description': $('#form-main #form-description').val(),
781
                    'text': $('#form-main #form-text').val(),
782
                    'language': $('#form-main #form-language').val(),
783
                    'status': $('#form-main #form-status').val(),
784
                    'content': JSON.stringify(objFormGenerator.sections)
785
                }
786
                $.ajax({
787
                    'dataType': 'json',
788
                    'method': 'post',
789
                    'url': $('#form-main').attr('action'),
790
                    'data': data,
791
                }).done(function(response) {
792
                    if (response['success']) {
793
                        $.fn.showSuccess(response['data']);
794
                        if (formContinue == 1) {
795
                            $('#form-main').attr('action',response['action_edit']);
796
                            $('#form-main #form-id').val(response['id']);
797
                            $('#form-main #form-continue').val(0);
798
                        } else {
799
                            $('#row-edit').hide();
800
                            $('#row-forms').show();
801
                        /*---------- Reset Form -------- */
802
                        $('#form-main')[0].reset();
803
                        /*--------Reset Ckeditor ----------*/
804
                        CKEDITOR.instances['form-text'].setData('');
805
                        CKEDITOR.instances['form-description'].setData('');
806
                        /*--------Reset Sections ----------*/
807
                        clearSectionData();
808
                        /* ------- Refresh Table -----------*/
809
 
810
                        }
811
                        tableForm.fnDraw();
812
                    } else {
813
                        $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
814
                    }
815
                }).fail(function(jqXHR, textStatus, errorThrown) {
816
                    $.fn.showError(textStatus);
817
                });
818
                return false;
819
            }
820
        }
821
    });
822
    /**
997 geraldo 823
     * Validate rules form sections
977 geraldo 824
     */
997 geraldo 825
    var validatorFormsection = $("#form-section").validate({
977 geraldo 826
        ignore: [],
827
        errorClass: 'help-block',
828
        errorElement: 'span',
829
        rules: {
995 geraldo 830
            'section-text': {
977 geraldo 831
                required: true,
832
            },
995 geraldo 833
            'section-value': {
977 geraldo 834
                required: true,
835
                number: true,
836
                min: 1
837
            },
995 geraldo 838
            'section-type': {
977 geraldo 839
                required: true,
840
            },
995 geraldo 841
            'section-max-length': {
977 geraldo 842
                required: true,
843
                digits: true,
844
                min: 0
845
            },
995 geraldo 846
            'section-range': {
977 geraldo 847
                required: true,
848
                number: true,
849
                min: 1
850
            },
851
        },
852
        highlight: function(element) {
853
            $(element).closest('.form-group').addClass('has-error');
854
        },
855
        unhighlight: function(element) {
856
            $(element).closest('.form-group').removeClass('has-error');
857
        },
858
        errorPlacement: function(error, element) {
859
            if (element.attr("data-error-container")) {
860
                error.appendTo(element.attr("data-error-container"));
861
            } else {
862
                error.insertAfter(element);
863
            }
864
        },
865
        invalidHandler: function(form, validator) {
866
            if (!validator.numberOfInvalids())
867
                return;
868
            $('html, body').animate({
869
                scrollTop: $(validator.errorList[0].element).offset().top - 100
870
            }, 1000);
871
        },
872
        submitHandler: function(form) {
993 geraldo 873
            if ($('#form-section #section-id').val()) {
997 geraldo 874
                objFormGenerator.editsection(
995 geraldo 875
                    $('#form-section #section-section').val(),
993 geraldo 876
                    $('#form-section #section-id').val(),
995 geraldo 877
                    $('#form-section #section-text').val(),
878
                    $('#form-section #section-value').val(),
879
                    $('#form-section #section-type').val(),
880
                    $('#form-section #section-max-length').val(),
881
                    $('#form-section #section-multiline').val(),
882
                    $('#form-section #section-range').val()
977 geraldo 883
                );
884
            } else {
997 geraldo 885
                objFormGenerator.addsection(
995 geraldo 886
                    $('#form-section #section-section').val(),
887
                    $('#form-section #section-text').val(),
888
                    $('#form-section #section-value').val(),
889
                    $('#form-section #section-type').val(),
890
                    $('#form-section #section-max-length').val(),
891
                    $('#form-section #section-multiline').val(),
892
                    $('#form-section #section-range').val()
977 geraldo 893
                );
894
            }
895
            renderSectionData(objFormGenerator.sections);
993 geraldo 896
            $('#modal-section').modal('hide');
977 geraldo 897
            return false;
898
        }
899
    });
900
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
901
    $("#form-option").on('submit', function() {
902
        for (var instanceName in CKEDITOR.instances) {
903
            CKEDITOR.instances[instanceName].updateElement();
904
        }
905
    })
906
    /**
907
     * Validate rules form options
908
     */
909
    var validatorFormOption = $("#form-option").validate({
910
        ignore: [],
911
        errorClass: 'help-block',
912
        errorElement: 'span',
913
        rules: {
914
            'option-text': {
915
                required: true,
916
            },
917
            'option-value': {
918
                required: true,
919
                number: true,
920
                min: 1
921
            }
922
        },
923
        highlight: function(element) {
924
            $(element).closest('.form-group').addClass('has-error');
925
        },
926
        unhighlight: function(element) {
927
            $(element).closest('.form-group').removeClass('has-error');
928
        },
929
        errorPlacement: function(error, element) {
930
            if (element.attr("data-error-container")) {
931
                error.appendTo(element.attr("data-error-container"));
932
            } else {
933
                error.insertAfter(element);
934
            }
935
        },
936
        invalidHandler: function(form, validator) {
937
            if (!validator.numberOfInvalids())
938
                return;
939
            $('html, body').animate({
940
                scrollTop: $(validator.errorList[0].element).offset().top - 100
941
            }, 1000);
942
        },
943
        submitHandler: function(form) {
944
            if ($('#form-option #option-slug').val()) {
945
                objFormGenerator.editOption(
946
                    $('#form-option #option-section').val(),
997 geraldo 947
                    $('#form-option #option-section').val(),
977 geraldo 948
                    $('#form-option #option-slug').val(),
949
                    $('#form-option #option-text').val(),
950
                    $('#form-option #option-correct').val(),
951
                    $('#form-option #option-value').val()
952
                );
953
            } else {
954
                objFormGenerator.addOption(
955
                    $('#form-option #option-section').val(),
997 geraldo 956
                    $('#form-option #option-section').val(),
977 geraldo 957
                    $('#form-option #option-text').val(),
958
                    $('#form-option #option-correct').val(),
959
                    $('#form-option #option-value').val()
960
                );
961
            }
962
            renderSectionData(objFormGenerator.sections);
963
            $('#modal-option').modal('hide');
964
            return false;
965
        }
966
    });
967
    /**
997 geraldo 968
     * Clicked add new section
977 geraldo 969
     */
993 geraldo 970
    $('body').on('click', 'button.btn-add-section', function(e) {
971
        $('#modal-section').modal('show');
977 geraldo 972
    });
973
    /**
997 geraldo 974
     * Clicked edit section
977 geraldo 975
     */
993 geraldo 976
    $('body').on('click', 'button.btn-edit-section', function(e) {
977 geraldo 977
        e.preventDefault();
978
        var slug_section = $(this).data('section');
997 geraldo 979
        var slug = $(this).data('section');
977 geraldo 980
        var showForm = false;
997 geraldo 981
 
977 geraldo 982
    });
983
    /**
997 geraldo 984
     * Clicked remove section
977 geraldo 985
     */
993 geraldo 986
    $('body').on('click', 'button.btn-delete-section', function(e) {
977 geraldo 987
        e.preventDefault();
988
        var slug_section = $(this).data('section');
997 geraldo 989
        var slug = $(this).data('section');
977 geraldo 990
        bootbox.confirm({
993 geraldo 991
            title: "LABEL_DELETE LABEL_SECTION",
992
            message: "LABEL_SECTION_DELETE",
977 geraldo 993
            buttons: {
994
                cancel: {
995
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
996
                },
997
                confirm: {
998
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
999
                }
1000
            },
1001
            callback: function(result) {
1002
                if (result) {
997 geraldo 1003
                    objFormGenerator.deletesection(slug_section, slug);
977 geraldo 1004
                    renderSectionData(objFormGenerator.sections);
1005
                }
1006
            }
1007
        });
1008
    });
1009
    /**
1010
     * Clicked add new Option
1011
     */
1012
    $('body').on('click', 'button.btn-add-option', function(e) {
1013
        e.preventDefault();
1014
        var slug_section = $(this).data('section');
997 geraldo 1015
        var slug_section = $(this).data('section');
977 geraldo 1016
        var showForm = false;
1017
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1018
            if (slug_section == objFormGenerator.sections[i].slug_section) {
997 geraldo 1019
                for (j = 0; j < objFormGenerator.sections[i].sections.length; j++) {
1020
                    if (slug_section == objFormGenerator.sections[i].sections[j].slug_section) {
977 geraldo 1021
                        validatorFormOption.resetForm();
1022
                        $('#form-option #option-section').val(slug_section);
997 geraldo 1023
                        $('#form-option #option-section').val(slug_section);
977 geraldo 1024
                        $('#form-option #option-slug').val('');
1025
                        CKEDITOR.instances['option-text'].setData('', function() {
1026
                            editor.focus();
1027
                        });
1028
                        $('#form-option #option-correct').val('0');
997 geraldo 1029
                        if (objFormGenerator.sections[i].sections[j].type == 'rating-open') {
977 geraldo 1030
                            $('#form-option #option-correct').parent().hide();
1031
                        } else {
1032
                            $('#form-option #option-correct').parent().show();
1033
                        }
997 geraldo 1034
                        if (objFormGenerator.sections[i].sections[j].type == 'multiple' || objFormGenerator.sections[i].sections[j].type == 'rating-open') {
977 geraldo 1035
                            $('#form-option #option-value').val('0');
1036
                            $('#form-option #option-value').parent().show();
1037
                        } else {
1038
                            $('#form-option #option-value').val('1');
1039
                            $('#form-option #option-value').parent().hide();
1040
                        }
1041
                        renderSectionData(objFormGenerator.sections);
1042
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
1043
                        $('#modal-option').modal('show');
1044
                        return true;
1045
                    }
1046
                }
1047
            }
1048
        }
1049
    });
1050
    /**
1051
     * Clicked edit option
1052
     */
1053
    $('body').on('click', 'button.btn-edit-option', function(e) {
1054
        e.preventDefault();
1055
        var slug_section = $(this).data('section');
997 geraldo 1056
        var slug_section = $(this).data('section');
977 geraldo 1057
        var slug = $(this).data('slug');
1058
        var showForm = false;
1059
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1060
            if (slug_section == objFormGenerator.sections[i].slug_section) {
997 geraldo 1061
                for (j = 0; j < objFormGenerator.sections[i].sections.length; j++) {
1062
                    if (slug_section == objFormGenerator.sections[i].sections[j].slug_section) {
1063
                        for (k = 0; k < objFormGenerator.sections[i].sections[j].options.length; k++) {
1064
                            if (slug == objFormGenerator.sections[i].sections[j].options[k].slug_option) {
977 geraldo 1065
                                validatorFormOption.resetForm();
1066
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
997 geraldo 1067
                                $('#form-option #option-section').val(objFormGenerator.sections[i].sections[j].slug_section);
1068
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].sections[j].options[k].slug_option);
1069
                                CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].sections[j].options[k].text,
977 geraldo 1070
                                    function() {
1071
                                        editor.focus();
1072
                                    });
997 geraldo 1073
                                $('#form-option #option-correct').val(objFormGenerator.sections[i].sections[j].options[k].correct);
1074
                                if (objFormGenerator.sections[i].sections[j].type == 'multiple' || objFormGenerator.sections[i].sections[j].type == 'simple') {
977 geraldo 1075
                                    $('#form-option #option-correct').parent().show();
1076
                                } else {
1077
                                    $('#form-option #option-correct').parent().hide();
1078
                                }
997 geraldo 1079
                                $('#form-option #option-value').val(objFormGenerator.sections[i].sections[j].options[k].value);
1080
                                if (objFormGenerator.sections[i].sections[j].type == 'multiple' || objFormGenerator.sections[i].sections[j].type == 'rating-open') {
977 geraldo 1081
                                    $('#form-option #option-value').parent().show();
1082
                                } else {
1083
                                    $('#form-option #option-value').parent().hide();
1084
                                }
1085
                                showForm = true;
1086
                                break;
1087
                            }
1088
                        }
1089
                    }
1090
                    if (showForm) {
1091
                        break;
1092
                    }
1093
                }
1094
            }
1095
            if (showForm) {
1096
                break;
1097
            }
1098
        }
1099
        if (showForm) {
1100
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1101
            $('#modal-option').modal('show');
1102
        }
1103
    });
1104
    /**
1105
     * Clicked remove option
1106
     */
1107
    $('body').on('click', 'button.btn-delete-option', function(e) {
1108
        e.preventDefault();
1109
        var slug_section = $(this).data('section');
997 geraldo 1110
        var slug_section = $(this).data('section');
977 geraldo 1111
        var slug = $(this).data('slug');
1112
        bootbox.confirm({
1113
            title: "LABEL_DELETE LABEL_OPTION",
993 geraldo 1114
            message: "LABEL_SECTION_DELETE",
977 geraldo 1115
            buttons: {
1116
                cancel: {
1117
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1118
                },
1119
                confirm: {
1120
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1121
                }
1122
            },
1123
            callback: function(result) {
1124
                if (result) {
997 geraldo 1125
                    objFormGenerator.deleteOption(slug_section, slug_section, slug);
977 geraldo 1126
                    renderSectionData(objFormGenerator.sections);
1127
                }
1128
            }
1129
        });
1130
    })
1131
    /**
1132
     * Clicked new Form
1133
     */
1134
    $('button.btn-add-form').click(function(e) {
1135
        e.preventDefault();
1136
        objFormGenerator.clear();
1137
        objFormGenerator.render();
1138
        validatorForm.resetForm();
1139
        clearSectionData();
1140
        $('#form-main').attr('action', '$routeAdd');
1141
        $('#form-main #form-id').val('0');
1142
        $('#form-main #form-continue').val('0');
1143
        $('#form-main #form-name').val('');
1144
        $('#row-forms').hide();
1145
        $('#row-edit').show();
1146
        $('#form-main #form-name').focus();
1147
    });
1148
    /**
1149
     * Clicked cancel new/edit Form
1150
     */
1151
    $('button.btn-edit-cancel').click(function(e) {
1152
        e.preventDefault();
1153
        $('#row-edit').hide();
1154
        $('#row-forms').show();
1155
    });
1156
    /**
1157
     * Clicked save and continue new Form
1158
     */
1159
    $('button.btn-form-save-continue').click(function(e) {
1160
        e.preventDefault();
1161
        $('#form-main #form-continue').val('1')
1162
        $('#form-main').submit();
1163
    });
1164
    /**
1165
     * Clicked save and close new/edit Form
1166
     */
1167
    $('button.btn-form-save-close').click(function(e) {
1168
        e.preventDefault();
1169
        $('#form-main #form-continue').val('0')
1170
        $('#form-main').submit();
1171
    });
1172
    /**
1173
     * Remove Html Tags
1174
     */
1175
    const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
1176
    /**
1177
     * Render Sections data
1178
     */
998 geraldo 1179
    const renderSectionData = (data) => $("#rows").html('');
977 geraldo 1180
 
1181
 
1182
    /**
1183
     * Clear Div Section data
1184
     */
1185
    const clearSectionData = () => $("#rows").html('');
1186
    /**
1187
     * Clicked refresh button
1188
     */
1189
    $('button.btn-refresh').click(function(e) {
1190
        tableForm.fnDraw();
1191
    });
1192
 
1193
});
1194
JS;
1195
$this->inlineScript()->captureEnd();
1196
?>
1197
 
1198
<!-- Content Header (Page header) -->
1199
<section class="content-header">
1200
    <div class="container-fluid">
1201
        <div class="row mb-2">
1202
            <div class="col-sm-12">
984 geraldo 1203
                <h1>LABEL_PERFORMANCE_EVALUATION</h1>
977 geraldo 1204
            </div>
1205
        </div>
1206
    </div>
1207
    <!-- /.container-fluid -->
1208
</section>
1209
<section class="content">
1210
    <div class="container-fluid" id="row-forms">
1211
        <div class="row">
1212
            <div class="col-12">
1213
                <div class="card">
1214
                    <div class="card-body">
1215
                        <table id="gridTable" class="table   table-hover">
1216
                            <thead>
1217
                                <tr>
990 geraldo 1218
                                    <th>LABEL_NAME</th>
1219
                                    <th>LABEL_LANGUAGE</th>
1220
                                    <th>LABEL_ACTIVE</th>
977 geraldo 1221
                                    <th>LABEL_ACTIONS</th>
1222
                                </tr>
1223
                            </thead>
1224
                            <tbody></tbody>
1225
                        </table>
1226
                    </div>
1227
                    <div class="card-footer clearfix">
1228
                        <div style="float:right;">
1229
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1230
                            <?php if ($allowAdd) : ?>
1231
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1232
                            <?php endif; ?>
1233
                        </div>
1234
                    </div>
1235
                </div>
1236
            </div>
1237
        </div>
1238
    </div>
1239
 
1240
    <!-- Create/Edit Form -->
1241
 
1242
    <div class="row" id="row-edit" style="display: none">
1243
        <div class="col-xs-12 col-md-12">
1244
            <form action="#" name="form-main" id="form-main">
1245
                <input type="hidden" name="form-id" id="form-id" value="0" />
1246
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
990 geraldo 1247
                <div class="form-group">
1248
                    <label for="form-name">LABEL_FIRST_NAME</label>
1249
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
1250
                </div>
977 geraldo 1251
                <div class="row">
1252
                    <div class="col-xs-12 col-md-12 text-right">
994 geraldo 1253
                        <button type="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>
977 geraldo 1254
                    </div>
1255
                </div>
1256
                <br />
1257
                <div class="row">
1258
                    <div class="col-xs-12 col-md-12">
1259
                        <div class="panel-group" id="rows"></div>
1260
                    </div>
1261
                </div>
1262
                <div class="form-group">
1263
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1264
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1265
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1266
                </div>
1267
            </form>
1268
        </div>
1269
    </div>
1270
 
1271
    <!-- Create/Edit Form-->
1272
 
990 geraldo 1273
 
977 geraldo 1274
 
997 geraldo 1275
    <!-- section Modal -->
977 geraldo 1276
 
993 geraldo 1277
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
977 geraldo 1278
        <div class="modal-dialog modal-lg" role="document">
993 geraldo 1279
            <form action="#" name="form-section" id="form-section">
1280
                <input type="hidden" name="section-id" id="section-id" />
977 geraldo 1281
                <div class="modal-content">
1282
                    <div class="modal-header">
993 geraldo 1283
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
977 geraldo 1284
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1285
                            <span aria-hidden="true">&times;</span>
1286
                        </button>
1287
                    </div>
1288
                    <div class="modal-body">
1289
                        <div class="form-group">
995 geraldo 1290
                            <label for="section-text">LABEL_TEXT</label>
977 geraldo 1291
                            <!--  ckeditor -->
995 geraldo 1292
                            <textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
977 geraldo 1293
                        </div>
1294
                        <div class="form-group">
995 geraldo 1295
                            <label for="section-type">LABEL_TYPE</label>
1296
                            <select name="section-type" id="section-type" class="form-control">
977 geraldo 1297
                                <option value="open">LABEL_OPEN</option>
1298
                                <option value="simple">Simple</option>
1299
                                <option value="multiple">Multiple</option>
1300
                            </select>
1301
                        </div>
1302
                        <div class="form-group">
995 geraldo 1303
                            <label for="section-max-length">LABEL_MAXLENGTH</label>
1304
                            <input type="text" name="section-max-length" id="section-max-length"  class="form-control" />
977 geraldo 1305
                        </div>
1306
                    </div>
1307
                    <div class="modal-footer">
1308
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1309
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1310
                    </div>
1311
                </div>
1312
            </form>
1313
        </div>
1314
    </div>
1315
 
997 geraldo 1316
    <!-- End Modal section -->
977 geraldo 1317
 
1318
    <!-- Modal Options -->
1319
 
1320
    <div  id="modal-option" class="modal" tabindex="-1" role="dialog">
1321
        <div class="modal-dialog modal-lg" role="document">
1322
            <form action="#" name="form-option" id="form-option">
1323
                <input type="hidden" name="option-section" id="option-section" value="" />
997 geraldo 1324
                <input type="hidden" name="option-section" id="option-section" value="" />
977 geraldo 1325
                <input type="hidden" name="option-slug" id="option-slug" value="" />
1326
                <div class="modal-content">
1327
                    <div class="modal-header">
1328
                        <h4 class="modal-title">LABEL_OPTION</h4>
1329
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1330
                            <span aria-hidden="true">&times;</span>
1331
                        </button>
1332
                    </div>
1333
                    <div class="modal-body">
1334
                        <div class="form-group">
1335
                            <label for="option-text">LABEL_TEXT</label>
1336
                            <!--  ckeditor -->
1337
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1338
                        </div>
1339
                    </div>
1340
                    <div class="modal-footer">
1341
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1342
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1343
                    </div>
1344
                </div>
1345
            </form>
1346
        </div>
1347
    </div>
1348
 
1349
    <!-- End Modal Options -->
1350
 
1351
    <!---Template Sections --->
1352
    <script id="sectionTemplate" type="text/x-jsrender">
998 geraldo 1353
 
977 geraldo 1354
    </script>
1355
 
1356
    <!-- End Template Sections-->
1357
 
1358
</section>