@include('dashboard.include.header')

@foreach($item as $data)
@if($data->user != Auth::user()->resellerid AND Auth::user()->type=="Reseller")
<script>
    document.location.href = '/resellerdash'
</script>
@elseif($data->user != Auth::user()->resellerid AND Auth::user()->type=="User")
<script>
    document.location.href = '/resellerdash'
</script>
@endif
@endforeach

  
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
          @if($banned>0)
          <h1 class="m-0" style="color:red;">Invoice ID - {{ $cus_id }} / Banned Customer</h1>
          @else
          <h1 class="m-0">Invoice ID - {{ $cus_id }}</h1>
          @endif
          </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">View Order Details</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
    
    <section class="content">
      <div class="container-fluid">

      <div class="card">
        <div class="card-body">
        <div class="row">
        @foreach($item as $data)
        <div class="col-md-12">
        <b>Order Type :</b>&nbsp;&nbsp;
        @if($data->ordertype == 1) New Order
        @elseif($data->ordertype == 2)Exchange Order
        @elseif($data->ordertype == 3)Refund Order
        @endif
        &nbsp;&nbsp;&nbsp;&nbsp;<b>Delivery/Return Status :</b>&nbsp;&nbsp;
        @if($data->deliverystatus==21)Not Delivery
        @elseif($data->deliverystatus==18)Delivered
        @elseif($data->deliverystatus==22)Unauthorized Return
        @elseif($data->deliverystatus==23)Authorized Return
        @endif
        &nbsp;&nbsp;&nbsp;&nbsp;<b>Company :</b>&nbsp;&nbsp;{{ $data->pageName}}
        </div>

        </div><hr>
        <div class="row">
       
            <div class="col-md-5">
                    <b>Order Status :</b> 
                    @if($data->status =='0')   
                    <span class="badge badge-warning">Check Order</span>
                    @elseif($data->status =='1')   
                    <span class="badge badge-info">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 Order</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</span>
                    @elseif($data->status =='17')                
                    <span class="badge badge-primary">Received Order</span>
                    @elseif($data->status =='18')                
                    <span class="badge badge-primary">Delivered</span>
                    @elseif($data->status =='19')                
                    <span class="badge badge-primary">City Update</span>
                    @elseif($data->status =='20')                
                    <span class="badge badge-primary">Reseller Import</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
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <b>Print Status : </b>
                    @if($data->print =='1')   
                    <span class="badge badge-success">Print</span>
                    @elseif($data->print =='0')
                    <span class="badge badge-danger">Not Print</span>
                    @endif


            </div>
            <div class="col-md-4">

            </div>
            <div class="col-md-3"><button type="button" class="btn btn-block btn-primary btn-sm" data-toggle="modal" data-target="#myModal3"  style="float:right" data-whatever="@getbootstrap" disabled>Edit Customer Details</button></div>
          </div> <hr>
            <div class="row" style="padding-top:10px;">
                <div class="col-md-12" id="">
                    <table class="table borderless"  border="0">
                        <tbody>
                            <tr>
                            <td class="text-left"><b>Customer Name - </b>  {{ $data->name}}</td>
                            <td class="text-right"><b>Date - </b> {{ $data->created_at}}</td>
                            </tr>
                            <tr>
                            <td class="text-left"><b>Address - </b>  {{ $data->address}}</td>
                            <td class="text-right"><b>Page - </b> {{ $data->pageName}}</td>
                            </tr>
                            <tr>
                            <td class="text-left"><b>Phone Number - </b> {{ $data->phone}}</td>
                            <td class="text-right">
                            <b>Tracking Code - </b>{{ $data->tracking}}                            
                            </td>
                            </tr>
                            <tr>
                            <td class="text-left"><b>Note - </b> <b style="color:red;">{{ $data->note}}</b></td>
                            <td class="text-right">
                            @if($data->deliveryservice=="-")
                                @if($data->companydelivery=="1")
                                <b>Rider Name - </b>{{ $data->userget->name }}&nbsp; <b>Delivery Date </b> - {{$data->deliverydate}}
                                @endif
                            @else
                            <b>Delivery Service - </b>{{ $data->deliveryse->deliveryname }}
                            @endif
                            </td>
                            </td>
                            </tr>
                        </tbody>
                    </table>  
                </div>
            </div> 

             <hr>
             <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                        <label>City :</label>
                        <form method="post" class="cityupdateform" enctype="multipart/form-data">
                    {{csrf_field()}}
                        <input type="hidden" class="form-control" value="{{ $cus_id }}" name="id" placeholder="" required>
                    <select class="form-control select2" name="cituselect" id="cituselect" disabled>
                        <option value="" selected="selected" disabled>Select</option>
                        @foreach($city as $cityd)
                            <option value="{{ $cityd->id }}"@if($data->city==$cityd->id) selected @endif>{{ $cityd->city }}</option>
                            @endforeach
                    </select>
                    <script>
                                    $(function () {
                                    $('.select2').select2()
                                })
                    </script>
                    </form>
                </div>          
        </div>
        <div class="col-md-3">
            <div class="form-group">
                  <label>District :</label>
                  <input type="text" placeholder="" value="{{$data->district}}" id="district" class="form-control" readonly>
              </div>
        </div>
        <div class="col-md-3">
            <div class="form-group">
                  <label>Primary Phone Number :</label>
                  <form method="post" class="primaryphone" enctype="multipart/form-data">
                    {{csrf_field()}}
                    <input type="hidden" class="form-control" value="{{ $cus_id }}" name="id" placeholder="" required >
                  <input type="text" placeholder="" value="{{ $data->phone }}" name="phone" class="form-control" id="phone" readonly>
                  </form>
              </div>
        </div>
        <div class="col-md-3">
            <div class="form-group">
                  <label>Secondary Phone Number :</label>
                  <form method="post" class="secondaryphone" enctype="multipart/form-data">
                    {{csrf_field()}}
                    <input type="hidden" class="form-control" value="{{ $cus_id }}" name="id" placeholder="" required>
                  <input type="text" placeholder="" value="{{ $data->secondaryphone }}" id="secondary" name="secondary" class="form-control" readonly>
                    </form>
              </div>
        </div>
        </div>

          </div>
        </div>
        @endforeach

         <div class="card">
            <div class="card-body">
            <div class="row">
                <div class="col-md-12" align="right">
                <form action="/oneinvoiceprint" method="post" enctype="multipart/form-data">
            {{csrf_field()}}
                @foreach($item as $data)
                    <input type="hidden" value="{{$data->id}}" name="cus_id">
                    <input type="hidden" value="{{$data->deliveryservice}}" name="deliveryname">
                <button type="submit" formtarget="_blank" name="Colombo" value="Colombo" class="btn btn-info btn-xs">Colombo COD Invoice</button>  
                <button type="submit" formtarget="_blank" name="Out" value="Out" class="btn btn-dark btn-xs">Out COD Invoice</button>  
                @endforeach

                <a class="btn btn-warning btn-xs" onclick="printDiv('printableArea')" ><i class="fas fa-print"></i>&nbsp;Print Invoice</a>
                </form>
                </div>
                <!-- <div class="col-md-2" align="right"><button type="button" class="btn btn-sm btn-success" data-toggle="modal" data-target="#exampleModalCenter">Add items</button></div> -->
            </div> <br>
            <div class="row">
                <div class="col-md-12 here" name="here" id="here">
                <table class="table" id="book-table" name="book-table">
                    <thead>
                          <tr>
                          <th style="width:60px" class="text-center">QTY</th>
                            <th class="text-left">DESCRIPTION</th>
                            <th style="width:140px" class="text-right">UNIT PRICE</th>
                            <th style="width:90px" class="text-right">TOTAL</th>
                          </tr>
                    </thead>
                    <tbody>
                    @foreach($item3 as $data)
                                        
                    <tr>
                        <td class="text-center">{{$data->qty}}</td>
     
                        <td>{{$data->orders->pro_name}}
                            </td>
                        <td class="text-right">{{$data->pro_amount}}</td>
                        <td class="text-right">
                        {{$data->qty * $data->pro_amount}}
                        </td>
                    </tr>

                    
                    @endforeach 
                        
                            <tr>
                            <td colspan="2" rowspan="4">
                            
                            <td class="text-right"><strong>Delivery Charge</strong></td>
                            <td class="text-right">{{$deli}}</td>
                     
                        </tr> 
                        <tr>
                            <td class="text-right no-border">
                            <strong>Total</strong>
                            </td>
                            <td class="text-right"><strong>{{ $tot + $deli }}</strong></td>
                        </tr>
                       
                    </tbody>
                </table>  
                </div>
            </div>

 @if(Auth::user()->type == "Reseller" OR Auth::user()->type == "User")  
 @else         
            <div class="row">
                <div class="col-md-3">
                <div class="form-group">
                    <label for="">Delivery Date :</label>
                    
                    <form method="post" class="deliverydate1" enctype="multipart/form-data">
                    {{csrf_field()}}
                        <input type="hidden" class="form-control" value="{{ $cus_id }}" name="id" placeholder="" required>
                        @foreach($item as $data)
                        <div class="input-group date" id="reservationdate" data-target-input="nearest">
                            <input type="text" class="form-control datetimepicker-input" value="{{$data->deliverydate}}" 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;" />
                        @endforeach
                    </form>
                    

                </div>
                </div>
                </div>
        @endif

            </div>
        </div>
        @if((Auth::user()->type == "Reseller") OR (Auth::user()->type == "User"))    
        @else       
    <div class="card">
       <div class="card-body">
       <form action="/updatestatus" method="post" enctype="multipart/form-data">
        {{csrf_field()}}
        <div class="row">
        <div class="col-md-2"></div>
            <div class="col-md-3">
                <div class="form-group">
                    
                    @foreach($item as $data)
                        <input type="hidden" value="{{$data->id}}" name="cus_id">
                        <input type="hidden" value="{{$data->status}}" name="nowstatus">
                    
                        <input type="hidden" value="{{ $tot + $deli }}" name="total">
                        <select class="form-control" name="statusValu"  required>
                        <option value="" selected="selected" disabled>Change Status</option>
                        @if($data->status == 9 OR $data->status == 7 OR $data->status == 33 OR $data->status == 34 OR $data->status == 35 OR $data->status == 36)
                        @elseif($data->status == 18)
                        <option value="9">Money Recived</option>
                        @else
                        <option value="30">Remind Order</option>
                        <option value="18">Delivered</option>
                        @endif
                        </select>
                        @endforeach
                </div>
            </div>
            <div class="col-md-2">
            <button type="submit" class="btn btn-block btn-primary" >Change Order Status</button>
            </div>
            </form>
            <!-- <div class="col-md-2">
                <button type="button" class="btn btn-block btn-warning" data-toggle="modal" data-target="#exchangemodel" data-whatever="@getbootstrap">Exchange</button>
            </div> -->
            <div class="col-md-3">
            <button type="button" class="btn btn-block btn-success"  data-toggle="modal" data-target="#returnmodel" data-whatever="@getbootstrap">Delivery/Return Status</button>
            </div>
            <!-- <div class="col-md-2">
            <form action="/oneinvoiceprint" method="post" enctype="multipart/form-data">
            {{csrf_field()}}
                @foreach($item as $data)
                    <input type="hidden" value="{{$data->id}}" name="cus_id">
                    <input type="hidden" value="{{$data->deliveryservice}}" name="deliveryname">
                @endforeach
                <button type="submit" formtarget="_blank" value="Out" name="Out" class="btn btn-block btn-dark">Invoice Print</button>  
                </form>
            </div> -->
          </div>
        
        </div>
    </div>
@endif
<div class="card card-primary">
    <div class="card-header">
        <h3 class="card-title">Barcodes</h3>
    </div>
       <div class="card-body">
       @foreach($barord as $databar)
            <h5><b>{{ $databar->ordersbarcodepro->pro_name }} - </b>  {{ $databar->barcode }}</h5>
        @endforeach
       </div>
    
</div>

<br><br>


    <div class="card">
       <div class="card-body">
        <div class="row">
            <div class="col-md-12">
            <h4>Customer Order History</h4> <br>
            <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>Created Date</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($checkhistory as $data)
                    @if($data->id==$cus_id)
                    @else
                        <tr>
                            <td>{{$data->id}}</td>
                            <td>{{$data->name}}</td>
                            <td>{{$data->address}}</td>
                            <td>{{$data->phone}}</td>
                            <td>{{$data->created_at}}</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">Received Order</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>
                        @endif
                    @endforeach 
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

@if(Auth::user()->type == "Reseller" OR Auth::user()->type == "User")
    <div class="card-body">
        <div class="track">
        @foreach($statustrack as $statusda)
            @if($statusda->orderstatus == 0)
                <div class="step active"> <span class="icon"><i class="fa fa-spinner" aria-hidden="true"></i></span> <span class="text">Order Processing <p style="font-size:10px;">{{$statusda->created_at}}</p></span> </div>
            @elseif($statusda->orderstatus == 5 OR $statusda->orderstatus == 6)
            <div class="step active"> <span class="icon"><i class="fa fa-check"></i> </span> <span class="text"> Order Confirmed <p style="font-size:10px;">{{$statusda->created_at}}</p></span> </div>
            @elseif($statusda->orderstatus == 8)
            <div class="step active"> <span class="icon"><i class="fa fa-truck"></i> </span> <span class="text"> Dispatched Order <p style="font-size:10px;">{{$statusda->created_at}}</p></span> </div>
            @elseif($statusda->orderstatus == 18)
            <div class="step active"> <span class="icon"><i class="fa fa-check-square"></i> </span> <span class="text"> delivered <p style="font-size:10px;">{{$statusda->created_at}}</p></span> </div>
            @elseif($statusda->orderstatus == 33)
            <div class="step active"> <span class="icon"><i class="fa fa-check"></i> </span> <span class="text"> Money Received <p style="font-size:10px;">{{$statusda->created_at}}</p></span> </div>
            @elseif($statusda->orderstatus == 10)
            <div class="step active"> <span class="icon"><i class="fa fa-times"></i> </span> <span class="text"> Order Cancel <p style="font-size:10px;">{{$statusda->created_at}}</p></span> </div>
            @elseif($statusda->orderstatus == 7)
            <div class="step active"> <span class="icon"><i class="fa fa-user"></i> </span> <span class="text"> Order Return <p style="font-size:10px;">{{$statusda->created_at}}</p></span> </div>
            @endif
        @endforeach

        </div>
        
    </div><br><br><br>
@else


 <div class="card">
       <div class="card-body">
        <div class="row">
            <div class="col-md-12">
                <div id="content">
                    <ul class="timeline">
                     @foreach($statustrack as $datastrack)
                        @if($datastrack->orderstatus == 0)
                            <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Oder Create By</h3>
                            <p>{{ $datastrack->username }}</p>
                            </li>
                        @elseif($datastrack->orderstatus == 1)
                            <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Pending</h3>
                            <p>{{ $datastrack->username }}</p>
                            </li>
                        @elseif($datastrack->orderstatus == 2)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>1st attempt</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 3)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>2nd Attempt</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 4)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>3rd Attempt</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 5)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Colombo Confirm</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 6)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Out Confirm</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 7)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Return Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 8)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Dispatched Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 9)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Money Received</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 10)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Cancel Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 11)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Assign to Out</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 12)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Assign to Colombo</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 13)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Pick Out</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 14)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Pick Colombo</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 15)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Packed</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 16)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Hold Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 17)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Received Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 18)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Delivered</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 19)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>City Update</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 20)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Dropex Dispatched</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 21)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Not Delivered</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 22)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Unauthorized Return</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 23)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Authorized Return</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 24)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Sent an Exchange</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 25)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Exchange Order Created by</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 26)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Hold Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 27)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Reject Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 28)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Banned Customer</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 29)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Incomplete Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 30)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Remind Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 32)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Out Of Stock</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 33)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Paid to reseller</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 34)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Return to Reseller</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 35)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Refund Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 36)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Refund to Reseller</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @elseif($datastrack->orderstatus == 37)
                        <li class="event" data-date="{{ $datastrack->created_at }}">
                            <h3>Duplivate Order</h3>
                            <p>{{ $datastrack->username }}</p>
                        </li>
                        @endif
                        
                     @endforeach
                    </ul>
                </div>
            </div>
        </div>
       </div>
    </div>
@endif







      </div>
    </section>
  </div>
 
  <div style="text-align:right;">
                @foreach($item as $data)
                    Order Created By - {{ $data->pageName }} <br>
                    Last Updated Date  - {{ $data->updated_at }}
                @endforeach
            </div>

  <div class="modal fade" id="returnmodel" role="dialog">
  <div class="modal-dialog">
  
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
              <h4 class="modal-title">Order Status</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        
      </div>
      
          <form role="form" class="form-horizontal style-form" action="/returnstatus" method="post" enctype="multipart/form-data">
          {{csrf_field()}}
            <div class="modal-body">
            <input type="hidden" value="{{ $cus_id }}" name="cus_id">
            @foreach($item as $data)
                <div class="form-group">
                    <label>Order Status</label>
                        <select class="form-control" name="statusdelauth" required>
                            <option value="21"@if($data->deliverystatus=="21") selected @endif>Not Delivery</option>
                            <option value="18"@if($data->deliverystatus=="18") selected @endif>Delivered</option>
                            <option value="22" @if($data->deliverystatus=="22") selected @endif>Unauthorized Return</option>
                            <option value="23" @if($data->deliverystatus=="23") selected @endif>Authorized Return</option>
                        </select>
                </div>
            @endforeach                        
            </div>
      <div class="modal-footer">
      <button class="btn btn-primary" type="submit">Submit</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
      </form>
    </div>
    
  </div>

</div>





<div class="modal fade" id="exchangemodel" role="dialog">
  <div class="modal-dialog">
  
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
              <h4 class="modal-title">Exchange order</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        
      </div>
      
          <form role="form" class="form-horizontal style-form" action="/addexchange" method="post" enctype="multipart/form-data">
          {{csrf_field()}}
            <div class="modal-body">
            <input type="hidden" value="{{ $cus_id }}" name="cus_id">
                <div class="form-group">
                    <label>Item Status</label>
                        <select class="form-control" name="itemstatus2" required>
                            <option value="0">Other</option>
                            <option value="2">Damage Item</option>
                        </select>
                </div>
                @foreach($barord as $databar)
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" value="{{ $databar->id }}" id="flexCheckDefault{{ $databar->id }}" name="exchangeitems[]">
                    <label class="form-check-label" for="flexCheckDefault{{ $databar->id }}">{{ $databar->ordersbarcodepro->pro_name }}</label>
                </div>
                <div class="form-group">
                    <input type="hidden" placeholder="" value="{{ $databar->id }}" id="barcodeid" name="barcodeid[]" class="form-control">
                    <input type="text" placeholder="" value="{{ $databar->barcode }}" id="barcode" name="barcode[]" class="form-control">
                </div>
                @endforeach
            </div>
      <div class="modal-footer">
      <button class="btn btn-primary" type="submit">Exchange</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
      </form>
    </div>
    
  </div>

</div>



<div class="modal fade" id="myModal3" role="dialog">
  <div class="modal-dialog">
  
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
              <h4 class="modal-title">Update Customer Details</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        
      </div>
      
          <form role="form" class="form-horizontal style-form" action="/updatecusdetails" method="post" enctype="multipart/form-data">
          {{csrf_field()}}
            <div class="modal-body">
            @foreach($item as $data)
            <input type="hidden" value="{{ $cus_id }}" name="cus_id">
              <div class="form-group">
                  <label>Customer Name</label>
                  <input type="text" placeholder="" value="{{ $data->name }}" id="name" name="name" class="form-control">
              </div>
              <div class="form-group">
                  <label>Address</label>
                  <textarea type="text" placeholder="" value="{{ $data->address }}" id="address" rows="2" name="address" class="form-control">{{ $data->address }}</textarea>
              </div>
              <div class="form-group">
                  <label>Phone numbers</label>
                  <input type="text" placeholder=""  value="{{ $data->phone }}" id="phone" name="phone" class="form-control">
              </div>
              <div class="form-group">
                  <label>Tracking Code</label>
                  <input type="text" placeholder=""  value="{{ $data->tracking }}" id="tracking" name="tracking" class="form-control">
              </div>
              <div class="form-group">
                  <label>Note</label>
                  <textarea type="text" placeholder="" value="{{ $data->note }}" id="note" rows="2" name="note" class="form-control">{{ $data->note }}</textarea>
              </div>
              @endforeach
            </div>
      <div class="modal-footer">
      <button class="btn btn-primary" type="submit">Update Customer Deatils</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
      </form>
    </div>
    
  </div>

</div>



<style>
     @import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap');



.card {
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    background-clip: border-box;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.10rem
}

.card-header:first-child {
    border-radius: calc(0.37rem - 1px) calc(0.37rem - 1px) 0 0
}

.card-header {
    padding: 0.75rem 1.25rem;
    margin-bottom: 0;
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1)
}

.track {
    position: relative;
    background-color: #ddd;
    height: 7px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    margin-bottom: 60px;
    margin-top: 50px
}

.track .step {
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    width: 25%;
    margin-top: -18px;
    text-align: center;
    position: relative
}

.track .step.active:before {
    background: #FF5722
}

.track .step::before {
    height: 7px;
    position: absolute;
    content: "";
    width: 100%;
    left: 0;
    top: 18px
}

.track .step.active .icon {
    background: #ee5435;
    color: #fff
}

.track .icon {
    display: inline-block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    position: relative;
    border-radius: 100%;
    background: #ddd
}

.track .step.active .text {
    font-weight: 400;
    color: #000
}

.track .text {
    display: block;
    margin-top: 7px
}

.itemside {
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    width: 100%
}

.itemside .aside {
    position: relative;
    -ms-flex-negative: 0;
    flex-shrink: 0
}

.img-sm {
    width: 80px;
    height: 80px;
    padding: 7px
}

ul.row,
ul.row-sm {
    list-style: none;
    padding: 0
}

.itemside .info {
    padding-left: 15px;
    padding-right: 7px
}

.itemside .title {
    display: block;
    margin-bottom: 5px;
    color: #212529
}

p {
    margin-top: 0;
    margin-bottom: 1rem
}

.btn-warning {
    color: #ffffff;
    background-color: #ee5435;
    border-color: #ee5435;
    border-radius: 1px
}

.btn-warning:hover {
    color: #ffffff;
    background-color: #ff2b00;
    border-color: #ff2b00;
    border-radius: 1px
}
</style>

<style>
.borderless td, .borderless th {
    border: none;
}
.borderless tr{
    line-height: 1px;
}
</style>

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

<script>
$(document).ready(function() {
    $('#example12').DataTable();
} );


$('#reservationdate').datetimepicker({
    format: 'YYYY/MM/DD'
    });

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

    $('.deliverydate1').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliverydate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data, code, ex) {
                toastr.success('Delivery Date Update successfully!')
                jQuery.each(data, function(key,value){
        });

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






@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>

<script>
$('#deliverymodel').on('show.bs.modal', function (event) {
     var button = $(event.relatedTarget) // Button that triggered the modal
     var recipient = button.data('delivery') 
     var id = button.data('id') 
     var modal = $(this)
     modal.find('.modal-body #Delivery').val(recipient)
     modal.find('.modal-body #id').val(id)
   })
</script>

<script>
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>



   <div id="printableArea" style="display: none;">
    @foreach($item as $data)
  
  <div class="row">
    <div class="col-md-8"><h1> Invoice Number : 
    </h1>
    <p style="margin: -2mm 0mm 0mm 90mm;font-size:12px">{{$data->id}}</p>
    </div>
</div>
    <div class="row">
        <div class="col-md-6">
        <h5>Issued Date : {{$ldate}}</h5>
        <h5>Customer Name : {{$data->name}}</h5>
        <h5>Address : {{$data->address}}</h5>
        <h5>Phone Number : {{$data->phone}} / {{$data->secondaryphone}}</h5>
        </div>  
        <div class="col-md-6" align="right">
            <h5>Wasi Mart Holdings [pvt] Ltd</h5>
            <h5>wasimart.lk@gmail.com</h5>
        </div>    
    </div>
    @endforeach
<br><br>

 

    <table class="table" id="book-table" name="book-table">
            <thead>
                  <tr>
                    <th style="width:60px" class="text-center">QTY</th>
                    <th class="text-left">DESCRIPTION</th>
                    <th style="width:140px" class="text-right">UNIT PRICE</th>
                    <th style="width:90px" class="text-right">TOTAL</th>
   
                  </tr>
            </thead>
            <tbody>
                    
            @foreach($data->cus_or as $data) 
                    <tr>
                        <td class="text-center">{{ $data->qty }}</td>
                        <td>{{$data->orders->pro_name}}
                        </td>
                        <td class="text-right">{{$data->pro_amount}}</td>
                        <td class="text-right"> {{$data->qty * $data->pro_amount}}
                        </td>
                        <input type="hidden" value="">
                    </tr>
                    
            
                @endforeach
                    <tr>
                            <td colspan="2" rowspan="4">
                             
                              <td class="text-right"><strong>Delivery Charge</strong></td>
                              <td class="text-right">{{$deli}}</td>
                          </tr>

                          <tr>
                            <td class="text-right no-border">
                              <strong>Total</strong>
                            </td>
                            <td class="text-right"><strong>{{ $deli + $tot }}</strong></td>
                          </tr>
            </tbody>
        </table>  
        <br>
        <br>
        <br>
      </div>