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

          <div class="row">
            <div class="col-md-6"></div>
            <div class="col-md-3">
            <div class="form-group">
                <label>Select Delivery Service</label>
                <select class="form-control" name="delivery" id="delivery" 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" style="padding-top:32px;">
               <button type="submit" value="update" class="btn btn-primary btn-block">Orders Dispatch Create</button>
            </div>
           </div>
           </form>
        </div>
       </div>

      <div class="card">
        <div class="card-body">
          <div class="row">
            <div class="col-md-12">
                <table id="example12" class="table table-bordered" style="width:100%; font-size:13px;">
                    <thead>
                        <tr>
                            <th>Dispatch Id</th>
                            <th>Deliver Service Name</th>
                            <th>No Of Line</th>
                            <th>Create Date</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $cuso; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($data->id); ?></td>
                            <td><?php echo e($data->getdelivername->deliveryname); ?></td>
                            <td><?php echo e($data->noofline); ?></td>
                            <td><?php echo e($data->created_at); ?></td>
                            <td class="text-center">                  
                            <form method="post" action="/dispatchupdate">
                                <?php echo e(csrf_field()); ?>          
                                <input type="hidden" value="<?php echo e($data->courierservice); ?>" name="delivery" required>
                                <input type="hidden" value="<?php echo e($data->id); ?>" name="id" required>
                                <input type="hidden" value="<?php echo e($data->noofline); ?>" name="noof" required>
                                <!-- <button type="submit"  class="btn btn-primary btn-xs">Update</button> -->
                            <form>
                                <a data-id="<?php echo e($data->id); ?>" class="btn btn-primary btn-xs" href="courierexcel/<?php echo e($data->id); ?>">View</a>
                            </td>
                            
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                    </tbody>
                    <tfoot>
                        <tr>
                            <th>Dispatch Id</th>
                            <th>Deliver Service Name</th>
                            <th>No Of Line</th>
                            <th>Create Date</th>
                            <th>Action</th>
                        </tr>
                    </tfoot>
                </table>
            </div>
          </div><br>


          </div>
        </div>


    <div class="col-sm-6">
    <h1 class="m-0"><h2>New Orders</h2></h1>
    </div>
      <div class="card">
        <div class="card-body">
        <table id="example123" class="table table-bordered" style="width:100%; font-size:13px;">
                    <thead>
                        <tr>
                            <th>Id</th>
                            <th>Name</th>
                            <th>Address</th>
                            <th>Phone</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($data->id); ?></td>
                            <td><?php echo e($data->name); ?></td>
                            <td><?php echo e($data->address); ?></td>
                            <td><?php echo e($data->phone); ?></td>
                            <td class="text-center">                            
                                <a data-id="<?php echo e($data->id); ?>" class="btn btn-primary btn-xs" href="viwedetailsconfirm/<?php echo e($data->id); ?>">View</a>
                            </td>
                            
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                    </tbody>
                    <tfoot>
                        <tr>
                            <th>Id</th>
                            <th>Name</th>
                            <th>Address</th>
                            <th>Phone</th>
                            <th>Action</th>
                        </tr>
                    </tfoot>
                </table>
        </div>
      </div>
      </div>
    </section>
  </div>
 



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

<script>
  $(function () {
    $("#example12").DataTable({
      "responsive": true, "autoWidth": false,"order": [[ 0, "desc" ]],
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
  });

$(document).ready(function() {
    $('#ffffff').DataTable();
} );
$(document).ready(function() {
    $('#example123').DataTable();
} );
// $(':input[type="submit"]').prop('disabled', true);

$('#delivery').on('change', function(){
    var id = $(this).val();
    $.ajax({
            url: "<?php echo e(url('/getdispatchcreatedata')); ?>/"+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) {
                    jQuery.each(data, function(key,value){
                        for(i=0; i<value.length; i++){
                            var rid = value[i].id;
                            var ret = value[i].created_at.split(" ");
                            var str1 = ret[0];
                            var todayDate = new Date().toISOString().slice(0, 10);
                            if(str1==todayDate){

                                    swal({
                                        title: "Error!",
                                        text: "Already Created, Please Check Again!!!",
                                        icon: "error",
                                        button: "OK",
                                    });
                                    // $(':input[type="submit"]').prop('disabled', true);
                            }
                            else{
                                // $(':input[type="submit"]').prop('disabled', false);
                            }

                        }

                    });

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