@extends('adminlte::page')
@section('css')
<style>
    .btn-default{
        border: 1px solid black !important;
        background-color: grey;
    }
</style>
@stop
@section('content')
@include('administrator.agency.commission-report.form-withdrawal-commission')
<?php Fun::lang() ?>
<div class="title-page">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="#">Agency</a></li>
            <li><a href="#">Commission Detail</a></li>
        </ul>
    </div>
</div>

<div class="page">

    <div class="top-content">
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                <div class="title-add">
                    <div class="pull-left">
                        <h3>Commission</h3>
                    </div>
                </div>
                <div class="pull-right">
                    <!-- <a class="button_sm button_primary" href="{{route('accouting-capital.create')}}"><span class="fa fa-plus"></span>  Create New</a> -->
                </div>
            </div>
        </div>
    </div>
    <div class="box-body table-responsive">
        <table id="datatable_accounting_capital" class="table table-striped table-bordered table-hover nowrap">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Agency</th>
                    <th>Commission</th>
                    <th>Commission Withdraw</th>
                    <th>Commission Available</th>
                    <th>Action</th>
                </tr>
            </thead>
        </table>
    </div>
</div>
@endsection @section('js')

<script type="text/javascript">
    $(document).ready(function() {
        $('.main-spinner').show();
        $('#datatable_accounting_capital').DataTable({
            "lengthMenu": [
                [20, 25, 50, 100, 500],
                [20, 25, 50, 100, 500]
            ],
            ordering: false,
            serverSide: false,
            ajax: "{{ route('get-commission-detail') }}",
            columns: [
                {
                    data: 'DT_RowIndex'
                },
                {
                    data: 'agency_name'
                },
                {
                    data: 'commission'
                },
                {
                    data: 'deposit'
                },
                {
                    className:"available_balance",
                    data: 'balance'
                },
                {
                    data: 'action'
                }
            ],
            "initComplete": function(settings, json) {
                $('.main-spinner').hide();
            }
        });

        $.fn.dataTable.ext.errMode = 'throw';
    });
    $(document).on('click','.btn-withdraw-commission',function(){

        var id      = $(this).data('id');
        var balance = $(this).parent().siblings('.available_balance').text();
        balance     = parseFloat(balance);

        $('#commission_id').val(id);
        $('#amount').val(balance);

        $('#withdrawal-commission').modal('show');
    });
</script>
@endsection