{% extends "./layout/default" %}

{% block breadcrumbs %}
    {{ Breadcrumbs.renderIfExists }}
{% endblock %}
{% block content %}
    {% include 'partials.boxes' %}

    <div class="row">
        <div class="col-lg-8 col-md-12 col-sm-12">
            {# ACCOUNTS #}
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'yourAccounts'|_ }}</h3>
                </div>
                <div class="box-body">
                    <canvas id="accounts-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>

            {# BUDGETS #}
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'budgetsAndSpending'|_ }}</h3>
                </div>
                <div class="box-body">
                    <canvas id="budgets-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>
            {# CATEGORIES #}
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'categories'|_ }}</h3>

                </div>
                <div class="box-body">
                    <canvas id="categories-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-md-6 col-sm-12">
            {% if billCount > 0 %}
                {# BILLS #}
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ 'bills'|_ }}</h3>

                    </div>
                    <div class="box-body">
                        <div style="width:100%;margin:0 auto;">
                            <canvas id="bills-chart" style="width:100%;height:200px;" height="200"></canvas>
                        </div>

                    </div>
                </div>
            {% endif %}

            {# TRANSACTIONS #}
            {% for data in transactions %}
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title"><a href="{{ route('accounts.show', data[1].id) }}">{{ data[1].name }}</a></h3>

                        <div class="box-tools pull-right">
                            <div class="btn-group">
                                <button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i></button>
                                <ul class="dropdown-menu" role="menu">
                                    <li><a href="{{ route('transactions.create','withdrawal') }}?account_id={{ data[1].id }}"><i
                                                    class="fa fa-long-arrow-left fa-fw"></i> {{ 'newWithdrawal'|_ }}</a></li>
                                    <li><a href="{{ route('transactions.create','deposit') }}?account_id={{ data[1].id }}"><i
                                                    class="fa fa-long-arrow-right fa-fw"></i> {{ 'newDeposit'|_ }}</a></li>
                                    <li><a href="{{ route('transactions.create','transfer') }}?account_from_id={{ data[1].id }}"><i
                                                    class="fa fa-fw fa-exchange"></i> {{ 'newTransfer'|_ }}</a></li>
                                </ul>
                            </div>
                        </div>


                    </div>

                    {% if data[0].count > 0 %}
                        <div class="box-body no-padding">
                            {% include 'list.journals-tiny' with {'transactions': data[0],'account': data[1]} %}
                        </div>
                    {% else %}
                        <div class="box-body">
                            <p>
                                <em>
                                    {{ trans('firefly.no_transactions_account', {name: data[1].name}) }}
                                </em>
                            </p>
                        </div>
                    {% endif %}

                    <div class="box-footer clearfix">
                        <a class="btn btn-sm btn-default btn-flat pull-right"
                           href="{{ route('accounts.show',data[1].id) }}">{{ (data[1]|balance)|formatAmountPlain }}</a>
                    </div>
                </div>
            {% endfor %}
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">
            {# EXPENSE ACCOUNTS #}
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'expense_accounts'|_ }}</h3>

                </div>
                <div class="box-body">
                    <canvas id="expense-accounts-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>
            {# OPTIONAL REVENUE ACCOUNTS #}
            {% if showDepositsFrontpage %}
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ 'revenue_accounts'|_ }}</h3>

                    </div>
                    <div class="box-body">
                        <canvas id="revenue-accounts-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                    </div>
                </div>
            {% endif %}
        </div>
    </div>

{% endblock %}
{% block scripts %}
    <script type="text/javascript">
        var billCount = {{ billCount }};

        // uri's of charts:
        var accountFrontpageUri = '{{ route('chart.account.frontpage') }}';
        var accountRevenueUri = '{{ route('chart.account.revenue') }}';
        var accountExpenseUri = '{{ route('chart.account.expense') }}';
    </script>

    <script type="text/javascript" src="js/lib/Chart.bundle.min.js"></script>
    <script type="text/javascript" src="js/ff/charts.defaults.js"></script>
    <script type="text/javascript" src="js/ff/charts.js"></script>
    <script type="text/javascript" src="js/ff/index.js"></script>
{% endblock %}
{% block styles %}
{% endblock %}
