<!DOCTYPE html>
<html lang="{{ invoice['invoice.language'] }}">
<head>
    <meta charset="utf-8">
    <title>{% block title %}{{ invoice['invoice.number'] }}-{{ invoice['customer.company']|default(invoice['customer.name'])|u.snake }}{% endblock %}</title>
    <style>
        {{ encore_entry_css_source('invoice-pdf')|raw }}
    </style>
</head>
<body>
<!--mpdf
<htmlpageheader name="header">
    <table class="header">
        <tr>
            <td class="text-small">
                {{ invoice['template.company'] }} &ndash; {{ invoice['template.address']|nl2str(' – ') }}
                {% if invoice['template.vat_id'] is not empty %}
                    &ndash; {{ 'vat_id'|trans }}: {{ invoice['template.vat_id'] }}
                {% endif %}
            </td>
            <td class="text-small text-right">
                {{ 'export.page_of'|trans({'%page%': '{PAGENO}', '%pages%': '{nb}'}) }}
            </td>
        </tr>
    </table>
</htmlpageheader>
<sethtmlpageheader name="header" page="ALL" value="on" show-this-page="1" />
<htmlpagefooter name="footer">
    <table class="footer text-small">
        <tr>
            <td style="width: 33%">
                <strong>{{ 'address'|trans }}</strong>
                <br>
                {{ invoice['template.company'] }}<br>
                {{ invoice['template.address']|nl2br }}
            </td>
            <td class="text-center">
                <strong>{{ 'invoice_bank_account'|trans }}</strong>
                <br>
                {{ invoice['template.payment_details']|nl2br }}
            </td>
            <td class="text-right" style="width: 33%">
                <strong>{{ 'contact'|trans }}</strong>
                <br>
                {{ invoice['template.contact']|nl2br }}
            </td>
        </tr>
    </table>
</htmlpagefooter>
<sethtmlpagefooter page="ALL" value="on" name="footer" show-this-page="1" />
mpdf-->
    <table class="addresses">
        <tr>
            <td>
                <strong>{{ invoice['customer.company']|default(invoice['customer.name']) }}</strong><br>
                {{ invoice['customer.address']|nl2br }}
            </td>
            <td class="text-right">
                {% set classLeft = 'text-left' %}
                {% set classRight = 'text-right text-nowrap padding-left' %}
                <table style="width: 240px">
                    <tr>
                        <td class="{{ classLeft }}">{{ 'date'|trans }}</td>
                        <td class="{{ classRight }}">{{ invoice['invoice.date'] }}</td>
                    </tr>
                    <tr>
                        <td class="{{ classLeft }}">{{ 'invoice.service_date'|trans }}</td>
                        <td class="{{ classRight }}">{{ invoice['query.end_month'] }} {{ invoice['query.end_year'] }}</td>
                    </tr>
                    <tr>
                        <td class="{{ classLeft }}">{{ 'invoice.number'|trans }}</td>
                        <td class="{{ classRight }}">{{ invoice['invoice.number'] }}</td>
                    </tr>
                    <tr>
                        <td class="{{ classLeft }}">{{ 'invoice.due_days'|trans }}</td>
                        <td class="{{ classRight }}">{{ invoice['invoice.due_date'] }}</td>
                    </tr>
                    {% if invoice['customer.number'] is not empty %}
                        <tr>
                            <td class="{{ classLeft }}">{{ 'number'|trans }}</td>
                            <td class="{{ classRight }}">{{ invoice['customer.number'] }}</td>
                        </tr>
                    {% endif %}
                    {% if invoice['query.project.order_number'] is defined and invoice['query.project.order_number'] is not empty %}
                        <tr>
                            <td class="{{ classLeft }}">{{ 'orderNumber'|trans }}</td>
                            <td class="{{ classRight }}">{{ invoice['query.project.order_number'] }}</td>
                        </tr>
                    {% endif %}
                    {% if invoice['customer.vat_id'] is not empty %}
                        <tr>
                            <td class="{{ classLeft }}">{{ 'vat_id'|trans }}</td>
                            <td class="{{ classRight }}">{{ invoice['customer.vat_id'] }}</td>
                        </tr>
                    {% endif %}
                </table>
            </td>
        </tr>
    </table>

    <h2 style="margin-top: 60px">{{ invoice['template.title'] }}</h2>

    {% if invoice['customer.invoice_text'] is not empty%}
        <p>{{ invoice['customer.invoice_text']|md2html }}</p>
    {% endif %}

    <table class="items">
        <thead>
            <tr>
                <th class="first">{{ 'description'|trans }}</th>
                <th class="text-right">{{ 'unit_price'|trans }}</th>
                <th class="text-right">{{ 'amount'|trans }}</th>
                <th class="last text-right">{{ 'total_rate'|trans }}</th>
            </tr>
        </thead>
        <tbody>
        {% for invoiceLineItem in entries %}
            <!-- CONTENT_PART -->
            <tr>
                <td class="first">
                    {% if invoiceLineItem['entry.description'] is not empty %}
                        {{ invoiceLineItem['entry.description']|nl2br }}
                    {% else %}
                        {% if invoiceLineItem['entry.activity'] is defined %}
                            {{ invoiceLineItem['entry.activity'] }} /
                        {% endif %}
                        {{ invoiceLineItem['entry.project'] }}
                    {% endif %}
                </td>
                <td class="text-right text-nowrap">{{ invoiceLineItem['entry.rate'] }}</td>
                <td class="text-right text-nowrap">{{ invoiceLineItem['entry.amount'] }}</td>
                <td class="last text-right text-nowrap">{{ invoiceLineItem['entry.total'] }}</td>
            </tr>
        {% endfor %}
        </tbody>
        <tfoot>
            {% if not invoice['invoice.tax_hide'] %}
            <tr>
                <td colspan="3" class="text-right">
                    {{ 'invoice.subtotal'|trans }}
                </td>
                <td class="last text-right">{{ invoice['invoice.subtotal'] }}</td>
            </tr>
            <tr>
                <td colspan="3" class="text-right">
                    {{ 'invoice.tax'|trans }} ({{ invoice['invoice.vat'] }}%)
                </td>
                <td class="last text-right">{{ invoice['invoice.tax'] }}</td>
            </tr>
            {% endif %}
            <tr>
                <td colspan="3" class="text-right text-nowrap">
                    <strong>{{ 'invoice.total'|trans }}</strong>
                </td>
                <td class="last text-right">
                    <strong>{{ invoice['invoice.total'] }}</strong>
                </td>
            </tr>
        </tfoot>
    </table>

    {% if invoice['template.payment_terms'] is not empty %}
        <div class="paymentTerms">
            {{ invoice['template.payment_terms']|md2html }}
        </div>
    {% endif %}
</body>
</html>
