@extends('layouts.app')

@section('content')
<div class="card">
    <div class="card-body">
        <h3 class="card-title">Bills Sent Summary</h3>
        <div class="table-responsive">
            <table class="table table-bordered" id="users-table">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Dealer Name</th>
                            <th>Type</th>
                            <th>KW</th>
                            <th>User Comment</th>
                            <th>Admin Comment</th>
                            <th>Updated On</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                </table>
        </div>
    </div>
</div>
<div class="modal fade" id="loadModalAjax" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="display: none;" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
    </div>
    <!-- /.modal-content -->
   </div>
  <!-- /.modal-dialog -->
</div>

@stop

@section('javascript')
    <script>
        var t = $('#users-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: '{!! url('/') !!}/users/billSentReportAnyData',
                dom: 'Bfrtip',
                'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
                columns: [
                    { data: 'id', name: 'id', searchable:false },
                    { data: 'dealer_name', name: 'dealer_name' },
                    { data: 'kw_type', name: 'kw_type' },
                    { data: 'kw', name: 'kw' },
                    { data: 'user_comment', name: 'user_comment' },
                    { data: 'admin_comment', name: 'admin_comment' },
                    { data: 'updated_at', name: 'updated_at', searchable:false },
                    { data: 'status', name: 'status' },
                    { data: 'action', name: 'action' },
                ],
                "columnDefs": [
                    {
                        "render": function ( data, type, row, meta) {
                            return meta.row + meta.settings._iDisplayStart + 1;
                         },
                        "targets": 0
                    },
                    // {
                    //     "render": function ( data, type, row ) {
                    //         return data.replace(".00", "")+'%';
                    //     },
                    //     "targets": 3
                    // },

                    {
                        "render": function ( data, type, row ) {
                        if(data==0){
                            return '<span class="table-primary">Pending</span>';
                        }else if(data==2){
                            return '<span class="table-danger">Declined</span>';
                        }else{
                            return '<span class="table-success">Approved</span>';
                        }
                        },
                        "targets": 7
                    }
                ],
                'order': [[1, 'asc']],
                drawCallback: function( settings ) {
                    //openModal();
                  }
            });


            

    </script>
@endsection
