@include('dashboard.include.header')

  
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Reseller Order</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">Reseller Order</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">

      <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">
                        <form class="form-horizontal" method="POST" action="/resellerorderfilter">
                        {{csrf_field()}}
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                <label>Date Range</label>
                                <div class="input-group">
                                    <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="bi bi-calendar-date"></i>
                                    </span>
                                    </div>
                                    <input type="text" class="form-control float-right" id="reservation" value="{{$date}}" name="daterange">
                                </div>
                                </div>
                            </div>
                            <!-- <div class="col-md-3">
                                <div class="form-group">
                                    <label>Select Reseller</label>
                                    <select class="form-control select2" name="reseller" id="reseller" style="width: 100%;" required>
                                        <option value="" selected="selected" disabled>Select</option>
                                            @foreach($rese as $data)
                                            <option value="{{ $data->id }}">{{ $data->companyname }}</option>
                                            @endforeach
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label>Order Status</label>
                                    <select class="select2" name="OrderStatus" id="OrderStatus" data-placeholder="Order Status" style="width: 100%;">
                                            <option value="20">Pending</option>
                                            <option value="17">Confirm Orders</option>
                                            <option value="4">Hold Orders</option>
                                            <option value="7" >Return Order</option>
                                            <option value="8" >Dispatched Orders</option>
                                            <option value="9" >Money Received</option>
                                            <option value="10">Cancel</option>
                                            <option value="18">Delivered</option>
                                            <option value="33">Paid to Reseller</option>
                                            <option value="34">Return to Reseller</option>
                                            <option value="35">Refund paid</option>
                                            <option value="36">Refund Reseller</option>
                                            <option value="37">Duplicate Orders</option>
                                    </select>
                                    </div>
                                </div> -->
                            <div class="col-md-1" style="padding-top:30px;">
                                <button type="submit" class="btn btn-primary btn-block">Filter</button>
                            </div>


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




                    <div class="card">
                        <div class="card-body">
                        <div class="row">
                            <div class="col-md-12">
                                <table id="example12" data-page-length='50' class="table table-bordered" style="width:100%; font-size:11px;">
                                    <thead>
                                        <tr>
                                            <th>Company Name</th>
                                            <th>Received Orders</th>
                                            <th>Dispatch Orders</th>
                                            <th>Return Orders</th>
                                            <th>Deliverd Orders</th>
                                            <th>Success Rate</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    @foreach($maindata as $data)
                                    @if($data['con'] > "0")
                                    <tr>
                                        <td>{{ $data['name'] }}</td>
                                        <td>{{ $data['con'] }}</td>
                                        <td>{{ $data['dis'] }}</td>
                                        <td>{{ $data['ret'] }}</td>
                                        <td>{{ $data['mone'] }}</td>
                                        <td>{{number_format( $data['rate'],2,'.',',') }} %</td>
                                    </tr>
                                    @endif
                                    @endforeach
                                    </tbody>
                                    <tfoot>
                                    @php $bank=0; $deli=0; $tot=0; $produ=0; $servi=0; $payb=0;$commi=0;$totalcomref=0; @endphp
                                    @foreach($maindata as $data)
                                    @if($data['con'] > "0")
                                        @php 
                                        $tot+=$data['con'];
                                        $deli+=$data['dis'];
                                        $produ+=$data['ret'];
                                        $commi+=$data['mone'];
                                        @endphp
                                    @endif
                                    @endforeach
                                        <tr>
                                            <th>Total</th>
                                            <th>{{$tot}}</th>
                                            <th>{{$deli}}</th>
                                            <th>{{$produ}}</th>
                                            <th>{{$commi}}</th>
                                            <th></th>
                                        </tr>



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

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




  @include('dashboard.include.footer')

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


    }).buttons().container().appendTo('#example12_wrapper .col-md-6:eq(0)');
} );


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

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