Proyectos de Subversion LeadersLinked - Backend

Rev

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

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