<?php $__env->startSection('content'); ?>
    <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>Add New Publisher</h4>
                        </div>
                        <div class="card-body">
                            <form action="<?php echo e(route('admin.insert-publishers')); ?>" method="POST" id="add_new_publisher" enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                <div class="row">

                                    <div class="col-lg-6 form-group">
                                        <label> Publisher Name</label>
                                        <input type="text" name="name" class="form-control" required="">
                                    </div>
                                    <div class="col-lg-6 form-group">
                                        <label> Email</label>
                                        <input type="email" name="email" class="form-control" required="">
                                    </div>
                                    <div class="col-lg-6 form-group">
                                        <label> Password</label>
                                        <input type="password" name="password" class="form-control" required="">
                                    </div>
                                    <div class="col-lg-6 form-group">
                                        <label>Confirm password</label>
                                        <input type="password" name="confirm_password" class="form-control" required="">
                                    </div>
                                    <div class="col-lg-6 form-group">
                                        <label> Address</label>
                                        <input type="text" name="address" class="form-control">
                                    </div>
                                    <div class="col-lg-6 form-group">
                                        <label class="form-label">Countries</label>

                                        <select class="form-control" name="countries" style="width: 100%">
                                            <option></option>

                                            <?php $__currentLoopData = $country_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $site): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($site->country_name); ?>"><?php echo e($site->country_name); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="col-lg-6  form-group">
                                        <label> City</label>
                                        <input type="text" name="city" class="form-control">
                                    </div>
                                    <div class="col-lg-6  form-group">
                                        <label> Region</label>
                                        <input type="text" name="region" class="form-control">
                                    </div>
                                    <div class="col-lg-6  form-group">
                                        <label> Payment term</label>
                                         <select class="form-control"   name="payment_terms">
                                                    <option  value="net45">Every
                                                45 Days</option>
                                            <option value="net30">
                                                Monthly</option>
                                            <option value="net15">Every
                                                15 days</option>
                                            <option value="net7">
                                                Weekly</option>
                                        </select>
                                    </div>

                                    <div class="col-lg-6  form-group">
                                        <label> Account Status</label>
                                        <select type="text" name="status" id="statusin" class="form-control" required="">

                                            <option value="Inactive">Inactive</option>
                                            <option value="Active">Active</option>
                                        </select>
                                    </div>
                                    <div class="col-lg-6  form-group">
                                        <label> Affliate Manager</label>
                                        <select type="text" name="affliate_manager" class="form-control" required="">
                                            <option value="">Select Affliate Manager</option>
                                            <?php $__currentLoopData = $Affliate; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $affiliate): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($affiliate->id); ?>"><?php echo e($affiliate->name); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>

                                    <div class="col-lg-6  form-group">
                                        <label> Photo</label>
                                        <input type="file" name="photo" class="form-control">
                                    </div>
                                    <div class="col-lg-6  form-group">
                                        <label> Select Publisher Type</label>
                                         <select class="form-control" name="publisher_type" id="publisher_type">
                                         <option value="1">CPA & SMARTLINK NETWORK</option>
                                                    <option value="0">SMARTLINK NETWORK</option>
                                                </select>
                                                </div>

                                </div>

                                <div class="col-lg-12  text-center m-4">
                                    <button type="submit" class="btn  btn-primary">Create</button>
                                </div>

                    
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <script>
        $(function() {
            $.ajaxSetup({
  headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});
            $('#add_new_publisher').submit(function(e) {
                e.preventDefault();
                let form = $(this);
                let data =  new FormData(this);
                $.ajax({
                    url: "<?php echo e(route('admin.insert-publishers')); ?>",
                    type: 'POST',
                    dataType: 'JSON',
                    data: data,
                     cache:false,
            contentType: false,
            processData: false,
                    success: function(result) {
                        $('.text-danger').remove();
                        $('.loader').fadeOut();
                        // console.log(result);
                        if (!result.status) {
                            Swal.fire('Failed', result.message, 'error');

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


                        location.replace('<?php echo e(route('admin.manage-publishers')); ?>');
                        }
                    },
                    error: function(xhr) {
                        $('.loader').fadeOut();
                        $('.text-danger').remove();
                        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/publisher/new-publisher.blade.php ENDPATH**/ ?>