<?php $__env->startSection('ElementLoi'); ?>
    <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">Elements de Lois</h2>
                    <div class="card-tools">
                    </div>
                </div>
                <!-- /.card-header -->
                <div class="card-body">
                    <a id="btnModalFormElementLoi" href="#modalFormElementLoi" 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 élément à une Loi</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="nom_loi" data-sortable="true">Nom Loi</th>
                                <th data-field="nom_type_element" data-sortable="true">Nom du type de l'élément</th>
                                <th data-field="nom_element" data-sortable="true">Nom de l'élément</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_AjoutElement.addElement', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('Admin.pages.File_AjoutElement.deleteElement', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('Admin.pages.File_AjoutElement.editElement', \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="editElementLoi" style="color:#2f4f4f" href="javascript:void(0)" title="Modifier">',
                '<i class="fas fa-edit" aria-hidden="true"></i>',
                '</a>',
                '&nbsp;&nbsp;',
                '<a class="deleteElementLoi" style="color:red" href="javascript:void(0)" title="Supprimer">',
                '<i class="fas fa-trash" aria-hidden="true"></i>',
                '</a>',
            ].join('');
        }

        window.actionEvents = {
            'click .editElementLoi': function(e, value, row, index) {
                var id = row.id;
                //console.log(id);
                if (row && row.id) {
            var id = row.id;
            console.log(id);
            // Reste du code...
        } else {
            console.error('ID non défini dans la ligne sélectionnée.');
        }
                $('#ModalEdit').modal('show');
                $.ajax({
                    type: "GET",
                    url: "<?php echo e(route('elemntloi.edit', ['id' => ':id'])); ?>".replace(':id', id),


                    success: function(response) {

                        $('#lois_id').val(response.ElementLois.loi_id);
                        $('#type_elements_id').val(response.ElementLois.type_element_id);
                        $('#nom_elements').val(response.ElementLois.nom_element);
                        $('#text_elements').summernote({
                            minHeight: 100,
                            maxHeight: 200,
                            focus: true
                        });
                        setTimeout(function() {
                            $('#text_elements').summernote('code', response.ElementLois.text_element);
                        }, 100); // Adjust the timeout duration as needed

                        $('#id').val(response.ElementLois.id);
                        $('#element_id').val(response.ElementLois.element_id);
                    }
                });
            },

            'click .deleteElementLoi': function(e, value, row, index) {
                var id = row.id;
                console.log('second texte');
                console.log(id);
                $('#ModalDelete').modal('show');
                $('#deleteing_id').val(id);
            },

        };

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

            html.push('<p><b>Contenu des éléments de la loi  : </b> ' + row.text_element + '</p>')


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

<script>
    // your custom ajax request here
    function ajaxRequest(params) {
        var url = '<?php echo e(route('elemntloi.create')); ?>'
        $.get(url + '?' + $.param(params.data)).then(function(res) {
            params.success(res)
        })
    }
</script>

<script>
    $(function() {
        // Summernote
        $('#summer').summernote({
            minHeight: null,             // set minimum height of editor
            maxHeight: null,             // set maximum height of editor
            focus: true
        });

        // 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 /home/p59qce1cziqc/public_html/takaback.com/resources/views/Admin/pages/File_AjoutElement/AjoutElement.blade.php ENDPATH**/ ?>