@extends('adminlte::page')

@section('content')

<?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="#">Manage Agency Wallet</a></li>
            <li><a href="#">Request Withdraw</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>Request Withdraw</h3>
                    </div>
                </div>
            </div>
        </div>
        <form action="{{url('/realty/withdraw-funds-requested-print')}}" method="POST">
            @csrf
            <div class="form-search">
                <div class="row">
                    <div class="col-xs-12 col-sm-4 col-md-4 ">
                        <div class="form-group">
                            <strong>Form Date</strong>
                            {!! Form::text('form_date', null, array('placeholder' => 'Form Date','class' => 'form-control date_picker','autocomplete'=>'off')) !!}
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-4 col-md-4 ">
                        <div class="form-group">
                            <strong>To Date</strong>
                            {!! Form::text('to_date', null, array('placeholder' => 'To Date','class' => 'form-control date_picker','autocomplete'=>'off')) !!}
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-4 col-md-4 ">
                        <div class="form-group">
                            <strong>Status</strong>
                            <select class="form-control select2" name="action">
                                <option value="0">Please Select</option>
                                <option value="1">Done</option>
                                <option value="2">Reject</option>
                                <option value="3">Proccess</option>
                                <option value="4">Request</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-4 col-md-4 form-group">
                        <div class="form-group">
                            <strong>Agency</strong>
                            {!! Form::select('agencys', $agencys, null, ['class' => 'form-control select2 form-control agencys']) !!}
                        </div>
                    </div>&nbsp
                    <div class="col-xs-8 col-sm-8 col-md-8 text-right">
                        <button type="button" class="button_primary btn-sm search" onclick="searching()"><span class="fa fa-search"> Search</span></button>
                        ​​​​​​​​​​​​​​​​@can('Withdraw-Fund-Request-Print')
                        <button type="submit" class="button_primary btn-sm search"><span class="fa fa-print"> Print</span></button>
                        @endcan
                    </div>

                </div>
            </div>
            {!! Form::close() !!}
    </div>

    <div class="box-body table-responsive">
        <table id="datatable_item" class="table table-striped table-bordered table-hover nowrap">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Requested Date</th>
                    <th>Transaction</th>
                    <th>Agent Name</th>
                    <th>Contact Person</th>
                    <th>Remark</th>
                    <th>Bank Info</th>
                    <th>Aproved / Reject Date</th>
                    <th>Amount Request</th>
                    <th>Amount Aproved</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody class="tbody"></tbody>
            <tfoot class="tfoot">
            </tfoot>
        </table>
    </div>
</div>

<div class="modal fade bs-modal-lg" id="popUpApprove" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h3 class="modal-title">Are you sure?</h3>
            </div>
            <br />
            <form role="form" method="POST" id="form-action" action="{{route('withdraw.approve')}}">
                {{csrf_field()}}
                <div class="row">
                    <div class="col-md-12">
                        <div class="col-md-12">
                            <div class="a"></div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" data-dismiss="modal" class="button_danger"><i class="fa fa-close"></i> No</button>
                    <button type="submit" class="button_success" data-toggle="modal"><i class="fa fa-save"></i> OK</button>
                </div>
            </form>
        </div>
    </div>
</div>

@endsection
@section('js')
<script type="text/javascript" src="{{asset('assets/controller/withdraw-approve.js')}}"></script>
<script type="text/javascript">
    function searching() {
        $('#datatable_item').DataTable().destroy();
        var form_date = $('input[name="form_date"]').val();
        var to_date = $('input[name="to_date"]').val();
        var action = $('select[name="action"]').val();
        var agencys = $('.agencys').val();

        $('#datatable_item').DataTable({
            ordering: false,
            "serverSide": true,
            "searching": true,
            "lengthMenu": [
                [20, 30, 50, 100, -1],
                [20, 30, 50, 100, "All"]
            ],
            ajax: {
                method: 'POST',
                url: '/realty/datatable_get_funds_request_withdrawal',
                async: false,
                data: {
                    _token: '{{ csrf_token() }}',
                    form_date: form_date,
                    to_date: to_date,
                    action: action,
                    agencys: agencys,
                },
            },
            columns: [{
                    data: 'DT_RowIndex'
                },
                {
                    data: 'request_date'
                },
                {
                    data: 'operation_type'
                },
                {
                    data: 'account_funds'
                },
                {
                    data: 'phone'
                },
                {
                    data: 'remark'
                },
                {
                    data: 'bank_account_info'
                },
                {
                    data: 'app_rej_date'
                },
                {
                    data: 'amount',
                    "className": 'text-right'
                },
                {
                    data: 'confirm_withdraw',
                    "className": 'text-right'
                },
                {
                    data: 'status'
                },
            ],
            "initComplete": function(settings, json) {
                $('.main-spinner').hide();
            },
        });
        $.fn.dataTable.ext.errMode = 'throw';
    }
</script>

@endsection