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('publications/posts/add');
$routeDatatable = $this->url('publications/posts');
$routeDashboard = $this->url('dashboard');

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

$typeURL = \LeadersLinked\Model\Page::TYPE_URL;
$typePAGE = \LeadersLinked\Model\Page::TYPE_PAGE;

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

$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.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/bootstrap-fileinput/css/fileinput.min.css'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.css'));


$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/piexif.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/sortable.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/fileinput.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/locales/es.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/fas/theme.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.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/select2/js/select2.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/i18n/es.js'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.css'));

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

$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'));




$status_active = \LeadersLinked\Model\Post::STATUS_ACTIVE;

$this->inlineScript()->captureStart();
echo <<<JS
    jQuery( document ).ready(function( $ ) {
        $.validator.addMethod('requiredDescriptionAdd', function (value, element, param) {
            CKEDITOR.instances.description_add.updateElement();            

            var value = CKEDITOR.instances.description_add.getData();
            value = $.trim($.fn.stripHtml(value));
            return value.length > 0;
        }, 'ERROR_REQUIRED');

        $.validator.addMethod('requiredDescriptionEdit', function (value, element, param) {
            CKEDITOR.instances.description_edit.updateElement();                 

             var value = CKEDITOR.instances.description_edit.getData();
            value = $.trim($.fn.stripHtml(value));
            return value.length > 0;
        }, 'ERROR_REQUIRED');


        var allowEdit   = $allowEdit;
        var allowDelete = $allowDelete;
        
        var gridTable = $('#gridTable').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': 'title' },
                { 'mDataProp': 'date' },
                { 'mDataProp': 'active' },
                { 'mDataProp': 'actions' },
            ],
            'columnDefs': [
                {
                    'targets': 0,
                    'className' : 'text-vertical-middle',
                    'render' : function ( data, type, row ) {
                        var s = data ;
                        if(row['actions']['link_view'] ) {
                            s = s + '<br><button class="btn btn-light btn-view" data-href="' + row['actions']['link_view']+ '" data-toggle="tooltip" title="LABEL_POST"><i class="fa fa-external-link-alt"></i></button>&nbsp;<br>';
                        }
                        return s;
                    }
                },
                {
                    'targets': 1,
                    'className' : 'text-vertical-middle',
                },
                {
                    'targets': -2,
                    'orderable': false,
                    'className' : 'text-center',
                      'render' : function ( data, type, row ) {
                      
                        checked = data == 'a'  ? '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 &&  data['link_edit']) {
                            s = s + '<button class="btn btn-primary btn-sm btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pen"></i> LABEL_EDIT </button>&nbsp;';
                        }
                        if(allowDelete && data['link_delete']) {
                            s = s + '<button class="btn btn-danger btn-sm 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;
                    }
                }
              ],
        });


        var validatorAdd = $('#form-add').validate({
            debug: true,
            onclick: false,
            onkeyup: false,
            ignore: [],
            rules: {
                'title': {
                    required: true,
                    maxlength: 128,
                },
                'description': {
                    requiredDescriptionAdd: true,
                },
                'url': {
                    description: false, 
                },
                'status': {
                    require: false,
                },
                'date': {
                    required: true,
                    
                },
               'image': {
                    required: true,
                    extension: 'jpg|jpeg|png',
                    accept: 'image/jpg,image/jpeg,image/png'
                },
               'file': {
                    required: true,
                    extension: 'jpg|jpeg|png|webm,mp4,webm|wav|mp3|pdf',
                    accept: 'image/jpg,image/jpeg,image/png,video/webm,video/mpeg,video/mp4,audio/wav, audio/mpeg, application/pdf'
                },
            },
            submitHandler: function(form)
            {
    
                var formdata = false;
                if (window.FormData){
                    formdata = new FormData(form); //form[0]);
                }
    
                $('#modal-add .btn-primary').prop('disabled', true);
                
                $.ajax({
                    'dataType'  : 'json',
                    'accept'    : 'application/json',
                    'method'    : 'post',
                    'url'       :  '$routeAdd',
                    'data'      :  formdata,
                    'processData': false,
                    'contentType': false,
                }).done(function(response) {
                    if(response['success']) {
                        $.fn.showSuccess(response['data']);
                        $('#modal-add .btn-primary').prop('disabled', false);
                        $('#modal-add').modal('hide');
                        
                        gridTable.api().ajax.reload(null, false);
                    } else {
                        validatorAdd.resetForm();
                        $('#modal-add .btn-primary').prop('disabled',false);
                        if(jQuery.type(response['data']) == 'string') {
                            $.fn.showError(response['data']);
                        } else  {
                            $.each(response['data'], function( fieldname, errors ) {
                                $.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
                            });
                        }
                    }
                }).fail(function( jqXHR, textStatus, errorThrown) {
                    $.fn.showError(textStatus);
                }).always(function() {
                    NProgress.done();
                });
                return false;
            },
            invalidHandler: function(form, validator) {
                
            }
            

        });

        var validatorEdit = $('#form-edit').validate({
            debug: true,
            onclick: false,
            onkeyup: false,
            ignore: [],
            rules: {
                'title': {
                    required: true,
                    maxlength: 128,
                },
                'description': {
                    requiredDescriptionEdit: true,
                },
                'url': {
                    description: false, 
                },
                'status': {
                    require: false,
                },
                'date': {
                    required: true,
                    
                },
               'image': {
                    required: false,
                    extension: 'jpg|jpeg|png',
                    accept: 'image/jpg,image/jpeg,image/png'
                },
               'file': {
                    required: false,
                    extension: 'jpg|jpeg|png|webm,mp4,webm|wav|mp3|pdf',
                    accept: 'image/jpg,image/jpeg,image/png,video/webm,video/mpeg,video/mp4,audio/wav, audio/mpeg, application/pdf'
                },
            },
            submitHandler: function(form)
            {
    
                var formdata = false;
                if (window.FormData){
                    formdata = new FormData(form); //form[0]);
                }
    
                $('input[type="submit"]').prop('disabled', true);
    
                $.ajax({
                    'dataType'  : 'json',
                    'accept'    : 'application/json',
                    'method'    : 'post',
                    'url'       :  $('#form-edit').attr('action'),
                    'data'      :  formdata,
                    'processData': false,
                    'contentType': false,
                }).done(function(response) {
                    if(response['success']) {
                        $.fn.showSuccess(response['data']);
                        $('#modal-edit').modal('hide');
                        
                        gridTable.api().ajax.reload(null, false);
                    } else {
                        validatorAdd.resetForm();
                        if(jQuery.type(response['data']) == 'string') {
                            $.fn.showError(response['data']);
                        } else  {
                            $.each(response['data'], function( fieldname, errors ) {
                                $.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
                            });
                        }
                    }
                }).fail(function( jqXHR, textStatus, errorThrown) {
                    $.fn.showError(textStatus);
                }).always(function() {
                    NProgress.done();
                });
                return false;
            },
            invalidHandler: function(form, validator) {
                
            }
            

        });
        
        $('body').on('click', 'button.btn-add', function(e) {
            e.preventDefault();

            $('#form-add #title').val('');
            $('#form-add #date').val('');
            $('#form-add #url').val('');
            $('#form-add #status').bootstrapToggle('on');

            $('#form-add #file').fileinput('reset');
            $('#form-add #file').val('');

            $('#form-add #image').fileinput('reset');
            $('#form-add #image').val('');

            CKEDITOR.instances.description_add.setData('');
            validatorAdd.resetForm();

            $('#modal-add').modal('show');
        });
        
        $('body').on('click', 'button.btn-edit', function(e) {
            e.preventDefault();
            NProgress.start();
            var action = $(this).data('href');

            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'get',
                'url'       :  action,
            }).done(function(response) {
                if(response['success']) {

                    $('#form-edit').attr('action', action);
                    $('#form-edit #title').val(response['data']['title']);
                    $('#form-edit #date').val(response['data']['date']);
                    $('#form-edit #url').val(response['data']['url']);
                    $('#form-edit #status').bootstrapToggle(response['data']['status'] == 'a' ? 'on' : 'off');
        
                    $('#form-edit #file').fileinput('reset');
                    $('#form-edit #file').val('');
        
                    $('#form-edit #image').fileinput('reset');
                    $('#form-edit #image').val('');
        
                    var description = $.trim(response['data']['description']);
                    CKEDITOR.instances.description_edit.setData(description.length > 0 ? description : '');
    
                    validatorEdit.resetForm();
        
                    $('#modal-edit').modal('show');

               
                } else {
                    $.fn.showError(response['data']);
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
            });
        });

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

        $('body').on('click', 'button.btn-cancel', function(e) {
            e.preventDefault();
            $('#modal-add').modal('hide');
            $('#modal-edit').modal('hide');
        });

        $('body').on('click', 'button.btn-view', function(e) {
            e.preventDefault();
           
            var href = $(this).data('href');
            window.open(href, '_blank');

        });

    $('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']);
                            gridTable.api().ajax.reload(null, false);
                        } else {
                            $.fn.showError(response['data']);
                        }
                    }).fail(function( jqXHR, textStatus, errorThrown) {
                        $.fn.showError(textStatus);
                    }).always(function() {
                        NProgress.done();
                    });
            }
       });
    });
        

        $('#form-add #date').datetimepicker({
            locale: 'es',
            format: 'DD/MM/YYYY'
        });

        $('#form-edit #date').datetimepicker({
            locale: 'es',
            format: 'DD/MM/YYYY'
        });

        $('#form-add #image').fileinput({
            theme: 'fa',
            language: 'es',
            showUpload: false,
            dropZoneEnabled: false,
            maxFileCount: 1,
            allowedFileExtensions: ['jpeg', 'jpg', 'png'],
            msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $image_size',
        });
    
    
        $('#form-edit #image').fileinput({
            theme: 'fa',
            language: 'es',
            showUpload: false,
            dropZoneEnabled: false,
            maxFileCount: 1,
            allowedFileExtensions: ['jpeg', 'jpg', 'png'],
            msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $image_size',
        });

        $('#form-add #file').fileinput({
            theme: 'fa',
            language: 'es',
            showUpload: false,
            dropZoneEnabled: false,
            maxFileCount: 1,
            allowedFileExtensions: ['webm','mp4','mpeg','jpg','jpeg','png', 'wav', 'mp3', 'pdf'],
        });

        $('#form-edit #file').fileinput({
            theme: 'fa',
            language: 'es',
            showUpload: false,
            dropZoneEnabled: false,
            maxFileCount: 1,
            allowedFileExtensions: ['webm','mp4','mpeg','jpg','jpeg','png', 'wav', 'mp3', 'pdf'],
        });


        $('#form-add #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
        $('#form-edit #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
        CKEDITOR.replace( 'description_add', {
            toolbar: [
                    { name: 'editing', items: ['Scayt'] },
                    { name: 'links', items: ['Link', 'Unlink'] },
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
                    '/',
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
                    { name: 'styles', items: ['Styles', 'Format'] },
                    { name: 'tools', items: ['Maximize'] }
                ],
                removePlugins: 'elementspath,Anchor',
                heigth: 100
        });
        CKEDITOR.replace( 'description_edit', {
            toolbar: [
                    { name: 'editing', items: ['Scayt'] },
                    { name: 'links', items: ['Link', 'Unlink'] },
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
                    '/',
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
                    { name: 'styles', items: ['Styles', 'Format'] },
                    { name: 'tools', items: ['Maximize'] }
                ],
                removePlugins: 'elementspath,Anchor',
                heigth: 100
        });
    });
JS;
$this->inlineScript()->captureEnd();
?>



<div class="container">
        <div class="card" id="">
                
                <div class="card-body">
                        <h6 class="card-title">LABEL_POSTS</h6>
                        <div class="row">
                         <div class="col-12 mt-3">
                                 <table id="gridTable" class="table   table-bordered">
                        <thead>
                                <tr>
                                        <th>LABEL_TITLE</th>
                                <th>LABEL_DATE</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"><i class="fa fa-plus"></i> LABEL_ADD </button>
                        <?php endif; ?>
                </div>
        </div>
</div>



<!-- The Modal -->
<div class="modal" id="modal-add">
    <div class="modal-dialog  modal-xl">
        <div class="modal-content">

            <!-- Modal Header -->
            <div class="modal-header">
                <h6 class="modal-title">LABEL_ADD</h6>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
            </div>

                <?php
                $form = $this->formAdd;
                $form->setAttributes([
                    'method'    => 'post',
                    'name'      => 'form-add',
                    'id'        => 'form-add'
                ]);

                $form->prepare();
                echo $this->form()->openTag($form);
                ?>
            <div class="modal-body">

                <div class="row">
                         <div class="col-12 mt-3">
                    <?php
                    $element = $form->get('date');
                    $element->setOptions(['label' => 'LABEL_DATE']);
                    $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('title');
                    $element->setOptions(['label' => 'LABEL_TITLE']);
                    $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('description');
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
                    $element->setAttributes(['id' => 'description_add', '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('url');
                    $element->setOptions(['label' => 'LABEL_URL']);
                    $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('status');
                    $element->setAttributes(['class' => 'form-control']);
                    echo $this->formCheckbox($element);
                    ?>
                         </div>
                     </div>
                <div class="row">
                         <div class="col-12 mt-3">

                    <?php
                    $element = $form->get('image');
                    $element->setAttributes(['class' => 'form-control']);
                    $element->setOptions(['label' => 'LABEL_IMAGE']);
                    $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
                    echo $this->formLabel($element);
                    ?>
                    <div class="file-loading">
                        <?php echo $this->formFile($element); ?>
                    </div>

                         </div>
                     </div>
                <div class="row">
                         <div class="col-12 mt-3">

                    <?php
                    $element = $form->get('file');
                    $element->setAttributes(['class' => 'form-control']);
                    $element->setOptions(['label' => 'LABEL_FILE']);
                    $element->setAttributes(['accept' => 'video/webm,video/mp4,video/mpeg,image/jpg,image/jpeg,image/png,audio/wav,audio/mpeg,application/pdf']);
                    echo $this->formLabel($element);
                    ?>
                    <div class="file-loading">
                        <?php echo $this->formFile($element); ?>
                    </div>

                         </div>
                     </div>


                
            </div>

            <!-- Modal footer -->
            <div class="modal-footer text-right">
                                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
                        <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
            </div>
            <?php echo $this->form()->closeTag($form); ?>

        </div>
    </div>
</div>



<!-- The Modal -->
<div class="modal" id="modal-edit">
    <div class="modal-dialog  modal-xl">
        <div class="modal-content">

            <!-- Modal Header -->
            <div class="modal-header">
                <h6 class="modal-title">LABEL_EDIT</h6>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
            </div>

                <?php
                $form = $this->formEdit;
                $form->setAttributes([
                    'method'    => 'post',
                    'name'      => 'form-edit',
                    'id'        => 'form-edit'
                ]);

                $form->prepare();
                echo $this->form()->openTag($form);
                ?>
            <div class="modal-body">

                <div class="row">
                         <div class="col-12 mt-3">
                    <?php
                    $element = $form->get('date');
                    $element->setOptions(['label' => 'LABEL_DATE']);
                    $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('title');
                    $element->setOptions(['label' => 'LABEL_TITLE']);
                    $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('description');
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
                    $element->setAttributes(['id' => 'description_edit', '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('url');
                    $element->setOptions(['label' => 'LABEL_URL']);
                    $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('status');
                    $element->setAttributes(['class' => 'form-control']);
                    echo $this->formCheckbox($element);
                    ?>
                         </div>
                     </div>
                <div class="row">
                         <div class="col-12 mt-3">

                    <?php
                    $element = $form->get('image');
                    $element->setAttributes(['class' => 'form-control']);
                    $element->setOptions(['label' => 'LABEL_IMAGE']);
                    $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
                    echo $this->formLabel($element);
                    ?>
                    <div class="file-loading">
                        <?php echo $this->formFile($element); ?>
                    </div>

                         </div>
                     </div>
                <div class="row">
                         <div class="col-12 mt-3">

                    <?php
                    $element = $form->get('file');
                    $element->setAttributes(['class' => 'form-control']);
                    $element->setOptions(['label' => 'LABEL_FILE']);
                    $element->setAttributes(['accept' => 'video/webm,video/mp4,video/mpeg,image/jpg,image/jpeg,image/png,audio/wav,audio/mpeg,application/pdf']);
                    echo $this->formLabel($element);
                    ?>
                    <div class="file-loading">
                        <?php echo $this->formFile($element); ?>
                    </div>

                         </div>
                     </div>

                
            </div>

            <!-- Modal footer -->
            <div class="modal-footer text-right">
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
                    <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
            </div>
                        <?php echo $this->form()->closeTag($form); ?>
        </div>
    </div>
</div>