<?php $__env->startSection('GestionPage'); ?>
    <?php echo $__env->make('sweetalert::alert', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <div class="pagetitle">
        <h1 class="fw-bold"><i class="bi bi-folder"></i> Categorie</h1>

    </div><!-- End Page Title -->
    <section class="section">
        <div class="container mt-4">
            <div class="card">
                <div class="card-body mt-4">
                    <button type="button"  class="btn text-white mb-4"
                        style="background-color:#0b3544;" data-bs-toggle="modal" data-bs-target="#basicModal"><i class="fas fa-plus-circle"></i> <span>Ajouter une Categorie</span></button>

                    <table class="table table-striped table-bordered table-hover" id="table" data-toggle="table"
                        data-ajax="ajaxRequest" data-toolbar="#btnModalFormGestionProduits" data-buttons-class="success"
                        data-show-refresh="false" data-show-toggle="false" data-show-fullscreen="false"
                        data-show-columns="false" data-show-columns-toggle-all="false" data-show-export="false"
                        data-page-list="[10, 25, 50, 100, all]" data-click-to-select="true" data-toggle="table"
                        data-search="true" data-select-item-name="toolbar1" data-pagination="true" data-sort-name="name"
                        data-page-size="10" data-sort-order="desc">
                        <thead>
                            <tr>
                                <th data-field="codeCategorie" data-sortable="true">Categorie ID</th>
                                <th data-field="nomCategorie" data-sortable="true">Nom Produit</th>
                                <th data-formatter="actionFormatter" data-events="actionEvents">Action</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </section>

    <!-- End #main -->

    <?php echo $__env->make('Admin.Categorie.deleteCategorie', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('Admin.Categorie.editCategorie', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('Admin.Categorie.addCategorie', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
    <script>
        // your custom ajax request here
        function ajaxRequest(params) {
            var url = '<?php echo e(route('Gestion+Categorie.create')); ?>'
            $.get(url + '?' + $.param(params.data)).then(function(res) {
                params.success(res)
            })
        }
    </script>
    <script>
        function actionFormatter(value, row, index) {
            return [
                '<a class="editProviders" style="color:blue" href="javascript:void(0)" title="Modifier">',
                '<i class="fas fa-edit" aria-hidden="true"></i>',
                '</a>',
                ' &nbsp &nbsp',
                '<a class="deleteProviders" style="color:red" href="javascript:void(0)" title="Supprimer">',
                '<i class="fas fa-trash" aria-hidden="true"></i>',
                '</a>'

            ].join('');
        }
        window.actionEvents = {
            'click .editProviders': function(e, value, row, index) {
                var id = row.id;

                $('#ModalEdit').modal('show');
                $.ajax({
                    type: "GET",
                    url: "<?php echo e(route('gestionCategorie.edit', ['id' => ':id'])); ?>".replace(':id', id),
                    success: function(response) {
                        console.log(response.Categorie);
                        $('#CodeCategorie').val(response.Categorie.CodeCategorie);
                        $('#nomCategorie').val(response.Categorie.nomCategorie);
                        $('#id').val(response.Categorie.id);
                    }

                });
            },

            'click .deleteProviders': function(e, value, row, index) {
                var id = row.id;
                $('#ModalDelete').modal('show');
                $('#deleteing_id').val(id);
            }
        };
    </script>



    <script>
        $(function() {
            $('.toastrDefaultSuccess').each(function() {
                toastr.success($(this).text());
            });
            $('.toastrDefaultWarning').each(function() {
                toastr.warning($(this).text());
            });
            $('.toastrDefaultError').each(function() {
                toastr.error($(this).text());
            });
        });
    </script>

    <script>
        window.addEventListener('online', function() {
            toastr.success('Internet connection restored.');
        });

        window.addEventListener('offline', function() {
            toastr.error('Internet connection lost.');
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin-layout.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\damal\Desktop\Expertik\GreatimesVersion2.0\resources\views/Admin/Categorie/categorie.blade.php ENDPATH**/ ?>