@extends('layouts.agencies')
@section('title', 'Add Funds')
@section('content')
<?php Fun::lang() ?>
<div class="main-content-wrapper">
    <div class="main-content-wrapper">
        <div class="breadcrumb">
            <div class="container">
                <ul class="">
                    <li><a href="{{asset('')}}">{{__('administrator.dashboard')}}<span>/</span></a></li>
                    <li><a href="#">Funds<span>/</span></a></li>
                    <li><a href="">Funds Withdraw</a></li>
                </ul>
            </div>
        </div>
        </section>
        <div class="main-box">
            <div class="main-content">
                <div class="main-admin-dashboard">
                    <div class="container">
                        <div class="page-wrapper">

                            <div class="row">
                                <div class="col-sm-12 col-xs-12">
                                    <div class="form-wrapper">
                                        @if (count($errors) > 0)
                                        <div class="alert-message alert-danger">
                                            <strong>Whoops!</strong> There were some problems with your input.<br><br>
                                            <ul>
                                                @foreach ($errors->all() as $error)
                                                <li>{{ $error }}</li>
                                                @endforeach
                                            </ul>
                                        </div>
                                        @endif

                                        <div style="text-align:center">
                                            <span class="step">Funds Info <span class="fa fa-angle-right"></span></span>
                                            <span class="step">Authorization <span class="fa fa-angle-right"></span></span>
                                            <span class="step">Submit Withdraw <span class="fa fa-angle-right"></span></span>
                                        </div>

                                        <div class="form-wrapper">
                                            <form id="regForm" method="POST" action="{{ route('transaction.withdraw_funds_store') }}">
                                                @csrf
                                                <div class="row">
                                                    <div class="tab">
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="" class="required">Account Name</label>
                                                                {!! Form::text('account_name', $funds_account[0]->account_name, array('class' => 'form-control account_name','readonly')) !!}
                                                                <span class="focus-border"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="" class="required">Account Number</label>
                                                                {!! Form::text('my_account', $funds_account[0]->account_number, array('class' => 'form-control acc_number','readonly')) !!}
                                                                <span class="focus-border"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="" class="required">Available Amount</label>
                                                                {!! Form::text('avaible_amount', $funds_account[0]->balance, array('class' => 'form-control avaible_amount number-only','readonly')) !!}
                                                                <span class="focus-border"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="" class="required">Amount Withdraw</label>
                                                                &nbsp<span class="message label label-danger" style="display: none;"></span>
                                                                {!! Form::text('amount',null, array('Placeholder' => 'Amount','class' => 'form-control credit_amount number-only')) !!}
                                                                <span class="focus-border"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="required" class="required">Bank Name</label>
                                                                {!! Form::select('bank_id',$bank_account,null,['class'=>'form-control select2','id'=>'bank_id']) !!}
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="required" class="required">Account Name</label>
                                                                {!! Form::text('accountbank_name',null,['class'=>'form-control','id'=>'accountbank_name','readonly']) !!}
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="required" class="required">Account Number</label>
                                                                {!! Form::text('bank_account',null,['class'=>'form-control','id'=>'bank_account','readonly']) !!}
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-sm-6">
                                                            <div class="col-3">
                                                                <label for="" class="">Remark</label>
                                                                <textarea name="remark" id="" rows="3" class="form-control remarks" style="width: 100%"></textarea>
                                                                <span class="focus-border"></span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="tab">
                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="" class="required">Account Number</label>
                                                                {!! Form::text('account_number', $funds_account[0]->account_number, array('placeholder' => 'Enter funds number','class' => 'form-control','readonly')) !!}
                                                                <span class="focus-border"></span>
                                                            </div>
                                                        </div>

                                                        <div class="form-group col-sm-6 col-xs-12">
                                                            <div class="col-3">
                                                                <label for="" class="required">Password</label>
                                                                {!! Form::password('password',array('placeholder' => 'Enter funds password','class' => 'form-control')) !!}
                                                                <span class="focus-border"></span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="tab">
                                                        <div class="col-md-6 col-sm-6 col-md-offset-3">
                                                            <div class="list-chart">
                                                                <h4>Withdraw Info</h4>
                                                                <ul class="personal-info">
                                                                    <li><span class="span">Account Name :</span><span class="acc-name"></span></li>
                                                                    <li><span class="span">Account Number :</span><span class="acc-number"></span></li>
                                                                    <li><span class="span">Available Amount :</span><span class="avai-amount"></span> </li>
                                                                    <li><span class="span">Withdraw Amount :</span><span class="credit-amount"></span> </li>
                                                                    <li><span class="span">Remark :</span><span class="remark"></span> </li>
                                                                </ul>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-xs-12 text-right  ">
                                                        <div class="form-group">
                                                            <button type="button" id="prevBtn" class="button_danger" onclick="nextPrev(-1)">
                                                                <span class="fa fa-angle-left"></span> Previous</button>
                                                            <button type="button" id="nextBtn" class="button_warning" onclick="nextPrev(1)">Next</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<style type="text/css">
</style>
@endsection
@section('script')
<script type="text/javascript" src="{{asset('assets/controller/step-tab-fund-withdraw.js')}}"></script>
<script>
    $(document).on('change', '#bank_id', function() {
        var id = $(this).find(':selected').val();
        var route = "{{route('get-agency-account-number-by-bank',':id')}}";
        route = route.replace(':id', id);
        $.ajax({
            type: "GET",
            dataType: "JSON",
            url: route,
            data: {
                _token: "{{csrf_token()}}"
            },
            success: function(response) {
                data = response['data'];
                $('#accountbank_name').val(data.account_name);
                $('#bank_account').val(data.account_number);
            },
            error: function(request, status, error) {
                $('#bank_account').val("");
                $('#accountbank_name').val("");
            }
        });
    });
</script>
@endsection