{# Document Management Macros Reusable components for document listing and management Usage: {% import 'admin/companies/documents/_macros.html.twig' as docs %} {{ docs.expiration_badge(media) }} #} {# Expiration Badge Displays expiration status with color coding and remaining days @param media Media entity with expiresAt property @return string Badge HTML #} {% macro expiration_badge(media) %} {% if media.expiresAt %} {% set now = 'now'|date('U') %} {% set expirationDate = media.expiresAt|date('U') %} {% set daysLeft = ((expirationDate - now) / 86400)|round(0, 'floor') %} {% if daysLeft < 0 %} {# Expired #} Expiré {% elseif daysLeft <= 7 %} {# Expiring soon (7 days or less) #} {{ daysLeft }}j restant{{ daysLeft > 1 ? 's' : '' }} {% elseif daysLeft <= 30 %} {# Expiring within a month #} {{ daysLeft }}j restants {% else %} {# OK - more than 30 days #} {{ media.expiresAt|date('d/m/Y') }} {% endif %} {% else %} Aucune {% endif %} {% endmacro %} {# File Icon Displays appropriate icon based on MIME type @param media Media entity @param size string Icon size (text-xl, text-2xl, text-4xl, text-6xl) @param show_label boolean Show file type label below icon @return string Icon HTML #} {% macro file_icon(media, size = 'text-2xl', show_label = false) %}
Image
{% endif %} {% elseif media.mimeType starts with 'video/' %} {% if show_label %}Vidéo
{% endif %} {% elseif media.mimeType == 'application/pdf' %} {% if show_label %}Word
{% endif %} {% elseif 'excel' in media.mimeType or 'spreadsheet' in media.mimeType or (media.originalFileName|split('.')|last|lower) in ['xls', 'xlsx'] %} {% if show_label %}Excel
{% endif %} {% elseif 'powerpoint' in media.mimeType or 'presentation' in media.mimeType or (media.originalFileName|split('.')|last|lower) in ['ppt', 'pptx'] %} {% if show_label %}PowerPoint
{% endif %} {% elseif 'zip' in media.mimeType or 'rar' in media.mimeType or 'archive' in media.mimeType %} {% if show_label %}Archive
{% endif %} {% else %} {% if show_label %}Fichier
{% endif %} {% endif %}{{ title }}
{% if message %}{{ message }}
{% endif %} {% if show_upload and company and not company.deletedAt and (is_granted('ROLE_ADMIN') or is_granted('ROLE_MANAGER')) %}