<?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>View Offers</h4>
                        </div>
                        <div class="card-body">

                            <form method="get">

                                <div class="row">

                                    <div class="col-lg-12 text-right">
                                        <a href="<?php echo e(url('admin/add-offer')); ?>" class="btn btn-outline-primary mt-2">Add New
                                            Offer</a>
                                    </div>

                                    <div class="col-lg-3">
                                        <label class="form-label">Countries</label>

                                        <select class="js-example-basic-multiple" id="countries" name="countries"
                                            style="width: 100%">
                                            <option></option>
                                            <?php $country=(isset($_GET['countries']))?$_GET['countries']:''; ?>
                                            <?php $__currentLoopData = $country_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $q): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($q->country_name); ?>"
                                                    <?php echo e($q->country_name == $country ? 'selected' : ''); ?>>
                                                    <?php echo e($q->country_name); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="col-lg-3">
                                        <label class="form-label">Name</label>
                                        <input type="" id="offer_name" name="name" class="form-control"
                                            value="<?php echo e(isset($_GET['name']) ? $_GET['name'] : ''); ?>" placeholder="Offer Name"
                                            id="name">
                                    </div>
                                    <div class="col-lg-3">
                                        <label class="form-label">Offer ID</label>
                                        <input type="" id="offer_id" name="id"
                                            value="<?php echo e(isset($_GET['id']) ? $_GET['id'] : ''); ?>" class="form-control"
                                            placeholder="Offer ID" id="id">
                                    </div>

                                    <div class="col-lg-3">
                                        <label class="form-label">Targeting</label>

                                        <select class="form-control" name="ua_target" id="ua_target"
                                            data-actions-box="true">
                                            <option value="">Select Target Browsers</option>
                                            <?php $ua_target=(isset($_GET[' ']))?$_GET['ua_target']:''; ?>
                                            <option value="Windows" <?php echo e($ua_target == 'Windows' ? 'selected' : ''); ?>>Windows
                                            </option>
                                            <option value="Android" <?php echo e($ua_target == 'Android' ? 'selected' : ''); ?>>Android
                                            </option>
                                            <option value="Iphone" <?php echo e($ua_target == 'Iphone' ? 'selected' : ''); ?>>Iphone
                                            </option>
                                            <option value="Ipad" <?php echo e($ua_target == 'Ipad' ? 'selected' : ''); ?>>Ipad
                                            </option>
                                            <option value="Mac" <?php echo e($ua_target == 'Mac' ? 'selected' : ''); ?>>Mac</option>

                                        </select>
                                    </div>
                                    <div class="col-lg-3">
                                        <label class="form-label">Status</label>
                                        <select type="text" name="status" id="status1" class="form-control" data-actions-box="true">
                                            <?php $status=(isset($_GET['status']))?$_GET['status']:''; ?>
                                            <option value="">Select Status</option>
                                            <option value="Inactive" <?php echo e($status == 'Inactive' ? 'selected' : ''); ?>>Inactive
                                            </option>
                                            <option value="Active" <?php echo e($status == 'Active' ? 'selected' : ''); ?>>Active
                                            </option>
                                        </select>
                                    
                                    </div>

                                    <div class="col-lg-3">
                                        <label>Traffic</label>
                                        <select type="text" name="traffic" id="traffic" class="form-control"
                                            data-actions-box="true">
                                            <option value="">Select Traffic</option>
                                            <?php $traffic=(isset($_GET['traffic']))?$_GET['traffic']:''; ?>

                                            <option value="smartlink" <?php echo e($traffic == 'smartlink' ? 'selected' : ''); ?>>
                                                Smartlink</option>


                                        </select>
                                    </div>
                                    <div class="col-lg-3">
                                        <label>Offer Type</label>
                                        <select type="text" name="offer_type" id="offer_type" class="form-control">
                                            <option value="">Select Type</option>
                                            <?php $offer_type=(isset($_GET['offer_type']))?$_GET['offer_type']:''; ?>
                                            <option value="Public" <?php echo e($offer_type == 'Public' ? 'selected' : ''); ?>>Public
                                            </option>
                                            <option value="Private" <?php echo e($offer_type == 'Private' ? 'selected' : ''); ?>>
                                                Private
                                            </option>

                                        </select>
                                    </div>

                                    <div class="col-lg-3 " style="margin-top: 33px">

                                        <button type="submit" class="btn btn-primary">Search</button>
                                    </div>

                                </div>
                            </form>
                            <div class="row">
                                <div class="col-lg-12 mt-3  table-responsive">

                                    <table id="offer_table" class="table table-bordered table-striped dt-responsive nowrap"
                                        style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                                        <thead class="thead thead-light">
                                            <tr>
                                                <th>OID</th>
                                                <th>Name</th>
                                                <th>Category</th>
                                                <th>Country</th>
                                                <th>Payout Type</th>
                                                <th>Payout</th>
                                                <th>Browsers</th>
                                                <th>Devices</th>
                                                <th>Status</th>
                                                <th>Offer Type</th>
                                                <th>Clicks</th>
                                                <th>Conversion</th>
                                                <th>Smartlink</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody class="text-dark">

                                        </tbody>
                                    </table>



                                </div>
                            </div>
                        </div>
                    </div>
                </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();

            <?php if(Session::has('success')): ?>
                Swal.fire({
                    title: '<?php echo e(Session::get('success')); ?>',


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

            $('#payout').change(function() {
                if ($('#payout').val() == 'fixed') {
                    $('#payout_amount').removeAttr('disabled', 'true');
                    $('#payout_amount').val('');
                } else {


                    $('#payout_amount').attr('disabled', 'true');


                }
            })
            $('select[name=offer_type]').change(function(e) {
                if ($('select[name=offer_type]').val() == 'special') {
                    $('.divhide').removeClass('d-none');


                } else {

                    $('.divhide').addClass('d-none');

                }
            })
            var offer_table = $('#offer_table').DataTable({

                "mark": true,

                "order": [

                    [0, "desc"]

                ],

                "columnDefs": [

                    {

                        "targets": [0],

                        "render": function(data, type, row, meta) {

                            return '#' + data;

                        }

                    },

                    {

                        "responsivePriority": 1,

                        "targets": 0

                    },

                    {

                        "responsivePriority": 2,

                        "targets": -1,

                        "orderable": false

                    }

                ],

                "processing": true,

                "serverSide": true,

                "ajax": {

                    url: "<?php echo e(route('admin.show-offers')); ?>",
                    "data": function(d) {
                        d.offer_name = $('#offer_name').val();
                        d.offer_id = $('#offer_id').val();
                        d.countries = $('#countries').val();
                        d.ua_target = $('#ua_target').val();
                        d.traffic = $('#traffic').val();
                        d.status = $('#status').val();
                        d.offer_type = $('#offer_type').val();
                    },
                    error: function(xhr) {

                        session_error(xhr);

                        // console.log(xhr.status);

                    }

                },

                "columns": [

                    {
                        "data": "id"
                    },

                    {
                        "data": "offer_name"
                    },
                    {
                        "data": "category.category_name"
                    },
                    {
                        "data": "countries"
                    },

                    {
                        "data": "payout_type"
                    },
                    {
                        "data": "payout"
                    },
                    {
                        "data": "browsers"
                    },
                    {
                        "data": "ua_target"
                    },

                    {
                        "data": "status"
                    },
                    {
                        "data": "offer_type"
                    },
                    {
                        "data": "clicks"
                    },
                    {
                        "data": "conversion"
                    },

                    {
                        "data": "smartlinkstatus"
                    },


                    {
                        "data": "action"
                    }

                ],

                drawCallback: function(settings) {

                    $(document).find('[data-toggle="tooltip"]').tooltip();

                },

                initComplete: function(settings, json) {

                    // $(document).find('[data-toggle="tooltip"]').tooltip();

                }

            });
            $('#offer_table').on('click', '.deleteData', function() {
                let id = $(this).attr('data-id');
                Swal.fire({
                    title: 'Are you sure?',
                    text: "You want to remove this Offer ",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: 'Yes, remove it!'
                }).then((result) => {
                    if (result.value) {
                        $.ajax({
                            url: "<?php echo e(route('admin.delete-offer')); ?>",
                            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/admin/aff.cpalider.com/backend/resources/views/admin/offer/view_offers.blade.php ENDPATH**/ ?>