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

{% block breadcrumbs %}
    {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, start, end) }}
{% endblock %}

{% block content %}

    {# charts #}
    <div class="row">
        <div class="col-lg-8 col-md-8 col-sm-12">
            <div class="box" id="year-inc-exp">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'incomeVsExpenses'|_ }}</h3>
                </div>
                <div class="box-body">
                    <canvas id="income-expenses-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-12">
            <div class="box" id="year-inc-exp-sum">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'incomeVsExpenses'|_ }}</h3>
                </div>
                <div class="box-body">
                    <canvas height="400" id="income-expenses-sum-chart" style="width:100%;height:400px;"></canvas>
                </div>
            </div>
        </div>
    </div>
    {# balances and inc vs exp #}
    <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'accountBalances'|_ }}</h3>
                </div>
                <div class="box-body table-responsive no-padding" id="accountReport">
                </div>
                {# loading indicator #}
                <div class="overlay">
                    <i class="fa fa-refresh fa-spin"></i>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'incomeVsExpenses'|_ }}</h3>
                </div>
                <div class="box-body table-responsive no-padding" id="incomeVsExpenseReport">
                </div>
                {# loading indicator #}
                <div class="overlay">
                    <i class="fa fa-refresh fa-spin"></i>
                </div>
            </div>
        </div>
    </div>

    {# income and expenses. #}
    <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'income'|_ }}</h3>
                </div>
                <div class="box-body table-responsive no-padding" id="incomeReport">
                </div>
                {# loading indicator #}
                <div class="overlay">
                    <i class="fa fa-refresh fa-spin"></i>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'expenses'|_ }}</h3>
                </div>
                <div class="box-body table-responsive no-padding" id="expenseReport">
                </div>
                {# loading indicator #}
                <div class="overlay">
                    <i class="fa fa-refresh fa-spin"></i>
                </div>
            </div>
        </div>
    </div>

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

    {# This is the budget overview generated by budget period report #}
    <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'budgets'|_ }}</h3>
                </div>
                <div class="box-body no-padding table-responsive" id="budgetPeriodReport">
                </div>
                {# loading indicator #}
                <div class="overlay">
                    <i class="fa fa-refresh fa-spin"></i>
                </div>
            </div>
        </div>
    </div>


    {# This is the chart that belongs to the above overview. #}
    <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'chart'|_ }}</h3>
                </div>
                <div class="box-body">
                    <canvas id="budget_chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>
        </div>
    </div>

    {# same thing but for categories (expenses) #}
    <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'categories'|_ }} ({{ 'expenses'|_ }})</h3>
                </div>
                <div class="box-body no-padding table-responsive" id="categoryExpense">
                </div>
                {# loading indicator #}
                <div class="overlay">
                    <i class="fa fa-refresh fa-spin"></i>
                </div>
            </div>
        </div>
    </div>

    {# same thing but for categories (income) #}
    <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'categories'|_ }} ({{ 'income'|_ }})</h3>
                </div>
                <div class="box-body no-padding table-responsive" id="categoryIncome">
                </div>
                {# loading indicator #}
                <div class="overlay">
                    <i class="fa fa-refresh fa-spin"></i>
                </div>
            </div>
        </div>
    </div>

    {# and the same chart too! #}
    <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'chart'|_ }}</h3>
                </div>
                <div class="box-body">
                    <canvas id="category_chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
                </div>
            </div>
        </div>
    </div>


{% endblock %}
{% block scripts %}
    <script type="text/javascript" src="js/lib/bootstrap-sortable.js"></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">
        var year = '{{ start.year }}';

        // to report another URL:
        var startDate = '{{ start.format('Ymd') }}';
        var endDate = '{{ end.format('Ymd') }}';
        var accountIds = '{{ accountIds }}';

        // report uri's
        var opChartUri = '{{ route('chart.report.operations', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
        var sumChartUri = '{{ route('chart.report.sum', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
        var netWorthUri = '{{ route('chart.report.net-worth', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';

        // data uri's
        var accountReportUri = '{{ route('report-data.account.general', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
        var incomeReportUri = '{{ route('report-data.operations.income', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
        var expenseReportUri = '{{ route('report-data.operations.expenses', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
        var incExpReportUri = '{{ route('report-data.operations.operations', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';

        var budgetPeriodReportUri = '{{ route('report-data.budget.period', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
        var categoryExpenseUri = '{{ route('report-data.category.expenses', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
        var categoryIncomeUri = '{{ route('report-data.category.income', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';


    </script>

    <script type="text/javascript" src="js/ff/reports/default/all.js"></script>
    <script type="text/javascript" src="js/ff/reports/default/year.js"></script>

{% endblock %}
{% block styles %}
    <link rel="stylesheet" href="css/bootstrap-sortable.css" type="text/css" media="all"/>
{% endblock %}
