@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 Packing</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 Packing</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
    
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">

    <form method="post" action="/searchinventorycolombo">
        {{csrf_field()}}
        <div class="row">

                <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" @if($deli=="all")selected @endif>All</option>
                                @foreach($delise as $data)
                                @if($data->type=="Delivery_Guy")
                                <option value="{{ $data->id }}"  @if($deli==$data->id )selected @endif>{{ $data->name }}</option>
                                @endif
                                @endforeach
                        </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="{{$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>
      @foreach($dataor as $datas)
      <div class="card">
        <div class="card-body">
        <form method="post" enctype="multipart/form-data" id="myForm" action="/checklistbarcode">
           {{csrf_field()}}
            <div class="row">
                <div class="col-md-4"> 
                    <div class="form-group">
                        <label for="">Item ID &nbsp;&nbsp;: &nbsp;&nbsp;</label>{{ $datas->item_id }}
                    </div>
                </div>
                <div class="col-md-5"> 
                    <div class="form-group">
                        <label for="">Item Name &nbsp;&nbsp;: &nbsp;&nbsp;</label>{{ $datas->name }}
                    </div>
                </div>
                <div class="col-md-3"> 
                    <label for="">Quantity&nbsp;&nbsp; : &nbsp;&nbsp;</label>{{ $datas->qty }}
                </div>
                @for ($i = 0; $i < $datas->qty; $i++)
                <div class="col-md-2"><input type="text" class="form-control" name="barcode[{{$datas->item_id}}]" id="barcode" value="" required></div>
                @endfor
            </div>
            </form>
        </div>
      </div>
      @endforeach
      <div class="card">
        <div class="card-body">
        <form method="post" enctype="multipart/form-data" id="myForm" action="/completeorderscmbo">
           {{csrf_field()}}
          <div class="row">
            <div class="col-md-12">

                <table id="example1" class="table table-bordered" style="width:100%; font-size:12px;">
                    <thead>

                        <tr>
                            <th><input type="checkbox" id="selectall"/></th>
                            <th>Id</th>
                            <th>Phone</th>
                            <th>tracking</th>
                            <th>items</th>
                            <th>Barcode</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>

                    @foreach($item as $data)
                        <tr>
                            <td><input type="checkbox" class="singlechkbox" name="checkids[]" id="checkids" value="{{$data->id}}"/></td>
                            <td>{{$data->id}}</td>
                            <td>{{$data->phone}}</td>
                            <td>{{$data->tracking}}</td>
                            <td></td>
                            <td></td>
                            <td class="text-center">                           
                                <a data-id="{{$data->id}}" class="btn btn-success btn-xs" href="viwedetailsinventory/{{$data->id}}">View Order</a>
                            </td>
                        </tr>
                        <input type="submit" style="display:none" />
                        </form>
                        @foreach($data->cus_or as $itemdata)

                        <tr>
                         <td colspan="4"></td>
                         <td>{{$itemdata->orders->name}}</td>
                         <td>
                         <form method="post" enctype="multipart/form-data" id="myForm" action="/addbarcodecmbo">
                        {{csrf_field()}}
                         <input type="hidden" name="itemid" value="{{$itemdata->id}}" required>
                         <input type="hidden" name="pro_id" value="{{$itemdata->item_id}}" required>
                         <input type="text" class="form-control" name="barcode" id="barcode" value="{{$itemdata->barcode}}" required></td>
                         <td class="text-center">                 
                                <button type="submit" class="btn btn-primary btn-xs">Add Barcode</button>           
                            </td>
                           </form>
                        </tr>
                        
                        @endforeach 
                    @endforeach 
                    </tbody>
                    <tfoot>
                        <tr>
                            <th><input type="checkbox" id="selectall"/></th>
                            <th>Id</th>
                            <th>Phone</th>
                            <th>tracking</th>
                            <th>items</th>
                            <th>Barcode</th>
                            <th>Action</th>
                        </tr>
                    </tfoot>
                </table>

            </div>
          </div> <br><br>
         
          <div class="row">
          <div class="col-md-9"></div>
            <div class="col-md-3"><input type="button" value="Send To Complete Orders" class="btn btn-primary btn-block" id="myButton" /></div>

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




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


<script type="text/javascript">
    $(document).ready(function() {
       $("#myButton").click(function() {
            $("#myForm").submit();
    
       });
    });
</script>


<script>

// $(document).ready(function() {

//     $('input:checkbox').change(function() {
//         if(this.checked) {
//             var values = $('input:checkbox:checked').map(function(){
//         return this.value;
//     }).toArray();
//     $('#checkvalue').val(values);
//     alert(values);


//         }
       
//     });
// });







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

</script>

<script>
@if (session('success'))
        // swal("Success!","{{session('success')}}","success");
        toastr.success('Your work has been successfully!')
// 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>





      <div class="card">
        <div class="card-body">
           @foreach($dataor as $datas)
           <form method="post" class="formsubmittest" >
                    {{csrf_field()}}
            <!-- <input type="hidden" class="form-control" name="id" id="id" value="{{ $datas->id }}" required> -->
            <!-- <input type="hidden" class="form-control" name="pro_id" id="pro_id" value="{{ $datas->productid }}" required> -->
            <div class="row">
                <div class="col-md-1"> 
                    <div class="form-group">
                        <label for="">ID &nbsp;&nbsp;: &nbsp;&nbsp;</label>{{ $datas->id }}
                    </div>
                </div>
                <div class="col-md-6"> 
                    <div class="form-group">
                        <label for="">Product Name &nbsp;&nbsp;: &nbsp;&nbsp;</label>{{ $datas->productgetn->name }}
                    </div>
                </div>

                <div class="col-md-3">
                <input type="text" class="form-control barcodeclassid inputs" name="barcode" id="barcode" value="{{ $datas->barcode }}"  maxlength="8" autofocus required>
                </div>
                </form>
            </div>
            @endforeach
            
        </div>
      </div>

<script>
      $('.barcodeclassid').change(function () {
    // alert("we are here");
     $(this).parents('form:first').submit();
    // var form = $(this).closest('form');
});

</script>
