<!DOCTYPE html>
<html lang="{{ invoice['invoice.language'] }}">
<head>
    <meta charset="utf-8">
    <title>{{ invoice['invoice.number'] }}-{{ invoice['customer.company']|default(invoice['customer.name'])|u.snake }}</title>
    <style>
        {{ encore_entry_css_source('invoice-pdf')|raw }}
    </style>
</head>
<body>
<!--mpdf
<htmlpageheader name="header">
    <table class="header">
        <tr>
            <td class="title">
                {{ invoice['template.title'] }}
            </td>
            <td class="date text-right">
                {{ 'date'|trans }}: {{ invoice['invoice.date'] }}
            </td>
        </tr>
    </table>
</htmlpageheader>
<sethtmlpageheader name="header" page="ALL" value="on" show-this-page="1" />
<htmlpagefooter name="footer">
    <table class="footer">
        <tr>
            <td>
                <strong>{{ 'contact'|trans }}</strong>:
                {{ invoice['template.contact']|nl2str(' – ') }}
                <br>
                <strong>{{ 'invoice_bank_account'|trans }}</strong>:
                {{ invoice['template.payment_details']|nl2str(' – ') }}
            </td>
            <td align="right">
                {{ 'export.page_of'|trans({'%page%': '{PAGENO}', '%pages%': '{nb}'}) }}
            </td>
        </tr>
    </table>
</htmlpagefooter>
<sethtmlpagefooter page="ALL" value="on" name="footer" show-this-page="1" />
mpdf-->
    <table class="addresses">
        <tr>
            <td style="width:60%">
                {{ 'invoice.to'|trans }}
                <br>
                <strong>{{ invoice['customer.company']|default(invoice['customer.name']) }}</strong>
                <br>
                {{ invoice['customer.address']|nl2br }}
                {% set country = invoice['customer.country']|country_name(invoice['invoice.language']) %}
                {% if country not in invoice['customer.address'] %}
                    <br> {{ country }}
                {% endif %}
                {% if invoice['customer.vat_id'] is not empty %}
                    <br>
                    {{ 'vat_id'|trans }}: {{ invoice['customer.vat_id'] }}
                {% endif %}
            </td>
            <td>
                {{ 'invoice.from'|trans }}
                <br>
                <strong>{{ invoice['template.company'] }}</strong>
                <br>
                {{ invoice['template.address']|trim|nl2br }}
                {% if invoice['template.country'] is not null %}
                    {% set country = invoice['template.country']|country_name(invoice['invoice.language']) %}
                    {% if country not in invoice['template.address'] %}
                        <br> {{ country }}
                    {% endif %}
                {% endif %}
                {% if invoice['template.vat_id'] is not empty %}
                    <br>
                    {{ 'vat_id'|trans }}:
                    {{ invoice['template.vat_id'] }}
                {% endif %}
            </td>
        </tr>
    </table>

    <p>
        {{ 'invoice.number'|trans }}:
        {{ invoice['invoice.number'] }}

        <br>
        {{ 'invoice.due_days'|trans }}:
        {{ invoice['invoice.due_date'] }}

        {% if invoice['customer.number'] is not empty %}
            <br>
            {{ 'number'|trans }}:
            {{ invoice['customer.number'] }}
        {% endif %}

        {% if invoice['project.counter'] == 1 and invoice['project.order_number'] is not empty %}
            <br>
            {{ 'orderNumber'|trans }}:
            {{ invoice['project.order_number'] }}
        {% endif %}
    </p>

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

    {% if invoice['project.counter'] == 1 and invoice['project.invoice_text'] is not empty %}
        {{ invoice['project.invoice_text']|md2html }}
    {% endif %}

    <table class="items">
        <thead>
            <tr>
                <th class="first"><strong>{{ 'date'|trans }}</strong></th>
                <th><strong>{{ 'description'|trans }}</strong></th>
                <th class="text-right"><strong>{{ 'unit_price'|trans }}</strong></th>
                <th class="text-right"><strong>{{ 'amount'|trans }}</strong></th>
                <th class="last text-right"><strong>{{ 'total_rate'|trans }}</strong></th>
            </tr>
        </thead>
        <tbody>
        {% for invoiceLineItem in entries %}
            <!-- CONTENT_PART -->
            <tr>
                <td nowrap class="first text-nowrap">{{ invoiceLineItem['entry.begin'] }}</td>
                <td>
                    {% 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 nowrap class="text-nowrap text-right">{{ invoiceLineItem['entry.rate'] }}</td>
                <td nowrap class="text-nowrap text-right">{{ invoiceLineItem['entry.amount'] }}</td>
                <td nowrap class="last text-nowrap text-right">{{ invoiceLineItem['entry.total'] }}</td>
            </tr>
        {% endfor %}
        </tbody>
        <tfoot>
            <tr>
                <td colspan="4" class="text-right">
                    {{ 'invoice.subtotal'|trans }}
                </td>
                <td class="last text-right">{{ invoice['invoice.subtotal'] }}</td>
            </tr>
            {% for taxRow in invoice['invoice.tax_rows'] %}
                {% if taxRow['show'] %}
                <tr>
                    <td colspan="4" class="text-right">
                        {{ taxRow['name']|trans }} ({{ taxRow['rate'] }}%)
                        {% if taxRow['note'] is not null %}
                            <sup>[{{ taxRow['counter'] }}]</sup>
                        {% endif %}
                    </td>
                    <td class="last text-right">{{ taxRow['amount']|money(taxRow['currency']) }}</td>
                </tr>
                {% endif %}
            {% endfor %}
            <tr>
                <td colspan="4" 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>

    {% for taxRow in invoice['invoice.tax_rows'] %}
        {% if taxRow['note'] is not null %}
            <p>
                <sup>[{{ taxRow['counter'] }}]</sup>
                {{ taxRow['note']|trans }}
            </p>
        {% endif %}
    {% endfor %}

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