Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16971 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php
$acl = $this->viewModel()->getRoot()->getVariable('acl');
$currentUser = $this->currentUserHelper();

$roleName = $currentUser->getUserTypeId();

$routeAdd = $this->url('organizational-climate/form/add');
$routeDatatable = $this->url('organizational-climate/form');
$routeDashboard = $this->url('dashboard');

$allowAdd = $acl->isAllowed($roleName, 'organizational-climate/form/add') ? 1 : 0;
$allowEdit = $acl->isAllowed($roleName, 'organizational-climate/form/edit') ? 1 : 0;
$allowDelete = $acl->isAllowed($roleName, 'organizational-climate/form/delete') ? 1 : 0;


//$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));


$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));






$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));

$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));


$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.min.css'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap5-theme/select2-bootstrap-5-theme.css'));

$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.full.min.js'));

$this->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment-with-locales.min.js'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));


$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));



$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));

// bootbox Alert //


// JsRender //
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.min.js'));

// Page Styles
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));

$status_active = \LeadersLinked\Model\SurveyForm::STATUS_ACTIVE;
$status_inactive = \LeadersLinked\Model\SurveyForm::STATUS_INACTIVE;

$this->headStyle()->captureStart();
echo <<<CSS
[data-toggle="collapse"] .fa:before {   
  content: "\f139";
}

[data-toggle="collapse"].collapsed .fa:before {
  content: "\f13a";
}
CSS;
$this->headStyle()->captureEnd();


$this->inlineScript()->captureStart();
echo <<<JS
    const FormGenerator = function() {
        this.uuid   = 0,
        this.table  = '',
        this.name   = '',
        this.text   = '',
        this.status     = '$status_active',
        this.sections   = []

    }

    FormGenerator.prototype.isValid = function() {

        if(this.sections.length == 0) {
            $.fn.showError('ERROR_QUESTIONARY_NOT_SECTIONS');
            return false;        
        }

        
        for (i = 0; i < this.sections.length; i++) {

            if(this.sections[i].questions.length == 0) {
                $.fn.showError('ERROR_QUESTIONARY_QUESTIONS'.replace('%s', this.sections[i].name));
                return false;
            }

            for (j = 0; j < this.sections[i].questions.length; j++) {
                if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
                    if (this.sections[i].questions[j].options.length == 0) {
                        var questionNumber = j + 1;
                        $.fn.showError('ERROR_QUESTIONARY_OPTIONS'.replace('%s', this.sections[i].name).replace('%n', questionNumber));
                        return false;
                    }

                    if (this.sections[i].questions[j].options.length < 2) {
                        var questionNumber = j + 1;
                        $.fn.showError('ERROR_QUESTIONARY_MIN_TWO_OPTIONS'.replace('%s', this.sections[i].name).replace('%n', questionNumber));
                        return false;
                    }
   

                }
            }

        }


        return true;

    }


    FormGenerator.prototype.clear = function() {
        this.sections = [];
        this.render();
    }


    FormGenerator.prototype.render = function() {

        $('#containter-sections').empty();
        this.sections.sort(function(a, b) {
            if (a.position > b.position) {
                return 1;
            } else if (a.position < b.position) {
                return -1;
            } else {
                return 0;
            }
        });

        for (i = 0; i < this.sections.length; i++) {
            this.sections[i].position = i;
            this.sections[i].questions.sort(function(a, b) {
                if (a.position > b.position) {
                    return 1;
                } else if (a.position < b.position) {
                    return -1;
                } else { 
                    return 0;
                }
            });
            for (j = 0; j < this.sections[i].questions.length; j++) {
                this.sections[i].questions[j].position = j;
                if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
                    this.sections[i].questions[j].options.sort(function(a, b) {
                        if (a.position > b.position) {
                            return 1;
                        } else if (a.position < b.position) {
                            return -1;
                        } else { 
                            return 0;
                        }
                    });
                    for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
                        this.sections[i].questions[j].options[k].position = j;
                    }
                }
            }
        }

        $('#containter-sections').html(
            $('#sectionTemplateAdd').render(this.sections)
        );

        $('[data-toggle="tooltip"]').tooltip();
    }

    FormGenerator.prototype.renderSection = function(slug_section) {
        for (i = 0; i < this.sections.length; i++) {
            if (slug_section == this.sections[i].slug_section) {
                for (j = 0; j < this.sections[i].questions.length; j++) {
                    this.sections[i].questions[j].position = j;
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
                        this.sections[i].questions[j].options.sort(function(a, b) {
                            if (a.position > b.position) {
                                return 1;
                            } else if (a.position < b.position) {
                                return -1;
                            } else {
                                return 0;   
                            }
                        });
                    }
                    for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
                        this.sections[i].questions[j].options[k].position = j;
                    }
                }


                var element = $('#panel-' + slug_section);
                if(element.length == 0) {
                    $('#containter-sections').append(
                        $('#sectionTemplateAdd').render(this.sections[i])
                    );
                } else {
                    $('#panel-' + slug_section).html(
                        $('#sectionTemplateReplace').render(this.sections[i])
                    );
                }
                $('[data-toggle="tooltip"]').tooltip();

                break
            } else {
                continue;
            }
            
        }


    }
        
    FormGenerator.prototype.addSection = function(name, text) {
        var d = new Date();
        var slug = 'section' + d.getTime();
        var position = 0;
        $.each(this.sections, function(index, section) {
            if (position < section.position) {
                position = section.position;
            }
        });
        position++;
        var section = {
            'slug_section': slug,
            'name': name,
            'text': text,
            'position': position,
            'questions': [],
            'status': 0
        }
        this.sections.push(section);

        return slug;
    }

    FormGenerator.prototype.editSection = function(slug, name, text) {
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug == this.sections[i].slug_section) {
                this.sections[i].name = name;
                this.sections[i].text = text;
                renderTable = true;
                break;
            }
        }
        if (renderTable) {
            this.renderSection(slug);
        }
    }

    FormGenerator.prototype.deleteSection = function(slug) {
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug == this.sections[i].slug_section) {
                this.sections.splice(i, 1);
                renderTable = true;
                break;
            }
        }
        if (renderTable) {
            $('#panel-' + slug).remove();
        }
    }

    FormGenerator.prototype.addQuestion = function(slug_section, text, type) {
        var d = new Date();
        var slug_question = 'question' + d.getTime();
        var position = 0;
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug_section == this.sections[i].slug_section) {
                $.each(this.sections[i].questions, function(index, question) {
                    if (position < question.position) {
                        position = question.position;
                    }
                });
                position++;
                var question = {
                    'slug_section': slug_section,
                    'slug_question': slug_question,
                    'text': text,
                    'type': type,
                    'position': position,
                    'options': []
                }
                this.sections[i].questions.push(question);
                renderTable = true;
                break;
            }
        }
        if (renderTable) {
            this.renderSection(slug_section);
        }
    }

    FormGenerator.prototype.editQuestion = function(slug_section, slug_question, text, type) {
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug_section == this.sections[i].slug_section) {
                for (j = 0; j < this.sections[i].questions.length; j++) {
                    if (slug_question == this.sections[i].questions[j].slug_question) {
                        this.sections[i].questions[j].text = text,
                        this.sections[i].questions[j].type = type;

                        renderTable = true;
                        break;
                    }
                }
            }
            if (renderTable) {
                break;
            }
        }
        if (renderTable) {
            this.renderSection(slug_section);
        }
    }

    FormGenerator.prototype.deleteQuestion = function(slug_section, slug_question) {
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug_section == this.sections[i].slug_section) {
                for (j = 0; j < this.sections[i].questions.length; j++) {
                    if (slug_question == this.sections[i].questions[j].slug_question) {
                        this.sections[i].questions.splice(j, 1);
                        renderTable = true;
                        break;
                    }
                }
            }
            if (renderTable) {
                break;
            }
        }
        if (renderTable) {
            this.renderSection(slug_section);
        }
    }

    FormGenerator.prototype.addOption = function(slug_section, slug_question, text) {
        var d = new Date();
        var slug_option = 'option' + d.getTime();
        var position = 0;
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug_section == this.sections[i].slug_section) {
                for (j = 0; j < this.sections[i].questions.length; j++) {
                    if (slug_question == this.sections[i].questions[j].slug_question) {
                        $.each(this.sections[i].questions[j].options, function(index, option) {
                            if (position < option.position) {
                                position = option.position;
                            }
                        });
                        position++;
                        var option = {
                            'slug_section': slug_section,
                            'slug_question': slug_question,
                            'slug_option': slug_option,
                            'text': text,
                            'checked': false
                        }
                        this.sections[i].questions[j].options.push(option);
                        renderTable = true;
                        break;
                    }
                    if (renderTable) {
                        break;
                    }
                }
            }
        }
        if (renderTable) {
            this.renderSection(slug_section);
        }
    }

    FormGenerator.prototype.editOption = function(slug_section, slug_question, option_slug, text) {
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug_section == this.sections[i].slug_section) {
                for (j = 0; j < this.sections[i].questions.length; j++) {
                    if (slug_question == this.sections[i].questions[j].slug_question) {
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
                            if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
                                this.sections[i].questions[j].options[k].text = text;
                                renderTable = true;
                                break;
                            }
                        }
                    }
                    if (renderTable) {
                        break;
                    }
                }
            }
            if (renderTable) {
                break;
            }
        }
        if (renderTable) {
            this.renderSection(slug_section);
        }
    }

    FormGenerator.prototype.deleteOption = function(slug_section, slug_question, option_slug) {
        var renderTable = false;
        for (i = 0; i < this.sections.length; i++) {
            if (slug_section == this.sections[i].slug_section) {
                for (j = 0; j < this.sections[i].questions.length; j++) {
                    if (slug_question == this.sections[i].questions[j].slug_question) {
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
                            if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
                                this.sections[i].questions[j].options.splice(k, 1);
                                renderTable = true;
                                break;
                            }
                        }
                    }
                    if (renderTable) {
                        break;
                    }
                }
            }
            if (renderTable) {
                break;
            }
        }
        if (renderTable) {
            this.renderSection(slug_section);
        }
    }


jQuery(document).ready(function($) {
    var objFormGenerator = new FormGenerator();
    objFormGenerator.render();


    var allowEdit = $allowEdit;
    var allowDelete = $allowDelete;
    
    var tableForm = $('#tableForm').dataTable({
        'processing': true,
        'serverSide': true,
        'searching': true,
        'order': [
            [0, 'asc']
        ],
        'ordering': true,
        'ordenable': true,
        'responsive': true,
        'select': false,
        'paging': true,
        'pagingType': 'simple_numbers',
        'ajax': {
            'url': '$routeDatatable',
            'type': 'get',
            'beforeSend': function(request) {
                NProgress.start();
            },
            'dataFilter': function(response) {
                var response = jQuery.parseJSON(response);
                var json = {};
                json.recordsTotal = 0;
                json.recordsFiltered = 0;
                json.data = [];
                if (response.success) {
                    json.recordsTotal = response.data.total;
                    json.recordsFiltered = response.data.total;
                    json.data = response.data.items;
                } else {
                    $.fn.showError(response.data)
                }
                return JSON.stringify(json);
            }
        },
        'language': {
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
            'sInfo': 'LABEL_DATATABLE_SINFO',
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
            'sInfoPostFix': '',
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
            'sUrl': '',
            'sInfoThousands': ',',
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
            'oPaginate': {
                'sFirst': 'LABEL_DATATABLE_SFIRST',
                'sLast': 'LABEL_DATATABLE_SLAST',
                'sNext': 'LABEL_DATATABLE_SNEXT',
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
            },
            'oAria': {
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
            },
        },
        'drawCallback': function(settings) {
            NProgress.done();
            
        },
        'aoColumns': [{
                'mDataProp': 'name'
            },
            {
                'mDataProp': 'status'
            },
            {
                'mDataProp': 'actions'
            },
        ],
        'columnDefs': [{
                'targets': 0,
                'className': 'text-vertical-middle',
            },
            {
                'targets': -2,
                'orderable': false,
                'className': 'text-center',
                'render': function(data, type, row) {
                    checked = data == '$status_active' ? ' checked="checked" ' : '';
                    return '<div class="form-check">' +
                        '<input type="checkbox" class="form-check-input" disabled="" ' + checked + '>' +
                        '<label class="form-check-label" for="checkCheckedDisabled"></label></div>' ;
                }
            },
            {
                'targets': -1,
                'orderable': false,
                'render': function(data, type, row) {
                    s = '';
                    if (allowEdit) {
                        s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pen"></i> LABEL_EDIT </button>&nbsp;';
                    }
                    if (allowDelete) {
                        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;';
                    }
                    return s;
                }
            }
        ],
    });

    $('body').on('click', 'button.btn-edit-form', function(e) {
        e.preventDefault();
        form_id = $(this).data('id')
        var action = $(this).data('href');
        $.ajax({
            'dataType': 'json',
            'accept': 'application/json',
            'method': 'get',
            'url': action,
        }).done(function(response) {
            if (response['success']) {
                validatorForm.resetForm();
                $('#form-main').attr('action', action);
                $('#form-main #form-id').val(response['data']['id']),
                $('#form-main #form-continue').val('0');
                $('#form-main #name').val(response['data']['name']),
                $('#form-main #text').val(response['data']['text']),
                $('#form-main #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')


                objFormGenerator.clear();
                objFormGenerator.sections = response['data']['content'] || [];
                objFormGenerator.render();
               
                $('#row-forms').hide();
                $('#row-edit').show();
                $('#form-main #name').focus();

            } else {
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
            }
        }).fail(function(jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        });
    });


    var validatorForm = $('#form-main').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                minlength: 2,
                maxlength: 128
            },
            'text':{
                required: true
            },
            'status': {
                required: false,
            },
        },

        submitHandler: function(form) {

            if(!objFormGenerator.isValid()) {
                return false;
            }

            var status = $('#form-main #status').prop('checked') ? '$status_active' : '$status_inactive';    
            var formContinue = parseInt($('#form-main #form-continue').val());
            var data = {
                'name': $('#form-main #name').val(),
                'text': $('#form-main #text').val(),
                'status': status,
                'content': JSON.stringify(objFormGenerator.sections)
            }

            $.ajax({
                'dataType': 'json',
                'method': 'post',
                'url': $('#form-main').attr('action'),
                'data': data,
            }).done(function(response) {
                if (response['success']) {
                    $.fn.showSuccess(response['data']['message']);
                    if (formContinue == 1) {
                        $('#form-main').attr('action',response['data']['action']);
                        $('#form-main #form-continue').val(0);
                    } else {
                        tableForm.api().ajax.reload(null, false);

                        $('#row-edit').hide();
                        $('#row-forms').show();
                        
                    }

                    

                } else {
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
                }
            }).fail(function(jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            });
            return false;
        }
    });

    var validatorFormSection = $("#form-section").validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'section-name': {
                required: true,
                minlength: 2,
                maxlength: 50
            },
            'section-text': {
                required: false,
            },
        },
        submitHandler: function(form) {
            // do other things for a valid form
            //form.submit();
            var slug = $('#form-section #section-slug').val();
            if (slug) {
                objFormGenerator.editSection(
                    $('#form-section #section-slug').val(),
                    $('#form-section #section-name').val(),
                    $('#form-section #section-text').val(),
                );
            } else {
                slug = objFormGenerator.addSection(
                    $('#form-section #section-name').val(),
                    $('#form-section #section-text').val()
                );
            }
         
            objFormGenerator.renderSection(slug);
            $('#modal-section').modal('hide');
            return false;
        }
    });

    var validatorFormQuestion = $("#form-question").validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'question-text': {
                required: true,
            },
            'question-type': {
                required: true,
            },
        },
        submitHandler: function(form) {

            if ($('#form-question #question-slug').val()) {
                objFormGenerator.editQuestion(
                    $('#form-question #question-section').val(),
                    $('#form-question #question-slug').val(),
                    $('#form-question #question-text').val(),
                    $('#form-question #question-type').val()
                );
            } else {
                objFormGenerator.addQuestion(
                    $('#form-question #question-section').val(),
                    $('#form-question #question-text').val(),
                    $('#form-question #question-type').val()
                );
            }
            objFormGenerator.renderSection($('#form-question #question-section').val());
            $('#modal-question').modal('hide');
            return false;
        }
    });

    var validatorFormOption = $("#form-option").validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'option-text': {
                required: true,
            }
           
        },
        submitHandler: function(form) {
            if ($('#form-option #option-slug').val()) {
                objFormGenerator.editOption(
                    $('#form-option #option-section').val(),
                    $('#form-option #option-question').val(),
                    $('#form-option #option-slug').val(),
                    $('#form-option #option-text').val()                  
                );
            } else {
                objFormGenerator.addOption(
                    $('#form-option #option-section').val(),
                    $('#form-option #option-question').val(),
                    $('#form-option #option-text').val()
                );
            }
            objFormGenerator.renderSection($('#form-option #option-section').val());
            $('#modal-option').modal('hide');
            return false;
        }
    });

    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
        e.preventDefault();
        validatorFormSection.resetForm();
       
        $('#form-section #section-slug').val('');
        $('#form-section #section-name').val('');
        $('#form-section #section-text').val('');
        $('#modal-section h6[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
        $('#modal-section').modal('show');
    });

    $('body').on('click', 'button.btn-edit-section', function(e) {
        e.preventDefault();
        var slug = $(this).data('section');
        var section;
        var showForm = false;
        for (i = 0; i < objFormGenerator.sections.length; i++) {
            section = objFormGenerator.sections[i];
            if (slug == section.slug_section) {
                validatorFormSection.resetForm();
                $('#form-section #section-slug').val(section.slug_section);
                $('#form-section #section-name').val(section.name);
                $('#form-section #section-text').val(section.text);
                showForm = true;
                break;
            }
        }
        if (showForm) {
            $('#modal-section h6[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
            $('#modal-section').modal('show');
        }
    });

    $('body').on('click', 'button.btn-delete-section', function(e) {
        e.preventDefault();
        var slug = $(this).data('section');

          swal.fire({
            title: "LABEL_DELETE LABEL_SECTION",
            message: "LABEL_QUESTION_DELETE",
            icon: 'question',
            cancelButtonText: 'LABEL_NO',
            showCancelButton: true,
            confirmButtonText: 'LABEL_YES'
          }).then((result) => {
            if (result.isConfirmed) {
                objFormGenerator.deleteSection(slug);
            }
          }); 
    });

    $('body').on('click', 'button.btn-add-question', function(e) {
        e.preventDefault();
        validatorFormQuestion.resetForm();
        var slug = $(this).data('section');
        $('#form-question #question-section').val(slug);
        $('#form-question #question-slug').val('');
        $('#form-question #question-text').val('');
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
        $('#modal-question h6[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
        $('#modal-question').modal('show');
    });

    $('body').on('click', 'button.btn-edit-question', function(e) {
        e.preventDefault();
        var slug_section = $(this).data('section');
        var slug = $(this).data('question');
        var showForm = false;
        for (i = 0; i < objFormGenerator.sections.length; i++) {
            if (slug_section == objFormGenerator.sections[i].slug_section) {
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
                        validatorFormQuestion.resetForm();
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
                        $('#form-question #question-text').val(objFormGenerator.sections[i].questions[j].text);
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);

                        showForm = true;
                        break;
                    }
                }
                break;
            }
        }
        if (showForm) {
            $('#modal-question h6[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
            $('#modal-question').modal('show');
        }
    });

    $('body').on('click', 'button.btn-delete-question', function(e) {
        e.preventDefault();
        var slug_section = $(this).data('section');
        var slug = $(this).data('question');

          swal.fire({
            title: "LABEL_DELETE LABEL_QUESTION",
            message: "LABEL_QUESTION_DELETE",
            icon: 'question',
            cancelButtonText: 'LABEL_NO',
            showCancelButton: true,
            confirmButtonText: 'LABEL_YES'
          }).then((result) => {
            if (result.isConfirmed) {
                objFormGenerator.deleteQuestion(slug_section, slug);
            }
          }); 


    });

    $('body').on('click', 'button.btn-add-option', function(e) {
        e.preventDefault();
        var slug_section = $(this).data('section');
        var slug_question = $(this).data('question');
        var showForm = false;
        for (i = 0; i < objFormGenerator.sections.length; i++) {
            if (slug_section == objFormGenerator.sections[i].slug_section) {
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
                        validatorFormOption.resetForm();
                        $('#form-option #option-section').val(slug_section);
                        $('#form-option #option-question').val(slug_question);
                        $('#form-option #option-slug').val('');
                        $('#form-option #option-text').val('');

                        $('#modal-option h6[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
                        $('#modal-option').modal('show');
                        return true;
                    }
                }
            }
        }
    });


    $('body').on('click', 'button.btn-edit-option', function(e) {
        e.preventDefault();
        var slug_section = $(this).data('section');
        var slug_question = $(this).data('question');
        var slug = $(this).data('slug');
        var showForm = false;
        for (i = 0; i < objFormGenerator.sections.length; i++) {
            if (slug_section == objFormGenerator.sections[i].slug_section) {
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
                                validatorFormOption.resetForm();
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
                                $('#form-option #option-text').val(objFormGenerator.sections[i].questions[j].options[k].text);
                                showForm = true;
                                break;
                            }
                        }
                    }
                    if (showForm) {
                        break;
                    }
                }
            }
            if (showForm) {
                break;
            }
        }
        if (showForm) {
            $('#modal-option h6[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
            $('#modal-option').modal('show');
        }
    });


    $('body').on('click', 'button.btn-delete-option', function(e) {
        e.preventDefault();
        var slug_section = $(this).data('section');
        var slug_question = $(this).data('question');
        var slug = $(this).data('slug');

          swal.fire({
            title: "LABEL_DELETE LABEL_OPTION",
            message: "LABEL_QUESTION_DELETE",
            icon: 'question',
            cancelButtonText: 'LABEL_NO',
            showCancelButton: true,
            confirmButtonText: 'LABEL_YES'
          }).then((result) => {
            if (result.isConfirmed) {
                objFormGenerator.deleteOption(slug_section, slug_question, slug);
            }
          }); 


    })


    $('button.btn-add-form').click(function(e) {
        e.preventDefault();
        objFormGenerator.clear();
        objFormGenerator.render();
        validatorForm.resetForm();
      
        $('#form-main').attr('action', '$routeAdd');
        $('#form-main #form-continue').val('0');
        $('#form-main #name').val('');
        $('#form-main #status').bootstrapToggle('on')
        $('#form-main #text').val('');
        $('#row-forms').hide();
        $('#row-edit').show();
        $('#form-main #name').focus();

    });

    $('#btn-edit-cancel').click(function(e) {
        e.preventDefault();

         tableForm.api().ajax.reload(null, false);

        $('#row-edit').hide();
        $('#row-forms').show();

       
    });


    $('#btn-form-save-continue').click(function(e) {
        e.preventDefault();
        $('#form-main #form-continue').val('1')
        $('#form-main').submit();
    });


    $('#btn-form-save-close').click(function(e) {
        e.preventDefault();

        $('#form-main #form-continue').val('0')
        $('#form-main').submit();
    });


    $('#modal-section, #modal-question, #modal-option').modal({
        backdrop: 'static',
        keyboard: false,
        show: false
    });

    $('button.btn-refresh').click(function(e) {
        tableForm.api().ajax.reload(null, false);
    });

 $('body').on('click', 'button.btn-delete', function(e) { 
        e.preventDefault();
        var action = $(this).data('href');


          swal.fire({
            title: 'LABEL_ARE_YOU_SURE',
            icon: 'question',
            cancelButtonText: 'LABEL_NO',
            showCancelButton: true,
            confirmButtonText: 'LABEL_YES'
          }).then((result) => {
            if (result.isConfirmed) {

                    NProgress.start();
                    $.ajax({
                        'dataType'  : 'json',
                        'accept'    : 'application/json',
                        'method'    : 'post',
                        'url'       :  action,
                    }).done(function(response) {
                        if(response['success']) {
                            $.fn.showSuccess(response['data']);
                            tableForm.api().ajax.reload(null, false);
                        } else {
                            $.fn.showError(response['data']);
                        }
                    }).fail(function( jqXHR, textStatus, errorThrown) {
                        $.fn.showError(textStatus);
                    }).always(function() {
                        NProgress.done();
                    });
            }
       });
    });

    
    $('#form-main #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});

});
JS;
$this->inlineScript()->captureEnd();
?>

<div class="container">
        <div class="card" id="row-forms">
                <div class="card-header">
                        <h6 class="card-title">LABEL_FORM_BUILDER</h6>
                </div>
                <div class="card-body">
                        
                        <div class="row">
                         <div class="col-12 mt-3">
                                <table id="tableForm" class="table   table-bordered">
                            <thead>
                                <tr>
                                    <th>LABEL_NAME</th>
                                    <th>LABEL_ACTIVE</th>
                                    <th>LABEL_ACTIONS</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                         </div>
                     </div>
                </div>
                <div class="card-footer text-right">
                <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
                <?php if ($allowAdd) : ?>
                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
                <?php endif; ?>
                </div>
        </div>
        
        <div class="card"  id="row-edit" style="display: none">
                <form name="form-main" id="form-main">
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
                <div class="card-header">
                        <h6 class="card-title">LABEL_FORM</h6>
                </div>
                <div class="card-body">
                        <h6 class="card-title"></h6>
                     
                <div class="row">
                    <div class="col-12 mt-3">
                    <?php
                    $element = $form->get('name');
                    $element->setOptions(['label' => 'LABEL_NAME']);
                    $element->setAttributes(['class' => 'form-control']);
                    echo $this->formLabel($element);
                    echo $this->formText($element);
                    ?>
                    </div>
                </div>

                <div class="row">
                    <div class="col-12 mt-3">
                    <?php
                    $element = $form->get('text');
                    $element->setOptions(['label' => 'LABEL_TEXT']);
                    $element->setAttributes(['class' => 'form-control']);
                    echo $this->formLabel($element);
                    echo $this->formTextArea($element);
                    ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-12 mt-3">
                    <?php
                    $element = $form->get('status');
                    $element->setAttributes(['class' => 'form-control']);
                    $element->setOptions(['label' => 'LABEL_STATUS']);
                    echo $this->formLabel($element);
                    echo '<br>';    
                    echo $this->formCheckbox($element);
                    ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-12 mt-3 text-right">
                        <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>
                    </div>
                </div>
                <div class="row">
                    <div class="col-12 mt-3">
                        <div class="panel-group" id="containter-sections"></div>
                    </div>
                </div>
                </div>
                <div class="card-footer text-right">
                    <button type="button" id="btn-form-save-continue" class="btn btn-info ">LABEL_SAVE & LABEL_CONTINUE</button>
                        <button type="button" id="btn-form-save-close" class="btn btn-primary ">LABEL_SAVE & LABEL_CLOSE</button>
                        <button type="button" id="btn-edit-cancel" class="btn btn-light ">LABEL_CANCEL</button>
                </div>
                 </form>
        </div>
        
</div>



    <div id="modal-section" class="modal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg" role="document">
            <form action="#" name="form-section" id="form-section">
                <input type="hidden" name="section-slug" id="section-slug" value="" />
                <div class="modal-content">
                    <div class="modal-header">
                        <h6 class="modal-title">LABEL_ADD LABEL_SECTION</h6>
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                                <div class="col-12 mt-3">
                            <label for="section-name">LABEL_FIRST_NAME</label>
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
                            </div>
                        </div>
                        <div class="row">
                                <div class="col-12 mt-3">
                            <label for="section-text">LABEL_TEXT</label>
                            <!--  ckeditor -->
                            <textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer text-right">
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
                        <button type="button" class="btn btn-light " data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!-- End Modal Section -->

    <!-- Question Modal -->

    <div id="modal-question" class="modal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg" role="document">
            <form action="#" name="form-question" id="form-question">
                <input type="hidden" name="question-section" id="question-section" />
                <input type="hidden" name="question-slug" id="question-slug" />
                <div class="modal-content">
                    <div class="modal-header">
                        <h6 class="modal-title">LABEL_ADD LABEL_QUESTION</h6>
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>

                    </div>
                    <div class="modal-body">
                        <div class="row">
                                <div class="col-12 mt-3">
                            <label for="question-text">LABEL_TEXT</label>
                            <!--  ckeditor -->
                            <textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
                            </div>
                        </div>
                        <div class="row">
                                <div class="col-12 mt-3">
                            <label for="question-type">LABEL_TYPE</label>
                            <select name="question-type" id="question-type" class="form-control">
                                <option value="simple">LABEL_SINGLE_SELECTION</option>
                                <option value="multiple">LABEL_MULTIPLE_SELECTION</option>
                                <option value="range1to5">LABEL_RANGE_1_5</option>

                            </select>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer text-right">
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
                        <button type="button" class="btn btn-light " data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <!-- End Modal Question -->

    <!-- Modal Options -->

    <div id="modal-option" class="modal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg" role="document">
            <form action="#" name="form-option" id="form-option">
                <input type="hidden" name="option-section" id="option-section" value="" />
                <input type="hidden" name="option-question" id="option-question" value="" />
                <input type="hidden" name="option-slug" id="option-slug" value="" />
                <div class="modal-content">
                    <div class="modal-header">
                        <h6 class="modal-title">LABEL_OPTION</h6>
                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                                <div class="col-12 mt-3">
                            <label for="option-text">LABEL_TEXT</label>
                            <!--  ckeditor -->
                            <textarea name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer text-right">
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
                        <button type="button" class="btn btn-light " data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
                    </div>
                </div>
            </form>
        </div>
    </div>



    
    <!---Template Sections --->
    <script id="sectionTemplateReplace" type="text/x-jsrender">

        <div class="panel-heading">
            <h6 class="panel-title">
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
                    <span class="section-name{{:slug_section}}">
                        {{:name}}
                    </span>
                </a>
            </h6>
        </div>
        <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th style="width: 10%;">LABEL_ELEMENT</th>
                                <th style="width: 50%;">LABEL_TEXT</th>
                                <th style="width: 10%;">LABEL_TYPE</th>
                                <th style="width: 20%;">LABEL_ACTIONS</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="tr-section">
                                <td class="text-left">LABEL_SECTION</td>
                                <td class="text-left">{{:name}}</td>
                                <td></td>
                                <td>
                                    <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>
                                    <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>
                                    <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>
                                </td>
                            </tr>
                            {{for questions}}
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
                                <td class="text-left">--LABEL_QUESTION</td>
                                <td class="text-left">
                                    {{:text}}
                                </td>
                                <td class="text-capitalize">
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
                                </td>
                                <td>
                                    <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>
                                    <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>
                                 
                                    {{if type == 'simple' ||  type=='multiple' }}
                                    <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>
                                    {{/if}}
                               
                                </td>
                            </tr>
                            {{for options}}
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
                                <td class="text-left">---LABEL_OPTION</td>
                                <td class="text-left">
                                    {{:text}}
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <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>
                                    <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>
                                </td>
                            </tr>
                            {{/for}}
                            {{/for}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </script>

    <!---Template Sections --->
    <script id="sectionTemplateAdd" type="text/x-jsrender">
    <div class="panel panel-default" id="panel-{{:slug_section}}">
        <div class="panel-heading">
            <h6 class="panel-title">
                <a class="d-block w-100 collapsed card-primary" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
                    <i class="fa" aria-hidden="true"></i>     
                    <span class="section-name{{:slug_section}}">
                        {{:name}}
                    </span>
                </a>
            </h6>
        </div>
        <div id="collapse-{{:slug_section}}" class="collapse show" data-parent="panel-{{:slug_section}}" style="">
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th style="width: 10%;">LABEL_ELEMENT</th>
                                <th style="width: 50%;">LABEL_TEXT</th>
                                <th style="width: 10%;">LABEL_TYPE</th>
                                <th style="width: 20%;">LABEL_ACTIONS</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="tr-section">
                                <td class="text-left">LABEL_SECTION</td>
                                <td class="text-left">{{:name}}</td>
                                <td></td>
                                <td>
                                    <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>
                                    <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>
                                    <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>
                                </td>
                            </tr>
                            {{for questions}}
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
                                <td class="text-left">--LABEL_QUESTION</td>
                                <td class="text-left">
                                    {{:text}}
                                </td>
                                <td class="text-capitalize">
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
                                </td>
                                <td>
                                    <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>
                                    <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>
                                 
                                    {{if type == 'simple' || type=='multiple' }}
                                    <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>
                                    {{/if}}
                               
                                </td>
                            </tr>
                            {{for options}}
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
                                <td class="text-left">---LABEL_OPTION</td>
                                <td class="text-left">
                                    {{:text}}
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <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>
                                    <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>
                                </td>
                            </tr>
                            {{/for}}
                            {{/for}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    </script>