<?php $__env->startSection("title", "Customers"); ?>
<?php $__env->startSection('content'); ?>

<div class="container-fluid">
    <!-- Page-Title -->
    <div class="row">
        <div class="col-sm-12">
            <div class="page-title-box">
                <div class="row">
                    <div class="col">
                        <h4 class="page-title">Customers</h4>
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="<?php echo e(route('home')); ?>">Landnkitchen</a></li>
                            <li class="breadcrumb-item active">Customers</li>
                        </ol>
                    </div><!--end col-->
                </div><!--end row-->
            </div><!--end page-title-box-->
        </div><!--end col-->
    </div><!--end row-->
    <!-- end page title end breadcrumb -->
    <div class="row">
        <div class="col-12">
            <?php if(Session::has('error')): ?>
                <div class="alert alert-danger" role="alert">
                    <?php echo e(Session::get('error')); ?>

                </div>
            <?php endif; ?>
            <?php if(Session::has('success')): ?>
                <div class="alert alert-success" role="alert">
                    <?php echo e(Session::get('success')); ?>

                </div>
            <?php endif; ?>
            <div class="table-responsive">
                <table id="datatable" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                    <thead>
                    <tr>
                        <th>SN</th>
                        <th>Name</th>
                        <th>Telephone</th>
                        <th>Email</th>
                        <th>Action</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php $sn = 1 ?>
                        <?php $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($sn); ?></td>
                            <td><?php echo e($row->first_name .' '. $row->last_name); ?></td>
                            <td><?php echo e($row->tel); ?></td>
                            <td><?php echo e($row->email); ?></td>
                            <td>
                                <a href="javascript:void(0)" class="js_delete_customer" data-toggle="modal" data-target="#deleteModal" data-id="<?php echo e($row->id); ?>" class="mr-2"><i class="las la-trash-alt text-danger font-18"></i></a>
                            </td>
                        </tr>
                        <?php $sn ++ ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div> <!-- end col -->
    </div> <!-- end row -->

</div><!-- container -->

  <!-- Delete Modal -->
  <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalTitle" aria-hidden="true">
    <form action="<?php echo e(route("delete.customer")); ?>" method="POST">
        <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
            <h5 class="modal-title" id="deleteModalTitle">Delete Product</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
            </div>
            <div class="modal-body" id="js_replace_delete_content">
            </div>
            <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
            <button type="submit" class="btn btn-primary">Yes</button>
            </div>
        </div>
        </div>
    </form>
  </div>

  <script src="<?php echo e(asset("js/jquery.min.js")); ?>"></script>
  <script>
        $(document).ready(function(){
            var loader = `<div class="text-center">
                            <i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
                        </div>`;

            const BASE_URL = "<?php echo e(url('/')); ?>";
            const REQUEST_URL = "<?=Request::url()?>";
            let CSRF = "<?php echo e(csrf_token()); ?>";

            $('body').on("click", '.js_delete_customer', function(e){
                $('#js_replace_delete_content').html(loader);
                const id = $(this).attr("data-id");
                var data = new FormData();
                data.append('id', id);

                $.ajax({
                    url: BASE_URL + '/admin/delete-customer/' + id,
                    method: "GET",
                    timeout: 5000,
                    data: data,
                    contentType: false,
                    cache: false,
                    processData: false,
                    headers: {'X-CSRF-TOKEN': CSRF},
                    success: function(response){
                        $('#js_replace_delete_content').html(response.html);
                    },
                    error: function(err){
                        alert("Oops, there was an error, try again later");
                    }
                })
            })
        });

  </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make("layouts.admin", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home2/landnkitchen/public_html/core/resources/views/admin/people/customers.blade.php ENDPATH**/ ?>