{% extends '@!EasyAdmin/crud/detail.html.twig' %} {% import 'admin/order/_icons.html.twig' as icons %} {% block main %} {% set order = entity.instance %} {% set statusColors = { 'bat1': 'dark', 'bat2': 'dark', 'bat3': 'dark', 'bat4': 'dark', 'new_order': 'primary', 'pending': 'warning', 'manufacturing': 'info', 'pending_delivery': 'secondary', 'delivered': 'success', 'cancelled': 'danger' } %} {% set statusColor = statusColors[order.status.value] ?? 'secondary' %} {% set statusStyle = { 'NEW': { color: '#3b82f6', icon: 'new' }, 'PENDING_TEXT': { color: '#58d19c', icon: 'text' }, 'PENDING_CREATION': { color: '#6c757d', icon: 'clock' }, 'BAT1': { color: '#f59e0b', icon: 'doc' }, 'BAT2': { color: '#f59e0b', icon: 'doc' }, 'BAT3': { color: '#f59e0b', icon: 'doc' }, 'BAT4': { color: '#f59e0b', icon: 'doc' }, 'BAT5': { color: '#f59e0b', icon: 'doc' }, 'PENDING_CORRECTIONS': { color: '#6c757d', icon: 'eye' }, 'VALIDATED': { color: '#00b129', icon: 'doc' }, 'PENDING': { color: '#6c757d', icon: 'clock' }, 'MANUFACTURING': { color: '#6c757d', icon: 'gear' }, 'PENDING_DELIVERY': { color: '#8b5cf6', icon: 'truck' }, 'DELIVERED': { color: '#00b129', icon: 'check' }, 'CANCELLED': { color: '#b3261e', icon: 'x' }, } %} {% set current = statusStyle[order.status.name] ?? { color: '#6c757d', icon: 'gear' } %}
{# ===== Carte résumé ===== #}

STATUT ACTUEL

{{ icons.icon(current.icon) }}  {{ order.status.label }} 
Créé le {{ order.createdAt|date('d/m/Y à H:i') }}
Mis à jour le {{ order.updatedAt|date('d/m/Y à H:i') }}
{% if order.status.name is same as "PENDING_CREATION" or order.status.name is same as "PENDING_CORRECTIONS" %} {% set daysElapsed = ((date().timestamp - order.updatedAt.timestamp) / 86400)|round(0, 'floor') %} {% set daysRemaining = 5 - daysElapsed %}
Jour(s) restant(s) {% if daysRemaining < 0 %} Expiré {% else %} {{ daysRemaining }} jour{{ daysRemaining > 1 ? 's' : '' }} {% endif %}
{% endif %}
CLIENT {{ order.customer.name }} 
COMMERCIAL

  {{ order.customer.commercial }}

  {{ order.customer.commercial.email }}

{# ===== Carte notes internes ===== #} {% if order.internalNotes %}

Notes internes

{{ order.internalNotes|nl2br }}

{% endif %}
{# ===== Carte historique des statuts ===== #}

Historique des statuts

{% set history = order.orderStatusHistories|sort((a, b) => b.createdAt <=> a.createdAt) %} {% if history is empty %}

Aucun historique.

{% else %}
{% for entry in history %} {% set current = statusStyle[entry.status.name] ?? { color: '#6c757d', icon: 'gear' } %}
{{ icons.icon(current.icon) }}
{{ entry.status.label }} {{ entry.createdAt|date('d/m/Y à H:i') }}
{% if entry.changedBy %}
Par {{ entry.changedBy }}
{% endif %} {% if entry.comments %}
Commentaires : {{ entry.comments }}
{% endif %}
{% endfor %}
{% endif %}
{# ===== Carte lignes de commande ===== #}

PRODUITS COMMANDES

{% if order.orderLines is empty %}

Aucune ligne de commande.

{% else %} {% for line in order.orderLines %} {% endfor %}
Produit SKU Qté Prix unitaire Prix total
{{ line.product.description }} {{ line.product.sku }} {{ line.quantity }} {{ line.product.price }} {{ line.totalPrice|number_format(2, ',', ' ') }} €
Total HT {{ order.orderLines|reduce((carry, l) => carry + l.totalPrice, 0)|number_format(2, ',', ' ') }} €
{% endif %}
{% endblock %}