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
4384 eleazar 1
<?php
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
$routeAdd = $this->url('survey/form/add');
8
$routeDatatable = $this->url('survey/form');
9
$routeDashboard = $this->url('dashboard');
10
 
11
$allowAdd = $acl->isAllowed($roleName, 'survey/form/add') ? 1 : 0;
12
$allowEdit = $acl->isAllowed($roleName, 'survey/form/edit') ? 1 : 0;
13
$allowDelete = $acl->isAllowed($roleName, 'survey/form/delete') ? 1 : 0;
14
 
15
 
16822 efrain 16
//$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
4384 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'));
4384 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'));
4384 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'));
4384 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'));
4384 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'));
4384 eleazar 38
 
16822 efrain 39
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.full.min.js'));
4384 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'));
4384 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'));
4384 eleazar 48
 
49
 
16822 efrain 50
 
51
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
52
 
4384 eleazar 53
// bootbox Alert //
54
 
16822 efrain 55
 
4384 eleazar 56
// JsRender //
16822 efrain 57
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.min.js'));
4384 eleazar 58
 
59
// Page Styles
60
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
61
 
4399 eleazar 62
$status_active = \LeadersLinked\Model\SurveyForm::STATUS_ACTIVE;
63
$status_inactive = \LeadersLinked\Model\SurveyForm::STATUS_INACTIVE;
4384 eleazar 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
 
4384 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;
4384 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
 
4384 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) {
4384 eleazar 153
                if (a.position > b.position) {
154
                    return 1;
16817 efrain 155
                } else if (a.position < b.position) {
4384 eleazar 156
                    return -1;
16817 efrain 157
                } else {
158
                    return 0;
4384 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;
4384 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) {
4384 eleazar 190
                for (j = 0; j < this.sections[i].questions.length; j++) {
191
                    this.sections[i].questions[j].position = j;
6467 eleazar 192
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
4384 eleazar 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) {
4384 eleazar 197
                                return -1;
16817 efrain 198
                            } else {
199
                                return 0;
4384 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
                    }
4384 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
                    );
4384 eleazar 218
                }
16817 efrain 219
                $('[data-toggle="tooltip"]').tooltip();
220
 
221
                break
222
            } else {
223
                continue;
4384 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;
4384 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;
4384 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;
4384 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;
4384 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': []
4384 eleazar 303
                }
16817 efrain 304
                this.sections[i].questions.push(question);
305
                renderTable = true;
306
                break;
4384 eleazar 307
            }
16817 efrain 308
        }
309
        if (renderTable) {
310
            this.renderSection(slug_section);
311
        }
312
    }
4384 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;
4384 eleazar 322
 
16817 efrain 323
                        renderTable = true;
324
                        break;
4384 eleazar 325
                    }
326
                }
327
            }
328
            if (renderTable) {
16817 efrain 329
                break;
4384 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;
4384 eleazar 346
                    }
347
                }
348
            }
349
            if (renderTable) {
16817 efrain 350
                break;
4384 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;
4384 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
4384 eleazar 379
                        }
16817 efrain 380
                        this.sections[i].questions[j].options.push(option);
381
                        renderTable = true;
382
                        break;
4384 eleazar 383
                    }
16817 efrain 384
                    if (renderTable) {
385
                        break;
386
                    }
4384 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;
4384 eleazar 406
                            }
407
                        }
408
                    }
16817 efrain 409
                    if (renderTable) {
410
                        break;
411
                    }
4384 eleazar 412
                }
413
            }
414
            if (renderTable) {
16817 efrain 415
                break;
4384 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;
4384 eleazar 434
                            }
435
                        }
436
                    }
16817 efrain 437
                    if (renderTable) {
438
                        break;
439
                    }
4384 eleazar 440
                }
441
            }
442
            if (renderTable) {
16817 efrain 443
                break;
4384 eleazar 444
            }
445
        }
16817 efrain 446
        if (renderTable) {
447
            this.renderSection(slug_section);
448
        }
449
    }
4384 eleazar 450
 
16817 efrain 451
 
4384 eleazar 452
jQuery(document).ready(function($) {
16817 efrain 453
    var objFormGenerator = new FormGenerator();
4384 eleazar 454
    objFormGenerator.render();
16817 efrain 455
 
456
 
4384 eleazar 457
    var allowEdit = $allowEdit;
458
    var allowDelete = $allowDelete;
16817 efrain 459
 
460
    var tableForm = $('#tableForm').dataTable({
4384 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
 
4384 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
            {
538
                'targets': -2,
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>' ;
4384 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;';
4384 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
 
4384 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');
4459 eleazar 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')
4384 eleazar 583
 
584
 
585
                objFormGenerator.clear();
586
                objFormGenerator.sections = response['data']['content'] || [];
587
                objFormGenerator.render();
588
 
589
                $('#row-forms').hide();
590
                $('#row-edit').show();
4459 eleazar 591
                $('#form-main #name').focus();
4384 eleazar 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());
4384 eleazar 618
            }
619
        }
620
    });
16817 efrain 621
 
622
    var validatorForm = $('#form-main').validate({
623
        debug: true,
624
        onclick: false,
625
        onkeyup: false,
4384 eleazar 626
        ignore: [],
627
        rules: {
16817 efrain 628
            'name': {
4384 eleazar 629
                required: true,
630
                minlength: 2,
16817 efrain 631
                maxlength: 128
4384 eleazar 632
            },
4466 eleazar 633
            'text':{
16817 efrain 634
                required: true
4384 eleazar 635
            },
16817 efrain 636
            'status': {
637
                required: false,
4384 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()) {
4384 eleazar 656
                return false;
16817 efrain 657
            }
4384 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);
4384 eleazar 679
                    } else {
16817 efrain 680
                        tableForm.api().ajax.reload(null, false);
681
 
682
                        $('#row-edit').hide();
683
                        $('#row-forms').show();
684
 
4384 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;
4384 eleazar 696
        }
697
    });
16817 efrain 698
 
4384 eleazar 699
    var validatorFormSection = $("#form-section").validate({
16817 efrain 700
        debug: true,
701
        onclick: false,
702
        onkeyup: false,
4384 eleazar 703
        ignore: [],
704
        rules: {
705
            'section-name': {
706
                required: true,
707
                minlength: 2,
708
                maxlength: 50
709
            },
9004 stevensc 710
            'section-text': {
4384 eleazar 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(),
9004 stevensc 722
                    $('#form-section #section-text').val(),
4384 eleazar 723
                );
724
            } else {
16817 efrain 725
                slug = objFormGenerator.addSection(
4384 eleazar 726
                    $('#form-section #section-name').val(),
9004 stevensc 727
                    $('#form-section #section-text').val()
4384 eleazar 728
                );
729
            }
16817 efrain 730
 
731
            objFormGenerator.renderSection(slug);
4384 eleazar 732
            $('#modal-section').modal('hide');
733
            return false;
734
        }
735
    });
16817 efrain 736
 
4384 eleazar 737
    var validatorFormQuestion = $("#form-question").validate({
16817 efrain 738
        debug: true,
739
        onclick: false,
740
        onkeyup: false,
4384 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
 
4384 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()
4384 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()
4384 eleazar 764
                );
765
            }
16817 efrain 766
            objFormGenerator.renderSection($('#form-question #question-section').val());
4384 eleazar 767
            $('#modal-question').modal('hide');
768
            return false;
769
        }
770
    });
16817 efrain 771
 
4384 eleazar 772
    var validatorFormOption = $("#form-option").validate({
16817 efrain 773
        debug: true,
774
        onclick: false,
775
        onkeyup: false,
4384 eleazar 776
        ignore: [],
777
        rules: {
778
            'option-text': {
779
                required: true,
780
            }
4546 eleazar 781
 
4384 eleazar 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(),
6276 eleazar 789
                    $('#form-option #option-text').val()
4384 eleazar 790
                );
791
            } else {
792
                objFormGenerator.addOption(
793
                    $('#form-option #option-section').val(),
794
                    $('#form-option #option-question').val(),
6276 eleazar 795
                    $('#form-option #option-text').val()
4384 eleazar 796
                );
797
            }
16817 efrain 798
            objFormGenerator.renderSection($('#form-option #option-section').val());
4384 eleazar 799
            $('#modal-option').modal('hide');
800
            return false;
801
        }
802
    });
16817 efrain 803
 
4384 eleazar 804
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
805
        e.preventDefault();
806
        validatorFormSection.resetForm();
16817 efrain 807
 
4384 eleazar 808
        $('#form-section #section-slug').val('');
809
        $('#form-section #section-name').val('');
16817 efrain 810
        $('#form-section #section-text').val('');
4384 eleazar 811
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
812
        $('#modal-section').modal('show');
813
    });
16817 efrain 814
 
4384 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);
4384 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
 
4384 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({
4384 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);
4384 eleazar 851
            }
852
        });
853
    });
16817 efrain 854
 
4384 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('');
4384 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
 
4384 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);
4384 eleazar 880
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
16817 efrain 881
 
4384 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
 
4384 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({
4384 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) {
4384 eleazar 909
                    objFormGenerator.deleteQuestion(slug_section, slug);
910
            }
911
        });
912
    });
16817 efrain 913
 
4384 eleazar 914
    $('body').on('click', 'button.btn-add-option', function(e) {
915
        e.preventDefault();
916
        var slug_section = $(this).data('section');
917
        var slug_question = $(this).data('question');
918
        var showForm = false;
919
        for (i = 0; i < objFormGenerator.sections.length; i++) {
920
            if (slug_section == objFormGenerator.sections[i].slug_section) {
921
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
922
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
923
                        validatorFormOption.resetForm();
924
                        $('#form-option #option-section').val(slug_section);
925
                        $('#form-option #option-question').val(slug_question);
926
                        $('#form-option #option-slug').val('');
16817 efrain 927
                        $('#form-option #option-text').val('');
928
 
4384 eleazar 929
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
930
                        $('#modal-option').modal('show');
931
                        return true;
932
                    }
933
                }
934
            }
935
        }
936
    });
16817 efrain 937
 
938
 
4384 eleazar 939
    $('body').on('click', 'button.btn-edit-option', function(e) {
940
        e.preventDefault();
941
        var slug_section = $(this).data('section');
942
        var slug_question = $(this).data('question');
943
        var slug = $(this).data('slug');
944
        var showForm = false;
945
        for (i = 0; i < objFormGenerator.sections.length; i++) {
946
            if (slug_section == objFormGenerator.sections[i].slug_section) {
947
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
948
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
949
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
950
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
951
                                validatorFormOption.resetForm();
952
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
953
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
954
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
16817 efrain 955
                                $('#form-option #option-text').val(objFormGenerator.sections[i].questions[j].options[k].text);
4384 eleazar 956
                                showForm = true;
957
                                break;
958
                            }
959
                        }
960
                    }
961
                    if (showForm) {
962
                        break;
963
                    }
964
                }
965
            }
966
            if (showForm) {
967
                break;
968
            }
969
        }
970
        if (showForm) {
971
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
972
            $('#modal-option').modal('show');
973
        }
974
    });
16817 efrain 975
 
976
 
4384 eleazar 977
    $('body').on('click', 'button.btn-delete-option', function(e) {
978
        e.preventDefault();
979
        var slug_section = $(this).data('section');
980
        var slug_question = $(this).data('question');
981
        var slug = $(this).data('slug');
16822 efrain 982
 
983
          swal.fire({
4384 eleazar 984
            title: "LABEL_DELETE LABEL_OPTION",
985
            message: "LABEL_QUESTION_DELETE",
16822 efrain 986
            icon: 'question',
987
            cancelButtonText: 'LABEL_NO',
988
            showCancelButton: true,
989
            confirmButtonText: 'LABEL_YES'
990
          }).then((result) => {
991
            if (result.isConfirmed) {
992
 
4384 eleazar 993
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
16822 efrain 994
 
4384 eleazar 995
            }
996
        });
997
    })
16817 efrain 998
 
999
 
4384 eleazar 1000
    $('button.btn-add-form').click(function(e) {
1001
        e.preventDefault();
1002
        objFormGenerator.clear();
1003
        objFormGenerator.render();
1004
        validatorForm.resetForm();
16817 efrain 1005
 
4384 eleazar 1006
        $('#form-main').attr('action', '$routeAdd');
1007
        $('#form-main #form-continue').val('0');
4459 eleazar 1008
        $('#form-main #name').val('');
16817 efrain 1009
        $('#form-main #status').bootstrapToggle('on')
1010
        $('#form-main #text').val('');
4384 eleazar 1011
        $('#row-forms').hide();
1012
        $('#row-edit').show();
4459 eleazar 1013
        $('#form-main #name').focus();
16817 efrain 1014
 
4384 eleazar 1015
    });
16817 efrain 1016
 
1017
    $('#btn-edit-cancel').click(function(e) {
4384 eleazar 1018
        e.preventDefault();
16817 efrain 1019
 
1020
         tableForm.api().ajax.reload(null, false);
1021
 
4384 eleazar 1022
        $('#row-edit').hide();
1023
        $('#row-forms').show();
16817 efrain 1024
 
1025
 
4384 eleazar 1026
    });
16817 efrain 1027
 
1028
 
1029
    $('#btn-form-save-continue').click(function(e) {
8365 eleazar 1030
        e.preventDefault();
1031
        $('#form-main #form-continue').val('1')
8366 eleazar 1032
        $('#form-main').submit();
4384 eleazar 1033
    });
16817 efrain 1034
 
1035
 
1036
    $('#btn-form-save-close').click(function(e) {
4384 eleazar 1037
        e.preventDefault();
16817 efrain 1038
 
4384 eleazar 1039
        $('#form-main #form-continue').val('0')
1040
        $('#form-main').submit();
1041
    });
8364 eleazar 1042
 
1043
 
4384 eleazar 1044
    $('#modal-section, #modal-question, #modal-option').modal({
1045
        backdrop: 'static',
1046
        keyboard: false,
1047
        show: false
1048
    });
1049
 
1050
    $('button.btn-refresh').click(function(e) {
16817 efrain 1051
        tableForm.api().ajax.reload(null, false);
4384 eleazar 1052
    });
4466 eleazar 1053
 
16822 efrain 1054
 $('body').on('click', 'button.btn-delete', function(e) {
1055
        e.preventDefault();
1056
        var action = $(this).data('href');
14208 stevensc 1057
 
16822 efrain 1058
 
1059
          swal.fire({
1060
            title: 'LABEL_ARE_YOU_SURE',
1061
            icon: 'question',
1062
            cancelButtonText: 'LABEL_NO',
1063
            showCancelButton: true,
1064
            confirmButtonText: 'LABEL_YES'
1065
          }).then((result) => {
1066
            if (result.isConfirmed) {
1067
 
1068
                    NProgress.start();
1069
                    $.ajax({
1070
                        'dataType'  : 'json',
1071
                        'accept'    : 'application/json',
1072
                        'method'    : 'post',
1073
                        'url'       :  action,
1074
                    }).done(function(response) {
1075
                        if(response['success']) {
1076
                            $.fn.showSuccess(response['data']);
1077
                            gridTable.api().ajax.reload(null, false);
1078
                        } else {
1079
                            $.fn.showError(response['data']);
1080
                        }
1081
                    }).fail(function( jqXHR, textStatus, errorThrown) {
1082
                        $.fn.showError(textStatus);
1083
                    }).always(function() {
1084
                        NProgress.done();
1085
                    });
1086
            }
1087
       });
1088
    });
1089
 
1090
 
16817 efrain 1091
 
1092
    $('#form-main #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
1093
 
4384 eleazar 1094
});
1095
JS;
1096
$this->inlineScript()->captureEnd();
1097
?>
1098
 
16864 efrain 1099
<div class="container">
1100
	<div class="card" id="row-forms">
1101
	 	<div class="card-header">
1102
	 		<h6 class="card-title">LABEL_FORM_BUILDER</h6>
1103
	 	</div>
1104
	 	<div class="card-body">
1105
 
1106
 
1107
	 		<div class="row">
1108
	 	         <div class="col-12 mt-3">
1109
	 	         	<table id="tableForm" class="table   table-bordered">
4384 eleazar 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>
16864 efrain 1119
 
1120
	 	         </div>
1121
	 	     </div>
1122
	 	</div>
1123
	 	<div class="card-footer text-right">
1124
			<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1125
   			<?php if ($allowAdd) : ?>
1126
          	<button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1127
      		<?php endif; ?>
1128
	 	</div>
1129
	</div>
1130
 
1131
 
1132
	<div class="card" id="row-edit" style="display: none">
1133
	 	<div class="card-header">
1134
	 		<h6 class="card-title">LABEL_FORM</h6>
1135
	 	</div>
1136
	 	<form name="form-main" id="form-main">
1137
        	<input type="hidden" name="form-continue" id="form-continue" value="0" />
1138
	 	<div class="card-body">
4384 eleazar 1139
 
16864 efrain 1140
		 	<div class="row">
1141
		 		<div class="col-12 mt-3">
4450 eleazar 1142
                    <?php
1143
                    $element = $form->get('name');
16817 efrain 1144
                    $element->setOptions(['label' => 'LABEL_NAME']);
4450 eleazar 1145
                    $element->setAttributes(['class' => 'form-control']);
1146
                    echo $this->formLabel($element);
1147
                    echo $this->formText($element);
1148
                    ?>
4384 eleazar 1149
                </div>
16864 efrain 1150
            </div>
16817 efrain 1151
 
16864 efrain 1152
		 	<div class="row">
1153
		 		<div class="col-12 mt-3">
14208 stevensc 1154
                    <?php
1155
                    $element = $form->get('text');
1156
                    $element->setOptions(['label' => 'LABEL_TEXT']);
1157
                    $element->setAttributes(['class' => 'form-control']);
1158
                    echo $this->formLabel($element);
1159
                    echo $this->formTextArea($element);
1160
                    ?>
4384 eleazar 1161
                </div>
16864 efrain 1162
            </div>
1163
		 	<div class="row">
1164
		 		<div class="col-12 mt-3">
14208 stevensc 1165
                    <?php
1166
                    $element = $form->get('status');
1167
                    $element->setAttributes(['class' => 'form-control']);
1168
                    $element->setOptions(['label' => 'LABEL_STATUS']);
1169
                    echo $this->formLabel($element);
16817 efrain 1170
                    echo '<br>';
1171
                    echo $this->formCheckbox($element);
14208 stevensc 1172
                    ?>
1173
                </div>
16864 efrain 1174
            </div>
1175
 
1176
		 	<div class="row">
1177
		 		<div class="col-12 mt-3 text-right">
1178
      				<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>
4384 eleazar 1179
                </div>
16864 efrain 1180
            </div>
1181
		 	<div class="row">
1182
		 		<div class="col-12 mt-3">
1183
             		<div class="panel-group" id="containter-sections"></div>
1184
           		</div>
1185
           	</div>
1186
	 	</div>
1187
	 	<div class="card-footer text-right">
1188
	 	  	<button type="button" id="btn-form-save-continue" class="btn btn-info ">LABEL_SAVE & LABEL_CONTINUE</button>
1189
         	<button type="button" id="btn-form-save-close" class="btn btn-primary ">LABEL_SAVE & LABEL_CLOSE</button>
1190
      		<button type="button" id="btn-edit-cancel" class="btn btn-light ">LABEL_CANCEL</button>
1191
	 	</div>
1192
	 	</form>
1193
	</div>
1194
</div>
4384 eleazar 1195
 
16864 efrain 1196
 
1197
 
4384 eleazar 1198
    <!-- Create/Edit Form-->
1199
 
1200
    <!-- Section Modal -->
14208 stevensc 1201
    <div id="modal-section" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1202
        <div class="modal-dialog modal-lg" role="document">
1203
            <form action="#" name="form-section" id="form-section">
1204
                <input type="hidden" name="section-slug" id="section-slug" value="" />
1205
                <div class="modal-content">
1206
                    <div class="modal-header">
16845 efrain 1207
                        <h6 class="modal-title">LABEL_ADD LABEL_SECTION</h6>
16864 efrain 1208
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1209
 
4384 eleazar 1210
                    </div>
1211
                    <div class="modal-body">
16864 efrain 1212
		 				<div class="row">
1213
		 					<div class="col-12 mt-3">
4384 eleazar 1214
                            <label for="section-name">LABEL_FIRST_NAME</label>
1215
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
16864 efrain 1216
                        	</div>
1217
                        </div>
1218
		 				<div class="row">
1219
		 					<div class="col-12 mt-3">
9004 stevensc 1220
                            <label for="section-text">LABEL_TEXT</label>
8981 stevensc 1221
                            <!--  ckeditor -->
14208 stevensc 1222
                            <textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
16864 efrain 1223
                        	</div>
1224
                        </div>
4384 eleazar 1225
                    </div>
16891 efrain 1226
                    <div class="modal-footer text-right">
4384 eleazar 1227
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
16864 efrain 1228
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
4384 eleazar 1229
                    </div>
1230
                </div>
1231
            </form>
1232
        </div>
1233
    </div>
1234
    <!-- End Modal Section -->
1235
 
1236
    <!-- Question Modal -->
1237
 
14208 stevensc 1238
    <div id="modal-question" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1239
        <div class="modal-dialog modal-lg" role="document">
1240
            <form action="#" name="form-question" id="form-question">
1241
                <input type="hidden" name="question-section" id="question-section" />
1242
                <input type="hidden" name="question-slug" id="question-slug" />
1243
                <div class="modal-content">
1244
                    <div class="modal-header">
16845 efrain 1245
                        <h6 class="modal-title">LABEL_ADD LABEL_QUESTION</h6>
16864 efrain 1246
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
4384 eleazar 1247
                    </div>
1248
                    <div class="modal-body">
16864 efrain 1249
		 				<div class="row">
1250
		 					<div class="col-12 mt-3">
4384 eleazar 1251
                            <label for="question-text">LABEL_TEXT</label>
1252
                            <!--  ckeditor -->
14208 stevensc 1253
                            <textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
16864 efrain 1254
                        	</div>
1255
                        </div>
1256
		 				<div class="row">
1257
		 					<div class="col-12 mt-3">
4384 eleazar 1258
                            <label for="question-type">LABEL_TYPE</label>
1259
                            <select name="question-type" id="question-type" class="form-control">
16817 efrain 1260
                                <option value="simple">LABEL_SINGLE_SELECTION</option>
1261
                                <option value="multiple">LABEL_MULTIPLE_SELECTION</option>
1262
                                <option value="range1to5">LABEL_RANGE_1_5</option>
14208 stevensc 1263
 
4384 eleazar 1264
                            </select>
16864 efrain 1265
                        	</div>
1266
                        </div>
4384 eleazar 1267
                    </div>
16891 efrain 1268
                    <div class="modal-footer text-right">
4384 eleazar 1269
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
16864 efrain 1270
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
4384 eleazar 1271
                    </div>
1272
                </div>
1273
            </form>
1274
        </div>
1275
    </div>
1276
 
1277
    <!-- End Modal Question -->
1278
 
1279
    <!-- Modal Options -->
1280
 
14208 stevensc 1281
    <div id="modal-option" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1282
        <div class="modal-dialog modal-lg" role="document">
1283
            <form action="#" name="form-option" id="form-option">
1284
                <input type="hidden" name="option-section" id="option-section" value="" />
1285
                <input type="hidden" name="option-question" id="option-question" value="" />
1286
                <input type="hidden" name="option-slug" id="option-slug" value="" />
1287
                <div class="modal-content">
1288
                    <div class="modal-header">
16845 efrain 1289
                        <h6 class="modal-title">LABEL_OPTION</h6>
16864 efrain 1290
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
4384 eleazar 1291
                    </div>
1292
                    <div class="modal-body">
16864 efrain 1293
		 				<div class="row">
1294
		 					<div class="col-12 mt-3">
4384 eleazar 1295
                            <label for="option-text">LABEL_TEXT</label>
1296
                            <!--  ckeditor -->
14208 stevensc 1297
                            <textarea name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
16864 efrain 1298
                        	</div>
4384 eleazar 1299
                        </div>
1300
                    </div>
16891 efrain 1301
                    <div class="modal-footer text-right">
4384 eleazar 1302
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
16864 efrain 1303
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
4384 eleazar 1304
                    </div>
1305
                </div>
1306
            </form>
1307
        </div>
1308
    </div>
1309
 
1310
 
16817 efrain 1311
 
1312
 
16864 efrain 1313
 
16817 efrain 1314
 
4384 eleazar 1315
    <!---Template Sections --->
16817 efrain 1316
    <script id="sectionTemplateReplace" type="text/x-jsrender">
1317
 
4384 eleazar 1318
        <div class="panel-heading">
16845 efrain 1319
            <h6 class="panel-title">
4384 eleazar 1320
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1321
                    <span class="section-name{{:slug_section}}">
1322
                        {{:name}}
1323
                    </span>
1324
                </a>
16845 efrain 1325
            </h6>
4384 eleazar 1326
        </div>
1327
        <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
1328
            <div class="panel-body">
1329
                <div class="table-responsive">
1330
                    <table class="table table-bordered">
1331
                        <thead>
1332
                            <tr>
1333
                                <th style="width: 10%;">LABEL_ELEMENT</th>
1334
                                <th style="width: 50%;">LABEL_TEXT</th>
1335
                                <th style="width: 10%;">LABEL_TYPE</th>
1336
                                <th style="width: 20%;">LABEL_ACTIONS</th>
1337
                            </tr>
1338
                        </thead>
1339
                        <tbody>
1340
                            <tr class="tr-section">
1341
                                <td class="text-left">LABEL_SECTION</td>
1342
                                <td class="text-left">{{:name}}</td>
1343
                                <td></td>
1344
                                <td>
1345
                                    <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>
1346
                                    <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>
1347
                                    <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>
1348
                                </td>
1349
                            </tr>
1350
                            {{for questions}}
16817 efrain 1351
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
4384 eleazar 1352
                                <td class="text-left">--LABEL_QUESTION</td>
1353
                                <td class="text-left">
16817 efrain 1354
                                    {{:text}}
4384 eleazar 1355
                                </td>
1356
                                <td class="text-capitalize">
1357
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
16817 efrain 1358
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
1359
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
1360
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
4384 eleazar 1361
                                </td>
1362
                                <td>
1363
                                    <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>
1364
                                    <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>
1365
 
16817 efrain 1366
                                    {{if type == 'simple' ||  type=='multiple' }}
4384 eleazar 1367
                                    <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>
1368
                                    {{/if}}
1369
 
1370
                                </td>
1371
                            </tr>
1372
                            {{for options}}
16817 efrain 1373
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
4384 eleazar 1374
                                <td class="text-left">---LABEL_OPTION</td>
1375
                                <td class="text-left">
16817 efrain 1376
                                    {{:text}}
4384 eleazar 1377
                                </td>
1378
                                <td>
16817 efrain 1379
                                    &nbsp;
1380
                                </td>
1381
                                <td>
1382
                                    <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>
1383
                                    <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>
1384
                                </td>
1385
                            </tr>
1386
                            {{/for}}
1387
                            {{/for}}
1388
                        </tbody>
1389
                    </table>
1390
                </div>
1391
            </div>
1392
        </div>
4384 eleazar 1393
 
16817 efrain 1394
    </script>
1395
 
1396
    <!---Template Sections --->
1397
    <script id="sectionTemplateAdd" type="text/x-jsrender">
1398
    <div class="panel panel-default" id="panel-{{:slug_section}}">
1399
        <div class="panel-heading">
16845 efrain 1400
            <h6 class="panel-title">
16817 efrain 1401
                <a class="d-block w-100 collapsed card-primary" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1402
                    <i class="fa" aria-hidden="true"></i>
1403
                    <span class="section-name{{:slug_section}}">
1404
                        {{:name}}
1405
                    </span>
1406
                </a>
16845 efrain 1407
            </h6>
16817 efrain 1408
        </div>
1409
        <div id="collapse-{{:slug_section}}" class="collapse show" data-parent="panel-{{:slug_section}}" style="">
1410
            <div class="panel-body">
1411
                <div class="table-responsive">
1412
                    <table class="table table-bordered">
1413
                        <thead>
1414
                            <tr>
1415
                                <th style="width: 10%;">LABEL_ELEMENT</th>
1416
                                <th style="width: 50%;">LABEL_TEXT</th>
1417
                                <th style="width: 10%;">LABEL_TYPE</th>
1418
                                <th style="width: 20%;">LABEL_ACTIONS</th>
1419
                            </tr>
1420
                        </thead>
1421
                        <tbody>
1422
                            <tr class="tr-section">
1423
                                <td class="text-left">LABEL_SECTION</td>
1424
                                <td class="text-left">{{:name}}</td>
1425
                                <td></td>
1426
                                <td>
1427
                                    <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>
1428
                                    <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>
1429
                                    <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>
1430
                                </td>
1431
                            </tr>
1432
                            {{for questions}}
1433
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
1434
                                <td class="text-left">--LABEL_QUESTION</td>
1435
                                <td class="text-left">
1436
                                    {{:text}}
1437
                                </td>
1438
                                <td class="text-capitalize">
1439
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1440
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
1441
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
1442
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
1443
                                </td>
1444
                                <td>
1445
                                    <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>
1446
                                    <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>
1447
 
1448
                                    {{if type == 'simple' || type=='multiple' }}
1449
                                    <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>
4384 eleazar 1450
                                    {{/if}}
16817 efrain 1451
 
4384 eleazar 1452
                                </td>
16817 efrain 1453
                            </tr>
1454
                            {{for options}}
1455
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
1456
                                <td class="text-left">---LABEL_OPTION</td>
1457
                                <td class="text-left">
1458
                                    {{:text}}
1459
                                </td>
4384 eleazar 1460
                                <td>
16817 efrain 1461
                                    &nbsp;
1462
                                </td>
1463
                                <td>
4384 eleazar 1464
                                    <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>
1465
                                    <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>
1466
                                </td>
1467
                            </tr>
1468
                            {{/for}}
1469
                            {{/for}}
1470
                        </tbody>
1471
                    </table>
1472
                </div>
1473
            </div>
1474
        </div>
1475
    </div>
1476
 
16817 efrain 1477
    </script>