title = "Balans taryhy"
url = "/balans-taryhy"
layout = "default"
is_hidden = 0
==
<?php
function onStart() {
    $this['transactions'] = \Auth::user()->transactions()->orderBy('id', 'desc')->paginate(5);
}
?>
==

<section class="post">
        <div class="auto_container">
            <div class="post_wrap">
                <div class="product_head">
                    <div class="product_title">
                        {{ 'account.balance'|_ }}
                    </div>
                    <div class="product_head-row">
                        <a href="{{ 'kabinet/balance'|page }}" class="add_post_btn">
                            <div class="post_icon">
                                <img src="{{'assets/images/svg/add.svg'|theme}}" alt="">
                            </div>
                            <div class="post_text">
                                {{ 'account.fill_up_balance'|_ }}
                            </div>
                        </a>
                    </div>
                </div>

                {% if transactions is empty %}
                <div class="my_advert-bg">
                    <div class="chat_wall">
                        <div class="chat_wall_img">
                            <img src="{{'assets/images/big_logo.png'|theme}}" alt="logo">
                        </div>
                        <div class="chat_wall_text">
                            {{'account.balance_no_actions'|_}}
                        </div>
                    </div>
                </div>
                <div class="mobile_add-btn">
                    <a href="{{ 'kabinet/balance'|page }}" class="add_post_btn">
                        <div class="post_icon">
                            <img src="{{'assets/images/svg/add.svg'|theme}}" alt="">
                        </div>
                        <div class="post_text">
                            {{ 'account.fill_up_balance'|_ }}
                        </div>
                    </a>
                </div>

                {% else %}

                <div class="history_table">
                    <table>
                        <thead>
                            <tr>
                            <th>№</th>
                            <th>{{ 'page.date'|_ }}</th>
                            <!-- <th>{{ 'page.prod_desc'|_ }}</th> -->
                            <th>{{ 'account.balance_transaction_amount'|_ }}</th>
                            <th>{{ 'account.balance_transaction_type'|_ }}</th>
                            </tr>
                        </thead>
                        <tbody>
                        {% for transaction in transactions%}
                            <tr>
                                <td>{{transaction.id}}</td>
                                <td>{{transaction.created_at|date('H:i - d.m.Y')}}</td>
                                <!-- <td>{{transaction.description}}</td> -->
                                <td>{{transaction.amount}} TMT</td>
                                <td>
                                    {% if transaction.amount > 0%}
                                    <p class="approved">{{'account.balance_fill_up'|_}}</p>
                                        {% else %}
                                    <p class="denied">{{'account.balance_withdraw'|_}} </p>
                                    {% endif %}
                                </td>
                            </tr>
                        
                        {% endfor %}
                        </tbody>
                    </table>
                </div>

                {% endif %}

                {% if transactions.total > transactions.perPage %}

                <div class="cat_end">
                    <a href="{{ transactions.previousPageUrl|default('#') }}" class="cat_arrow left">
                        <img src="{{ 'assets/images/svg/arrow-right.svg'|theme }}" alt="">
                    </a>
                    <form method="get" class="cat_form">
                        <input type="text" value="{{transactions.currentPage|default('1')}}" name="page"> 
                    </form>
                    <a href="{{ transactions.nextPageUrl|default('#') }}" class="cat_arrow ">
                        <img src="{{ 'assets/images/svg/arrow-right.svg'|theme }}" alt="">
                    </a>
                    <div class="cat_page">
                        {{ (transactions.total / transactions.perPage)|round(0,'ceil') }} {{ 'page.pages'|_ }}
                    </div>
                </div>
                
                {% endif %}
            </div>
        </div>
    </section>