<?php $__env->startSection('Activite'); ?>
    <style>
        .bg-cronos {
            background-color: #0b440e;
        }

        .btn-cronos {
            background-color: #0b440e;
            color: #ffff;
        }
    </style>
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">

                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <?php echo $__env->make('sweetalert::alert', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>


    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <!-- SELECT2 EXAMPLE -->
            <div class="card ">
                <div class="card-header bg-cronos">
                    <h2 class="card-title text-white">Gestion des Evènements</h2>
                    <div class="card-tools">
                    </div>
                </div>
                <!-- /.card-header -->
                <div class="card-body">
                    <a id="btnModalFormGestionEvents" href="#modalFormEvents"
                        class="btn btn-cronos text-white add" data-toggle="modal" data-backdrop="static"
                        data-keyboard="false"><i class="fas fa-plus-circle"></i> <span>Ajouter un Events</span></a>

                        <table class="table table-striped table-bordered table-hover" data-toolbar="#btnModalFormGestionStation"
                        id="table" data-toggle="table" data-search="true" data-pagination="true" data-ajax="ajaxRequest"
                        data-buttons-class="cronos" data-show-refresh="true" data-show-toggle="true" data-show-footer="false"
                        data-footer-style="footerStyle" data-show-fullscreen="true" data-show-columns="true"
                        data-show-columns-toggle-all="true" data-show-export="true"  data-detail-view="true" data-detail-formatter="detailFormatter"
                        data-click-to-select="true"
                        data-select-item-name="toolbar" data-sort-name="name" data-page-size="10" data-sort-order="desc"
                        data-export-types="['csv','excel','pdf']">

                        <thead>
                            <tr>
                                <th data-field="nomEvent" data-sortable="true">Nom évènement</th>
                                <th data-formatter="formatterImg">Image</th>
                                <th data-field="dateEvent" data-sortable="true">Date évènement</th>
                                <th data-field="heureEvent" data-sortable="true">Heure évènement</th>
                                <th data-field="lieuEvent" data-sortable="true">Lieu évènement</th>
                                <th data-field="maxGuest" data-sortable="true">Nombre de participants</th>
                                <th data-field="InfoMailEvent" data-sortable="true">Instruction</th>
                                <th data-formatter="actionFormatter" data-events="actionEvents">Action</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <!-- /.card-body -->
                <div class="card-footer"></div>
            </div>
            <!-- /.card -->

        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->

    <?php echo $__env->make('Admin.pages.File_Events.deleteEvents', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('Admin.pages.File_Events.editEvents', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('Admin.pages.File_Events.addEvents', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <!-- Modal-->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <script>
        function actionFormatter(value, row, index) {
            return [
                '<a class="editGestionEvents" style="color:#2f4f4f" href="javascript:void(0)" title="Modifier">',
                '<i class="fas fa-edit" aria-hidden="true"></i>',
                '</a>',
                '&nbsp;&nbsp;', // Ajout d'un espace supplémentaire
                '<a class="deleteGestionEvents" style="color:red" href="javascript:void(0)" title="Supprimer">',
                '<i class="fas fa-trash" aria-hidden="true"></i>',
                '</a>'
            ].join('');
        }

        window.actionEvents = {
            'click .editGestionEvents': function(e, value, row, index) {
                var id = row.id;
                $('#ModalEdit').modal('show');
                $.ajax({
                    type: "GET",
                    url: "<?php echo e(route('event.edit', ['id' => ':id'])); ?>".replace(':id', id),
                    success: function(response) {
                        $('#nomEvent').val(response.Events.nomEvent);
                        $('#dateEvent').val(response.Events.dateEvent);
                        $('#heureEvent').val(response.Events.heureEvent);
                        $('#lieuEvent').val(response.Events.lieuEvent);
                        $('#maxGuest').val(response.Events.maxGuest);
                        
                        $('#eventDesc').summernote({
                            minHeight: 100,
                            maxHeight: 200,
                            focus: true
                        });

                        setTimeout(function() {
                            $('#eventDesc').summernote('code', response.Events.eventDesc);
                        }, 100); // Adjust the timeout duration as needed



                $('#InfoMailEvent').summernote({
                            minHeight: 100,
                            maxHeight: 200,
                            focus: true
                        });

                        setTimeout(function() {
                            $('#InfoMailEvent').summernote('code', response.Events.InfoMailEvent);
                        }, 100); // Adjust the timeout duration as needed
                        
                        $('#id').val(response.Events.id);

                    }
                });
            },

            'click .deleteGestionEvents': function(e, value, row, index) {
                var id = row.id;
                $('#ModalDelete').modal('show');
                $('#deleteing_id').val(id);
            },
        };
        function formatterImg(value, row, index) {
            return [
                '<img src="' + 'img/' + row.Image + '" alt="" border="3" height="75" width="75"></img>'
            ].join('');

        };
        function detailFormatter(index, row) {
            var html = []

            html.push('<p><b>Texte   : </b> ' + row.eventDesc + '</p>')


            return html.join('');
        }
    </script>

    <script>
        // your custom ajax request here
        function ajaxRequest(params) {
            var url = '<?php echo e(route('Gestion+Events.create')); ?>'
            $.get(url + '?' + $.param(params.data)).then(function(res) {
                params.success(res)
            })
        }
    </script>
     <script>
        $(function() {
            // Summernote
            $('#summer').summernote({
                placeholder: 'Entrer un texte',
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: true
            });
            // Summernote
    $('#EditeurTexte').summernote({
                placeholder: 'Entrer un texte',
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: true
            });
            // Summernote

            // CodeMirror
            CodeMirror.fromTextArea(document.getElementById("codeMirrorDemo"), {
                mode: "htmlmixed",
                theme: "monokai"
            });
        })
        </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('Admin.pages.layout.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\takaback\resources\views/Admin/pages/File_Events/Events.blade.php ENDPATH**/ ?>