<!DOCTYPE html>
<html lang="{{ invoice['invoice.language'] }}">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <title>{{ invoice['invoice.number'] }}-{{ invoice['customer.company']|default(invoice['customer.name'])|u.snake }}</title>
    <style>
        {{ encore_entry_css_source('invoice')|raw }}
    </style>
</head>
<body class="invoice_print">
    <div class="wrapper">
        <section class="invoice">

            <div class="row">
                <div class="col-xs-12">
                    <h2 class="page-header">
                        <span contenteditable="true">{{ invoice['template.title'] }}</span>
                    </h2>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <table class="table no-border table-sm">
                        <tr>
                            <th class="ps-0">{{ 'invoice.from'|trans }}</th>
                            <td contenteditable="true">
                                {% if not invoice['user.see_others'] and invoice['user.display'] is defined %}
                                    {{ invoice['user.display'] }}
                                {% else %}
                                    {{ invoice['template.company'] }}
                                {% endif %}
                            </td>
                        </tr>
                        <tr>
                            <th class="ps-0">{{ 'date'|trans }}</th>
                            <td contenteditable="true">
                                {% if invoice['query.begin_month_number'] != invoice['query.end_month_number'] or invoice['query.begin_year'] != invoice['query.end_year'] %}
                                    {{ invoice['query.begin'] }} - {{ invoice['query.end'] }}
                                {% else %}
                                    {{ invoice['query.end_month'] }} {{ invoice['query.end_year'] }}
                                {% endif %}
                            </td>
                        </tr>
                        <tr>
                            <th class="ps-0">{{ 'customer'|trans }}</th>
                            <td contenteditable="true">
                                {% if invoice['customer.number'] is not empty %}
                                    [{{ invoice['customer.number'] }}]
                                {% endif %}
                                {{ invoice['customer.name'] }}
                                {% if invoice['customer.contact'] is not empty %}
                                    / {{ invoice['customer.contact'] }}
                                {% endif %}
                            </td>
                        </tr>
                        {% if invoice['query.project.name'] is defined %}
                            <tr>
                                <th class="ps-0">{{ 'project'|trans }}</th>
                                <td contenteditable="true">
                                    {{ invoice['query.project.name'] }}
                                    {% if invoice['query.project.order_number'] is not empty %}
                                        ({{ 'orderNumber'|trans }}: {{ invoice['query.project.order_number'] }})
                                    {% endif %}
                                </td>
                            </tr>
                        {% endif %}
                        {% if invoice['query.activity.name'] is defined %}
                            <tr>
                                <th class="ps-0">{{ 'activity'|trans }}</th>
                                <td contenteditable="true">
                                    {{ invoice['query.activity.name'] }}
                                </td>
                            </tr>
                        {% endif %}
                    </table>
                </div>
            </div>

            <div class="row invoice-items mt-2 mb-3">
                <div class="col-xs-12 table-responsive">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>{{ 'date'|trans }}</th>
                            {% if invoice['user.see_others'] %}
                                <th>{{ 'user'|trans }}</th>
                            {% endif %}
                            <th>{{ 'activity'|trans }}</th>
                            <th class="text-right">{{ 'hours'|trans }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for timesheet in entries %}
                            <tr>
                                <td>{{ timesheet['entry.begin'] }}</td>
                                {% if invoice['user.see_others'] %}
                                    <td>{{ timesheet['entry.user_display'] }}</td>
                                {% endif %}
                                <td contenteditable="true">
                                    {% if timesheet['entry.description'] is not empty %}
                                        {{ timesheet['entry.description']|nl2br }}
                                    {% else %}
                                        {% if timesheet['entry.activity'] is defined %}
                                            {{ timesheet['entry.activity'] }} /
                                        {% endif %}
                                        {{ timesheet['entry.project'] }}
                                    {% endif %}
                                </td>
                                <td class="text-right text-nowrap">{{ timesheet['entry.amount'] }}</td>
                            </tr>
                        {% endfor %}
                        </tbody>
                        <tfoot>
                        <tr>
                            <th></th>
                            {% if invoice['user.see_others'] %}
                                <th></th>
                            {% endif %}
                            <th>{{ 'invoice.total_working_time'|trans }}</th>
                            <th class="text-right text-nowrap">{{ invoice['invoice.duration_decimal'] }}</th>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    {% if invoice['template.payment_terms'] is not empty %}
                        <p class="lead">{{ 'payment_terms'|trans }}</p>

                        <div class="paymentTerms" contenteditable="true" style="margin-bottom: 100px">
                            {{ invoice['template.payment_terms']|md2html }}
                        </div>
                    {% endif %}

                    <div class="table-responsive">
                        <p class="bt-1 pb-4 pt-1">{{ 'invoice.signature_user'|trans }}</p>
                        <p class="bt-1 pb-4 pt-1">{{ 'invoice.signature_customer'|trans }}</p>
                    </div>
                </div>
            </div>

        </section>
    </div>
</body>
</html>
