{# Document Grid Card Component Used in grid view for document listing Required variables: - media: Media entity - company: Company entity (for actions context) #}
{# Selection Checkbox - Top Left Corner #}
{# Card Header with Preview #}
{% if media.category == 'image' or media.mimeType starts with 'image/' %} {# Image preview #} {{ media.originalFileName }} {% elseif media.mimeType starts with 'video/' %} {# Video icon #}

Vidéo

{% elseif media.mimeType == 'application/pdf' %} {# PDF icon #}

PDF

{% elseif 'word' in media.mimeType or (media.originalFileName|split('.')|last|lower) in ['doc', 'docx'] %} {# Word icon #}

Word

{% elseif 'excel' in media.mimeType or 'spreadsheet' in media.mimeType or (media.originalFileName|split('.')|last|lower) in ['xls', 'xlsx'] %} {# Excel icon #}

Excel

{% elseif 'powerpoint' in media.mimeType or 'presentation' in media.mimeType or (media.originalFileName|split('.')|last|lower) in ['ppt', 'pptx'] %} {# PowerPoint icon #}

PowerPoint

{% elseif 'zip' in media.mimeType or 'rar' in media.mimeType or 'archive' in media.mimeType %} {# Archive icon #}

Archive

{% else %} {# Generic file icon #}

Fichier

{% endif %} {# Visibility Badge - Top Right #}
{{ media.visibility|upper }}
{# Category Badge - Bottom Left #} {% if media.documentCategory %}
{{ media.documentCategory.name }}
{% endif %}
{# Card Body #}
{# Document Name #}

{{ media.originalFileName }}

{# File Type (Clean label instead of MIME type) #}

{% if media.mimeType == 'application/pdf' %} PDF {% elseif 'word' in media.mimeType or 'document' in media.mimeType %} Document Word {% elseif 'excel' in media.mimeType or 'spreadsheet' in media.mimeType %} Feuille Excel {% elseif 'powerpoint' in media.mimeType or 'presentation' in media.mimeType %} Présentation PowerPoint {% elseif 'image/' in media.mimeType %} Image ({{ media.mimeType|split('/')|last|upper }}) {% elseif 'video/' in media.mimeType %} Vidéo ({{ media.mimeType|split('/')|last|upper }}) {% elseif 'audio/' in media.mimeType %} Audio ({{ media.mimeType|split('/')|last|upper }}) {% elseif 'text/' in media.mimeType %} Fichier texte {% elseif 'zip' in media.mimeType or 'compressed' in media.mimeType or 'archive' in media.mimeType %} Archive {% else %} {{ media.mimeType|split('/')|last|upper }} {% endif %}

{# Document Info Grid #}
{# File Size #}
Taille : {{ media.formattedFileSize }}
{# Uploaded By #} {% if media.uploadedBy %}
Par :
{{ media.uploadedBy.fullName }} {{ media.uploadedBy.fullName }}
{% endif %} {# Upload Date #}
Date : {{ media.createdAt|date('d/m/Y') }}
{# Expiration Date #} {% if media.expiresAt %}
Expiration : {% set now = 'now'|date('U') %} {% set expirationDate = media.expiresAt|date('U') %} {% set daysLeft = ((expirationDate - now) / 86400)|round(0, 'floor') %} {% if daysLeft < 0 %} Expiré {% elseif daysLeft <= 7 %} {{ daysLeft }}j {% elseif daysLeft <= 30 %} {{ daysLeft }}j {% else %} OK {% endif %}
{% endif %} {# Tags #} {% if media.tags is not empty %}
Tags :
{% for tag in media.tags %} {% if tag.icon %} {% endif %} {{ tag.name }} {% endfor %}
{% endif %} {# Type Badge #}
{{ media.category|upper }}
{# Actions #}
{% if not company.deletedAt and (is_granted('ROLE_ADMIN') or is_granted('ROLE_MANAGER')) %} {% endif %} Télécharger Voir