@include('dashboard.include.header');

  
  <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">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">Colombo Orders</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
        <div class="row">
            <div class="col-md-4">
                <div class="form-group">
                    <label for="">Filter by Delivery Date :</label>

                    <form method="post" id="myform33" action="/searchdeliverydate" enctype="multipart/form-data">
                    {{csrf_field()}}
                        <input type="hidden" class="form-control" value="" name="id" placeholder="" required>

                        <div class="input-group date" id="reservationdate" data-target-input="nearest">
                            <input type="text" class="form-control datetimepicker-input" value="{{$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>
                        <input type="submit" style="visibility: hidden;" />
                    </form>
                  

                </div>
            </div>
           
            <div class="col-md-6">
            </div>
            @if((Auth::user()->type=="super_admin"))
            <div class="col-md-2">
              <form method="post" action="/daycloseupdate" enctype="multipart/form-data">
              {{csrf_field()}}
              <button type="submit" onClick="return show_alert()" class="btn btn-primary btn-block">Day Close</button>
              </form>
            </div>
            @endif
            
            </div>
        </div>
        </div>

      <div class="card">
        <div class="card-body">
        <form method="post" action="/adddeliveryguycmbo">
        {{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:12px;">
                    <thead>
                        <tr>
                            <th><input type="checkbox" id="selectall"/></th>
                            <th>Id</th>
                            <th>Delivery Date</th>
                            <th>Name</th>
                            <th>Address</th>
                            <th>items</th>
                            <th>COD</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($item as $data)
                        <tr>
                            <td><input type="checkbox" class="singlechkbox" name="checkids[]" value="{{$data->id}}"/></td>
                            <td>{{$data->id}}</td>
                            <td>{{$data->deliverydate}}</td>
                            <td>{{$data->name}}</td>
                            <td>{{$data->address}}</td>
                            <td>@foreach($data->cus_or as $itemdata)
                                    {{$itemdata->orders->pro_name}},
                                @endforeach 
                            </td>
                            <td>@if($data->paymentmethod=="paid")0.00 @else{{$data->cod}}@endif</td>
                            <td class="text-center">                            
                                <a data-id="{{$data->id}}" class="btn btn-primary btn-xs" href="viwedetails/{{$data->id}}">View</a>
                            </td>
                            
                        </tr>
                    @endforeach 
                    </tbody>
                    <tfoot>
                        <tr>
                            <th><input type="checkbox" id="selectall"/></th>
                            <th>Id</th>
                            <th>Delivery Date</th>
                            <th>Name</th>
                            <th>Address</th>
                            <th>items</th>
                            <th>COD</th>
                            <th>Action</th>
                        </tr>
                    </tfoot>
                </table>
                
            </div>
          </div> <br>
          <div class="row">
            <div class="col-md-4">
                <div class="form-group">
                    <label>Select Delivery Rider</label>
                    <select class="form-control" name="delivery_name" id="delivery_name" style="width: 100%;" required>
                        <option value="" selected="selected" disabled>Select</option>
                            @foreach($delise as $data)
                            @if($data->type=="Delivery_Guy")
                            <option value="{{ $data->id }}">{{ $data->name }}</option>
                            @endif
                            @endforeach
                    </select>
                </div>
            </div>
            <div class="col-md-3" style="padding-top:32px;"><button type="submit" class="btn btn-primary btn-block" name="rider" value="rider">Assign Delivery Rider</button></div>
            <div class="col-md-2" style="padding-top:32px;"><button type="submit" name="dropex" class="btn btn-block btn-dark" value="dropex">Send to Out</button></div>
            </div>
          </form>
          
          </div>
        </div>

      <div class="card">
        <div class="card-body">
        <div class="row">
        <div class="col-md-4">
            <table data-page-length='50' class="table table-bordered" style="width:100%; font-size:12px;">
                    <thead>
                        <tr>
                            <th>Delivery Date</th>
                            <th>Count</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($dataor as $dataordata)
                        <tr>
                            <td>{{$dataordata->deliverydate}}</td>
                            <td>{{$dataordata->count}}</td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
           
            </div>
        </div>
        </div>
     </div>


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


  @include('dashboard.include.footer');

<script>
    function show_alert() {
  if(!confirm("Are you Sure?")) {
    return false;
  }
  this.form.submit();
}
$('#reservationdate').datetimepicker({
    format: 'YYYY/MM/DD'
    });

document.getElementById('reservationdate').onchange = function(){ 
    $("#myform33").submit();
}



$(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": false
    }).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);
        }
 
    });
});



@if (session('success'))
        //swal("Success!","{{session('success')}}","success");

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


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


