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

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

{% block content %}
    <div class="row">
        {% if Route.getCurrentRoute.getName == 'categories.show' %}
            {# both charts #}
            <div class="{% if attachments.count() == 0 %}col-lg-6 col-md-12 col-sm-12 col-xs-12{% else %}col-lg-4 col-md-12 col-sm-12 col-xs-12{% endif %}">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">
                            {{ trans('firefly.chart_category_in_period', {name: category.name, start: start.isoFormat(monthAndDayFormat), end: end.isoFormat(monthAndDayFormat) }) }}
                        </h3>
                    </div>
                    <div class="box-body">
                        <canvas id="specific-period" class="wide-chart" height="400" width="100%"></canvas>
                    </div>
                </div>
            </div>
            <div class="{% if attachments.count() == 0 %}col-lg-6 col-md-12 col-sm-12 col-xs-12{% else %}col-lg-4 col-md-12 col-sm-12 col-xs-12{% endif %}">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">
                            {{ trans('firefly.chart_category_all', {name: category.name }) }}
                        </h3>
                    </div>
                    <div class="box-body">
                        <canvas id="category-everything" class="wide-chart" height="400" width="100%"></canvas>
                    </div>
                </div>
            </div>
        {% endif %}
        {% if Route.getCurrentRoute.getName == 'categories.show.all' %}
            {# all chart #}
            <div class="{% if attachments.count() == 0 %}col-lg-12 col-md-12 col-sm-12 col-xs-12{% else %}col-lg-8 col-md-12 col-sm-12 col-xs-12{% endif %}">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">
                            {{ trans('firefly.chart_category_all', {name: category.name }) }}
                        </h3>
                    </div>
                    <div class="box-body">
                        <canvas id="category-everything" class="wide-chart" height="400" width="100%"></canvas>
                    </div>
                </div>
            </div>
        {% endif %}
        {% if attachments.count() > 0 %}
            <div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">
                            {{ 'attachments'|_ }}
                        </h3>
                    </div>
                    <div class="box-body no-padding">
                        {% include 'list.attachments' %}
                    </div>
                </div>
            </div>
        {% endif %}
    </div>
    {% if periods|length > 0 %}
        <div class="row">
            <div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12">
                <p class="small text-center"><a href="{{ route('categories.show.all',[category.id]) }}">{{ 'showEverything'|_ }}</a></p>
            </div>
        </div>
    {% endif %}

    <div class="row">
        <div class="{% if periods|length > 0 %}col-lg-10 col-md-8 col-sm-12 col-xs-12{% else %}col-lg-12 col-md-12 col-sm-12 col-xs-12{% endif %}">

            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'transactions'|_ }}</h3>
                </div>
                <div class="box-body">
                    {% if periods|length > 0 %}
                        {% include 'list.groups' %}
                        <p>
                            <span class="fa fa-calendar"></span>
                            <a href="{{ route('categories.show.all', [category.id]) }}">
                                {{ 'show_all_no_filter'|_ }}
                            </a>
                        </p>
                    {% else %}
                        {% include 'list.groups' %}
                        <p>
                            <span class="fa fa-calendar"></span>
                            <a href="{{ route('categories.show', [category.id]) }}">
                                {{ 'show_the_current_period_and_overview'|_ }}
                            </a>
                        </p>
                    {% endif %}
                </div>
            </div>
        </div>
        {% if periods|length > 0 %}
            <div class="col-lg-2 col-md-4 col-sm-12 col-xs-12">
                {% include 'list.periods' %}
            </div>
        {% endif %}
    </div>

{% endblock %}
{% block scripts %}
    <script type="text/javascript" nonce="{{ JS_NONCE }}">
        var current = '{{ route('chart.category.current', [category.id]) }}';
        var everything = '{{ route('chart.category.all', [category.id]) }}';
        var specific = '{{ route('chart.category.specific', [category.id, start.format('Ymd')]) }}';
    </script>
    <script type="text/javascript" src="v1/js/lib/Chart.bundle.min.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
    <script type="text/javascript" src="v1/js/ff/charts.defaults.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
    <script type="text/javascript" src="v1/js/ff/charts.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
    <script type="text/javascript" src="v1/js/ff/categories/show.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
    {# required for groups.twig #}
    <script type="text/javascript" src="v1/js/ff/list/groups.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
{% endblock %}
