<?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">Courier Payment Add</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">Courier Payment Add</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
        <form method="post" action="/addcourierpayment">
        <?php echo e(csrf_field()); ?>

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

            <div class="col-md-3">
                <div class="form-group">
                    <label for="">Toatal COD Amount</label><input type="number" class="form-control" id="cod_amount" name="cod_amount" placeholder="Toatal COD Amount" required>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="">Total Delivery Charge</label><input type="number" class="form-control" id="deliverycharge" name="deliverycharge" placeholder="Total Delivery Charge" required>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="">Total Payable Amount</label><input type="number" class="form-control" id="payableamount" name="payableamount" placeholder="Total Payable Amount" required>
                </div>
            </div>

        </div>
        <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                        <label for="">Payment ID</label><input type="text" class="form-control" id="payid" name="payid" placeholder="Payment ID" required>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label>Bank</label>
                        <select class="form-control" name="bank" id="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->accountname); ?> - <?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 for="">Paid Date :</label>
                        <div class="input-group date" id="reservationdate" data-target-input="nearest">
                            <input type="text" class="form-control datetimepicker-input" value="<?php echo e($ldate); ?>" id="paid_date" 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" style="padding-top:32px;"><button type="submit" class="btn btn-primary btn-block">Add Payment</button></div>
        </div>
        </form><br><hr><br>
            <div class="row">
                <div class="col-md-12">
                <table id="example2" class="table table-bordered" style="width:100%; font-size:13px;">
                        <thead>
                            <tr>
                                <th>Delivery Company</th>
                                <th>Bank</th>
                                <th>COD Amount</th>
                                <th>Delivery Charge</th>
                                <th>Payable Amount</th>
                                <th>Payment ID</th>
                                <th>Paid Date</th>
                                <th>Status</th>
                                <th>Action</th>

                            </tr>
                        </thead>
                        <tbody>
                        <?php $__currentLoopData = $cuso; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $coudata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                            <td><?php echo e($coudata->deliveryrecivemoneyget->deliveryname); ?></td>
                            <td><?php echo e($coudata->bankname->bank); ?></td>
                            <td><?php echo e($coudata->codamount); ?></td>
                            <td><?php echo e($coudata->deliverycharge); ?></td>
                            <td><?php echo e($coudata->payablecod); ?></td>
                            <td><?php echo e($coudata->courierpaymentid); ?></td>
                            <td><?php echo e($coudata->paidat); ?></td>
                            <td class="text-center">
                                <?php if($coudata->status=='0'): ?>
                                <span class="badge badge-warning">Not Paid</span>
                                <?php elseif($coudata->status=='1'): ?>
                                <span class="badge badge-success">Paid</span>
                                <?php endif; ?>
                                </td>
                                <td class="text-center">   
                                    <?php if($coudata->status=='0'): ?>               
                                        <a data-id="<?php echo e($coudata->id); ?>" class="btn btn-primary btn-xs" href="receivedetails/<?php echo e($coudata->id); ?>">View</a>                                                                                                                                                                 
                                        <button type="button" class="btn btn-primary btn-xs supmodel" data-deliname="<?php echo e($coudata->deliveryrecivemoneyget->deliveryname); ?>" data-bank="<?php echo e($coudata->bank); ?>" data-id="<?php echo e($coudata->id); ?>" data-cod="<?php echo e($coudata->codamount); ?>" data-courierpaymentid="<?php echo e($coudata->courierpaymentid); ?>" data-paidat="<?php echo e($coudata->paidat); ?>" data-deliverycompany22="<?php echo e($coudata->deliverycompany); ?>" data-deliverycharge="<?php echo e($coudata->deliverycharge); ?>" data-payablecod="<?php echo e($coudata->payablecod); ?>" data-status="<?php echo e($coudata->status); ?>"   data-toggle="modal" data-target="#supmodel">Edit</button>
                                        &nbsp;<a href="" data-id="<?php echo e($coudata->id); ?>" class="btn btn-danger btn-xs button purchasingdelete" data-url=""><i class="far fa-trash-alt"></i> </a>
                                    <?php elseif($coudata->status=='1'): ?>
                                    <a data-id="<?php echo e($coudata->id); ?>" class="btn btn-primary btn-xs" href="receivedetails/<?php echo e($coudata->id); ?>">View</a>  
                                    <button type="button" class="btn btn-primary btn-xs supmodel" disabled>Edit</button>
                                    &nbsp;<a href=""  style=" pointer-events: none;cursor: default;" class="btn btn-danger btn-xs button purchasingdelete" data-url="" disabled><i class="far fa-trash-alt"></i> </a>
                                    <?php endif; ?>
                                    </td>  
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>

        </div>
        </div>
     

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


<div class="modal fade" id="supmodel" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
      <div class="modal-content">
      <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLongTitle">Courier Payment Details Change</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
          </button>
      </div>
      <form class="form-horizontal" method="POST" action="/courierpaymentupdate">
          <?php echo e(csrf_field()); ?>

      <div class="modal-body"> 
          <input type="hidden" name="id" id="id">    
          <input type="hidden" name="deliname" id="deliname">    
                <div class="form-group">
                    <label>Delivery Company Name</label>
                    <select class="form-control select2" name="delivery_name2" id="delivery_name2" style="width: 100%;" required>
                        <option value="" selected="selected" disabled>Select</option>
                            <?php $__currentLoopData = $delise; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($data->id); ?>"><?php echo e($data->deliveryname); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>

                <div class="form-group">
                    <label for="">Toatal COD Amount</label><input step=".01" type="number" class="form-control" id="cod_amount" name="cod_amount" placeholder="Toatal COD Amount" required>
                </div>

                <div class="form-group">
                    <label for="">Total Delivery Charge</label><input step=".01" type="number" class="form-control" id="deliverycharge" name="deliverycharge" placeholder="Total Delivery Charge" required>
                </div>

                <div class="form-group">
                    <label for="">Total Payable Amount</label><input step=".01" type="number" class="form-control" id="payableamount" name="payableamount" placeholder="Total Payable Amount" required>
                </div>
        
                <div class="form-group">
                        <label for="">Payment ID</label><input type="text" class="form-control" id="payid" name="payid" placeholder="Payment ID" required>
                    </div>
                    <div class="form-group">
                        <label>Bank</label>
                        <select class="form-control" name="bank" id="bank2" 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->accountname); ?> - <?php echo e($bankdata->bank); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>


                <div class="form-group">
                    <label for="">Paid Date :</label>
                        <div class="input-group date" id="reservationdate" data-target-input="nearest">
                            <input type="text" class="form-control datetimepicker-input" value="" id="paid_date" 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 class="form-group">
                <label for="">Paid Status</label>
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" name="paidstatus" value="" id="flexCheckChecked" checked>
                    <label class="form-check-label" for="flexCheckChecked">Paid</label>
                </div>
            </div>



      </div>
      <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Save changes</button>
      </div>
      </form>
      </div>
  </div>
</div>

  <?php echo $__env->make('dashboard.include.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
  <!-- cod courierpaymentid paidat deliverycompany deliverycharge payablecod status -->
<script>
$('#reservationdate').datetimepicker({
    format: 'YYYY/MM/DD'
    });

$('#supmodel').on('show.bs.modal', function (event) {

var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('id') 
var cod = button.data('cod') 
var courierpaymentid = button.data('courierpaymentid') 
var paidat = button.data('paidat') 
var deliverycompany1 = button.data('deliverycompany22') 
var deliverycharge = button.data('deliverycharge') 
var payablecod = button.data('payablecod') 
var status = button.data('status') 
var bank2 = button.data('bank') 
var deliname = button.data('deliname') 

var modal = $(this)
modal.find('.modal-body #id').val(recipient)
modal.find('.modal-body #deliname').val(deliname)
modal.find('.modal-body #cod_amount').val(cod)
modal.find('.modal-body #deliverycharge').val(deliverycharge)
modal.find('.modal-body #payableamount').val(payablecod)
modal.find('.modal-body #payid').val(courierpaymentid)
modal.find('.modal-body #paid_date').val(paidat)
$("#delivery_name2").val(deliverycompany1).change();
$("#bank2").val(bank2).change();


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

$(document).ready(function() {
    $('#example2').DataTable();
} );



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

                swal({
                title: "Are you sure?",
                text: "Are you Sure to Remove Courier Payment",
                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('/deletecourierrecivemoney')); ?>/"+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) {
                                swal("Done!", "It was successfully deleted!", "success");
                                $(ele).closest('tr').hide();
                                // $("#here").load(location.href + " #here");
                                // window.location.href = "/supplier";
                            },
                            error: function (jqXHR, textStatus, errorThrown) {
                                swal("Warning", "Unable to Process your request", "error");
                            },
                        });

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

</script>
