<?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">Assign Colombo Orders</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">Assign Colombo Orders</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">

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

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

          <div class="row">
          <div class="col-md-3">
                <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>
                            <?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-1" style="padding-top:32px;"><button type="submit" name="searchrider" value="searchrider" class="btn btn-dark btn-block">Filter</button></div>
        </div> 
        </form>
        
        </div>
      </div>


      <div class="card">
        <div class="card-body">
        <form method="post" action="/printstatuschangecolombo">
        <?php echo e(csrf_field()); ?>

          <div class="row">
            <div class="col-md-12">

                <table id="example1" data-page-length='50' class="table table-bordered" style="width:100%; font-size:11px;">
                    <thead>
                        <tr>
                            <th><input type="checkbox" id="selectall"/></th>
                            <th>Id</th>
                            <th>Delivery Date</th>
                            <th>Name</th>
                            <th>Address</th>
                            <!-- <th>Phone</th> -->
                            <th>items</th>
                            <th>COD</th>
                            <th>Print Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><input type="checkbox" class="singlechkbox" name="checkids[]" value="<?php echo e($data->id); ?>"/></td>
                            <td><?php echo e($data->id); ?></td>
                            <td><?php echo e($data->deliverydate); ?></td>
                            <td><?php echo e($data->name); ?></td>
                            <td><?php echo e($data->address); ?></td>
                            <!-- <td><?php echo e($data->phone); ?></td> -->
                            <td><?php $__currentLoopData = $data->cus_or; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $itemdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php echo e($itemdata->orders->pro_name); ?>,
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                            </td>
                            <td><?php if($data->paymentmethod=="paid"): ?>0.00 <?php else: ?><?php echo e($data->cod); ?><?php endif; ?></td>
                            <td>
                            <?php if($data->print=="0"): ?>
                            <span class="badge badge-warning">Not Print</span>
                            <?php else: ?>
                            <span class="badge badge-success">Printed</span>
                            <?php endif; ?>
                            </td>
                            <td class="text-center">                       
                                     
                                <a data-id="<?php echo e($data->id); ?>" class="btn btn-primary btn-xs" href="viwedetails/<?php echo e($data->id); ?>">View</a>
                            </td>
                            
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                    </tbody>
                    <tfoot>
                        <tr>
                            <th><input type="checkbox" id="selectall"/></th>
                            <th>Id</th>
                            <th>Delivery Date</th>
                            <th>Name</th>
                            <th>Address</th>
                            <!-- <th>Phone</th> -->
                            <th>items</th>
                            <th>COD</th>
                            <th>Print Status</th>
                            <th>Action</th>
                        </tr>
                    </tfoot>
                </table>
                
            </div>
          </div> <br><br>          
          
          </div>
        </div>
        <div class="card">
        <div class="card-body">
          <div class="row">
                <input type="hidden" value="<?php echo e($deli); ?>" name="delivery_name">
          <div class="col-md-1"></div>
            <!-- <div class="col-md-2" style="padding-top:32px;"><button type="submit" name="pdfprint" value="pdfprint" formtarget="_blank" class="btn btn-success btn-block">Print Route</button></div> -->
            <!-- <div class="col-md-2" style="padding-top:32px;"><button type="submit" name="invoicepdf" value="invoicepdf" formtarget="_blank" class="btn btn-secondary btn-block">Print Invoice</button></div> -->
            <div class="col-md-2" style="padding-top:30px;">
                <!-- <button type="submit" formtarget="_blank" name="ebay" value="ebay" class="btn btn-dark btn-block">Invoices Sticker</button> -->
            </div>
            <div class="col-md-2" style="padding-top:32px;">
                <!-- <button type="submit"  formtarget="_blank"  class="btn btn-warning btn-block" name="check" value="check">Check List</button>  -->
            </div>
            <div class="col-md-2" style="padding-top:32px;"><button type="submit" name="sendprint" onClick="return show_alert()" value="sendprint" class="btn btn-primary btn-block">Send to Print</button></div>
            <!-- <div class="col-md-2" style="padding-top:32px;"><button type="submit" name="sendpacking" onClick="return show_alert()" value="sendpacking" class="btn btn-primary btn-block">Send to Packing</button></div> -->
            
        </div> 
          </form>
        </div>
      </div>   <br><br><br>

    <div class="card">
        <div class="card-body">
          <div class="row">
            <div class="col-md-12">
                <table data-page-length='50' id="colombo" class="table table-striped table-hover" style="width:100%; font-size:12px;">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Address</th>
                            <th>Phone</th>
                            <th>Products</th>
                            <th>COD</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                </table>
            </div>
          </div>
          </div>
        </div>



      </div>
    </section>
  </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 Details</h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              
            </div>
            
            <form method="post" enctype="multipart/form-data" id="colombostupdate">
            <?php echo e(csrf_field()); ?>

                <div class="modal-body">
                <input type="hidden" id="id" name="id">
                
                <div class="form-group">
                    <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="" 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 class="form-group">
                    <label>Order Status</label>
                        <select class="form-control" name="statusdelauth" id="statusdelauth" required>
                            <option value="1">Pending</option>
                            <option value="5">Confirm Colombo</option>
                            <option value="10">Cancel</option>
                            <option value="12">Assigned Colombo</option>
                        </select>
                </div>
                <div class="form-group">
                    <label>Assign Rider</label>
                        <select class="form-control" name="deliveryrid" id="deliveryrid" required>
                            <?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 echo e($data->name); ?></option>
                            <?php endif; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                </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>
$('#reservationdate').datetimepicker({
    format: 'YYYY/MM/DD'
    });





$(document).ready(function() {
  var table = $('#colombo').DataTable({
        "ajax": {   "url": '/colomboprintcusd',
                    "type": 'POST',
                    "data": function ( d ) {
                    return $('.formFilter').serialize();
                    }
        },
        columns: [
            { data: 'name', name: 'name' },
            { data: 'address', name: 'address'},
            { data: 'phone', name: 'phone'},
            { data: 'productname', name: 'productname' },
            { data: 'cod', name: 'cod'},
            { data: 'action', name: 'action', orderable: false, searchable: false}
        ],
        columnDefs: [
                      {
                          "targets": 5, // your case first column
                          "className": "text-center",
                          "width": "4%"
                    },
                    {
                          "targets": 4,
                          "className": "text-center",
                    },
                    {
                          "targets": 3,
                          "className": "text-left",
                          "color": "#00ff00",

                    }
                    ],
    });
} );

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

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

var id = button.data('id') 
var status = button.data('status') 
var note1 = button.data('date') 
var rider = button.data('rider') 
var modal = $(this)

modal.find('.modal-body #id').val(id)
modal.find('.modal-body #delivery_date').val(note1)
$("#statusdelauth").val(status).change();
$("#deliveryrid").val(rider).change();


})
// $(function() {
//     $('#delivery_name').change(function() {
//         this.form.submit();
//     });

// });
$('#colombostupdate').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/colomboprintriderstatusupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                $("#editordermodel").modal('hide');  
                toastr.success('Your work has been saved!')
                $('#colombo').DataTable().ajax.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });





function show_alert() {
  if(!confirm("Are you Sure?")) {
    return false;
  }
  this.form.submit();
}


$(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": false,"order": [[ 7, "asc" ]],
      "buttons": ["colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
  });
</script>
<script type="text/javascript">
jQuery(function($) {
    $('body').on('click', '#selectall', function() {
        $('.singlechkbox').prop('checked', this.checked);
    });
 
    $('body').on('click', '.singlechkbox', function() {
        if($('.singlechkbox').length == $('.singlechkbox:checked').length) {
            $('#selectall').prop('checked', true);
        } else {
            $("#selectall").prop('checked', false);
        }
 
    });
});

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

Swal.fire({
  
  type: 'success',
  title: 'Your work has been saved',
  text: "<?php echo e(session('success')); ?>",
  showConfirmButton: false,
  timer: 1500
});


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


