<?php echo $__env->make('dashboard.include.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

  
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0"></h1>
            <a href="/reseller">Go Back</a>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/home">Home</a></li>
              <li class="breadcrumb-item active">Reseller Advance</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">

        <div class="card card-success">
        <div class="card-header">
            <h3 class="card-title">Add Advance</h3>
        </div>
            <div class="card-body">
            <?php $__currentLoopData = $datas2; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dadetail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="row">
                <div class="col-md-4"> 
                    <div class="form-group">
                        <label for="">Reseller Name &nbsp;&nbsp;: &nbsp;&nbsp;</label><?php echo e($dadetail->companyname); ?>

                    </div>
                </div>
                <div class="col-md-5"> 
                    <label for="">Address&nbsp;&nbsp; : &nbsp;&nbsp;</label><?php echo e($dadetail->address); ?>

                </div>
                <div class="col-md-3"> 
                    <label for="">Phone Number&nbsp;&nbsp; : &nbsp;&nbsp;</label><?php echo e($dadetail->phone); ?>

                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <hr> <br>

            <form class="form-horizontal" method="POST" action="/addadvance">
                <?php echo e(csrf_field()); ?>

            <div class="row">
            <input type="hidden" class="form-control" value="<?php echo e($nowid); ?>" name="sid" required> 
                <div class="col-md-3"> 
                    <div class="form-group">
                        <label for="">Advance </label><input type="number" class="form-control" name="advance" placeholder="Advance" required>
                    </div>
                </div>        
                <div class="col-md-1" style="padding-top:30px;"><button type="submit" class="btn btn-block btn-primary">Add</button> </div>
           
            </div> 
            </form>
<hr> <br>
            <table id="example2" class="table table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Advance</th>
                                <th>Paid ID</th>
                                <th>Paid Date</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                    <?php $__currentLoopData = $supdata; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $supdatad): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($supdatad->id); ?></td>
                            <td><?php echo e($supdatad->advance); ?></td>
                            <td class="text-center">
                            <?php if($supdatad->paidid=='-'): ?>
                            <span class="badge badge-warning">Not Paid Yet</span>
                            <?php else: ?>
                             <?php echo e($supdatad->paidid); ?>

                            <?php endif; ?>
                            </td> 
                            <td class="text-center">
                            <?php if($supdatad->paiddate=='-'): ?>
                            <span class="badge badge-warning">Not Paid Yet</span>
                            <?php else: ?>
                             <?php echo e($supdatad->paiddate); ?>

                            <?php endif; ?>
                            </td> 
                            <td class="text-center">
                            <?php if($supdatad->status=='0'): ?>
                            <span class="badge badge-success">Paid to Reseller</span>
                            <?php elseif($supdatad->status=='1'): ?>
                            <span class="badge badge-warning">Deducted from payment</span>
                            <?php endif; ?>
                            </td> 
                            <td class="text-center">
                                <?php if($supdatad->status=='0'): ?>
                                <a href="" data-supllierid="<?php echo e($supdatad->resellerid); ?>" data-id="<?php echo e($supdatad->id); ?>" class="btn btn-danger btn-xs button bankdetailsdelete" data-url="">Delete </a>
                                <?php elseif($supdatad->status=='1'): ?>
                                <a href="" class="btn btn-danger btn-xs button" data-url="">Delete </a>
                                <?php endif; ?>
                                
                            </td>                        
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                    </table>
            </div>
        </div>
      </div>
    </section>
  </div>




  <?php echo $__env->make('dashboard.include.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;

<script>
$(document).ready(function() {
    $('#example').DataTable();
    $('#example2').DataTable();
} );
</script>
<script>

$(document).on('click', '.bankdetailsdelete', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    var supid = $(this).data('supllierid');
    let ele = this;
    console.log(id);

                swal({
                title: "Are you sure?",
                text: "Are you Sure to Remove this Entry",
                icon: "warning",
                showCancelButton: true,
    confirmButtonColor: '#3085d6',
    cancelButtonColor: '#d33',
    confirmButtonText: 'Yes, delete it!',
                dangerMode: true,
            }).then(function(isConfirm) {
                
                if (isConfirm.value===true) {

                        $.ajax({
                            url: "<?php echo e(url('/advancedelete')); ?>/"+id ,
                            method: "POST",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            cache: false,
                            contentType: false,
                            processData: false,
                            dataType: 'JSON',
                            data:{
                                "id":id
                            },
                            success: function (result, code, ex) {
                                window.location.href = "/advance/"+supid;
                            },
                            error: function (jqXHR, textStatus, errorThrown) {
                                swal("Warning", "Unable to Process your request", "error");
                            },
                        });

                } else {
                    swal("Cancelled", "No Removed", "error");
                }
            })
});


      
$('#bankmodel').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var id = button.data('id') 
var reseller = button.data('reseller') 
var charge = button.data('charge') 
var status = button.data('status') 
var res = button.data('res') 



var modal = $(this)
modal.find('.modal-body #id').val(id)
modal.find('.modal-body #supid').val(res)
modal.find('.modal-body #Commision').val(charge)
$("#reseller").val(reseller).change();

if(status==1){
    $( "#flexCheckChecked" ).prop( "checked", true );
}else{
    $( "#flexCheckChecked" ).prop( "checked", false  );
}
})


$('.select2').select2()

</script>