@extends('adminlte::page')
@section('content')
<?php Fun::lang() ?>
<div class="page-wrapper">
    <div class="row">
        <div class="col-sm-12 col-xs-12">
            <div class="box-header">
                <div class="pull-left">
                    <h2>Add Commission</h2>
                </div>
            </div>
            <div class="box-body table-responsive">
                <table id="datatable_client_payment" class="table table-striped table-bordered table-hover nowrap">
                    <thead>
                        <tr>
                            <th></th>
                            <th>No</th>
                            <th>Client Name</th>
                            <th>Agency Name</th>
                            <th>Close Sale</th>
                            <th>Item Name</th>
                            <th>Category</th>
                            <th>Project</th>
                            <th>Commission Amount</th>
                            <th>Commission Close</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
@endsection
@section('js')
<script type="text/javascript">
    var index = $('#datatable_client_payment').DataTable({
        ordering: false,
        "serverSide": true,
        "lengthMenu": [
            [20, 30, 50, 100, -1],
            [20, 30, 50, 100, "All"]
        ],
        ajax: "{{ route('sale-report-by-agent') }}",
        columns: [{
                data: 'DT_RowIndex'
            },
            {
                data: 'project_name'
            },
            {
                data: 'category_name'
            },
            {
                data: 'item_house'
            },
            {
                data: 'item_count'
            },
            {
                data: ''
            },
            {
                data: 'project_name'
            },
            {
                data: 'commission_amount'
            },
            {
                data: 'close_commission'
            },
            {
                data: 'action'
            }
        ],

        "initComplete": function(settings, json) {
            $('.main-spinner').hide();
        }
    });
    index.on('order.dt search.dt', function() {
        index.column(0, {
            search: 'applied',
            order: 'applied'
        }).nodes().each(function(cell, i) {
            cell.innerHTML = i + 1;
        });
    }).draw();
    $.fn.dataTable.ext.errMode = 'throw';
</script>
@endsection