<?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">Rider Payment Recive</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">Rider Payment Recive</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">

    <form method="post" action="/paymentrecovecolomboserch">
        <?php echo e(csrf_field()); ?>

        <div class="row">
        <div class="col-md-1"></div>
                <div class="col-md-4">
                    <div class="form-group">
                        <label>Filter orders by rider name</label>
                        <select class="form-control" name="delivery_name" id="delivery_name" style="width: 100%;" required>
                            <option value="" selected="selected" disabled>Select</option>
                            <option value="all" <?php if($deli=="all"): ?>selected <?php endif; ?>>All</option>
                                <?php $__currentLoopData = $delise; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($data->type=="Delivery_Guy"): ?>
                                <option value="<?php echo e($data->id); ?>"  <?php if($deli==$data->id ): ?>selected <?php endif; ?>><?php echo e($data->name); ?></option>
                                <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>

                <div class="col-md-4">
                <div class="form-group row">
                    <label for="">Delivery 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="delivery_date" name="delivery_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-2" style="padding-top:32px;"><button type="submit" class="btn btn-primary btn-block">Search</button></div>

  </div>
  
  </form>
        </div>
        </div>
        <form method="post" id="formFilter">
        <?php echo e(csrf_field()); ?>

            <input type="hidden" value="<?php echo e($ldate); ?>" name="date">
            <input type="hidden" value="<?php echo e($deli); ?>" name="rider">
        </form>
        <div class="card">
            <div class="card-body">
            <div class="row">
          <div class="col-md-4">
                    <form method="post" id="formsubmi1">
                        <?php echo e(csrf_field()); ?>

                        <input type="hidden" class="form-control" name="riderid" id="riderid" value="<?php echo e($deli); ?>" required>
                        <input type="hidden" class="form-control" name="date" id="date" value="<?php echo e($ldate); ?>" required>
                    </form>
                    <form method="post" id="formsubmi2">
                        <?php echo e(csrf_field()); ?>

                        <input type="hidden" class="form-control" name="riderid" id="riderid" value="<?php echo e($deli); ?>" required>
                        <input type="hidden" class="form-control" name="date" id="date" value="<?php echo e($ldate); ?>" required>
                    </form>
                </div>
          </div><br>
          <div class="row">
            <div class="col-md-12" id="here"> 
            <table id="count" class="table table-bordered"  style="width:100%;">
                    <thead>
                        <tr>
                            <th>Number of Line</th>
                            <th>Total Collected COD</th>
                            <th>Total Delivery Charge</th>
                            <th>Total Net COD</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><?php echo e($noofline); ?></td>
                            <td><?php echo e($tcod); ?></td>
                            <td><?php echo e($riderdelivery); ?></td>
                            <td><?php echo e($tcod - $riderdelivery); ?></td>
                            <td><button type="button" class="btn btn-outline-warning btn-sm" onClick="window.location.reload();">Reload</button></td>
                        </tr>

                    </tbody>
                </table>
                <hr>
                </div>
                <div class="col-md-12">
                <table id="example12" class="table table-bordered" style="width:100%;">
                    <thead>
                        <tr>
                            <th>Invoice ID</th>
                            <th>Name</th>
                            <th>Phone</th>
                            <th>Bill No</th>
                            <th>COD</th>
                            <th>Status</th>
                            <th>Delivery Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                </table>
            </div>
          </div> 
          </div>
          </div>





     

      </div>
    </section>
  </div>
  <div class="modal fade" id="editordermodelbarcode" role="dialog">
        <div class="modal-dialog">
        
          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
                    <h4 class="modal-title">Update Barcods</h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              
            </div>
            <form method="post" id="myformbarcode">
            <?php echo e(csrf_field()); ?>

                <div class="modal-body">

                    <div class="applenddata2"></div>
                </div>
         
            <div class="modal-footer">
            <input type="submit" name="btnform1" id="action" class="btn btn-primary right" value="Submit"/>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </form>
          </div>
          
        </div>

</div>

  <div class="modal fade" id="editordermodel" role="dialog">
        <div class="modal-dialog">
        
          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
                    <h4 class="modal-title">Update Delivery Details</h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              
            </div>
            
            <form method="post" enctype="multipart/form-data" id="myform">
            <?php echo e(csrf_field()); ?>

                <div class="modal-body">
                <input type="hidden" id="id" name="id">
                <div class="form-group">
                    <label for="recipient-name" class="col-form-label">Bill Number :</label>
                    <input type="text" class="form-control" id="code" name="code" required>
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" name="recivemon" value="" id="flexCheckDefault">
                    <label class="form-check-label" for="flexCheckDefault">Recived Money</label>
                </div>

                </div>
                  
            <div class="modal-footer">
            <input type="submit" name="btnform1" id="action" class="btn btn-primary right" value="Submit"/>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </form>
          </div>
          
        </div>

</div>


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


  <script>
// $('.barcodeclassid').change(function () {
//      $(this).parents('form:first').submit();
// });



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

var button = $(event.relatedTarget) // Button that triggered the modal

var id = button.data('id') 
var tracking = button.data('tracking') 
var status = button.data('status') 
var modal = $(this)
//   modal.find('.modal-title').text('New message to ' + recipient)
modal.find('.modal-body #id').val(id)
modal.find('.modal-body #code').val(tracking)
if(status==9){
    $( "#flexCheckDefault" ).prop( "checked", true );
}else{
    $( "#flexCheckDefault" ).prop( "checked", false  );
}

})


$('#myform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/accountcolombostatusupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                $("#editordermodel").modal('hide');  
                $('#example12').DataTable().ajax.reload();
                toastr.success('Details Update Successfully!')
                // location.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });



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

var button = $(event.relatedTarget) 
var id = button.data('id') 

var modal = $(this)
modal.find('.modal-body #id').val(id)

    $.ajax({
            url: "<?php echo e(url('/getbarcodecustomer')); ?>/"+id ,
            method: "get",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'JSON',
            success: function (data) {
                    console.log(data)
                    $('.att-group2').remove()

                    jQuery.each(data, function(key,value){
                    
                        for(i=0; i<value.length; i++){
 
                        $('.applenddata2').append('<div class="form-group att-group2"><label class="col-form-label">'+ value[i].ordersbarcodepro.name +' :</label><input type="hidden" name="id[]" value="'+ value[i].id +'"><input type="text" class="form-control" class="barcodeclassid" name="barcode[]" id="barcode" value="'+ value[i].barcode +'" required></div>')

                        }


                        
                    
                    });

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






})

</script>
<script>
$('#reservationdate').datetimepicker({
    format: 'YYYY/MM/DD'
    });




$(document).ready(function() {
  var table = $('#example12').DataTable({
        "ajax": {   "url": '/getcusdatatoacc',
                    "type": 'POST',
                    "data": function ( d ) {
                    return $('#formFilter').serialize();
                    }
        },
        columns: [
            { data: 'id', name: 'id' },
            { data: 'name', name: 'name' },
            { data: 'phone', name: 'phone' },
            {  data: 'tracking', name: 'tracking' },
            { data: 'cod', name: 'cod'},
            { data: 'status', 
              render: function(data) { 
                if(data==0) {
                  return '<span class="badge badge-warning">Check Order</span>' 
                }
                else if(data==1){
                  return '<span class="badge badge-info">Pending</span>'
                }
                else if(data==2){
                  return '<span class="badge badge-warning" >1st Attempt</span>'
                }
                else if(data==3){
                  return '<span class="badge badge-warning">2nd Attempt</span>'
                }
                else if(data==4){
                  return '<span class="badge badge-warning">3rd Attempt</span>'
                }
                else if(data==5){
                  return '<span class="badge badge-primary">Colombo Orders</span>  '
                }
                else if(data==6){
                  return '<span class="badge badge-primary">Out Orders</span>'
                }
                else if(data==7){
                  return '<span class="badge badge-info">Return Order</span>'
                }
                else if(data==8){
                  return '<span class="badge badge-warning">Dispatched Order</span>'
                }
                else if(data==9){
                  return '<span class="badge badge-success">Money Recived</span>'
                }
                else if(data==10){
                  return '<span class="badge badge-danger">Cancel Order</span>'
                }
                else if(data==11){
                  return '<span class="badge badge-primary">Out Assigned</span>'
                }
                else if(data==12){
                  return '<span class="badge badge-primary">Colombo Assigned</span>'
                }
                else if(data==13){
                  return '<span class="badge badge-primary">Out Pick</span>'
                }
                else if(data==14){
                  return '<span class="badge badge-primary">Colombo Pick</span>'
                }
                else if(data==15){
                  return ' <span class="badge badge-primary">Packed</span>'
                }
                else if(data==16){
                  return '<span class="badge badge-primary">Phone Off</span>'
                }
                else if(data==17){
                  return '<span class="badge badge-primary">He will call</span>'
                }
                else if(data==18){
                  return '<span class="badge badge-warning">Delivered</span>'
                }
                else if(data==19){
                  return '<span class="badge badge-primary">Dropex Confirm</span>'
                }
                else if(data==20){
                  return '<span class="badge badge-primary">Dropex Dispatched</span>'
                }
                },
              defaultContent: '<span class="badge badge-danger">Colombo Print</span>'
            },
            { data: 'deliverystatus', 
              render: function(data) { 
                if(data==21) {
                  return '<span class="badge badge-warning">Not Delivery</span>' 
                }
                else if(data==18){
                  return '<span class="badge badge-success">Delivered</span>'
                }
                else if(data==0){
                  return '<span class="badge badge-warning">Not Delivery</span>'
                }
                else if(data==1){
                  return '<span class="badge badge-success">Delivered</span>'
                }
                },
              defaultContent: '<span class="badge badge-danger">Not Delivery</span>'
            },
            { data: 'action', name: 'action', orderable: false, searchable: false}
        ]
    });
} );





$('#myformbarcode').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/accountbarcodeupdate",
            method:"POST",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                $("#editordermodelbarcode").modal('hide');  
                // $('#example').data.reload();
                $('#example12').DataTable().ajax.reload();
                toastr.success('Barcode Update Successfully!')
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });

</script>

