@include('dashboard.include.header')
@foreach($item as $data)

    @if(Auth::user()->email=="ashan.mal@gmail.com" OR Auth::user()->email=="wasimart.lk@gmail.com")
    @else
        @if($data->status== 7 OR $data->status == 8 OR $data->status == 9 OR $data->status == 18)                         
           <script>
                document.location.href = '/viwedetails/{{ $cus_id }}'
           </script>
        @else
        @endif
    @endif
@endforeach
  
  <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"></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">View Order Details</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
    @foreach($item as $data)
    <section class="content">
      <div class="container-fluid">
     
            <div class="alert alert-success alert-dismissible ccolor">
            <div class="row">

                <div class="col-md-10" align="left">
                    <h3 >{{ $data->name}} - Invoice ID - {{ $cus_id }} 
                    @if($data->ordertype == 2) (Exchange)
                    @elseif($data->ordertype == 3)(Refund)
                    @endif
                    </h3>
                </div>

                </div>
            </div>
            </div>
    
</section>
    
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
        <div class="row">
        
        <div class="col-md-12">

        </div>

        </div>
        <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-info">Return Order</span>
                    @elseif($data->status =='8')                
                    <span class="badge badge-info">Dispatched Order</span>
                    @elseif($data->status =='9')                
                    <span class="badge badge-success">Money Recive 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 order</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-warning">City Update</span>
                    @elseif($data->status =='20')                
                    <span class="badge badge-success">Dropex Dispatched</span>
                    @elseif($data->status =='26')                
                    <span class="badge badge-primary">Hold</span>
                    @elseif($data->status =='27')                
                    <span class="badge badge-dark">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">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 }}
                                @endif
                            @else
                            <b>Delivery Service - </b>{{ $data->deliveryse->deliveryname }}
                            @endif
                            </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">
                        <option value="empty" selected="selected" disabled>Select</option>
                        @foreach($city as $cityd)
                            <option value="{{ $cityd->id }}"@if($data->tracecity==$cityd->id) selected @endif>{{ $cityd->city_name }}</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">
                  </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">
                    </form>
              </div>
        </div>
        </div>


          </div>
        </div>
        @endforeach
         <div class="card">
            <div class="card-body">
            <div class="row">
                <div class="col-md-4"></div>
                  
                <div class="col-md-8" 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">
                @if($data->status==12 OR $data->status==8 OR $data->status==14 OR $data->status==15)
                <button type="submit" formtarget="_blank" name="Colombo" value="Colombo" class="btn btn-info btn-xs">Colombo COD Invoice</button>  
                @elseif($data->status==11 OR $data->status==13 OR $data->status==8 OR $data->status==15)
                <button type="submit" formtarget="_blank" name="Out" value="Out" class="btn btn-dark btn-xs">Out COD Invoice</button>  
                @endif
                @endforeach

                <a class="btn btn-warning btn-xs" onclick="printDiv('printableArea')" ><i class="fas fa-print"></i>&nbsp;Print Invoice</a>
                </div>
                </form>
            </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 class="text-left">DESCRIPTION</th>
                            <th style="width:10px" class="text-right">QTY</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> {{$data->orders->pro_name}}                      
                        </td>
                        <td class="text-center">{{$data->qty}}</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>
            <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>
                @foreach($item as $data)
                <div class="col-md-3">
                        <div class="form-group">
                        <label>Payment Method :</label>
                        <form method="post" id="paymentmethodupdate" enctype="multipart/form-data">
                        {{csrf_field()}}
                        <input type="hidden" class="form-control" value="{{ $cus_id }}" name="id" placeholder="" required>
                        <select class="form-control" name="payment" id="payment" style="width: 100%;" required>
                            <option value="" selected="selected" disabled>Select</option>
                            <option value="cash" @if($data->paymentmethod=="cash" )selected @endif >Cash on delivery</option>
                            <option value="paid" @if($data->paymentmethod=="paid" )selected @endif >Paid</option>

                        </select>
                        </form>
                    </div>
                </div>
                @endforeach
                <div class="col-md-4"></div>
                <div class="col-md-1" style="padding-top:32px;">
                <form method="post" id="deliveryform100" enctype="multipart/form-data">
                    {{csrf_field()}}
                    <input type="hidden" class="form-control" value="{{ $cus_id }}" name="id" placeholder="" required>
                    <!-- <button type="submit" name="deliverydown" class="btn btn-block btn-xs btn-info" value="deliverydown">250</button> -->
                    </form>
                </div>
                <div class="col-md-1" style="padding-top:32px;">
                <form method="post" id="deliveryform300" enctype="multipart/form-data">
                    {{csrf_field()}}
                    <input type="hidden" class="form-control" value="{{ $cus_id }}" name="id" placeholder="" required>
                    <!-- <button type="submit" name="deliveryup" class="btn btn-block btn-xs btn-info" value="deliveryup">275</button> -->
                    </form>
                </div>
                
            </div>
            </div>
        </div>

 @if(Auth::user()->type=="Reseller" OR Auth::user()->type == "User")   
 @else    
    <div class="card">
       <div class="card-body">
       <form class="statuschangeform" action="/btnstatuschange" method="post" enctype="multipart/form-data">
                {{csrf_field()}}
        <div class="row">
            @foreach($item as $data)
                <input type="hidden" value="{{$data->id}}" name="cus_id">
                <input type="hidden" value="{{$data->status}}" name="nowstatus">
            <div class="col-md-2"><button type="submit" onClick="return validateForm()" name="Confirm" class="btn btn-block btn-success" value="Confirm">Out Confirm</button></div>
            </form>
            @if($data->status =='12')  
            <div class="col-md-2"><button type="submit" onClick="return validateForm()" name="Colombo" class="btn btn-block btn-info" value="Colombo" disabled>Colombo Confirm</button></div>
            @else
            <div class="col-md-2">
            <button type="button" class="btn btn-block btn-info"  onClick="return validateForm2()" data-id="{{$data->id}}" data-toggle="modal">Colombo Confirm</button>
                
            </div>
            @endif
            @endforeach
            <div class="col-md-2">
                <div class="form-group">
                <form action="/updatestatus" 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->status}}" name="nowstatus">
                    @endforeach
                        <input type="hidden" value="{{ $tot + $deli }}" name="total">
                        <select class="form-control" name="statusValu"  required>
                        <option value="" selected="selected" disabled>Change Status</option>
                        <option value="1">Reseller Pending</option>
                        <option value="17">Seller Center Pending</option>
                        <option value="27">Reject</option>
                        @foreach($item as $data)
                        @if($data->ordertype == 3)
                        <option value="35">Paid to Customer(Refund)</option>
                        @endif
                        @endforeach
                        </select>
                </div>
            </div>
            <div class="col-md-2">
            <button type="submit" class="btn btn-block btn-primary" >Change Status</button>
            </div>
            </form>
          </div>

        </div>
    </div>

<br><br>
@endif

    <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>Recived Money</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>
    
    
    <div style="text-align:right;text-size:10px;">
                @foreach($item as $data)
                    Order Created By - {{ $data->pageName }} <br>
                    Last Updated Date  - {{ $data->updated_at }}
                @endforeach
            </div>
    
    
      </div>
    </section>
  </div>
 


 <div class="modal fade" id="notemodel" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
      <div class="modal-content">
      <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLongTitle">Cancel Order</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
          </button>
      </div>
      <form class="form-horizontal" method="POST" action="/reasonupdateview">
          {{csrf_field()}}
      <div class="modal-body"> 
          <input type="hidden" name="id5" id="id5">    
         
          <div class="form-group">
                  <label>Reason</label>
                  <input type="text" placeholder="Reason"  id="reason" name="reason" class="form-control">
              </div>

      </div>
      <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Save changes</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>
.borderless td, .borderless th {
    border: none;
}
.borderless tr{
    line-height: 1px;
}

</style>

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


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

<script>



// delivery_date
function validateForm() {
    var mySelect = document.getElementById("cituselect");
    var mySelect3 = document.getElementById("fardercituselect");
  if (mySelect.value === "empty")  {
    // alert("You must select City & District!");
    swal({
            title: "Error!",
            text: "You must select city & district!",
            icon: "error",
            button: "OK",
        });
    return false;
  }
  else if (mySelect3.value === "empty"){
    swal({
            title: "Error!",
            text: "You must select fardar express city!",
            icon: "error",
            button: "OK",
        });
    return false;
  }
  else{

  }
;
}

function validateForm2() {
    var dateVariable = $("#delivery_date").val();
    var todayadate = $.datepicker.formatDate('yy/mm/dd', new Date());
    var mySelect = document.getElementById("cituselect");
    var mySelect3 = document.getElementById("fardercituselect");

  if (mySelect.value === "empty") {
    // alert("You must select City & District!");
    swal({
            title: "Error!",
            text: "You must select city & district!",
            icon: "error",
            button: "OK",
        });
       
    return false;
  }else  if(dateVariable < todayadate){
    swal({
            title: "Error!",
            text: "You must Change Delivery Date",
            icon: "error",
            button: "OK",
        });
      return false;
  }  
  else if (mySelect3.value === "empty"){
    swal({
            title: "Error!",
            text: "You must select fardar express city!",
            icon: "error",
            button: "OK",
        });
    return false;
  }
  else{
    $('#colomboconfmodel').modal('toggle');
  };
}

$(function() {
    $('#cituselect').change(function() {
        // this.form.submit();
        var mobNum = $(this).val();
    $(".cityupdateform").submit();

    });

        $('#fardercituselect').change(function() {
        // this.form.submit();
        var mobNum = $(this).val();
    $(".fardercityupdateform").submit();

    });

$("#payment").change(function () {
    $("#paymentmethodupdate").submit();
    });

});
$(document).ready(function(){

    var mobNum = $("#phone").val()
    var filter = /^\d*(?:\.\d{1,2})?$/;
    if (filter.test(mobNum)) {
        if(mobNum.length==10){

            $("#phone").removeClass("is-invalid");
            $("#phone").addClass("is-valid");
            } else {

            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
            }
        }
        else {
            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
        }
  
    $('#phone').on('input', function() { 
    var mobNum = $(this).val();
    var filter = /^\d*(?:\.\d{1,2})?$/;

    if (filter.test(mobNum)) {
        if(mobNum.length==10){

            toastr.success('Valid Phone Number')
            $("#phone").removeClass("is-invalid");
            $("#phone").addClass("is-valid");
            $(".primaryphone").submit();
            } else {

            // toastr.error('Please Put 10  Digit Mobile Number')
            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
            }
        }
        else {
            toastr.error('Not a Valid Number')
            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
        }


 });
  
 $('#secondary').on('input', function() { 
    var mobNum = $(this).val();
    var filter = /^\d*(?:\.\d{1,2})?$/;

    if (filter.test(mobNum)) {
        if(mobNum.length==10){

            toastr.success('Valid Phone Number')
            $("#secondary").removeClass("is-invalid");
            $("#secondary").addClass("is-valid");
            $(".secondaryphone").submit();
            } else {

            // toastr.error('Please Put 10  Digit Mobile Number')
            $("#secondary").removeClass("is-valid");
            $("#secondary").addClass("is-invalid");
            
            }
        }
        else {
            toastr.error('Not a Valid Number')
            $("#secondary").removeClass("is-valid");
            $("#secondary").addClass("is-invalid");
            
        }


 });
});


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

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



$(document).ready(function()
{
    $(window).bind("beforeunload", function() { 
        $("#pendingbtn").trigger('click'); 
    });
});




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

$('#notemodel').on('show.bs.modal', function (event) {
     var button = $(event.relatedTarget) // Button that triggered the modal
     var id = button.data('id') 
     var modal = $(this)
     modal.find('.modal-body #id5').val(id)
   })

</script>

<script>

$(function() {
    const Toast = Swal.mixin({
      toast: true,
      position: 'top-end',
      showConfirmButton: false,
      timer: 3000
    });
  });



    $('#deliveryupdateform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliveryupdateview",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                $("#deliverymodel").modal('hide');  
                $("#here").load(location.href + " #here");
                location.reload();
                toastr.success('Delivery Charges Added successfully!')
                

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


        $('#paymentmethodupdate').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/paymentmethodup",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                // $("#deliverymodel").modal('hide');  
                $("#here").load(location.href + " #here");
                // location.reload();
                toastr.success('Payment Method Added successfully!')
                

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

    
    $('.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");
            },
            
        })
    });


    
    $('.cityupdateform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/cityupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data, code, ex) {
                toastr.success('City and District Update successfully!')
                jQuery.each(data, function(key,value){
                    $('#district').val(value);
        });

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

        $('.fardercityupdateform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/fardercityupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data, code, ex) {
                toastr.success('City Update successfully!')

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


    $('.secondaryphone').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/secondaryphoneupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                // $("#deliverymodel").modal('hide');  
                $("#here").load(location.href + " #here");
                // location.reload();
                toastr.success('Primary Phone Number Update successfully!')
                

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


    $('.primaryphone').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/primaryphoneupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                // $("#deliverymodel").modal('hide');  
                // location.reload();
                toastr.success('Primary Phone Number Update successfully!')
                

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


    $('#deliveryform100').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliverybtnupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                // $("#deliverymodel").modal('hide');  
                $("#here").load(location.href + " #here");
                // location.reload();
                toastr.success('Delivery Charges Added successfully!')
                

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

        $('#deliveryform300').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliverybtnupdate2",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                // $("#deliverymodel").modal('hide');  
                $("#here").load(location.href + " #here");
                // location.reload();
                toastr.success('Delivery Charges Added successfully!')
                

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


$('#editordermodel').on('show.bs.modal', function (event) {
     
     var button = $(event.relatedTarget) // Button that triggered the modal
     var recipient = button.data('delivery') 
     var proname = button.data('proname') 
     var qty = button.data('qty') 
     var id = button.data('id') 
     var cid = button.data('cid') 
     var proprice = button.data('proprice') 
   
     var modal = $(this)
   //   modal.find('.modal-title').text('New message to ' + recipient)
     modal.find('.modal-body #Delivery').val(recipient)
   //   modal.find('.modal-body #nameproduct').val(proname)
     modal.find('.modal-body #quantity').val(qty)
     modal.find('.modal-body #id').val(id)
     modal.find('.modal-body #cusid').val(cid)
     modal.find('.modal-body #product_price').val(proprice)
   $("#nameproduct2").val(proname).change();   
   })

</script>


<div class="modal fade colomboconfmodel" id="colomboconfmodel" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLongTitle">Update Delivery Rider</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <form method="post" action="/vieworderriderassign" enctype="multipart/form-data">
            {{csrf_field()}}
        <div class="modal-body">
        <input type="hidden" value="{{ $cus_id }}" name="cus_id">
        @foreach($item as $data)
        <input type="hidden" value="{{$data->status}}" name="nowstatus">
        @endforeach
        <div class="form-group">
            <label>Assign Rider</label>
                <select class="form-control" name="deliveryrid" id="deliveryrid" required>
                <option value="" selected disabled>Select</option>
                <option value="notassign">Colombo Confirm</option>
                    @foreach($delise as $data)
                    @if($data->type=="Delivery_Guy")
                    <option value="{{ $data->id }}">{{ $data->name }}</option>
                    @endif
                    @endforeach
                </select>
        </div>

        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            <button type="submit" class="btn btn-primary">Save changes</button>
        </div>
        </form>
        </div>
    </div>
    </div>

 <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>{{$data->getpage2->companyname}}</h5>
            <h5>{{$data->getpage2->address}}</h5>
            <h5>{{$data->getpage2->phone}}</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>