Proyectos de Subversion LeadersLinked - Backend

Rev

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