{% extends "layout/base.html.twig" %}
{% block content %}

    <div class="widget">
        <div class="widget-body">
            <div class="row">
                <div class="col-md-4">
                    <p>Current Wallet State</p>
                    <h2>{{ institution.Wallet }} AED</h2>
                   
                <form method="post" action={{ path('withdraw',{'wallet': institution.Wallet }) }} enctype="multipart/form-data">
                    <div class="student">
                        <div class="form-group">
                            <label for="email">Withdraw Money:</label>
                            <br>
                            <br>
                         <label for="email">Enter Password to withdraw money</label>
                        <input type="password" class="form-control" id="cle" placeholder="password" name="password">
                        </div>
                        <p>
                         {% for by in insti %}
                            Your Bank Account Information<br>
                            Name on Account: {{ by.institutionName }}<br>
                            Bank Name: {{ by.bankName }}<br>
                            IBAN: {{ by.iban }}<br>
                            SWIFT: {{ by.swift }}
                            {% endfor %}
                        </p>
                       
                       
                        <button type="submit" id="btn" onclick={{ path('withdraw',{'wallet': institution.Wallet }) }} class="btn btn-default">Withdraw {{ institution.Wallet }} AED </button>
                    </div>
                </form>
                </div>

                <div class="col-md-8">
                    <table id="product-list" class="table table-hover dt-responsive nowrap">
                        <thead>
                        <tr>
                            <th>Requests</th>
                            <th>Amount</th>
                            <th>Date</th>
                            <th>Status</th>
                        </tr>
                        </thead>
                        <tbody>

                        {% for by in withdraw %}
                            <tr>
                                <td>{{ by.request }}</td>
                                <td>{{ by.amount }} AED</td>
                                <td>{{ by.date ? by.date|date('Y-m-d') : '' }}</td>
                                <td>{{ by.statut ? 'Confirmed' : 'Pending' }}</td>

                            </tr>

                        {% else %}
                            <tr>
                                <td colspan="12">no records found</td>
                            </tr>
                        {% endfor %}

                    </table>

                </div>
            </div>
        </div>
    </div>
    <script>
   if({{ institution.Wallet }} < {{ data.minimum}}){
            document.getElementById("cle").disabled = true;
           document.getElementById("btn").disabled = true;
        }
    </script>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        $(document).ready(function() {
            $('#product-list').DataTable();
        } );
    </script>


{% endblock %}
