<?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">Wholesale  Payment</h1>
          </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">Wholesale Payment</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">


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


      <div class="card">
        <div class="card-body">

          <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                    <label>Wholesaler Name</label>
                    <input type="hidden" name="wholename" id="wholename"> 
                    <select class="form-control select2" name="wholeid" id="wholeid" style="width: 100%;" required>
                        <option value="" selected="selected" disabled>Select</option>
                        <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $itemd): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($itemd->id); ?>"><?php echo e($itemd->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                    </select>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="">Wholesaler Balance Payment</label><input type="text" class="form-control" id="whobalance" name="whobalance" placeholder="Supplier Balance Payment" readonly required>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="">Paid Amount</label><input type="number" class="form-control" id="amount" name="amount" placeholder="Paid Amount" required>
                </div>
            </div>
            <div class="col-md-3">
            <div class="form-group">
                <label>Payment Method</label>
                <select class="form-control" name="payment" id="payment" style="width: 100%;" required>
                    <option value="" selected="selected" disabled>Select</option>
                    <option value="cash">Cash</option>
                    <option value="cheque">Cheque</option>
                    <option value="Wire Transfer">Wire Transfer</option>
                </select>
            </div>
            </div>

 
          
          </div>
<div class="row">
    <div class="col-md-3">
        <div class="form-group">
            <label>Select bank</label>
            <select class="form-control select2" name="bank" style="width: 100%;" required>
                <option value="" selected="selected" disabled>Select</option>
                <?php $__currentLoopData = $ban; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bankdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($bankdata->id); ?>"><?php echo e($bankdata->bank); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
            </select>
        </div>
    </div>


    <div class="col-md-3">
        <div class="form-group">
        <label id="pdate">Paid Date</label>
            <div class="input-group date" id="reservationdate" data-target-input="nearest">
                <input type="text" class="form-control datetimepicker-input"  name="paid_date" data-target="#reservationdate"/ required>
                <div class="input-group-append" data-target="#reservationdate" data-toggle="datetimepicker">
                    <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-3 ChequeNumber">
    <div class="form-group">
        <label for="">Cheque Number</label>
        <input type="text" class="form-control" id="Cheque" name="Cheque" value="-" required>
    </div>
    </div>
    
</div>
<br>
<div class="row">
<div class="col-md-2"><button type="submit" class="btn btn-block btn-primary">Add Payment</button> </div>
</div>

        </div>
        </div>

</form>





      </div>
    </section>
  </div>
 




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

<script>
 


$(function () {
    $('.select2').select2()
})

$('#reservationdate').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss'
});
$('#reservationdate2').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss'
});
$('.ChequeNumber').hide();

$('#payment').on('change', function(){
  var id = $(this).val();

  if(id=="cash"){
    $("#pdate").html("Paid Date");
    $('.ChequeNumber').hide();
}else if(id=="cheque"){
  $("#pdate").html("Cheque Date");
  $('.ChequeNumber').show();
}
else if(id=="Wire Transfer"){
    $("#pdate").html("Paid Date");
    $('.ChequeNumber').hide();
    }
else if(id=="credit"){
  $("#pdate").html("Credit Date");
  $('.ChequeNumber').hide();
}    
});

$('#wholeid').on('change', function(){
    var id = $(this).val();
    $.ajax({
            url: "<?php echo e(url('/getwholesalebalance')); ?>/"+id ,
            method: "get",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'JSON',
            data:{
                "id":id
            },
            success: function (data) {
                // swal("Done!", "It was successfully deleted!", "success");

                    jQuery.each(data, function(key,value){
                        for(i=0; i<value.length; i++){
                            var rid = value[i].id;
                            $('#whobalance').val(value[i].balance);
                            $('#wholename').val(value[i].name);
                            // $("#branch").val(value[i].balance).change();
                        }

                    });

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
        });
});

<?php if(session('success')): ?>
        // swal("Success!","<?php echo e(session('success')); ?>","success");
        toastr.success('Payment Added successfully!')

<?php endif; ?>
<?php if(session('error')): ?>
    swal({
            title: "Error!",
            text: "<?php echo e(session('error')); ?>",
            icon: "error",
            button: "OK",
        });
<?php endif; ?>
</script>
