{# templates/tracking/_Tab_track_container.html.twig #}
<style>
:root {
--afi-primary: #006E51;
--afi-success: #28a745;
--afi-danger: #e53e3e;
--afi-border: #edf2f7;
}
/* Conteneur Zigzag */
.timeline-zigzag {
position: relative;
padding: 20px 0;
margin-top: 30px;
}
.timeline-zigzag::before {
content: '';
position: absolute;
left: 50%; width: 3px; height: 100%;
background: linear-gradient(to bottom, var(--afi-success), #e9ecef);
transform: translateX(-50%);
}
.zigzag-item {
position: relative;
width: 50%;
padding: 10px 40px;
box-sizing: border-box;
}
.zigzag-item.left { left: 0; text-align: right; }
.zigzag-item.right { left: 50%; text-align: left; }
/* Points centraux */
.zigzag-dot {
position: absolute;
top: 20px;
width: 18px; height: 18px;
background: #fff;
border: 4px solid var(--afi-success);
border-radius: 50%;
z-index: 10;
}
.left .zigzag-dot { right: -10px; }
.right .zigzag-dot { left: -10px; }
/* Cartes */
.timeline-content {
background: #fff;
padding: 20px;
border-radius: 18px;
box-shadow: 0 10px 25px rgba(0,0,0,0.05);
border: 1px solid var(--afi-border);
transition: 0.3s ease;
display: inline-block;
width: 100%;
text-align: left;
}
/* Style pour la DERNIÈRE sous-étape globale */
.latest-status-marker {
border: 2px solid var(--afi-success) !important;
background: rgba(40, 167, 69, 0.03);
animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4); }
70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}
.sub-tracking-list {
padding-left: 15px;
border-left: 2px solid #f1f5f9;
margin-top: 12px;
}
.afi-comment {
font-size: 0.75rem;
color: var(--afi-danger);
font-weight: 600;
background: rgba(229, 62, 62, 0.05);
padding: 5px 10px;
border-radius: 6px;
margin-top: 5px;
display: inline-block;
font-style: italic;
}
/* Mobile Responsive */
@media (max-width: 768px) {
.timeline-zigzag::before { left: 20px; }
.zigzag-item { width: 100%; left: 0 !important; padding-left: 45px; padding-right: 10px; text-align: left !important; }
.zigzag-dot { left: 11px !important; }
}
</style>
<div class="container mt-4">
<div class="text-center mb-5">
<h1 class="font-weight-bold" style="color: #1a202c;">{{ programme_contenaire.numeroContenaire }}</h1>
{# Identification des derniers états pour le header[cite: 1, 2] #}
{% set sortedSuivis = programme_contenaire.suiviContenaires|sort((a, b) => a.dateOperation <=> b.dateOperation) %}
{% set lastBase = sortedSuivis|last %}
{# On cherche la sous-étape la plus récente de TOUT le projet #}
{% set allSubSuivis = [] %}
{% for ct in programme_contenaire.suiviContenaires %}
{% for ss in ct.getSousSuivis %}
{% set allSubSuivis = allSubSuivis|merge([ss]) %}
{% endfor %}
{% endfor %}
{% set globalLatestSub = (allSubSuivis|sort((a, b) => a.createdAt <=> b.createdAt))|last %}
<div class="d-flex flex-column align-items-center">
<span class="badge badge-pill shadow-sm px-4 py-2 mb-2" style="background: #fff; border: 1px solid var(--afi-border);">
<i class="fa fa-map-marker-alt text-primary mr-2"></i>
{% if lastBase %}{{ lastBase.lieu }}{% else %}Origin Port{% endif %}
</span>
{% if globalLatestSub %}
<div class="status-badge-hero px-3 py-1" style="background: var(--afi-primary); color: white; border-radius: 20px; font-size: 0.8rem; font-weight: bold;">
CURRENT STATUS: {{ globalLatestSub.sousPosition.libelle|upper }}
</div>
{% endif %}
</div>
</div>
<div class="timeline-zigzag">
{% for ct in programme_contenaire.suiviContenaires|sort((a, b) => b.dateOperation <=> a.dateOperation) %}
<div class="zigzag-item {{ loop.index0 is even ? 'left' : 'right' }}">
<div class="zigzag-dot"></div>
<div class="timeline-content">
<div class="d-flex justify-content-between align-items-center mb-2">
<strong class="text-uppercase" style="color: #1a202c;">{{ ct.lieu }}</strong>
<small class="text-muted"><i class="far fa-calendar-alt"></i> {{ ct.dateOperation|date('M d, Y') }}</small>
</div>
<div class="sub-tracking-list">
{% for ss in ct.getSousSuivis|sort((a, b) => b.createdAt <=> a.createdAt) %}
<div class="sub-tracking-item py-1 {{ (globalLatestSub and ss.id == globalLatestSub.id) ? 'latest-status-marker p-2 rounded' : '' }}">
<div class="d-flex justify-content-between align-items-center">
<span style="font-size: 0.85rem; font-weight: 700;">
<i class="fa {{ (globalLatestSub and ss.id == globalLatestSub.id) ? 'fa-sync-alt fa-spin text-primary' : 'fa-check-circle text-success' }} mr-2"></i>
{{ ss.sousPosition.libelle }}
</span>
<small class="text-muted" style="font-size: 0.7rem;">{{ ss.createdAt|date('H:i') }}</small>
</div>
{% if ss.commentaire is defined and ss.commentaire %}
<div class="afi-comment">
<i class="fa fa-info-circle mr-1"></i> {{ ss.commentaire }}
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
</div>
{% else %}
<div class="text-center py-5">
<p class="text-muted italic">No tracking history found for this container.</p>
</div>
{% endfor %}
</div>
</div>