Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 14212 | Rev 16817 | 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
 
16
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
17
 
18
 
19
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
21
 
22
 
23
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
24
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
26
 
27
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
28
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
29
 
30
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
34
 
35
 
36
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
38
 
39
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
40
 
41
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
42
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
44
 
45
 
46
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
47
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
48
 
49
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
50
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
51
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
52
 
53
// bootbox Alert //
54
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
55
 
56
// JsRender //
57
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
58
 
59
// 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
 
65
$this->inlineScript()->captureStart();
66
echo <<<JS
67
    const classFormGenerator = function() {
68
    this.id = 0,
69
        this.table = '',
70
        this.name = '',
71
        this.text = '',
72
        this.status = 'a',
73
        this.sections = [],
74
        this.clear = function() {
75
            this.sections = [];
76
            this.render();
77
        },
78
        /**
79
         * Render array sections
80
         */
81
        this.renderSection = function(slug_section) {
82
            var s = '';
83
            for (i = 0; i < this.sections.length; i++) {
84
                if (slug_section != this.sections[i].slug_section) {
85
                    continue;
86
                }
87
                for (j = 0; j < this.sections[i].questions.length; j++) {
88
                    this.sections[i].questions[j].position = j;
6467 eleazar 89
                    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 90
                        this.sections[i].questions[j].options.sort(function(a, b) {
91
                            if (a.position > b.position) {
92
                                return 1;
93
                            }
94
                            if (a.position < b.position) {
95
                                return -1;
96
                            }
97
                            return 0;
98
                        });
99
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
100
                            this.sections[i].questions[j].options[k].position = j;
101
                        }
102
                    }
103
                }
104
            }
105
            $('[data-toggle="tooltip"]').tooltip();
106
        },
107
        this.render = function() {
108
            this.sections.sort(function(a, b) {
109
                if (a.position > b.position) {
110
                    return 1;
111
                }
112
                if (a.position < b.position) {
113
                    return -1;
114
                }
115
                return 0;
116
            });
117
            var s = '';
118
            for (i = 0; i < this.sections.length; i++) {
119
                this.sections[i].position = i;
120
                this.sections[i].questions.sort(function(a, b) {
121
                    if (a.position > b.position) {
122
                        return 1;
123
                    }
124
                    if (a.position < b.position) {
125
                        return -1;
126
                    }
127
                    return 0;
128
                });
129
                for (j = 0; j < this.sections[i].questions.length; j++) {
130
                    this.sections[i].questions[j].position = j;
6467 eleazar 131
                    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 132
                        this.sections[i].questions[j].options.sort(function(a, b) {
133
                            if (a.position > b.position) {
134
                                return 1;
135
                            }
136
                            if (a.position < b.position) {
137
                                return -1;
138
                            }
139
                            return 0;
140
                        });
141
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
142
                            this.sections[i].questions[j].options[k].position = j;
143
                        }
144
                    }
145
                }
146
            }
147
            $('[data-toggle="tooltip"]').tooltip();
148
        },
149
        /**
150
         * Add element to section array
151
         */
4546 eleazar 152
        this.addSection = function(name, text) {
4384 eleazar 153
            var d = new Date();
154
            var slug = 'section' + d.getTime();
155
            var position = 0;
156
            $.each(this.sections, function(index, section) {
157
                if (position < section.position) {
158
                    position = section.position;
159
                }
160
            });
161
            position++;
162
            var section = {
163
                'slug_section': slug,
164
                'name': name,
165
                'text': text,
166
                'position': position,
167
                'questions': [],
168
                'status': 0
169
            }
170
            this.sections.push(section);
171
        },
172
         /**
173
         * Edit element to section array
174
         */
4546 eleazar 175
        this.editSection = function(slug, name, text) {
4384 eleazar 176
            var renderTable = false;
177
            for (i = 0; i < this.sections.length; i++) {
178
                if (slug == this.sections[i].slug_section) {
179
                    this.sections[i].name = name;
180
                    this.sections[i].text = text;
181
                    renderTable = true;
182
                    break;
183
                }
184
            }
185
            if (renderTable) {
186
                this.renderSection(slug);
187
            }
188
        },
189
         /**
190
         * Remove element to section array
191
         */
192
        this.deleteSection = function(slug) {
193
            var renderTable = false;
194
            for (i = 0; i < this.sections.length; i++) {
195
                if (slug == this.sections[i].slug_section) {
196
                    this.sections.splice(i, 1);
197
                    renderTable = true;
198
                    break;
199
                }
200
            }
201
            if (renderTable) {
202
                $('#panel' + slug).remove();
203
            }
204
        },
205
         /**
206
         * Add element to question array
207
         */
6467 eleazar 208
        this.addQuestion = function(slug_section, text, type, maxlength, multiline, range) {
4384 eleazar 209
            var d = new Date();
210
            var slug_question = 'question' + d.getTime();
211
            var position = 0;
212
            var renderTable = false;
213
            for (i = 0; i < this.sections.length; i++) {
214
                if (slug_section == this.sections[i].slug_section) {
215
                    $.each(this.sections[i].questions, function(index, question) {
216
                        if (position < question.position) {
217
                            position = question.position;
218
                        }
219
                    });
220
                    position++;
221
                    var question = {
222
                        'slug_section': slug_section,
223
                        'slug_question': slug_question,
224
                        'text': text,
225
                        'type': type,
226
                        'position': position,
227
                        'maxlength': maxlength,
228
                        'multiline': multiline,
6467 eleazar 229
                        'range': range,
4384 eleazar 230
                        'options': [],
231
                        'answer': type=='multiple' ? [] : ''
232
                    }
233
                    this.sections[i].questions.push(question);
234
                    renderTable = true;
235
                    break;
236
                }
237
            }
238
            if (renderTable) {
239
                this.renderSection(slug_section);
240
            }
241
        },
242
         /**
243
         * Add element to question array
244
         */
6467 eleazar 245
        this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline, range) {
4384 eleazar 246
            var renderTable = false;
247
            for (i = 0; i < this.sections.length; i++) {
248
                if (slug_section == this.sections[i].slug_section) {
249
                    for (j = 0; j < this.sections[i].questions.length; j++) {
250
                        if (slug_question == this.sections[i].questions[j].slug_question) {
251
                            this.sections[i].questions[j].text = text,
252
                                this.sections[i].questions[j].type = type;
253
                            if (type == 'open') {
254
                                this.sections[i].questions[j].maxlength = maxlength;
255
                                this.sections[i].questions[j].multiline = multiline;
256
                                this.sections[i].questions[j].options = [];
257
                            } else {
258
                                this.sections[i].questions[j].maxlength = 0;
259
                                this.sections[i].questions[j].multiline = 0;
260
                            }
6467 eleazar 261
                            if (type == 'rating-range') {
262
                                this.sections[i].questions[j].range = range;
263
                            } else {
264
                                this.sections[i].questions[j].range = 0;
265
                            }
4384 eleazar 266
 
267
                            if(type=='multiple'){
268
                                this.sections[i].questions[j].answer = [];
269
                            }else{
270
                                this.sections[i].questions[j].answer = '';
271
                            }
272
 
273
                            renderTable = true;
274
                            break;
275
                        }
276
                    }
277
                }
278
                if (renderTable) {
279
                    break;
280
                }
281
            }
282
            if (renderTable) {
283
                this.renderSection(slug_section);
284
            }
285
        },
286
        /**
287
         * Remove element to question array
288
         */
289
        this.deleteQuestion = function(slug_section, slug_question) {
290
            var renderTable = false;
291
            for (i = 0; i < this.sections.length; i++) {
292
                if (slug_section == this.sections[i].slug_section) {
293
                    for (j = 0; j < this.sections[i].questions.length; j++) {
294
                        if (slug_question == this.sections[i].questions[j].slug_question) {
295
                            this.sections[i].questions.splice(j, 1);
296
                            renderTable = true;
297
                            break;
298
                        }
299
                    }
300
                }
301
                if (renderTable) {
302
                    break;
303
                }
304
            }
305
            if (renderTable) {
306
                this.renderSection(slug_section);
307
            }
308
        },
309
        /**
310
         * Add element to option array
311
         */
6276 eleazar 312
        this.addOption = function(slug_section, slug_question, text) {
4384 eleazar 313
            var d = new Date();
314
            var slug_option = 'option' + d.getTime();
315
            var position = 0;
316
            var renderTable = false;
317
            for (i = 0; i < this.sections.length; i++) {
318
                if (slug_section == this.sections[i].slug_section) {
319
                    for (j = 0; j < this.sections[i].questions.length; j++) {
320
                        if (slug_question == this.sections[i].questions[j].slug_question) {
321
                            $.each(this.sections[i].questions[j].options, function(index, option) {
322
                                if (position < option.position) {
323
                                    position = option.position;
324
                                }
325
                            });
326
                            position++;
327
                            var option = {
328
                                'slug_section': slug_section,
329
                                'slug_question': slug_question,
330
                                'slug_option': slug_option,
331
                                'text': text,
332
                                'checked': false
333
                            }
334
                            this.sections[i].questions[j].options.push(option);
335
                            renderTable = true;
336
                            break;
337
                        }
338
                        if (renderTable) {
339
                            break;
340
                        }
341
                    }
342
                }
343
            }
344
            if (renderTable) {
345
                this.renderSection(slug_section);
346
            }
347
        },
348
        /**
349
         * Edit element to option array
350
         */
6276 eleazar 351
        this.editOption = function(slug_section, slug_question, option_slug, text) {
4384 eleazar 352
            var renderTable = false;
353
            for (i = 0; i < this.sections.length; i++) {
354
                if (slug_section == this.sections[i].slug_section) {
355
                    for (j = 0; j < this.sections[i].questions.length; j++) {
356
                        if (slug_question == this.sections[i].questions[j].slug_question) {
357
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
358
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
359
                                    this.sections[i].questions[j].options[k].text = text;
360
                                    renderTable = true;
361
                                    break;
362
                                }
363
                            }
364
                        }
365
                        if (renderTable) {
366
                            break;
367
                        }
368
                    }
369
                }
370
                if (renderTable) {
371
                    break;
372
                }
373
            }
374
            if (renderTable) {
375
                this.renderSection(slug_section);
376
            }
377
        },
378
        /**
379
         * Remove element to option array
380
         */
381
        this.deleteOption = function(slug_section, slug_question, option_slug) {
382
            var renderTable = false;
383
            for (i = 0; i < this.sections.length; i++) {
384
                if (slug_section == this.sections[i].slug_section) {
385
                    for (j = 0; j < this.sections[i].questions.length; j++) {
386
                        if (slug_question == this.sections[i].questions[j].slug_question) {
387
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
388
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
389
                                    this.sections[i].questions[j].options.splice(k, 1);
390
                                    renderTable = true;
391
                                    break;
392
                                }
393
                            }
394
                        }
395
                        if (renderTable) {
396
                            break;
397
                        }
398
                    }
399
                }
400
                if (renderTable) {
401
                    break;
402
                }
403
            }
404
            if (renderTable) {
405
                this.renderSection(slug_section);
406
            }
407
        }
408
}
409
 
410
function htmlEntities(str) {
411
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
412
}
413
jQuery(document).ready(function($) {
414
    var objFormGenerator = new classFormGenerator();
415
    objFormGenerator.render();
416
    var allowEdit = $allowEdit;
417
    var allowDelete = $allowDelete;
418
    /**
419
     * Get rows and set data table
420
     */
421
    var tableForm = $('#gridTable').dataTable({
422
        'processing': true,
423
        'serverSide': true,
424
        'searching': true,
425
        'order': [
426
            [0, 'asc']
427
        ],
428
        'ordering': true,
429
        'ordenable': true,
430
        'responsive': true,
431
        'select': false,
432
        'paging': true,
433
        'pagingType': 'simple_numbers',
434
        'ajax': {
435
            'url': '$routeDatatable',
436
            'type': 'get',
437
            'beforeSend': function(request) {
438
                NProgress.start();
439
            },
440
            'dataFilter': function(response) {
441
                var response = jQuery.parseJSON(response);
442
                var json = {};
443
                json.recordsTotal = 0;
444
                json.recordsFiltered = 0;
445
                json.data = [];
446
                if (response.success) {
447
                    json.recordsTotal = response.data.total;
448
                    json.recordsFiltered = response.data.total;
449
                    json.data = response.data.items;
450
                } else {
451
                    $.fn.showError(response.data)
452
                }
453
                return JSON.stringify(json);
454
            }
455
        },
456
        'language': {
457
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
458
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
459
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
460
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
461
            'sInfo': 'LABEL_DATATABLE_SINFO',
462
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
463
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
464
            'sInfoPostFix': '',
465
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
466
            'sUrl': '',
467
            'sInfoThousands': ',',
468
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
469
            'oPaginate': {
470
                'sFirst': 'LABEL_DATATABLE_SFIRST',
471
                'sLast': 'LABEL_DATATABLE_SLAST',
472
                'sNext': 'LABEL_DATATABLE_SNEXT',
473
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
474
            },
475
            'oAria': {
476
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
477
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
478
            },
479
        },
480
        'drawCallback': function(settings) {
481
            NProgress.done();
482
            $('button.btn-delete').confirmation({
483
                rootSelector: 'button.btn-delete',
484
                title: 'LABEL_ARE_YOU_SURE',
485
                singleton: true,
486
                btnOkLabel: 'LABEL_YES',
487
                btnCancelLabel: 'LABEL_NO',
488
                onConfirm: function(value) {
489
                    action = $(this).data('href');
490
                    NProgress.start();
491
                    $.ajax({
492
                        'dataType': 'json',
493
                        'accept': 'application/json',
494
                        'method': 'post',
495
                        'url': action,
496
                    }).done(function(response) {
497
                        if (response['success']) {
498
                            $.fn.showSuccess(response['data']);
499
                            tableForm.fnDraw();
500
                        } else {
501
                            $.fn.showError(response['data']);
502
                        }
503
                    }).fail(function(jqXHR, textStatus, errorThrown) {
504
                        $.fn.showError(textStatus);
505
                    }).always(function() {
506
                        NProgress.done();
507
                    });
508
                },
509
            });
510
        },
511
        'aoColumns': [{
512
                'mDataProp': 'name'
513
            },
514
            {
515
                'mDataProp': 'status'
516
            },
517
            {
518
                'mDataProp': 'actions'
519
            },
520
        ],
521
        'columnDefs': [{
522
                'targets': 0,
523
                'className': 'text-vertical-middle',
524
            },
525
            {
526
                'targets': 1,
527
                'className': 'text-vertical-middle',
528
            },
529
            {
530
                'targets': -2,
531
                'orderable': false,
532
                'className': 'text-center',
533
                'render': function(data, type, row) {
8303 eleazar 534
                    checked = data == 'A' ? ' checked="checked" ' : '';
4384 eleazar 535
                    return '<div class="checkbox checkbox-success">' +
536
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
537
                        '<label ></label></div>';
538
                }
539
            },
540
            {
541
                'targets': -1,
542
                'orderable': false,
543
                'render': function(data, type, row) {
544
                    s = '';
545
                    if (allowEdit) {
546
                        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;';
547
                    }
548
                    if (allowDelete) {
549
                        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;';
550
                    }
551
                    return s;
552
                }
553
            }
554
        ],
555
    });
556
    /**
557
     * Clicked on edit form
558
     */
559
    $('body').on('click', 'button.btn-edit-form', function(e) {
560
        e.preventDefault();
561
        form_id = $(this).data('id')
562
        var action = $(this).data('href');
563
        $.ajax({
564
            'dataType': 'json',
565
            'accept': 'application/json',
566
            'method': 'get',
567
            'url': action,
568
        }).done(function(response) {
569
            if (response['success']) {
570
                validatorForm.resetForm();
571
                $('#form-main').attr('action', action);
572
                $('#form-main #form-id').val(response['data']['id']),
573
                $('#form-main #form-continue').val('0');
4459 eleazar 574
                $('#form-main #name').val(response['data']['name']),
4384 eleazar 575
 
576
                /*----------Set Ckeditor ------------*/
4466 eleazar 577
                CKEDITOR.instances.description.setData(response['data']['description']);
578
                CKEDITOR.instances.text.setData(response['data']['text']);
4384 eleazar 579
 
4493 eleazar 580
                $('#form-main #status').val(response['data']['status']);
4384 eleazar 581
 
582
                /*-------------Render Sections -------*/
583
 
584
                objFormGenerator.clear();
585
                objFormGenerator.sections = response['data']['content'] || [];
586
                objFormGenerator.render();
587
                renderSectionData(objFormGenerator.sections);
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
    $(document).on('click', '[data-type="select_all"]', function() {
601
        if ($('input[name="select_all"]:checked').val() == 'all') {
602
            $('[data-type="select"]').prop('checked', true);
603
            $('[data-action="delete"]').removeClass('hide');
604
        } else {
605
            $('[data-type="select"]').prop('checked', false);
606
            $('[data-action="delete"]').addClass('hide');
607
        }
608
    });
609
 
610
    function getLength() {
611
        return $('[data-type="select"]').length;
612
    }
613
 
614
    function currentSelected() {
615
        var selected = [];
616
        $.each($("input[name='select[]']:checked"), function() {
617
            selected.push($(this).val());
618
        });
619
        return selected;
620
    }
621
    $(document).on('change', "input[name='select[]']", function() {
622
        var c = currentSelected();
623
        var cc = getLength();
624
        if (c.length == cc) {
625
            if ($('[data-action="delete"]').hasClass('hide')) {
626
                $('[data-action="delete"]').removeClass('hide');
627
            }
628
            return true;
629
        } else {
630
            $('input[name="select_all"]').prop('checked', false);
631
        }
632
        if (c.length > 0) {
633
            if ($('[data-action="delete"]').hasClass('hide')) {
634
                $('[data-action="delete"]').removeClass('hide');
635
            }
636
        } else {
637
            if (!$('[data-action="delete"]').hasClass('hide')) {
638
                $('[data-action="delete"]').addClass('hide');
639
            }
640
        }
641
    });
642
    var form3 = $('#form_sample_3');
643
    var error3 = $('.alert-danger', form3);
644
    var success3 = $('.alert-success', form3);
645
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
646
    $("#form-main").on('submit', function() {
647
        for (var instanceName in CKEDITOR.instances) {
648
            CKEDITOR.instances[instanceName].updateElement();
649
        }
650
    })
651
    /**
652
     * Validate rules form
653
     */
654
    var validatorForm = $("#form-main").validate({
655
        ignore: [],
656
        errorClass: 'help-block',
657
        errorElement: 'span',
658
        rules: {
659
            'form-name': {
660
                required: true,
661
                minlength: 2,
662
                maxlength: 50
663
            },
4466 eleazar 664
            'description':{
665
                updateCkeditor:function() {
666
                    CKEDITOR.instances.description.updateElement();
667
                },
4384 eleazar 668
            },
4466 eleazar 669
            'text':{
670
                updateCkeditor:function() {
671
                    CKEDITOR.instances.text.updateElement();
672
                },
4384 eleazar 673
            },
674
            'forrm-status': {
675
                required: true,
676
            },
677
        },
678
        highlight: function(element) {
679
            $(element).closest('.form-group').addClass('has-error');
680
        },
681
        unhighlight: function(element) {
682
            $(element).closest('.form-group').removeClass('has-error');
683
        },
684
        errorPlacement: function(error, element) {
685
            if (element.attr("data-error-container")) {
686
                error.appendTo(element.attr("data-error-container"));
687
            } else {
688
                error.insertAfter(element);
689
            }
690
        },
691
        invalidHandler: function(form, validator) {
692
            if (!validator.numberOfInvalids())
693
                return;
694
            $('html, body').animate({
695
                scrollTop: $(validator.errorList[0].element).offset().top - 100
696
            }, 1000);
697
        },
698
        submitHandler: function(form) {
699
            var error = false;
700
            if (objFormGenerator.sections.length == 0) {
701
                $.fn.showError('ERROR_SECCTIONS');
702
                return false;
703
            } else {
704
                for (i = 0; i < objFormGenerator.sections.length; i++) {
705
                    if (objFormGenerator.sections[i].questions.length == 0) {
706
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
707
                        return false;
708
                    }
709
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
710
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
6467 eleazar 711
                            objFormGenerator.sections[i].questions[j].type == 'multiple' ||
712
                            objFormGenerator.sections[i].questions[j].type == 'rating-open') {
4384 eleazar 713
                            var questionNumber = j + 1;
714
                            var numberCorrect = 0;
715
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
716
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
717
                                return false;
718
                            }
719
                            var totalOption = 0;
720
                            var maxOption = 0;
721
                        }
722
                    }
723
                }
724
                var formContinue = parseInt($('#form-main #form-continue').val());
725
                var data = {
4459 eleazar 726
                    'name': $('#form-main #name').val(),
727
                    'description': $('#form-main #description').val(),
728
                    'text': $('#form-main #text').val(),
729
                    'status': $('#form-main #status').val(),
4384 eleazar 730
                    'content': JSON.stringify(objFormGenerator.sections)
731
                }
732
                $.ajax({
733
                    'dataType': 'json',
734
                    'method': 'post',
735
                    'url': $('#form-main').attr('action'),
736
                    'data': data,
737
                }).done(function(response) {
738
                    if (response['success']) {
739
                        $.fn.showSuccess(response['data']);
740
                        if (formContinue == 1) {
741
                            $('#form-main').attr('action',response['action_edit']);
742
                            $('#form-main #form-id').val(response['id']);
8366 eleazar 743
                            $('#form-main #form-continue').val(0);
4384 eleazar 744
                        } else {
745
                            $('#row-edit').hide();
746
                            $('#row-forms').show();
747
                        /*---------- Reset Form -------- */
748
                        $('#form-main')[0].reset();
749
                        /*--------Reset Ckeditor ----------*/
4466 eleazar 750
                        CKEDITOR.instances.text.setData('');
751
                        CKEDITOR.instances.description.setData('');
4384 eleazar 752
                        /*--------Reset Sections ----------*/
753
                        clearSectionData();
754
                        /* ------- Refresh Table -----------*/
755
 
756
                        }
757
                        tableForm.fnDraw();
758
                    } else {
759
                        $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
760
                    }
761
                }).fail(function(jqXHR, textStatus, errorThrown) {
762
                    $.fn.showError(textStatus);
763
                });
764
                return false;
765
            }
766
        }
767
    });
768
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
769
    $("#form-section").on('submit', function() {
770
        for (var instanceName in CKEDITOR.instances) {
771
            CKEDITOR.instances[instanceName].updateElement();
772
        }
773
    })
774
    /**
775
     * Validate rules form section
776
     */
777
    var validatorFormSection = $("#form-section").validate({
778
        ignore: [],
779
        errorClass: 'help-block',
780
        errorElement: 'span',
781
        rules: {
782
            'section-name': {
783
                required: true,
784
                minlength: 2,
785
                maxlength: 50
786
            },
9004 stevensc 787
            'section-text': {
4384 eleazar 788
                required: false,
789
            },
790
        },
791
        highlight: function(element) {
792
            $(element).closest('.form-group').addClass('has-error');
793
        },
794
        unhighlight: function(element) {
795
            $(element).closest('.form-group').removeClass('has-error');
796
        },
797
        errorPlacement: function(error, element) {
798
            if (element.attr("data-error-container")) {
799
                error.appendTo(element.attr("data-error-container"));
800
            } else {
801
                error.insertAfter(element);
802
            }
803
        },
804
        invalidHandler: function(form, validator) {
805
            if (!validator.numberOfInvalids())
806
                return;
807
            $('html, body').animate({
808
                scrollTop: $(validator.errorList[0].element).offset().top - 100
809
            }, 1000);
810
        },
811
        submitHandler: function(form) {
812
            // do other things for a valid form
813
            //form.submit();
814
            var slug = $('#form-section #section-slug').val();
815
            if (slug) {
816
                objFormGenerator.editSection(
817
                    $('#form-section #section-slug').val(),
818
                    $('#form-section #section-name').val(),
9004 stevensc 819
                    $('#form-section #section-text').val(),
4384 eleazar 820
                );
821
            } else {
822
                objFormGenerator.addSection(
823
                    $('#form-section #section-name').val(),
9004 stevensc 824
                    $('#form-section #section-text').val()
4384 eleazar 825
                );
826
            }
827
            renderSectionData(objFormGenerator.sections);
828
            $('#modal-section').modal('hide');
829
            return false;
830
        }
831
    });
832
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
833
    $("#form-question").on('submit', function() {
834
        for (var instanceName in CKEDITOR.instances) {
835
            CKEDITOR.instances[instanceName].updateElement();
836
        }
837
    })
838
    /**
839
     * Validate rules form Questions
840
     */
841
    var validatorFormQuestion = $("#form-question").validate({
842
        ignore: [],
843
        errorClass: 'help-block',
844
        errorElement: 'span',
845
        rules: {
846
            'question-text': {
847
                required: true,
848
            },
849
            'question-type': {
850
                required: true,
851
            },
852
            'question-max-length': {
853
                required: true,
854
                digits: true,
855
                min: 0
856
            },
6467 eleazar 857
            'question-range': {
858
                required: true,
859
                number: true,
860
                min: 1
861
            },
4384 eleazar 862
        },
863
        highlight: function(element) {
864
            $(element).closest('.form-group').addClass('has-error');
865
        },
866
        unhighlight: function(element) {
867
            $(element).closest('.form-group').removeClass('has-error');
868
        },
869
        errorPlacement: function(error, element) {
870
            if (element.attr("data-error-container")) {
871
                error.appendTo(element.attr("data-error-container"));
872
            } else {
873
                error.insertAfter(element);
874
            }
875
        },
876
        invalidHandler: function(form, validator) {
877
            if (!validator.numberOfInvalids())
878
                return;
879
            $('html, body').animate({
880
                scrollTop: $(validator.errorList[0].element).offset().top - 100
881
            }, 1000);
882
        },
883
        submitHandler: function(form) {
884
            if ($('#form-question #question-slug').val()) {
885
                objFormGenerator.editQuestion(
886
                    $('#form-question #question-section').val(),
887
                    $('#form-question #question-slug').val(),
888
                    $('#form-question #question-text').val(),
889
                    $('#form-question #question-type').val(),
890
                    $('#form-question #question-max-length').val(),
6467 eleazar 891
                    $('#form-question #question-multiline').val(),
892
                    $('#form-question #question-range').val()
4384 eleazar 893
                );
894
            } else {
895
                objFormGenerator.addQuestion(
896
                    $('#form-question #question-section').val(),
897
                    $('#form-question #question-text').val(),
898
                    $('#form-question #question-type').val(),
899
                    $('#form-question #question-max-length').val(),
6467 eleazar 900
                    $('#form-question #question-multiline').val(),
901
                    $('#form-question #question-range').val()
4384 eleazar 902
                );
903
            }
904
            renderSectionData(objFormGenerator.sections);
905
            $('#modal-question').modal('hide');
906
            return false;
907
        }
908
    });
909
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
910
    $("#form-option").on('submit', function() {
911
        for (var instanceName in CKEDITOR.instances) {
912
            CKEDITOR.instances[instanceName].updateElement();
913
        }
914
    })
915
    /**
916
     * Validate rules form options
917
     */
918
    var validatorFormOption = $("#form-option").validate({
919
        ignore: [],
920
        errorClass: 'help-block',
921
        errorElement: 'span',
922
        rules: {
923
            'option-text': {
924
                required: true,
925
            }
4546 eleazar 926
 
4384 eleazar 927
        },
928
        highlight: function(element) {
929
            $(element).closest('.form-group').addClass('has-error');
930
        },
931
        unhighlight: function(element) {
932
            $(element).closest('.form-group').removeClass('has-error');
933
        },
934
        errorPlacement: function(error, element) {
935
            if (element.attr("data-error-container")) {
936
                error.appendTo(element.attr("data-error-container"));
937
            } else {
938
                error.insertAfter(element);
939
            }
940
        },
941
        invalidHandler: function(form, validator) {
942
            if (!validator.numberOfInvalids())
943
                return;
944
            $('html, body').animate({
945
                scrollTop: $(validator.errorList[0].element).offset().top - 100
946
            }, 1000);
947
        },
948
        submitHandler: function(form) {
949
            if ($('#form-option #option-slug').val()) {
950
                objFormGenerator.editOption(
951
                    $('#form-option #option-section').val(),
952
                    $('#form-option #option-question').val(),
953
                    $('#form-option #option-slug').val(),
6276 eleazar 954
                    $('#form-option #option-text').val()
4384 eleazar 955
                );
956
            } else {
957
                objFormGenerator.addOption(
958
                    $('#form-option #option-section').val(),
959
                    $('#form-option #option-question').val(),
6276 eleazar 960
                    $('#form-option #option-text').val()
4384 eleazar 961
                );
962
            }
963
            renderSectionData(objFormGenerator.sections);
964
            $('#modal-option').modal('hide');
965
            return false;
966
        }
967
    });
968
    /**
969
     * Clicked on add new section
970
     */
971
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
972
        e.preventDefault();
973
        validatorFormSection.resetForm();
974
        $('#form-section #section-slug').val('');
975
        $('#form-section #section-name').val('');
9004 stevensc 976
        CKEDITOR.instances['section-text'].setData('');
4384 eleazar 977
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
978
        $('#modal-section').modal('show');
979
    });
980
    /**
981
     * Clicked on edit section
982
     */
983
    $('body').on('click', 'button.btn-edit-section', function(e) {
984
        e.preventDefault();
985
        var slug = $(this).data('section');
986
        var section;
987
        var showForm = false;
988
        for (i = 0; i < objFormGenerator.sections.length; i++) {
989
            section = objFormGenerator.sections[i];
990
            if (slug == section.slug_section) {
991
                validatorFormSection.resetForm();
992
                $('#form-section #section-slug').val(section.slug_section);
993
                $('#form-section #section-name').val(section.name);
9004 stevensc 994
                CKEDITOR.instances['section-text'].setData(section.text);
4384 eleazar 995
                showForm = true;
996
                break;
997
            }
998
        }
999
        if (showForm) {
1000
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
1001
            $('#modal-section').modal('show');
1002
        }
1003
    });
1004
    /**
1005
     * Clicked on remove section
1006
     */
1007
    $('body').on('click', 'button.btn-delete-section', function(e) {
1008
        e.preventDefault();
1009
        var slug = $(this).data('section');
1010
        bootbox.confirm({
1011
            title: "LABEL_DELETE LABEL_SECTION",
1012
            message: "LABEL_QUESTION_DELETE",
1013
            buttons: {
1014
                cancel: {
1015
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1016
                },
1017
                confirm: {
1018
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1019
                }
1020
            },
1021
            callback: function(result) {
1022
                if (result) {
1023
                    objFormGenerator.deleteSection(slug);
1024
                    renderSectionData(objFormGenerator.sections);
1025
                }
1026
            }
1027
        });
1028
    });
1029
    /**
1030
     * Clicked add new question
1031
     */
1032
    $('body').on('click', 'button.btn-add-question', function(e) {
1033
        e.preventDefault();
1034
        validatorFormQuestion.resetForm();
1035
        var slug = $(this).data('section');
1036
        $('#form-question #question-section').val(slug);
1037
        $('#form-question #question-slug').val('');
1038
        CKEDITOR.instances['question-text'].setData('');
1039
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1040
        $('#form-question #question-max-length').val('0');
1041
        $('#form-question #question-max-length').parent().show();
1042
        $('#form-question #question-multiline').val('0');
1043
        $('#form-question #question-multiline').parent().show();
6467 eleazar 1044
        $('#form-question #question-range').val('10');
1045
        $('#form-question #question-range').parent().hide();
4384 eleazar 1046
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1047
        $('#modal-question').modal('show');
1048
    });
1049
    /**
1050
     * Clicked edit question
1051
     */
1052
    $('body').on('click', 'button.btn-edit-question', function(e) {
1053
        e.preventDefault();
1054
        var slug_section = $(this).data('section');
1055
        var slug = $(this).data('question');
1056
        var showForm = false;
1057
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1058
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1059
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1060
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
1061
                        validatorFormQuestion.resetForm();
1062
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
1063
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
1064
                        CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
1065
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
1066
                        if (objFormGenerator.sections[i].questions[j].type == 'open') {
1067
                            $('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
1068
                            $('#form-question #question-max-length').parent().show();
1069
                            $('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
1070
                            $('#form-question #question-multiline').parent().show();
1071
                        } else {
1072
                            $('#form-question #question-max-length').val('0');
1073
                            $('#form-question #question-max-length').parent().hide();
1074
                            $('#form-question #question-multiline').val('0');
1075
                            $('#form-question #question-multiline').parent().hide();
1076
                        }
6467 eleazar 1077
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
1078
                            $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
1079
                            $('#form-question #question-range').parent().show();
1080
                        } else {
1081
                            $('#form-question #question-range').val('10');
1082
                            $('#form-question #question-range').parent().hide();
1083
                        }
4384 eleazar 1084
                        showForm = true;
1085
                        break;
1086
                    }
1087
                }
1088
                break;
1089
            }
1090
        }
1091
        if (showForm) {
1092
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
1093
            $('#modal-question').modal('show');
1094
        }
1095
    });
1096
    /**
1097
     * Clicked remove question
1098
     */
1099
    $('body').on('click', 'button.btn-delete-question', function(e) {
1100
        e.preventDefault();
1101
        var slug_section = $(this).data('section');
1102
        var slug = $(this).data('question');
1103
        bootbox.confirm({
1104
            title: "LABEL_DELETE LABEL_QUESTION",
1105
            message: "LABEL_QUESTION_DELETE",
1106
            buttons: {
1107
                cancel: {
1108
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1109
                },
1110
                confirm: {
1111
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1112
                }
1113
            },
1114
            callback: function(result) {
1115
                if (result) {
1116
                    objFormGenerator.deleteQuestion(slug_section, slug);
1117
                    renderSectionData(objFormGenerator.sections);
1118
                }
1119
            }
1120
        });
1121
    });
1122
    /**
1123
     * Clicked add new Option
1124
     */
1125
    $('body').on('click', 'button.btn-add-option', function(e) {
1126
        e.preventDefault();
1127
        var slug_section = $(this).data('section');
1128
        var slug_question = $(this).data('question');
1129
        var showForm = false;
1130
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1131
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1132
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1133
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1134
                        validatorFormOption.resetForm();
1135
                        $('#form-option #option-section').val(slug_section);
1136
                        $('#form-option #option-question').val(slug_question);
1137
                        $('#form-option #option-slug').val('');
14211 stevensc 1138
                        CKEDITOR.replace('option-text', {
1139
                            toolbar: [
1140
                                        { name: 'editing', items: ['Scayt'] },
1141
                                        { name: 'links', items: ['Link', 'Unlink'] },
1142
                                        { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
1143
                                        { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
1144
                                        '/',
1145
                                        { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
1146
                                        { name: 'styles', items: ['Styles', 'Format'] },
1147
                                        { name: 'tools', items: ['Maximize'] }
1148
                                    ],
1149
                                    removePlugins: 'elementspath,Anchor',
1150
                                    heigth: 100
14212 stevensc 1151
                        })
4384 eleazar 1152
                        CKEDITOR.instances['option-text'].setData('', function() {
1153
                            editor.focus();
1154
                        });
6276 eleazar 1155
 
4384 eleazar 1156
                        renderSectionData(objFormGenerator.sections);
1157
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
1158
                        $('#modal-option').modal('show');
1159
                        return true;
1160
                    }
1161
                }
1162
            }
1163
        }
1164
    });
1165
    /**
1166
     * Clicked edit option
1167
     */
1168
    $('body').on('click', 'button.btn-edit-option', function(e) {
1169
        e.preventDefault();
1170
        var slug_section = $(this).data('section');
1171
        var slug_question = $(this).data('question');
1172
        var slug = $(this).data('slug');
1173
        var showForm = false;
1174
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1175
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1176
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1177
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1178
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
1179
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
1180
                                validatorFormOption.resetForm();
1181
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
1182
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
1183
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
1184
                                CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
1185
                                    function() {
1186
                                        editor.focus();
1187
                                    });
1188
                                showForm = true;
1189
                                break;
1190
                            }
1191
                        }
1192
                    }
1193
                    if (showForm) {
1194
                        break;
1195
                    }
1196
                }
1197
            }
1198
            if (showForm) {
1199
                break;
1200
            }
1201
        }
1202
        if (showForm) {
1203
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1204
            $('#modal-option').modal('show');
1205
        }
1206
    });
1207
    /**
1208
     * Clicked remove option
1209
     */
1210
    $('body').on('click', 'button.btn-delete-option', function(e) {
1211
        e.preventDefault();
1212
        var slug_section = $(this).data('section');
1213
        var slug_question = $(this).data('question');
1214
        var slug = $(this).data('slug');
1215
        bootbox.confirm({
1216
            title: "LABEL_DELETE LABEL_OPTION",
1217
            message: "LABEL_QUESTION_DELETE",
1218
            buttons: {
1219
                cancel: {
1220
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1221
                },
1222
                confirm: {
1223
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1224
                }
1225
            },
1226
            callback: function(result) {
1227
                if (result) {
1228
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
1229
                    renderSectionData(objFormGenerator.sections);
1230
                }
1231
            }
1232
        });
1233
    })
4546 eleazar 1234
 
4384 eleazar 1235
    /**
1236
     * Format input number (Form Question)
1237
     */
1238
    $('#form-question #question-max-length').inputNumberFormat({
1239
        'decimal': 0
1240
    });
1241
    /**
1242
     * Detect when updating question status and hide/Show options
1243
     */
1244
    $('#form-question #question-type').change(function(e) {
1245
        e.preventDefault();
1246
        if ($('#form-question #question-type').val() == 'open') {
1247
            $('#form-question #question-max-length').parent().show();
1248
            $('#form-question #question-multiline').parent().show();
1249
        } else {
1250
            $('#form-question #question-max-length').val('0');
1251
            $('#form-question #question-max-length').parent().hide();
1252
            $('#form-question #question-multiline').val('0');
1253
            $('#form-question #question-multiline').parent().hide();
1254
        }
6467 eleazar 1255
        $('#form-question #question-range').val('10');
1256
        if ($('#form-question #question-type').val() == 'rating-range') {
1257
            $('#form-question #question-range').parent().show();
1258
        } else {
1259
            $('#form-question #question-range').parent().hide();
1260
        }
4384 eleazar 1261
    });
1262
    /**
1263
     * Clicked new Form
1264
     */
1265
    $('button.btn-add-form').click(function(e) {
1266
        e.preventDefault();
1267
        objFormGenerator.clear();
1268
        objFormGenerator.render();
1269
        validatorForm.resetForm();
1270
        clearSectionData();
1271
        $('#form-main').attr('action', '$routeAdd');
1272
        $('#form-main #form-continue').val('0');
4459 eleazar 1273
        $('#form-main #name').val('');
1274
        $('#form-main #status').val('$status_inactive');
4466 eleazar 1275
        CKEDITOR.instances.text.setData('');
1276
        CKEDITOR.instances.description.setData('');
4384 eleazar 1277
        $('#row-forms').hide();
1278
        $('#row-edit').show();
4459 eleazar 1279
        $('#form-main #name').focus();
4384 eleazar 1280
    });
1281
    /**
1282
     * Clicked cancel new/edit Form
1283
     */
1284
    $('button.btn-edit-cancel').click(function(e) {
1285
        e.preventDefault();
1286
        $('#row-edit').hide();
1287
        $('#row-forms').show();
1288
    });
1289
    /**
1290
     * Clicked save and continue new Form
1291
     */
1292
    $('button.btn-form-save-continue').click(function(e) {
8365 eleazar 1293
        e.preventDefault();
1294
        $('#form-main #form-continue').val('1')
8366 eleazar 1295
        $('#form-main').submit();
4384 eleazar 1296
    });
1297
    /**
1298
     * Clicked save and close new/edit Form
1299
     */
1300
    $('button.btn-form-save-close').click(function(e) {
1301
        e.preventDefault();
1302
        $('#form-main #form-continue').val('0')
1303
        $('#form-main').submit();
1304
    });
8364 eleazar 1305
 
1306
    const saveData = (action) => {
1307
 
1308
            $.ajax({
1309
                'dataType': 'json',
1310
                'method': 'post',
1311
                'url': $('#form-main').attr('action'),
1312
                'data': {
1313
                    'name': $('#form-main #form-name').val(),
1314
 
1315
                    'status': $('#form-main #form-status').val(),
1316
                    'description': $('#form-main #form-description').val(),
1317
                    'content': JSON.stringify(sections)
1318
                },
1319
            }).done(function(response) {
1320
                if (response['success']) {
1321
                    $.fn.showSuccess(response['data']);
1322
                    if (action == 1) {
1323
                        $('#form-main').attr('action', response['action_edit']);
1324
                    } else {
1325
                        $('#row-form').hide();
1326
                        $('#row-lists').show();
1327
                        /*---------- Reset Form -------- */
1328
                        $('#form-main')[0].reset();
1329
                        /*--------Reset Sections ----------*/
1330
                        sections = [];
1331
                        tableForm.fnDraw();
1332
                    }
1333
                    return;
1334
                } else {
1335
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
1336
                    return;
1337
                }
1338
            });
1339
 
1340
    }
1341
 
4384 eleazar 1342
    /**
1343
     * Modal Settings
1344
     */
1345
    $('#modal-section, #modal-question, #modal-option').modal({
1346
        backdrop: 'static',
1347
        keyboard: false,
1348
        show: false
1349
    });
1350
    /**
1351
     * Get Question type
1352
     */
1353
    const getQuestionTypeBySlug = (slug_section, slug_question) => {
1354
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1355
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1356
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1357
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1358
                        return objFormGenerator.sections[i].questions[j].type;
1359
                    }
1360
                }
1361
            }
1362
        }
1363
    }
1364
    /**
1365
     * Remove Html Tags
1366
     */
1367
    const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
1368
    /**
1369
     * Render Sections data
1370
     */
1371
    const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
1372
        getType: getQuestionTypeBySlug,
1373
        removeTags: removeTags
1374
    }));
1375
 
1376
 
1377
    /**
1378
     * Clear Div Section data
1379
     */
1380
    const clearSectionData = () => $("#rows").html('');
1381
    /**
1382
     * Clicked refresh button
1383
     */
1384
    $('button.btn-refresh').click(function(e) {
1385
        tableForm.fnDraw();
1386
    });
4466 eleazar 1387
 
9004 stevensc 1388
    CKEDITOR.replace('description', {
8967 stevensc 1389
        toolbar: [
1390
                    { name: 'editing', items: ['Scayt'] },
1391
                    { name: 'links', items: ['Link', 'Unlink'] },
1392
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
1393
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
1394
                    '/',
1395
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
1396
                    { name: 'styles', items: ['Styles', 'Format'] },
1397
                    { name: 'tools', items: ['Maximize'] }
1398
                ],
1399
                removePlugins: 'elementspath,Anchor',
1400
                heigth: 100
9004 stevensc 1401
    });
14208 stevensc 1402
 
9004 stevensc 1403
    CKEDITOR.replace('text', {
1404
        toolbar: [
1405
                    { name: 'editing', items: ['Scayt'] },
1406
                    { name: 'links', items: ['Link', 'Unlink'] },
1407
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
1408
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
1409
                    '/',
1410
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
1411
                    { name: 'styles', items: ['Styles', 'Format'] },
1412
                    { name: 'tools', items: ['Maximize'] }
1413
                ],
1414
                removePlugins: 'elementspath,Anchor',
1415
                heigth: 100
1416
    });
4384 eleazar 1417
 
1418
});
1419
JS;
1420
$this->inlineScript()->captureEnd();
1421
?>
1422
 
1423
<!-- Content Header (Page header) -->
1424
<section class="content-header">
1425
    <div class="container-fluid">
1426
        <div class="row mb-2">
1427
            <div class="col-sm-12">
1428
                <h1>LABEL_SELF_EVALUATION_FORMS</h1>
1429
            </div>
1430
        </div>
1431
    </div>
1432
    <!-- /.container-fluid -->
1433
</section>
1434
<section class="content">
1435
    <div class="container-fluid" id="row-forms">
1436
        <div class="row">
1437
            <div class="col-12">
1438
                <div class="card">
1439
                    <div class="card-body">
1440
                        <table id="gridTable" class="table   table-hover">
1441
                            <thead>
1442
                                <tr>
1443
                                    <th>LABEL_NAME</th>
1444
                                    <th>LABEL_ACTIVE</th>
1445
                                    <th>LABEL_ACTIONS</th>
1446
                                </tr>
1447
                            </thead>
1448
                            <tbody></tbody>
1449
                        </table>
1450
                    </div>
1451
                    <div class="card-footer clearfix">
1452
                        <div style="float:right;">
1453
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1454
                            <?php if ($allowAdd) : ?>
1455
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1456
                            <?php endif; ?>
1457
                        </div>
1458
                    </div>
1459
                </div>
1460
            </div>
1461
        </div>
1462
    </div>
1463
 
1464
    <!-- Create/Edit Form -->
1465
 
1466
    <div class="row" id="row-edit" style="display: none">
1467
        <div class="col-xs-12 col-md-12">
1468
            <form action="#" name="form-main" id="form-main">
1469
                <input type="hidden" name="form-id" id="form-id" value="0" />
1470
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
4450 eleazar 1471
                <?php
14208 stevensc 1472
                //$form = $this->formAdd;
1473
                $form->setAttributes([
1474
                    'method' => 'post',
1475
                    'name' => 'form-main',
1476
                    'action' => $routeAdd,
1477
                    'id' => 'form-main'
1478
                ]);
1479
                $form->prepare();
1480
                echo $this->form()->openTag($form);
4450 eleazar 1481
                ?>
14208 stevensc 1482
                <div class="form-group">
4450 eleazar 1483
                    <?php
1484
                    $element = $form->get('name');
1485
                    $element->setOptions(['label' => 'LABEL_FIRST_NAME']);
1486
                    $element->setAttributes(['class' => 'form-control']);
1487
                    echo $this->formLabel($element);
1488
                    echo $this->formText($element);
1489
                    ?>
4384 eleazar 1490
                </div>
1491
                <div class="form-group">
14208 stevensc 1492
                    <?php
1493
                    $element = $form->get('description');
1494
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
1495
                    $element->setAttributes(['class' => 'form-control']);
1496
                    echo $this->formLabel($element);
1497
                    echo $this->formTextArea($element);
1498
                    ?>
4384 eleazar 1499
                </div>
1500
                <div class="form-group">
14208 stevensc 1501
                    <?php
1502
                    $element = $form->get('text');
1503
                    $element->setOptions(['label' => 'LABEL_TEXT']);
1504
                    $element->setAttributes(['class' => 'form-control']);
1505
                    echo $this->formLabel($element);
1506
                    echo $this->formTextArea($element);
1507
                    ?>
4384 eleazar 1508
                </div>
1509
                <div class="form-group">
14208 stevensc 1510
                    <?php
1511
                    $element = $form->get('status');
1512
                    $element->setAttributes(['class' => 'form-control']);
1513
                    $element->setOptions(['label' => 'LABEL_STATUS']);
1514
                    echo $this->formLabel($element);
1515
                    echo $this->formSelect($element);
1516
                    ?>
1517
                </div>
1518
                <br />
4384 eleazar 1519
                <div class="row">
1520
                    <div class="col-xs-12 col-md-12 text-right">
1521
                        <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>
1522
                    </div>
1523
                </div>
1524
                <br />
1525
                <div class="row">
1526
                    <div class="col-xs-12 col-md-12">
1527
                        <div class="panel-group" id="rows"></div>
1528
                    </div>
1529
                </div>
1530
                <div class="form-group">
1531
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1532
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1533
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1534
                </div>
1535
            </form>
1536
        </div>
1537
    </div>
1538
 
1539
    <!-- Create/Edit Form-->
1540
 
1541
    <!-- Section Modal -->
14208 stevensc 1542
    <div id="modal-section" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1543
        <div class="modal-dialog modal-lg" role="document">
1544
            <form action="#" name="form-section" id="form-section">
1545
                <input type="hidden" name="section-slug" id="section-slug" value="" />
1546
                <div class="modal-content">
1547
                    <div class="modal-header">
1548
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
1549
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1550
                            <span aria-hidden="true">&times;</span>
1551
                        </button>
1552
                    </div>
1553
                    <div class="modal-body">
1554
                        <div class="form-group">
1555
                            <label for="section-name">LABEL_FIRST_NAME</label>
1556
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
1557
                        </div>
1558
                        <div class="form-group">
9004 stevensc 1559
                            <label for="section-text">LABEL_TEXT</label>
8981 stevensc 1560
                            <!--  ckeditor -->
14208 stevensc 1561
                            <textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
9004 stevensc 1562
                            <script>
1563
                                CKEDITOR.replace('section-text', {
14208 stevensc 1564
                                    toolbar: [{
1565
                                            name: 'editing',
1566
                                            items: ['Scayt']
1567
                                        },
1568
                                        {
1569
                                            name: 'links',
1570
                                            items: ['Link', 'Unlink']
1571
                                        },
1572
                                        {
1573
                                            name: 'paragraph',
1574
                                            items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote']
1575
                                        },
1576
                                        {
1577
                                            name: 'basicstyles',
1578
                                            items: ['Bold', 'Italic', 'Strike', 'RemoveFormat']
1579
                                        },
9004 stevensc 1580
                                        '/',
14208 stevensc 1581
                                        {
1582
                                            name: 'insert',
1583
                                            items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar']
1584
                                        },
1585
                                        {
1586
                                            name: 'styles',
1587
                                            items: ['Styles', 'Format']
1588
                                        },
1589
                                        {
1590
                                            name: 'tools',
1591
                                            items: ['Maximize']
1592
                                        }
9004 stevensc 1593
                                    ],
1594
                                    removePlugins: 'elementspath,Anchor',
1595
                                    heigth: 100
1596
                                });
1597
                            </script>
4384 eleazar 1598
                        </div>
1599
                    </div>
1600
                    <div class="modal-footer">
1601
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1602
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1603
                    </div>
1604
                </div>
1605
            </form>
1606
        </div>
1607
    </div>
1608
    <!-- End Modal Section -->
1609
 
1610
    <!-- Question Modal -->
1611
 
14208 stevensc 1612
    <div id="modal-question" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1613
        <div class="modal-dialog modal-lg" role="document">
1614
            <form action="#" name="form-question" id="form-question">
1615
                <input type="hidden" name="question-section" id="question-section" />
1616
                <input type="hidden" name="question-slug" id="question-slug" />
1617
                <div class="modal-content">
1618
                    <div class="modal-header">
1619
                        <h4 class="modal-title">LABEL_ADD LABEL_QUESTION</h4>
1620
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1621
                            <span aria-hidden="true">&times;</span>
1622
                        </button>
1623
                    </div>
1624
                    <div class="modal-body">
1625
                        <div class="form-group">
1626
                            <label for="question-text">LABEL_TEXT</label>
1627
                            <!--  ckeditor -->
14208 stevensc 1628
                            <textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
9006 stevensc 1629
                            <script>
1630
                                CKEDITOR.replace('question-text', {
14208 stevensc 1631
                                    toolbar: [{
1632
                                            name: 'editing',
1633
                                            items: ['Scayt']
1634
                                        },
1635
                                        {
1636
                                            name: 'links',
1637
                                            items: ['Link', 'Unlink']
1638
                                        },
1639
                                        {
1640
                                            name: 'paragraph',
1641
                                            items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote']
1642
                                        },
1643
                                        {
1644
                                            name: 'basicstyles',
1645
                                            items: ['Bold', 'Italic', 'Strike', 'RemoveFormat']
1646
                                        },
1647
                                        '/',
1648
                                        {
1649
                                            name: 'insert',
1650
                                            items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar']
1651
                                        },
1652
                                        {
1653
                                            name: 'styles',
1654
                                            items: ['Styles', 'Format']
1655
                                        },
1656
                                        {
1657
                                            name: 'tools',
1658
                                            items: ['Maximize']
1659
                                        }
1660
                                    ],
1661
                                    removePlugins: 'elementspath,Anchor',
1662
                                    heigth: 100
9006 stevensc 1663
                                });
1664
                            </script>
4384 eleazar 1665
                        </div>
1666
                        <div class="form-group">
1667
                            <label for="question-type">LABEL_TYPE</label>
1668
                            <select name="question-type" id="question-type" class="form-control">
1669
                                <option value="open">LABEL_OPEN</option>
1670
                                <option value="simple">Simple</option>
1671
                                <option value="multiple">Multiple</option>
14208 stevensc 1672
 
4384 eleazar 1673
                            </select>
1674
                        </div>
1675
                        <div class="form-group">
1676
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
14208 stevensc 1677
                            <input type="text" name="question-max-length" id="question-max-length" class="form-control" />
4384 eleazar 1678
                        </div>
1679
                        <div class="form-group">
1680
                            <label for="question-multiline">LABEL_MULTI_LINE</label>
1681
                            <select name="question-multiline" id="question-multiline" class="form-control">
1682
                                <option value="1">LABEL_YES</option>
1683
                                <option value="0">LABEL_NOT</option>
1684
                            </select>
1685
                        </div>
6467 eleazar 1686
                        <div class="form-group">
1687
                            <label for="question-range">LABEL_RANGE</label>
1688
                            <select name="question-range" id="question-range" class="form-control">
1689
                                <option value="10">1-10</option>
1690
                                <option value="6">1-6</option>
1691
                                <option value="5">1-5</option>
1692
                            </select>
1693
                        </div>
4384 eleazar 1694
                    </div>
1695
                    <div class="modal-footer">
1696
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1697
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1698
                    </div>
1699
                </div>
1700
            </form>
1701
        </div>
1702
    </div>
1703
 
1704
    <!-- End Modal Question -->
1705
 
1706
    <!-- Modal Options -->
1707
 
14208 stevensc 1708
    <div id="modal-option" class="modal" tabindex="-1" role="dialog">
4384 eleazar 1709
        <div class="modal-dialog modal-lg" role="document">
1710
            <form action="#" name="form-option" id="form-option">
1711
                <input type="hidden" name="option-section" id="option-section" value="" />
1712
                <input type="hidden" name="option-question" id="option-question" value="" />
1713
                <input type="hidden" name="option-slug" id="option-slug" value="" />
1714
                <div class="modal-content">
1715
                    <div class="modal-header">
1716
                        <h4 class="modal-title">LABEL_OPTION</h4>
1717
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1718
                            <span aria-hidden="true">&times;</span>
1719
                        </button>
1720
                    </div>
1721
                    <div class="modal-body">
1722
                        <div class="form-group">
1723
                            <label for="option-text">LABEL_TEXT</label>
1724
                            <!--  ckeditor -->
14208 stevensc 1725
                            <textarea name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
14212 stevensc 1726
                            <script>
14213 stevensc 1727
                                CKEDITOR.replace('option-text', {
14212 stevensc 1728
                                    toolbar: [{
1729
                                            name: 'editing',
1730
                                            items: ['Scayt']
1731
                                        },
1732
                                        {
1733
                                            name: 'links',
1734
                                            items: ['Link', 'Unlink']
1735
                                        },
1736
                                        {
1737
                                            name: 'paragraph',
1738
                                            items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote']
1739
                                        },
1740
                                        {
1741
                                            name: 'basicstyles',
1742
                                            items: ['Bold', 'Italic', 'Strike', 'RemoveFormat']
1743
                                        },
1744
                                        '/',
1745
                                        {
1746
                                            name: 'insert',
1747
                                            items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar']
1748
                                        },
1749
                                        {
1750
                                            name: 'styles',
1751
                                            items: ['Styles', 'Format']
1752
                                        },
1753
                                        {
1754
                                            name: 'tools',
1755
                                            items: ['Maximize']
1756
                                        }
1757
                                    ],
1758
                                    removePlugins: 'elementspath,Anchor',
1759
                                    heigth: 100
1760
                                });
1761
                            </script>
4384 eleazar 1762
                        </div>
1763
                    </div>
1764
                    <div class="modal-footer">
1765
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1766
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1767
                    </div>
1768
                </div>
1769
            </form>
1770
        </div>
1771
    </div>
1772
 
1773
    <!-- End Modal Options -->
1774
 
1775
    <!---Template Sections --->
8991 stevensc 1776
    <script id="sectionTemplate" type="text/x-jsrender">
14208 stevensc 1777
        <div class="panel panel-default" id="panel-{{:slug_section}}">
4384 eleazar 1778
        <div class="panel-heading">
1779
            <h4 class="panel-title">
1780
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1781
                    <span class="section-name{{:slug_section}}">
1782
                        {{:name}}
1783
                    </span>
1784
                </a>
1785
            </h4>
1786
        </div>
1787
        <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
1788
            <div class="panel-body">
1789
                <div class="table-responsive">
1790
                    <table class="table table-bordered">
1791
                        <thead>
1792
                            <tr>
1793
                                <th style="width: 10%;">LABEL_ELEMENT</th>
1794
                                <th style="width: 50%;">LABEL_TEXT</th>
1795
                                <th style="width: 10%;">LABEL_TYPE</th>
1796
                                <th style="width: 20%;">LABEL_ACTIONS</th>
1797
                            </tr>
1798
                        </thead>
1799
                        <tbody>
1800
                            <tr class="tr-section">
1801
                                <td class="text-left">LABEL_SECTION</td>
1802
                                <td class="text-left">{{:name}}</td>
1803
                                <td></td>
1804
                                <td>
1805
                                    <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>
1806
                                    <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>
1807
                                    <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>
1808
                                </td>
1809
                            </tr>
1810
                            {{for questions}}
1811
                            <tr class="tr-question">
1812
                                <td class="text-left">--LABEL_QUESTION</td>
1813
                                <td class="text-left">
1814
                                    {{:~removeTags(text)}}
1815
                                </td>
1816
                                <td class="text-capitalize">
1817
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1818
                                    {{if type == 'simple'}} Simple {{/if}}
1819
                                    {{if type == 'multiple'}} Multiple {{/if}}
1820
                                </td>
1821
                                <td>
1822
                                    <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>
1823
                                    <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>
1824
 
6467 eleazar 1825
                                    {{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
4384 eleazar 1826
                                    <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>
1827
                                    {{/if}}
1828
 
1829
                                </td>
1830
                            </tr>
1831
                            {{for options}}
1832
                            <tr class="tr-option">
1833
                                <td class="text-left">---LABEL_OPTION</td>
1834
                                <td class="text-left">
1835
                                    {{:~removeTags(text)}}
1836
                                </td>
1837
                                <td>
1838
 
1839
                                    {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
1840
                                    {{/if}}
1841
                                </td>
1842
                                <td>
1843
                                    <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>
1844
                                    <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>
1845
                                </td>
1846
                            </tr>
1847
                            {{/for}}
1848
                            {{/for}}
1849
                        </tbody>
1850
                    </table>
1851
                </div>
1852
            </div>
1853
        </div>
1854
    </div>
1855
    </script>
1856
 
1857
    <!-- End Template Sections-->
1858
 
1859
</section>