<?php $__env->startSection('content'); ?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-12 ">
                    <div class="card radius-10">
                        <div class="card-header">

                            <h4>View Offer Details </h4>

                        </div>
                        <div class="card-body">
                            <form action="" method="get">
                                <div class="row">
                                    <div class="col-lg-12">
                                        <?php if(Session::has('danger')): ?>
                                            <div class="alert alert-danger">
                                                <?php echo e(Session::get('danger')); ?>

                                            </div>
                                        <?php endif; ?>
                                    </div>
                                    <div class="col-lg-8">
                                        <label class="form-label">Select Offer</label>
                                        
                                        <select id="offer_id" class="form-control">
                                            <option selected>Open this select offer</option>
                                            <?php $__currentLoopData = $offer; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                              <option value="<?php echo e($item->id); ?>"><?php echo e($item->offer_name); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="col-lg-4">
                                        <button class="btn btn-dark " id="search_box" style="margin-top: 30px">Search</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="offer-details mt-3"></div>
            <div class="card radius-10 mt-4 offers-details-tb">
                <div class="table-container" style="overflow-y: auto;">
                    <table class="table" style="width: full">
                      <thead class="thead-dark" style="background-color: #292929; color: white;">
                        <tr style="font-size: 15px">
                          <th scope="col">ID</th>
                          <th scope="col">Offer</th>
                          <th scope="col">Payout</th>
                          <th scope="col">View</th>
                        </tr>
                      </thead>
                      <tbody id="table-body">
                        <?php $__currentLoopData = $offer; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            $percentage = $item->payout_percentage;
                            $payout = $item->payout;
                            $total = ($percentage / 100) * $payout;
                        ?>
                            <tr>
                                <input type="hidden" name="offer_id" class="offer-id" value="<?php echo e($item->id); ?>">
                                <td>#<?php echo e($item->id); ?></td>
                                <td><?php echo e($item->offer_name); ?></td>
                                <td><?php echo e($total); ?></td>
                                <td class="view-offer" style="cursor: pointer"><i class="far fa-eye"></i></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <script type="text/javascript" src="<?php echo e(config('app.url')); ?>/public/public/vendors/datatables/jquery.mark.min.js"></script>
    <script type="text/javascript">
        $(function() {
            <?php if(Session::has('success')): ?>
                Swal.fire({
                    title: '<?php echo e(Session::get('success')); ?>',


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

            $('#search_box').click(function(e) {
                e.preventDefault();
                var id = $('#offer_id').val();
                $.ajax({
                    url: '<?php echo e(route('manager.offer')); ?>',
                    type: 'GET',
                    dataType: 'JSON',
                    data: {
                        id: id
                    },
                    success: function(result) {
                        $('.loader').fadeOut();
                        // console.log(result);
                        if (!result.status) {

                        } else {

                        $('.offer-details').empty();
                        $('.offers-details-tb').empty();
                        $('.offer-details').html(result.data);


                        }
                    },

                });
            });

            $('.view-offer').click(function(e) {
                var id = $(this).closest('tr').find('.offer-id').val();
                $.ajax({
                    url: '<?php echo e(route('manager.offer')); ?>',
                    type: 'GET',
                    dataType: 'JSON',
                    data: {
                        id: id
                    },
                    success: function(result) {
                        $('.loader').fadeOut();
                        // console.log(result);
                        if (!result.status) {

                        } else {

                        $('.offer-details').empty();
                        $('.offers-details-tb').empty();
                        $('.offer-details').html(result.data);


                        }
                    },

                });
            });
        });
    </script>

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

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