{% extends 'base.html.twig' %}

{% block title %}{{ 'trans.Invoices' | trans }}{% endblock %}

{% block body %}
    <div class="container mt-4">
        <div class="row">
            <div class="col-md-4 col-lg-3 mb-4 d-none d-md-block">
                {% include 'user/_part/user_navigation_card.html.twig' %}
            </div>

            <div class="col-md-8 col-lg-9">
                <div class="row mb-2">
                    <div class="col-md-6">
                        <h2 class="mb-3">{{ 'trans.Invoices' | trans }}</h2>
                    </div>
                    <div class="col-md-6 text-md-right">
                        <a href="{{ path('app_user_invoice_details') }}" class="btn btn-secondary mb-1">
                            {{- 'trans.Invoice details' | trans -}}
                        </a>
                    </div>
                </div>

                <table class="table table-responsive-sm">
                    <thead>
                    <tr>
                        <th class="column-invoice-number">{{ 'trans.Invoice number' | trans }}</th>
                        <th>{{ 'trans.Amount' | trans }}</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for invoice in invoiceList %}
                        <tr>
                            <td>
                                <div class="text-break">{{ invoice.invoiceNumber }}</div>
                                <div class="text-muted text-break">
                                    {%- if invoice.invoiceDate -%}
                                        {{- invoice.invoiceDate | date -}}
                                    {%- else -%}
                                        {{- '-' -}}
                                    {%- endif -%}
                                </div>
                            </td>
                            <td>{{ invoice.totalMoneyFloat | moneyPrecise }}</td>
                            <td>
                                <a
                                        class="btn btn-dark float-right"
                                        href="{{ path('app_user_invoice_download', {'invoice': invoice.id}) }}"
                                        target="_blank"
                                >
                                    {{- 'trans.Download' | trans -}}
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}
