{% extends "layouts/base.twig" %} {% block title %} {{ translations.order_details | default('Szczegóły zamówienia') }} {% if order.getPoHash() %} – #{{ order.getPoHash() }}{% endif %} {% endblock %} {% block head %} {% endblock %} {% block page_heading %}
{{ translations.back_to_orders | default('Wróć do listy zamówień') }}

{{ translations.order_details | default('Szczegóły zamówienia') }}

{{ translations.order_details_subtitle | default('Pełne informacje o zamówieniu z perspektywy kuchni.') }}

{% endblock %} {% block content %} {# ── Nagłówek zamówienia (status + termin + wartość) ────────────────────── #}
{# Status #}
{{ translations.order_status | default('Status') }}
{% set statusKey = order.getOrderStatus() | lower | default('unknown') %} {% set statusLabel = translations['status_' ~ statusKey] | default(order.getOrderStatus() | capitalize | default('?')) %} {{ statusLabel }}
{# Termin odbioru #}
{{ translations.order_pickup_datetime | default('Termin odbioru') }}
{% if order.getPickUpDatetime() %}
{{ order.getPickUpDatetime() | date('H:i') }}
{{ order.getPickUpDatetime() | date('d.m.Y') }}
{% else %}
{{ translations.not_available | default('—') }}
{% endif %}
{# Wartość #}
{{ translations.order_total_value | default('Wartość') }}
{{ order.getTotalValue() | number_format(2, ',', ' ') }} {{ constant('APP_CURRENCY_SYMBOL') }}
{# Nr zamówienia #}
{{ translations.order_id | default('ID zamówienia') }}
#{{ order.getId() }}
{% if order.getPoHash() %}
{{ order.getPoHash() }}
{% endif %}
{# ── Lewa kolumna: klient + obsługa ────────────────────────────────── #}
{# Klient #}
{{ translations.section_client | default('Klient') }}
{{ translations.client_name | default('Nazwa klienta') }}
{{ order.getClientName() ?? translations.not_available | default('—') }}
{{ translations.client_type | default('Typ klienta') }}
{% if order.isB2B() %} {{ translations.type_b2b | default('Firma (B2B)') }} {% else %} {{ translations.type_individual | default('Indywidualny') }} {% endif %}
{% if order.getClientPhone() %}
{{ translations.client_phone | default('Telefon') }}
{% endif %} {% if order.getClientEmail() %}
{{ translations.client_email | default('E-mail') }}
{% endif %} {% if order.getClientTaxNumber() %}
{{ translations.client_tax_number | default('NIP') }}
{{ order.getClientTaxNumber() }}
{% endif %} {% if order.getClientCity() %}
{{ translations.client_city | default('Miejscowość') }}
{{ order.getClientCity() }}
{% endif %} {% if order.getClientPaymentTerms() %}
{{ translations.client_payment_terms | default('Warunki płatności') }}
{{ order.getClientPaymentTerms() }}
{% endif %} {% if order.getClientPersonalDiscountPercent() is not null and order.getClientPersonalDiscountPercent() > 0 %}
{{ translations.client_discount | default('Rabat indywidualny') }}
{{ order.getClientPersonalDiscountPercent() }}%
{% endif %} {% if order.getClientComment() %}
{{ translations.client_comment | default('Uwagi o kliencie') }}
{{ order.getClientComment() }}
{% endif %}
{# Obsługa zamówienia #}
{{ translations.section_employee | default('Obsługa zamówienia') }}
{# Przyjmujący #}
{{ order.getAcceptingEmployeeInitials() ?? '?' }}
{{ translations.accepting_employee | default('Przyjął zamówienie') }}
{{ order.getAcceptingEmployeeDisplayName() ?? translations.not_available | default('—') }}
{% if order.getAcceptingTimestamp() %}
{{ order.getAcceptingTimestamp() | date('d.m.Y H:i') }}
{% endif %}
{# Wydający #} {% if order.getIdIssuingEmployee() %}
{{ order.getIssuingEmployeeInitials() ?? '?' }}
{{ translations.issuing_employee | default('Wydał zamówienie') }}
{{ order.getIssuingEmployeeDisplayName() ?? translations.not_available | default('—') }}
{% if order.getIssuingTimestamp() %}
{{ order.getIssuingTimestamp() | date('d.m.Y H:i') }}
{% endif %}
{% endif %} {% if order.getCompletionTimestamp() %}
{{ translations.completion_timestamp | default('Data realizacji') }}
{{ order.getCompletionTimestamp() | date('d.m.Y H:i') }}
{% endif %}
{# Komentarz do zamówienia #} {% if order.getComment() %}
{{ translations.order_comment | default('Komentarz') }}

{{ order.getComment() }}

{% endif %} {# Powód nieodebrania #} {% if order.getNonCollectionIdReason() or order.getNonCollectionComment() %}
{{ translations.non_collection_reason | default('Powód nieodebrania') }}
{% if order.getNonCollectionComment() %}

{{ order.getNonCollectionComment() }}

{% endif %}
{% endif %}
{# ── Prawa kolumna: pozycje zamówienia ─────────────────────────────── #}
{{ translations.section_products | default('Pozycje zamówienia') }} {{ order.getProducts() | length }}
{% if order.getProducts() is not empty %}
{% set orderTotal = 0 %} {% for product in order.getProducts() %} {% set orderTotal = orderTotal + (product.getTotalGrossValueAfterDiscount() ?? 0) %} {% endfor %}
{{ translations.product_name | default('Produkt') }} {{ translations.product_quantity | default('Ilość') }} {{ translations.product_unit_price | default('Cena jedn.') }} {{ translations.product_tax | default('VAT') }} {{ translations.product_discount | default('Rabat') }} {{ translations.product_total | default('Razem brutto') }}
{{ product.getName() ?? translations.not_available | default('—') }} {% if product.getQuantityPerLabel() %}
{{ product.getQuantityPerLabel() }} {{ translations.unit_pcs_per_label|default('pcs/label') }}
{% endif %}
{{ product.getQuantity() }} {% if product.isPieceBased() %} {{ translations.unit_pcs|default('pcs.') }} {% else %} {{ translations.unit_kg|default('kg') }} {% endif %} {% if product.getUnitGrossPrice() is not null %} {{ product.getUnitGrossPrice() | number_format(2, ',', ' ') }} {{ constant('APP_CURRENCY_SYMBOL') }} {% else %} {{ translations.not_available | default('—') }} {% endif %} {% if product.getItemTaxPerc() is not null %} {{ product.getItemTaxPerc() }}% {% else %} {{ translations.not_available | default('—') }} {% endif %} {% if product.getItemDiscountValue() is not null and product.getItemDiscountValue() > 0 %} -{{ product.getItemDiscountValue() | number_format(2, ',', ' ') }} {{ constant('APP_CURRENCY_SYMBOL') }} {% else %} {{ translations.not_available | default('—') }} {% endif %} {% if product.getTotalGrossValueAfterDiscount() is not null %} {{ product.getTotalGrossValueAfterDiscount() | number_format(2, ',', ' ') }} {{ constant('APP_CURRENCY_SYMBOL') }} {% else %} {{ translations.not_available | default('—') }} {% endif %}
{{ translations.order_total_value | default('Wartość zamówienia') }} {{ order.getTotalValue() | number_format(2, ',', ' ') }} {{ constant('APP_CURRENCY_SYMBOL') }}
{% else %}
{{ translations.no_products | default('Brak pozycji w zamówieniu.') }}
{% endif %}
{% endblock %}