Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16971 | | 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
 
23
 
16929 efrain 24
 
25
 
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">' +
16971 efrain 544
                        '<input type="checkbox" class="form-check-input" disabled="" ' + checked + '>' +
16822 efrain 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
 
602
    var validatorForm = $('#form-main').validate({
603
        debug: true,
604
        onclick: false,
605
        onkeyup: false,
4384 eleazar 606
        ignore: [],
607
        rules: {
16817 efrain 608
            'name': {
4384 eleazar 609
                required: true,
610
                minlength: 2,
16817 efrain 611
                maxlength: 128
4384 eleazar 612
            },
4466 eleazar 613
            'text':{
16817 efrain 614
                required: true
4384 eleazar 615
            },
16817 efrain 616
            'status': {
617
                required: false,
4384 eleazar 618
            },
619
        },
16929 efrain 620
 
4384 eleazar 621
        submitHandler: function(form) {
16817 efrain 622
 
623
            if(!objFormGenerator.isValid()) {
4384 eleazar 624
                return false;
16817 efrain 625
            }
4384 eleazar 626
 
16817 efrain 627
            var status = $('#form-main #status').prop('checked') ? '$status_active' : '$status_inactive';
628
            var formContinue = parseInt($('#form-main #form-continue').val());
629
            var data = {
630
                'name': $('#form-main #name').val(),
631
                'text': $('#form-main #text').val(),
632
                'status': status,
633
                'content': JSON.stringify(objFormGenerator.sections)
634
            }
635
 
636
            $.ajax({
637
                'dataType': 'json',
638
                'method': 'post',
639
                'url': $('#form-main').attr('action'),
640
                'data': data,
641
            }).done(function(response) {
642
                if (response['success']) {
643
                    $.fn.showSuccess(response['data']['message']);
644
                    if (formContinue == 1) {
645
                        $('#form-main').attr('action',response['data']['action']);
646
                        $('#form-main #form-continue').val(0);
4384 eleazar 647
                    } else {
16817 efrain 648
                        tableForm.api().ajax.reload(null, false);
649
 
650
                        $('#row-edit').hide();
651
                        $('#row-forms').show();
652
 
4384 eleazar 653
                    }
16817 efrain 654
 
655
 
656
 
657
                } else {
658
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
659
                }
660
            }).fail(function(jqXHR, textStatus, errorThrown) {
661
                $.fn.showError(textStatus);
662
            });
663
            return false;
4384 eleazar 664
        }
665
    });
16817 efrain 666
 
4384 eleazar 667
    var validatorFormSection = $("#form-section").validate({
16817 efrain 668
        debug: true,
669
        onclick: false,
670
        onkeyup: false,
4384 eleazar 671
        ignore: [],
672
        rules: {
673
            'section-name': {
674
                required: true,
675
                minlength: 2,
676
                maxlength: 50
677
            },
9004 stevensc 678
            'section-text': {
4384 eleazar 679
                required: false,
680
            },
681
        },
682
        submitHandler: function(form) {
683
            // do other things for a valid form
684
            //form.submit();
685
            var slug = $('#form-section #section-slug').val();
686
            if (slug) {
687
                objFormGenerator.editSection(
688
                    $('#form-section #section-slug').val(),
689
                    $('#form-section #section-name').val(),
9004 stevensc 690
                    $('#form-section #section-text').val(),
4384 eleazar 691
                );
692
            } else {
16817 efrain 693
                slug = objFormGenerator.addSection(
4384 eleazar 694
                    $('#form-section #section-name').val(),
9004 stevensc 695
                    $('#form-section #section-text').val()
4384 eleazar 696
                );
697
            }
16817 efrain 698
 
699
            objFormGenerator.renderSection(slug);
4384 eleazar 700
            $('#modal-section').modal('hide');
701
            return false;
702
        }
703
    });
16817 efrain 704
 
4384 eleazar 705
    var validatorFormQuestion = $("#form-question").validate({
16817 efrain 706
        debug: true,
707
        onclick: false,
708
        onkeyup: false,
4384 eleazar 709
        ignore: [],
710
        rules: {
711
            'question-text': {
712
                required: true,
713
            },
714
            'question-type': {
715
                required: true,
716
            },
717
        },
718
        submitHandler: function(form) {
16817 efrain 719
 
4384 eleazar 720
            if ($('#form-question #question-slug').val()) {
721
                objFormGenerator.editQuestion(
722
                    $('#form-question #question-section').val(),
723
                    $('#form-question #question-slug').val(),
724
                    $('#form-question #question-text').val(),
16817 efrain 725
                    $('#form-question #question-type').val()
4384 eleazar 726
                );
727
            } else {
728
                objFormGenerator.addQuestion(
729
                    $('#form-question #question-section').val(),
730
                    $('#form-question #question-text').val(),
16817 efrain 731
                    $('#form-question #question-type').val()
4384 eleazar 732
                );
733
            }
16817 efrain 734
            objFormGenerator.renderSection($('#form-question #question-section').val());
4384 eleazar 735
            $('#modal-question').modal('hide');
736
            return false;
737
        }
738
    });
16817 efrain 739
 
4384 eleazar 740
    var validatorFormOption = $("#form-option").validate({
16817 efrain 741
        debug: true,
742
        onclick: false,
743
        onkeyup: false,
4384 eleazar 744
        ignore: [],
745
        rules: {
746
            'option-text': {
747
                required: true,
748
            }
4546 eleazar 749
 
4384 eleazar 750
        },
751
        submitHandler: function(form) {
752
            if ($('#form-option #option-slug').val()) {
753
                objFormGenerator.editOption(
754
                    $('#form-option #option-section').val(),
755
                    $('#form-option #option-question').val(),
756
                    $('#form-option #option-slug').val(),
6276 eleazar 757
                    $('#form-option #option-text').val()
4384 eleazar 758
                );
759
            } else {
760
                objFormGenerator.addOption(
761
                    $('#form-option #option-section').val(),
762
                    $('#form-option #option-question').val(),
6276 eleazar 763
                    $('#form-option #option-text').val()
4384 eleazar 764
                );
765
            }
16817 efrain 766
            objFormGenerator.renderSection($('#form-option #option-section').val());
4384 eleazar 767
            $('#modal-option').modal('hide');
768
            return false;
769
        }
770
    });
16817 efrain 771
 
4384 eleazar 772
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
773
        e.preventDefault();
774
        validatorFormSection.resetForm();
16817 efrain 775
 
4384 eleazar 776
        $('#form-section #section-slug').val('');
777
        $('#form-section #section-name').val('');
16817 efrain 778
        $('#form-section #section-text').val('');
4384 eleazar 779
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
780
        $('#modal-section').modal('show');
781
    });
16817 efrain 782
 
4384 eleazar 783
    $('body').on('click', 'button.btn-edit-section', function(e) {
784
        e.preventDefault();
785
        var slug = $(this).data('section');
786
        var section;
787
        var showForm = false;
788
        for (i = 0; i < objFormGenerator.sections.length; i++) {
789
            section = objFormGenerator.sections[i];
790
            if (slug == section.slug_section) {
791
                validatorFormSection.resetForm();
792
                $('#form-section #section-slug').val(section.slug_section);
793
                $('#form-section #section-name').val(section.name);
16817 efrain 794
                $('#form-section #section-text').val(section.text);
4384 eleazar 795
                showForm = true;
796
                break;
797
            }
798
        }
799
        if (showForm) {
800
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
801
            $('#modal-section').modal('show');
802
        }
803
    });
16817 efrain 804
 
4384 eleazar 805
    $('body').on('click', 'button.btn-delete-section', function(e) {
806
        e.preventDefault();
807
        var slug = $(this).data('section');
16822 efrain 808
 
809
          swal.fire({
4384 eleazar 810
            title: "LABEL_DELETE LABEL_SECTION",
811
            message: "LABEL_QUESTION_DELETE",
16822 efrain 812
            icon: 'question',
813
            cancelButtonText: 'LABEL_NO',
814
            showCancelButton: true,
815
            confirmButtonText: 'LABEL_YES'
816
          }).then((result) => {
817
            if (result.isConfirmed) {
818
                objFormGenerator.deleteSection(slug);
4384 eleazar 819
            }
820
        });
821
    });
16817 efrain 822
 
4384 eleazar 823
    $('body').on('click', 'button.btn-add-question', function(e) {
824
        e.preventDefault();
825
        validatorFormQuestion.resetForm();
826
        var slug = $(this).data('section');
827
        $('#form-question #question-section').val(slug);
828
        $('#form-question #question-slug').val('');
16817 efrain 829
        $('#form-question #question-text').val('');
4384 eleazar 830
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
831
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
832
        $('#modal-question').modal('show');
833
    });
16817 efrain 834
 
4384 eleazar 835
    $('body').on('click', 'button.btn-edit-question', function(e) {
836
        e.preventDefault();
837
        var slug_section = $(this).data('section');
838
        var slug = $(this).data('question');
839
        var showForm = false;
840
        for (i = 0; i < objFormGenerator.sections.length; i++) {
841
            if (slug_section == objFormGenerator.sections[i].slug_section) {
842
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
843
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
844
                        validatorFormQuestion.resetForm();
845
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
846
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
16817 efrain 847
                        $('#form-question #question-text').val(objFormGenerator.sections[i].questions[j].text);
4384 eleazar 848
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
16817 efrain 849
 
4384 eleazar 850
                        showForm = true;
851
                        break;
852
                    }
853
                }
854
                break;
855
            }
856
        }
857
        if (showForm) {
858
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
859
            $('#modal-question').modal('show');
860
        }
861
    });
16817 efrain 862
 
4384 eleazar 863
    $('body').on('click', 'button.btn-delete-question', function(e) {
864
        e.preventDefault();
865
        var slug_section = $(this).data('section');
866
        var slug = $(this).data('question');
16822 efrain 867
 
868
          swal.fire({
4384 eleazar 869
            title: "LABEL_DELETE LABEL_QUESTION",
870
            message: "LABEL_QUESTION_DELETE",
16822 efrain 871
            icon: 'question',
872
            cancelButtonText: 'LABEL_NO',
873
            showCancelButton: true,
874
            confirmButtonText: 'LABEL_YES'
875
          }).then((result) => {
876
            if (result.isConfirmed) {
4384 eleazar 877
                    objFormGenerator.deleteQuestion(slug_section, slug);
878
            }
879
        });
880
    });
16817 efrain 881
 
4384 eleazar 882
    $('body').on('click', 'button.btn-add-option', function(e) {
883
        e.preventDefault();
884
        var slug_section = $(this).data('section');
885
        var slug_question = $(this).data('question');
886
        var showForm = false;
887
        for (i = 0; i < objFormGenerator.sections.length; i++) {
888
            if (slug_section == objFormGenerator.sections[i].slug_section) {
889
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
890
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
891
                        validatorFormOption.resetForm();
892
                        $('#form-option #option-section').val(slug_section);
893
                        $('#form-option #option-question').val(slug_question);
894
                        $('#form-option #option-slug').val('');
16817 efrain 895
                        $('#form-option #option-text').val('');
896
 
4384 eleazar 897
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
898
                        $('#modal-option').modal('show');
899
                        return true;
900
                    }
901
                }
902
            }
903
        }
904
    });
16817 efrain 905
 
906
 
4384 eleazar 907
    $('body').on('click', 'button.btn-edit-option', function(e) {
908
        e.preventDefault();
909
        var slug_section = $(this).data('section');
910
        var slug_question = $(this).data('question');
911
        var slug = $(this).data('slug');
912
        var showForm = false;
913
        for (i = 0; i < objFormGenerator.sections.length; i++) {
914
            if (slug_section == objFormGenerator.sections[i].slug_section) {
915
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
916
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
917
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
918
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
919
                                validatorFormOption.resetForm();
920
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
921
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
922
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
16817 efrain 923
                                $('#form-option #option-text').val(objFormGenerator.sections[i].questions[j].options[k].text);
4384 eleazar 924
                                showForm = true;
925
                                break;
926
                            }
927
                        }
928
                    }
929
                    if (showForm) {
930
                        break;
931
                    }
932
                }
933
            }
934
            if (showForm) {
935
                break;
936
            }
937
        }
938
        if (showForm) {
939
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
940
            $('#modal-option').modal('show');
941
        }
942
    });
16817 efrain 943
 
944
 
4384 eleazar 945
    $('body').on('click', 'button.btn-delete-option', function(e) {
946
        e.preventDefault();
947
        var slug_section = $(this).data('section');
948
        var slug_question = $(this).data('question');
949
        var slug = $(this).data('slug');
16822 efrain 950
 
951
          swal.fire({
4384 eleazar 952
            title: "LABEL_DELETE LABEL_OPTION",
953
            message: "LABEL_QUESTION_DELETE",
16822 efrain 954
            icon: 'question',
955
            cancelButtonText: 'LABEL_NO',
956
            showCancelButton: true,
957
            confirmButtonText: 'LABEL_YES'
958
          }).then((result) => {
959
            if (result.isConfirmed) {
960
 
4384 eleazar 961
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
16822 efrain 962
 
4384 eleazar 963
            }
964
        });
965
    })
16817 efrain 966
 
967
 
4384 eleazar 968
    $('button.btn-add-form').click(function(e) {
969
        e.preventDefault();
970
        objFormGenerator.clear();
971
        objFormGenerator.render();
972
        validatorForm.resetForm();
16817 efrain 973
 
4384 eleazar 974
        $('#form-main').attr('action', '$routeAdd');
975
        $('#form-main #form-continue').val('0');
4459 eleazar 976
        $('#form-main #name').val('');
16817 efrain 977
        $('#form-main #status').bootstrapToggle('on')
978
        $('#form-main #text').val('');
4384 eleazar 979
        $('#row-forms').hide();
980
        $('#row-edit').show();
4459 eleazar 981
        $('#form-main #name').focus();
16817 efrain 982
 
4384 eleazar 983
    });
16817 efrain 984
 
985
    $('#btn-edit-cancel').click(function(e) {
4384 eleazar 986
        e.preventDefault();
16817 efrain 987
 
988
         tableForm.api().ajax.reload(null, false);
989
 
4384 eleazar 990
        $('#row-edit').hide();
991
        $('#row-forms').show();
16817 efrain 992
 
993
 
4384 eleazar 994
    });
16817 efrain 995
 
996
 
16943 efrain 997
    $('button.btn-cancel').click(function(e) {
998
        e.preventDefault();
999
        $('modal-section').modal('hide');
1000
        $('#modal-question').modal('hide');
1001
        $('#modal-option').modal('hide');
1002
 
1003
    });
1004
 
16817 efrain 1005
    $('#btn-form-save-continue').click(function(e) {
8365 eleazar 1006
        e.preventDefault();
1007
        $('#form-main #form-continue').val('1')
8366 eleazar 1008
        $('#form-main').submit();
4384 eleazar 1009
    });
16817 efrain 1010
 
1011
 
1012
    $('#btn-form-save-close').click(function(e) {
4384 eleazar 1013
        e.preventDefault();
16817 efrain 1014
 
4384 eleazar 1015
        $('#form-main #form-continue').val('0')
1016
        $('#form-main').submit();
1017
    });
8364 eleazar 1018
 
1019
 
4384 eleazar 1020
    $('#modal-section, #modal-question, #modal-option').modal({
1021
        backdrop: 'static',
1022
        keyboard: false,
1023
        show: false
1024
    });
1025
 
1026
    $('button.btn-refresh').click(function(e) {
16817 efrain 1027
        tableForm.api().ajax.reload(null, false);
4384 eleazar 1028
    });
4466 eleazar 1029
 
16822 efrain 1030
 $('body').on('click', 'button.btn-delete', function(e) {
1031
        e.preventDefault();
1032
        var action = $(this).data('href');
14208 stevensc 1033
 
16822 efrain 1034
 
1035
          swal.fire({
1036
            title: 'LABEL_ARE_YOU_SURE',
1037
            icon: 'question',
1038
            cancelButtonText: 'LABEL_NO',
1039
            showCancelButton: true,
1040
            confirmButtonText: 'LABEL_YES'
1041
          }).then((result) => {
1042
            if (result.isConfirmed) {
1043
 
1044
                    NProgress.start();
1045
                    $.ajax({
1046
                        'dataType'  : 'json',
1047
                        'accept'    : 'application/json',
1048
                        'method'    : 'post',
1049
                        'url'       :  action,
1050
                    }).done(function(response) {
1051
                        if(response['success']) {
1052
                            $.fn.showSuccess(response['data']);
1053
                            gridTable.api().ajax.reload(null, false);
1054
                        } else {
1055
                            $.fn.showError(response['data']);
1056
                        }
1057
                    }).fail(function( jqXHR, textStatus, errorThrown) {
1058
                        $.fn.showError(textStatus);
1059
                    }).always(function() {
1060
                        NProgress.done();
1061
                    });
1062
            }
1063
       });
1064
    });
1065
 
1066
 
16817 efrain 1067
 
1068
    $('#form-main #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
1069
 
4384 eleazar 1070
});
1071
JS;
1072
$this->inlineScript()->captureEnd();
1073
?>
1074
 
16864 efrain 1075
<div class="container">
1076
	<div class="card" id="row-forms">
1077
	 	<div class="card-header">
1078
	 		<h6 class="card-title">LABEL_FORM_BUILDER</h6>
1079
	 	</div>
1080
	 	<div class="card-body">
1081
 
1082
 
1083
	 		<div class="row">
1084
	 	         <div class="col-12 mt-3">
1085
	 	         	<table id="tableForm" class="table   table-bordered">
4384 eleazar 1086
                            <thead>
1087
                                <tr>
1088
                                    <th>LABEL_NAME</th>
1089
                                    <th>LABEL_ACTIVE</th>
1090
                                    <th>LABEL_ACTIONS</th>
1091
                                </tr>
1092
                            </thead>
1093
                            <tbody></tbody>
1094
                        </table>
16864 efrain 1095
 
1096
	 	         </div>
1097
	 	     </div>
1098
	 	</div>
1099
	 	<div class="card-footer text-right">
16992 efrain 1100
			<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
16864 efrain 1101
   			<?php if ($allowAdd) : ?>
1102
          	<button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1103
      		<?php endif; ?>
1104
	 	</div>
1105
	</div>
1106
 
1107
 
1108
	<div class="card" id="row-edit" style="display: none">
1109
	 	<div class="card-header">
1110
	 		<h6 class="card-title">LABEL_FORM</h6>
1111
	 	</div>
1112
	 	<form name="form-main" id="form-main">
1113
        	<input type="hidden" name="form-continue" id="form-continue" value="0" />
1114
	 	<div class="card-body">
4384 eleazar 1115
 
16864 efrain 1116
		 	<div class="row">
1117
		 		<div class="col-12 mt-3">
4450 eleazar 1118
                    <?php
1119
                    $element = $form->get('name');
16817 efrain 1120
                    $element->setOptions(['label' => 'LABEL_NAME']);
4450 eleazar 1121
                    $element->setAttributes(['class' => 'form-control']);
1122
                    echo $this->formLabel($element);
1123
                    echo $this->formText($element);
1124
                    ?>
4384 eleazar 1125
                </div>
16864 efrain 1126
            </div>
16817 efrain 1127
 
16864 efrain 1128
		 	<div class="row">
1129
		 		<div class="col-12 mt-3">
14208 stevensc 1130
                    <?php
1131
                    $element = $form->get('text');
1132
                    $element->setOptions(['label' => 'LABEL_TEXT']);
1133
                    $element->setAttributes(['class' => 'form-control']);
1134
                    echo $this->formLabel($element);
1135
                    echo $this->formTextArea($element);
1136
                    ?>
4384 eleazar 1137
                </div>
16864 efrain 1138
            </div>
1139
		 	<div class="row">
1140
		 		<div class="col-12 mt-3">
14208 stevensc 1141
                    <?php
1142
                    $element = $form->get('status');
1143
                    $element->setAttributes(['class' => 'form-control']);
1144
                    $element->setOptions(['label' => 'LABEL_STATUS']);
1145
                    echo $this->formLabel($element);
16817 efrain 1146
                    echo '<br>';
1147
                    echo $this->formCheckbox($element);
14208 stevensc 1148
                    ?>
1149
                </div>
16864 efrain 1150
            </div>
1151
 
1152
		 	<div class="row">
1153
		 		<div class="col-12 mt-3 text-right">
1154
      				<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 1155
                </div>
16864 efrain 1156
            </div>
1157
		 	<div class="row">
1158
		 		<div class="col-12 mt-3">
1159
             		<div class="panel-group" id="containter-sections"></div>
1160
           		</div>
1161
           	</div>
1162
	 	</div>
1163
	 	<div class="card-footer text-right">
1164
	 	  	<button type="button" id="btn-form-save-continue" class="btn btn-info ">LABEL_SAVE & LABEL_CONTINUE</button>
1165
         	<button type="button" id="btn-form-save-close" class="btn btn-primary ">LABEL_SAVE & LABEL_CLOSE</button>
1166
      		<button type="button" id="btn-edit-cancel" class="btn btn-light ">LABEL_CANCEL</button>
1167
	 	</div>
1168
	 	</form>
1169
	</div>
1170
</div>
4384 eleazar 1171
 
16864 efrain 1172
 
1173
 
4384 eleazar 1174
    <!-- Create/Edit Form-->
1175
 
1176
    <!-- Section Modal -->
14208 stevensc 1177
    <div id="modal-section" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1178
        <div class="modal-dialog modal-lg" role="document">
1179
            <form action="#" name="form-section" id="form-section">
1180
                <input type="hidden" name="section-slug" id="section-slug" value="" />
1181
                <div class="modal-content">
1182
                    <div class="modal-header">
16845 efrain 1183
                        <h6 class="modal-title">LABEL_ADD LABEL_SECTION</h6>
16864 efrain 1184
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1185
 
4384 eleazar 1186
                    </div>
1187
                    <div class="modal-body">
16864 efrain 1188
		 				<div class="row">
1189
		 					<div class="col-12 mt-3">
4384 eleazar 1190
                            <label for="section-name">LABEL_FIRST_NAME</label>
1191
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
16864 efrain 1192
                        	</div>
1193
                        </div>
1194
		 				<div class="row">
1195
		 					<div class="col-12 mt-3">
9004 stevensc 1196
                            <label for="section-text">LABEL_TEXT</label>
8981 stevensc 1197
                            <!--  ckeditor -->
14208 stevensc 1198
                            <textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
16864 efrain 1199
                        	</div>
1200
                        </div>
4384 eleazar 1201
                    </div>
16891 efrain 1202
                    <div class="modal-footer text-right">
4384 eleazar 1203
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
16943 efrain 1204
                        <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
4384 eleazar 1205
                    </div>
1206
                </div>
1207
            </form>
1208
        </div>
1209
    </div>
1210
    <!-- End Modal Section -->
1211
 
1212
    <!-- Question Modal -->
1213
 
14208 stevensc 1214
    <div id="modal-question" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1215
        <div class="modal-dialog modal-lg" role="document">
1216
            <form action="#" name="form-question" id="form-question">
1217
                <input type="hidden" name="question-section" id="question-section" />
1218
                <input type="hidden" name="question-slug" id="question-slug" />
1219
                <div class="modal-content">
1220
                    <div class="modal-header">
16845 efrain 1221
                        <h6 class="modal-title">LABEL_ADD LABEL_QUESTION</h6>
16864 efrain 1222
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
4384 eleazar 1223
                    </div>
1224
                    <div class="modal-body">
16864 efrain 1225
		 				<div class="row">
1226
		 					<div class="col-12 mt-3">
4384 eleazar 1227
                            <label for="question-text">LABEL_TEXT</label>
1228
                            <!--  ckeditor -->
14208 stevensc 1229
                            <textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
16864 efrain 1230
                        	</div>
1231
                        </div>
1232
		 				<div class="row">
1233
		 					<div class="col-12 mt-3">
4384 eleazar 1234
                            <label for="question-type">LABEL_TYPE</label>
1235
                            <select name="question-type" id="question-type" class="form-control">
16817 efrain 1236
                                <option value="simple">LABEL_SINGLE_SELECTION</option>
1237
                                <option value="multiple">LABEL_MULTIPLE_SELECTION</option>
1238
                                <option value="range1to5">LABEL_RANGE_1_5</option>
14208 stevensc 1239
 
4384 eleazar 1240
                            </select>
16864 efrain 1241
                        	</div>
1242
                        </div>
4384 eleazar 1243
                    </div>
16891 efrain 1244
                    <div class="modal-footer text-right">
4384 eleazar 1245
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
16943 efrain 1246
                        <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
4384 eleazar 1247
                    </div>
1248
                </div>
1249
            </form>
1250
        </div>
1251
    </div>
1252
 
1253
    <!-- End Modal Question -->
1254
 
1255
    <!-- Modal Options -->
1256
 
14208 stevensc 1257
    <div id="modal-option" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1258
        <div class="modal-dialog modal-lg" role="document">
1259
            <form action="#" name="form-option" id="form-option">
1260
                <input type="hidden" name="option-section" id="option-section" value="" />
1261
                <input type="hidden" name="option-question" id="option-question" value="" />
1262
                <input type="hidden" name="option-slug" id="option-slug" value="" />
1263
                <div class="modal-content">
1264
                    <div class="modal-header">
16845 efrain 1265
                        <h6 class="modal-title">LABEL_OPTION</h6>
16864 efrain 1266
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
4384 eleazar 1267
                    </div>
1268
                    <div class="modal-body">
16864 efrain 1269
		 				<div class="row">
1270
		 					<div class="col-12 mt-3">
4384 eleazar 1271
                            <label for="option-text">LABEL_TEXT</label>
1272
                            <!--  ckeditor -->
14208 stevensc 1273
                            <textarea name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
16864 efrain 1274
                        	</div>
4384 eleazar 1275
                        </div>
1276
                    </div>
16891 efrain 1277
                    <div class="modal-footer text-right">
4384 eleazar 1278
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
16943 efrain 1279
                        <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
4384 eleazar 1280
                    </div>
1281
                </div>
1282
            </form>
1283
        </div>
1284
    </div>
1285
 
1286
 
16817 efrain 1287
 
1288
 
16864 efrain 1289
 
16817 efrain 1290
 
4384 eleazar 1291
    <!---Template Sections --->
16817 efrain 1292
    <script id="sectionTemplateReplace" type="text/x-jsrender">
1293
 
4384 eleazar 1294
        <div class="panel-heading">
16845 efrain 1295
            <h6 class="panel-title">
4384 eleazar 1296
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1297
                    <span class="section-name{{:slug_section}}">
1298
                        {{:name}}
1299
                    </span>
1300
                </a>
16845 efrain 1301
            </h6>
4384 eleazar 1302
        </div>
1303
        <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
1304
            <div class="panel-body">
1305
                <div class="table-responsive">
1306
                    <table class="table table-bordered">
1307
                        <thead>
1308
                            <tr>
1309
                                <th style="width: 10%;">LABEL_ELEMENT</th>
1310
                                <th style="width: 50%;">LABEL_TEXT</th>
1311
                                <th style="width: 10%;">LABEL_TYPE</th>
1312
                                <th style="width: 20%;">LABEL_ACTIONS</th>
1313
                            </tr>
1314
                        </thead>
1315
                        <tbody>
1316
                            <tr class="tr-section">
1317
                                <td class="text-left">LABEL_SECTION</td>
1318
                                <td class="text-left">{{:name}}</td>
1319
                                <td></td>
1320
                                <td>
1321
                                    <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>
1322
                                    <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>
1323
                                    <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>
1324
                                </td>
1325
                            </tr>
1326
                            {{for questions}}
16817 efrain 1327
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
4384 eleazar 1328
                                <td class="text-left">--LABEL_QUESTION</td>
1329
                                <td class="text-left">
16817 efrain 1330
                                    {{:text}}
4384 eleazar 1331
                                </td>
1332
                                <td class="text-capitalize">
1333
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
16817 efrain 1334
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
1335
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
1336
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
4384 eleazar 1337
                                </td>
1338
                                <td>
1339
                                    <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>
1340
                                    <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>
1341
 
16817 efrain 1342
                                    {{if type == 'simple' ||  type=='multiple' }}
4384 eleazar 1343
                                    <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>
1344
                                    {{/if}}
1345
 
1346
                                </td>
1347
                            </tr>
1348
                            {{for options}}
16817 efrain 1349
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
4384 eleazar 1350
                                <td class="text-left">---LABEL_OPTION</td>
1351
                                <td class="text-left">
16817 efrain 1352
                                    {{:text}}
4384 eleazar 1353
                                </td>
1354
                                <td>
16817 efrain 1355
                                    &nbsp;
1356
                                </td>
1357
                                <td>
1358
                                    <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>
1359
                                    <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>
1360
                                </td>
1361
                            </tr>
1362
                            {{/for}}
1363
                            {{/for}}
1364
                        </tbody>
1365
                    </table>
1366
                </div>
1367
            </div>
1368
        </div>
4384 eleazar 1369
 
16817 efrain 1370
    </script>
1371
 
1372
    <!---Template Sections --->
1373
    <script id="sectionTemplateAdd" type="text/x-jsrender">
1374
    <div class="panel panel-default" id="panel-{{:slug_section}}">
1375
        <div class="panel-heading">
16845 efrain 1376
            <h6 class="panel-title">
16817 efrain 1377
                <a class="d-block w-100 collapsed card-primary" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1378
                    <i class="fa" aria-hidden="true"></i>
1379
                    <span class="section-name{{:slug_section}}">
1380
                        {{:name}}
1381
                    </span>
1382
                </a>
16845 efrain 1383
            </h6>
16817 efrain 1384
        </div>
1385
        <div id="collapse-{{:slug_section}}" class="collapse show" data-parent="panel-{{:slug_section}}" style="">
1386
            <div class="panel-body">
1387
                <div class="table-responsive">
1388
                    <table class="table table-bordered">
1389
                        <thead>
1390
                            <tr>
1391
                                <th style="width: 10%;">LABEL_ELEMENT</th>
1392
                                <th style="width: 50%;">LABEL_TEXT</th>
1393
                                <th style="width: 10%;">LABEL_TYPE</th>
1394
                                <th style="width: 20%;">LABEL_ACTIONS</th>
1395
                            </tr>
1396
                        </thead>
1397
                        <tbody>
1398
                            <tr class="tr-section">
1399
                                <td class="text-left">LABEL_SECTION</td>
1400
                                <td class="text-left">{{:name}}</td>
1401
                                <td></td>
1402
                                <td>
1403
                                    <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>
1404
                                    <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>
1405
                                    <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>
1406
                                </td>
1407
                            </tr>
1408
                            {{for questions}}
1409
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
1410
                                <td class="text-left">--LABEL_QUESTION</td>
1411
                                <td class="text-left">
1412
                                    {{:text}}
1413
                                </td>
1414
                                <td class="text-capitalize">
1415
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1416
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
1417
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
1418
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
1419
                                </td>
1420
                                <td>
1421
                                    <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>
1422
                                    <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>
1423
 
1424
                                    {{if type == 'simple' || type=='multiple' }}
1425
                                    <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 1426
                                    {{/if}}
16817 efrain 1427
 
4384 eleazar 1428
                                </td>
16817 efrain 1429
                            </tr>
1430
                            {{for options}}
1431
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
1432
                                <td class="text-left">---LABEL_OPTION</td>
1433
                                <td class="text-left">
1434
                                    {{:text}}
1435
                                </td>
4384 eleazar 1436
                                <td>
16817 efrain 1437
                                    &nbsp;
1438
                                </td>
1439
                                <td>
4384 eleazar 1440
                                    <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>
1441
                                    <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>
1442
                                </td>
1443
                            </tr>
1444
                            {{/for}}
1445
                            {{/for}}
1446
                        </tbody>
1447
                    </table>
1448
                </div>
1449
            </div>
1450
        </div>
1451
    </div>
1452
 
16817 efrain 1453
    </script>