{% extends "pdf/base.twig" %}

{% block style %}
.listing-title {
    page-break-after: avoid;
}

.listing-table > tbody > tr > td {
    height: 6mm;
    font-size: 8pt;
}
{% endblock %}

{% block content %}
<table class="layout-table">
    <tr>
        <td class="third">
            {{ include('blocks/company-address.twig', {
                company: company,
                showLegalNumbers: false,
                showLogo: false,
            }) }}
        </td>
        <td class="two-third">
            <h1 class="box center">{{ translate('materials-list') }}</h1>
            <h3 class="center">
                {{ translate('as-of-date', date|format_date('long', locale=locale)) }}
                {% if parkOnlyName is not null %}
                {{ translate('for-park') }}
                {% else %}
                ({{ translate('all-parks') }})
                {% endif %}
            </h3>
            {% if parkOnlyName is not null %}
            <h2 class="center">{{ parkOnlyName }}</h2>
            {% endif %}
        </td>
    </tr>
</table>

{% for park in parksMaterialsList %}
    {% if parkOnlyName is null %}
    <h3 class="listing-title">
        {% if park['name'] is not empty %}
        {{ park['name'] }}
        {% else %}
        ({{ translate('unknown-park') }})
        {% endif %}
    </h3>
    {% endif %}
    <table class="listing-table">
        <thead>
            <tr>
                <th style="width: 30mm;">{{ translate('reference') }}</th>
                <th>
                    {{ translate('designation') }}
                    {% if park['name'] is not empty %}
                    <span class="normal lightest">- {{ translate('park-name', park['name']) }}</span>
                    {% endif %}
                </th>
                <th style="width: 20mm;">{{ translate('replacement-value') }}</th>
                <th style="width: 16mm;">{{ translate('stock-quantity') }}</th>
                <th style="width: 25mm;">{{ translate('recount-quantity') }}</th>
            </tr>
        </thead>
        <tbody>
        {% for subCategory in park['materials'] %}
            <tr>
                <td class="section-title" colspan="5">
                    {% if subCategory['name'] is not empty %}
                    {{ subCategory['category'] }} - {{ subCategory['name'] }}
                    {% else %}
                    {{ subCategory['category'] }} - {{ translate('otherMaterials') }}
                    {% endif %}
                </td>
            </tr>
            {% for material in subCategory['materials'] %}
                {{ include('blocks/materials/line-list.twig', { material: material }) }}
            {% endfor %}
        {% endfor %}
        </tbody>
    </table>
{% endfor %}

<h3 class="listing-title">{{ translate('notes') }}</h3>
<div class="inset" style="height: 100mm;"></div>
{% endblock %}
