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

{% block breadcrumbs %}
    {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, piggyBank) }}
{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-lg-8 col-md-8 col-sm-6">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'events'|_ }}</h3>
                </div>
                <div class="box-body">
                    <canvas id="piggy-bank-history" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-6">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'details'|_ }}</h3>

                    <!-- ACTIONS MENU -->
                    <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('piggy-banks.edit', piggyBank.id) }}"><i class="fa fa-pencil fa-fw"></i> {{ 'edit'|_ }}</a></li>
                                <li><a href="{{ route('piggy-banks.delete', piggyBank.id) }}"><i class="fa fa-trash fa-fw"></i> {{ 'delete'|_ }}</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover">
                        <tr>
                            <td style="width:40%;">{{ 'account'|_ }}</td>
                            <td><a href="{{ route('accounts.show', piggyBank.account_id) }}">{{ piggyBank.account.name }}</a></td>
                        </tr>
                        <tr>
                            <td>{{ 'target_amount'|_ }}</td>
                            <td>{{ piggyBank.targetamount|formatAmount }}</td>
                        </tr>
                        <tr>
                            <td>{{ 'saved_so_far'|_ }}</td>
                            <td>{{ currentRelevantRepAmount(piggyBank)|formatAmount }}</td>
                        </tr>
                        <tr>
                            <td>{{ 'left_to_save'|_ }}</td>
                            <td>{{ (piggyBank.targetamount - currentRelevantRepAmount(piggyBank))|formatAmount }}</td>
                        </tr>
                        <tr>
                            <td>{{ 'start_date'|_ }}</td>
                            <td>
                                {% if piggyBank.startdate %}
                                    {{ piggyBank.startdate.format('jS F Y') }}
                                {% else %}
                                    <em>{{ 'no_start_date'|_ }}</em>
                                {% endif %}
                            </td>
                        </tr>
                        <tr>
                            <td>{{ 'target_date'|_ }}</td>
                            <td>
                                {% if piggyBank.targetdate %}
                                    {{ piggyBank.targetdate.format('jS F Y') }}
                                {% else %}
                                    <em>{{ 'no_target_date'|_ }}</em>
                                {% endif %}
                            </td>
                        </tr>
                        {% if piggyBank.targetdate %}
                            <tr>
                                <td>{{ 'suggested_amount'|_ }}</td>
                                <td>
                                    {{ suggestedMonthlyAmount(piggyBank)|formatAmount }}
                                </td>
                            </tr>
                        {% endif %}
                    </table>
                </div>
            </div>
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'table'|_ }}</h3>
                </div>
                <div class="box-body table-responsive no-padding">
                    {% include 'list/piggy-bank-events' %}
                </div>
            </div>
        </div>
    </div>
    {% if note %}
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ trans('form.notes') }}</h3>
                    </div>
                    <div class="box-body">
                        {{ note.markdown|raw }}
                    </div>
                </div>

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

{% block scripts %}
    <script type="text/javascript">
        var piggyBankID = {{ piggyBank.id }};
    </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/piggy-banks/show.js"></script>
{% endblock %}
