<?php $__env->startSection('content'); ?>
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
    <link href="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/dataTables.bootstrap4.css" rel="stylesheet"
        type="text/css" />
    <link href="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/datatables.mark.css" rel="stylesheet"
        type="text/css" />
    <link href="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/buttons.bootstrap4.css" rel="stylesheet"
        type="text/css" />
    <link href="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/responsive.bootstrap4.css" rel="stylesheet"
        type="text/css" />
    <link href="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/select.bootstrap4.css" rel="stylesheet"
        type="text/css" />
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>

    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
    <div class="page-content-wrapper">
    <div class="content-page">
                <div class="content">

                    <!-- Start Content-->
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="bg-flower">
                                    <img src="<?php echo e(config('app.url')); ?>/public/public/assets/assets/images/flowers/img-3.png">
                                </div>

                                <div class="bg-flower-2">
                                    <img src="<?php echo e(config('app.url')); ?>/public/public/assets/assets/images/flowers/img-1.png">
                                </div>
                    <div class="card radius-10">
                        <div class="card-header">
                            <h4>Offer Approval Requests</h4>
                        </div>
                        <div class="card-body">
                            <form id="form1">
                                <div class="row">
                                </div>
                            </form>
                            <div class="row">
                                <div class="col-lg-12 mt-3  table-responsive">

                                    <table id="offer_approval_request" class="table table-sm  ">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>Offer</th>
                                                <th>Publisher</th>
                                                <th>Description</th>
                                                <th>Date</th>
                                                <th>Status</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody id="showdata" class="text-dark">
                                        
                                        </tbody>
                                        <tfoot>
        
                                        </tfoot>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Delete MODAL -->

                    <div id="deleteModal" class="modal fade" tabindex="-1" role="dialog">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title">Delete Approval Request</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    Do You want to delete this Approval Request.
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-danger" id="btnDelete">Delete</button>
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- End Delete MODAL -->
                </div>

            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
        crossorigin="anonymous"></script>
    <script type="text/javascript" src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/jquery.mark.min.js">
    </script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/dataTables.bootstrap4.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/dataTables.buttons.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/buttons.bootstrap4.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/dataTables.keyTable.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/dataTables.select.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/buttons.html5.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/buttons.print.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/dataTables.responsive.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/responsive.bootstrap4.min.js"></script>
    <script src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/datatables.mark.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
    <script type="text/javascript">
        <?php $site = DB::table('site_settings')->first(); ?>
        $(function() {

            $(function() {
                $('.selectpicker').selectpicker();
            });


            $('#description').summernote({
                height: 150
            });
            $('#requirements').summernote({
                height: 150
            });
            $('.js-example-basic-multiple').select2();
                var offer_approval_request = $('#offer_approval_request').DataTable({
                processing: true,
                serverSide: true,
                responsive: true,
                ajax: "<?php echo e(route('admin.show-approval-request')); ?>",
                columns: [{
                        "data": "id"
                    },
                    {
                        "data": "offer.offer_name"
                    },
                    {
                        "data": "publisher1.name"
                    },
                    {
                        "data": "description"
                    },
                    {
                        "data": "date"
                    },
                    {
                        "data": "approval_status"
                    },
                    {
                        "data": "action"
                    },
                
                
                ],
            });
            <?php if(Session::has('success')): ?>
                Swal.fire({
                    title: '<?php echo e(Session::get('success')); ?>',


                    confirmButtonText: 'Ok'
                })
            <?php endif; ?>

        
            $('#offer_approval_request').on('click', '.approveData', function() {
                let id = $(this).attr('data-id');
                Swal.fire({
                    title: 'Are you sure?',
                    text: "You want to Approve this Offer Request ",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: 'Yes, Approve it!'
                }).then((result) => {
                    if (result.value) {
                        $.ajax({
                            url: "<?php echo e(route('admin.approve-request')); ?>",
                            type: 'GET',
                            dataType: 'JSON',
                            data: {
                                id: id
                            },
                            success: function(result) {
                                $('.loader').fadeOut();
                                // console.log(result);
                                if (!result.status) {
                                    Swal.fire('Failed', result.message, 'error');

                                } else {
                                    Swal.fire('Success', result.message, 'success');

                                    location.reload();

                                }
                            },
                            error: function(xhr) {
                                $('.loader').fadeOut();
                                if (xhr.status == 422) {
                                    $.each(xhr.responseJSON.errors, function(k, v) {
                                        form.find('[name="' + k + '"]').after(
                                            '<div class="text-danger">' + v[
                                                0] +
                                            '</div>');
                                    });
                                } else if (xhr.status == 419) {
                                    window.location.href = "";
                                }
                                // console.log(xhr);
                            }
                        });
                    }
                });
            });
            $('#offer_approval_request').on('click', '.rejectData', function() {
                let id = $(this).attr('data-id');
                Swal.fire({
                    title: 'Are you sure?',
                    text: "You want to Reject this Offer Request ",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: 'Yes, Reject it!'
                }).then((result) => {
                    if (result.value) {
                        $.ajax({
                            url: "<?php echo e(route('admin.reject-request')); ?>",
                            type: 'GET',
                            dataType: 'JSON',
                            data: {
                                id: id
                            },
                            success: function(result) {
                                $('.loader').fadeOut();
                                // console.log(result);
                                if (!result.status) {
                                    Swal.fire('Failed', result.message, 'error');

                                } else {
                                    Swal.fire('Success', result.message, 'success');

                                    location.reload();

                                }
                            },
                            error: function(xhr) {
                                $('.loader').fadeOut();
                                if (xhr.status == 422) {
                                    $.each(xhr.responseJSON.errors, function(k, v) {
                                        form.find('[name="' + k + '"]').after(
                                            '<div class="text-danger">' + v[
                                                0] +
                                            '</div>');
                                    });
                                } else if (xhr.status == 419) {
                                    window.location.href = "";
                                }
                                // console.log(xhr);
                            }
                        });
                    }
                });
            });

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

<?php echo $__env->make('admin.layout.admin-dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/fiverrbdbse/public_html/backend/resources/views/admin/offer/approval_request.blade.php ENDPATH**/ ?>