@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">Product Wise 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">Product Wise Orders</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">

      <div class="card">
        <div class="card-body">
        <form class="form-horizontal" method="POST" action="/productwiseordersfilter">
          {{csrf_field()}}
          <div class="row">
            <div class="col-md-4">
                  <div class="form-group">
                      <label>Product Name</label>
                      <select class="form-control select2" name="delivery" id="delivery" style="width: 100%;" required>
                          <option value="" selected="selected" disabled>Select</option>
                              @foreach($delise as $data)
                              <option value="{{ $data->id }}" @if($del==$data->id) selected @endif>{{ $data->pro_name }}</option>
                              @endforeach
                      </select>
                  </div>
              </div>

              <div class="col-md-3">
                <div class="form-group">
                <label>Date Range</label>
                  <div class="input-group">
                      <div class="input-group-prepend">
                      <span class="input-group-text">
                          <i class="far fa-calendar-alt"></i>
                      </span>
                      </div>
                      <input type="text" class="form-control float-right" id="reservation" value="{{$date}}" name="daterange">
                  </div>
                  </div>
              </div>
              <div class="col-md-1" style="padding-top:30px;">
                <button type="submit" class="btn btn-primary btn-block">Filter</button>
            </div>


          </div>
          </form>
        </div>
      </div>




      <div class="card">
        <div class="card-body">
          <div class="row">
            <div class="col-md-12">
                <table id="example12" data-page-length='50' 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>COD</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        @if($del=="null")

                        @else
                        @foreach($items as $data)
                        <tr>
                            <td><a target="_blank" href="/viewallorders/{{ $data->id }}">{{ $data->id }}</a></td>
                            <td>{{$data->name}}</td>
                            <td>{{$data->address}}</td>
                            <td>{{$data->phone}}</td>
                            <td>{{$data->cod}}</td>
                            <td>
                            @if($data->status =='0')   
                            <span class="badge badge-warning">Check Order</span>
                            @elseif($data->status =='1')   
                            <span class="badge badge-primary">Pending</span>
                            @elseif($data->status =='2')               
                            <span class="badge badge-warning" >1st Attempt</span>
                            @elseif($data->status =='3')                
                            <span class="badge badge-warning">2nd Attempt</span>
                            @elseif($data->status =='4')               
                            <span class="badge badge-warning">3rd Attempt</span>
                            @elseif($data->status =='5')            
                            <span class="badge badge-primary">Colombo Confirm</span>                  
                            @elseif($data->status =='6')                
                            <span class="badge badge-primary">Out Confirm</span>
                            @elseif($data->status =='7')                
                            <span class="badge badge-danger">Return Order</span>
                            @elseif($data->status =='8')                
                            <span class="badge badge-info">Dispatched Order</span>
                            @elseif($data->status =='9')                
                            <span class="badge badge-secondary">Money Received</span>
                            @elseif($data->status =='10')                
                            <span class="badge badge-danger">Cancel Order</span>
                            @elseif($data->status =='11')                
                            <span class="badge badge-primary">Out Assigned</span>
                            @elseif($data->status =='12')                
                            <span class="badge badge-primary">Colombo Assigned</span>
                            @elseif($data->status =='13')                
                            <span class="badge badge-primary">Out Pick</span>
                            @elseif($data->status =='14')                
                            <span class="badge badge-primary">Colombo Pick</span>
                            @elseif($data->status =='15')                
                            <span class="badge badge-primary">Packed</span>
                            @elseif($data->status =='16')                
                            <span class="badge badge-primary">Hold Order</span>
                            @elseif($data->status =='17')                
                            <span class="badge badge-primary">Udrop Pending</span>
                            @elseif($data->status =='18')                
                            <span class="badge badge-success">Delivered</span>
                            @elseif($data->status =='26')                
                            <span class="badge badge-primary">Hold</span>
                            @elseif($data->status =='27')                
                            <span class="badge badge-primary">Reject</span>
                            @elseif($data->status =='28')                
                            <span class="badge badge-dark">Banned Customer</span>
                            @elseif($data->status =='29')                
                            <span class="badge badge-info">Incomplete Order</span>
                            @elseif($data->status =='30')                
                            <span class="badge badge-warning">Remind Order</span>
                            @elseif($data->status =='32')                
                            <span class="badge badge-warning">Out Of Stock</span>
                            @elseif($data->status =='33')                
                            <span class="badge badge-warning">Paid to Reseller</span>
                            @elseif($data->status =='34')                
                            <span class="badge badge-warning">Return to Reseller</span>
                            @elseif($data->status =='35')                
                            <span class="badge badge-warning">Refund Order</span>
                            @elseif($data->status =='36')                
                            <span class="badge badge-warning">Refund to Reseller</span>
                            @elseif($data->status =='37')                
                            <span class="badge badge-warning">Duplicate Order</span>
                            @endif
                        </td>
                        </tr>
                        @endforeach
                        @endif                          
                     
                    </tbody>

                </table>
            </div>
          </div>
          </div>
        </div>

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



  @include('dashboard.include.footer')

<script>
$(document).ready(function() {
    $('#example12').DataTable({
        "responsive": true, "lengthChange": true, "autoWidth": false,"order": [[ 0, "asc" ]],
      // "buttons": ["copy", "csv", "excel", "pdf", "print"]
      "buttons": [ {extend: 'copy',footer: true,exportOptions: {columns: [0,1,2,3,4,5]}},   
      {extend: 'csv',footer: true,exportOptions: {columns: [0,1,2,3,4,5]}},
      {extend: 'excel',footer: true,exportOptions: {columns: [0,1,2,3,4,5]}},
      {extend: 'pdf',footer: true,exportOptions: {columns: [0,1,2,3,4,5]}},
      {extend: 'print',footer: true,exportOptions: {columns: [0,1,2,3,4,5]}},      
    ]  
    }).buttons().container().appendTo('#example12_wrapper .col-md-6:eq(0)');
} );


    $('#reservation').daterangepicker({
        locale: {
            format: 'YYYY/MM/DD'
        }
    });

    $('.select2').select2()
</script>