var/cache/dev/twig/0f/0f3df1a455e94db56dfae3d739ee91e6.php line 62
<?phpuse Twig\Environment;use Twig\Error\LoaderError;use Twig\Error\RuntimeError;use Twig\Extension\SandboxExtension;use Twig\Markup;use Twig\Sandbox\SecurityError;use Twig\Sandbox\SecurityNotAllowedTagError;use Twig\Sandbox\SecurityNotAllowedFilterError;use Twig\Sandbox\SecurityNotAllowedFunctionError;use Twig\Source;use Twig\Template;/* partials/_document_upload.html.twig */class __TwigTemplate_eb73f4d32b77ae0e816878de4093ad13 extends \Twig\Template{private $source;private $macros = [];public function __construct(Environment $env){parent::__construct($env);$this->source = $this->getSourceContext();$this->parent = false;$this->blocks = [];}protected function doDisplay(array $context, array $blocks = []){$macros = $this->macros;$__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];$__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "partials/_document_upload.html.twig"));$__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];$__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "partials/_document_upload.html.twig"));// line 1$context["input_class"] = ((array_key_exists("input_class", $context)) ? (_twig_default_filter((isset($context["input_class"]) || array_key_exists("input_class", $context) ? $context["input_class"] : (function () { throw new RuntimeError('Variable "input_class" does not exist.', 1, $this->source); })()), "w-full px-4 py-2 rounded-lg border border-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition")) : ("w-full px-4 py-2 rounded-lg border border-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition"));// line 2echo "<div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8\">";// line 4$context['_parent'] = $context;$context['_seq'] = twig_ensure_traversable((isset($context["document_labels"]) || array_key_exists("document_labels", $context) ? $context["document_labels"] : (function () { throw new RuntimeError('Variable "document_labels" does not exist.', 4, $this->source); })()));foreach ($context['_seq'] as $context["field"] => $context["config"]) {// line 5echo " ";// line 6echo " ";$context["fileName"] = twig_get_attribute($this->env, $this->source, (isset($context["candidature"]) || array_key_exists("candidature", $context) ? $context["candidature"] : (function () { throw new RuntimeError('Variable "candidature" does not exist.', 6, $this->source); })()), $context["field"], [], "any", false, false, false, 6);// line 7echo " ";$context["fileExists"] = ( !(null === (isset($context["fileName"]) || array_key_exists("fileName", $context) ? $context["fileName"] : (function () { throw new RuntimeError('Variable "fileName" does not exist.', 7, $this->source); })())) && ((isset($context["fileName"]) || array_key_exists("fileName", $context) ? $context["fileName"] : (function () { throw new RuntimeError('Variable "fileName" does not exist.', 7, $this->source); })()) != ""));// line 8echo " ";$context["isImage"] = preg_match("/\\.(jpg|jpeg|png|gif|webp|svg)\$/i", (isset($context["fileName"]) || array_key_exists("fileName", $context) ? $context["fileName"] : (function () { throw new RuntimeError('Variable "fileName" does not exist.', 8, $this->source); })()));// line 9echo " ";// line 10echo " ";$context["fileUrl"] = $this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl(((("media/" . twig_get_attribute($this->env, $this->source, (isset($context["candidature"]) || array_key_exists("candidature", $context) ? $context["candidature"] : (function () { throw new RuntimeError('Variable "candidature" does not exist.', 10, $this->source); })()), "numero", [], "any", false, false, false, 10)) . "/") . (isset($context["fileName"]) || array_key_exists("fileName", $context) ? $context["fileName"] : (function () { throw new RuntimeError('Variable "fileName" does not exist.', 10, $this->source); })())));// line 11echo "<div class=\"transform transition-all duration-300 hover:-translate-y-1\"><div class=\"bg-white rounded-xl p-5 border-2 border-dashed border-slate-200 hover:border-indigo-400 hover:bg-indigo-50/30 transition-all group cursor-pointer upload-area\" data-field=\"";// line 13echo twig_escape_filter($this->env, $context["field"], "html", null, true);echo "\"><div class=\"flex flex-col items-center text-center\"><!-- Cadre d'aperçu (toujours visible) --><div class=\"w-full mb-3 bg-slate-50 rounded-lg border border-slate-200 overflow-hidden\" style=\"height: 120px;\"><div class=\"w-full h-full flex items-center justify-center preview-container\" id=\"preview-";// line 17echo twig_escape_filter($this->env, $context["field"], "html", null, true);echo "\">";// line 18if (((isset($context["fileExists"]) || array_key_exists("fileExists", $context) ? $context["fileExists"] : (function () { throw new RuntimeError('Variable "fileExists" does not exist.', 18, $this->source); })()) && (isset($context["isImage"]) || array_key_exists("isImage", $context) ? $context["isImage"] : (function () { throw new RuntimeError('Variable "isImage" does not exist.', 18, $this->source); })()))) {// line 19echo " <img src=\"";echo twig_escape_filter($this->env, (isset($context["fileUrl"]) || array_key_exists("fileUrl", $context) ? $context["fileUrl"] : (function () { throw new RuntimeError('Variable "fileUrl" does not exist.', 19, $this->source); })()), "html", null, true);echo "\"alt=\"Aperçu ";// line 20echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["config"], "text", [], "any", false, false, false, 20), "html", null, true);echo "\"class=\"w-full h-full object-contain p-1\"onerror=\"this.parentElement.innerHTML = '<i class=\\'fas fa-exclamation-triangle text-red-500 text-2xl\\'></i><span class=\\'text-xs text-red-500 ml-1\\'>Erreur</span>'\">";} elseif (( // line 23(isset($context["fileExists"]) || array_key_exists("fileExists", $context) ? $context["fileExists"] : (function () { throw new RuntimeError('Variable "fileExists" does not exist.', 23, $this->source); })()) && !(isset($context["isImage"]) || array_key_exists("isImage", $context) ? $context["isImage"] : (function () { throw new RuntimeError('Variable "isImage" does not exist.', 23, $this->source); })()))) {// line 24echo " ";// line 25echo " <div class=\"flex flex-col items-center justify-center text-slate-400\"><i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i><span class=\"text-xs\">PDF</span></div>";} else {// line 30echo " <div class=\"flex flex-col items-center justify-center text-slate-400\"><i class=\"fas fa-";// line 31echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["config"], "icon", [], "any", false, false, false, 31), "html", null, true);echo " text-3xl mb-1\"></i><span class=\"text-xs\">Aucun fichier</span></div>";}// line 35echo " </div></div>";// line 38echo $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(twig_get_attribute($this->env, $this->source, (isset($context["form"]) || array_key_exists("form", $context) ? $context["form"] : (function () { throw new RuntimeError('Variable "form" does not exist.', 38, $this->source); })()), $context["field"], [], "any", false, false, false, 38), 'widget', ["attr" => ["class" => "hidden file-input", "data-field" => // line 40$context["field"], "accept" => twig_get_attribute($this->env, $this->source, // line 41$context["config"], "accept", [], "any", false, false, false, 41), "data-max-size" => "10485760", "data-current-file" => (( // line 43$context["fileName"]) ?? (""))]]);// line 44echo "";// line 46echo "<label class=\"block text-sm font-semibold text-slate-700 mb-1\">";// line 48echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["config"], "text", [], "any", false, false, false, 48), "html", null, true);echo "<span class=\"text-xs font-normal text-slate-500 ml-1\">(";// line 49echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["config"], "formats", [], "any", false, false, false, 49), "html", null, true);echo ")</span></label>";// line 53echo " ";if ((isset($context["fileExists"]) || array_key_exists("fileExists", $context) ? $context["fileExists"] : (function () { throw new RuntimeError('Variable "fileExists" does not exist.', 53, $this->source); })())) {// line 54echo " <div class=\"mt-4 w-full\"><a href=\"";// line 55echo twig_escape_filter($this->env, (isset($context["fileUrl"]) || array_key_exists("fileUrl", $context) ? $context["fileUrl"] : (function () { throw new RuntimeError('Variable "fileUrl" does not exist.', 55, $this->source); })()), "html", null, true);echo "\" target=\"_blank\" class=\"inline-flex items-center justify-center w-full sm:w-auto px-4 py-2.5 rounded-lg bg-indigo-600 text-white text-sm font-semibold hover:bg-indigo-700 transition shadow-sm hover:shadow focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2\"><i class=\"fas fa-download mr-2\"></i> Télécharger</a></div>";}// line 60echo " </div></div></div>";}$_parent = $context['_parent'];unset($context['_seq'], $context['_iterated'], $context['field'], $context['config'], $context['_parent'], $context['loop']);$context = array_intersect_key($context, $_parent) + $_parent;// line 64echo "</div><script>document.addEventListener('DOMContentLoaded', function() {// Gestion du clic sur la zone d'uploaddocument.querySelectorAll('.upload-area').forEach(area => {area.addEventListener('click', function(e) {// Ne pas déclencher si on clique sur un lien (comme le téléchargement)if (e.target.tagName === 'A' || e.target.closest('a')) {return;}const field = this.dataset.field;const fileInput = document.querySelector(`.file-input[data-field=\"\${field}\"]`);if (fileInput) {fileInput.click();}});});// Gestion du changement de fichierdocument.querySelectorAll('.file-input').forEach(input => {input.addEventListener('change', function(e) {const field = this.dataset.field;const file = e.target.files[0];// Vérifier la taille du fichierif (file && file.size > parseInt(this.dataset.maxSize)) {alert('Le fichier dépasse la limite de ' + (parseInt(this.dataset.maxSize) / 1048576) + ' Mo.');this.value = '';return;}if (file) {// Mettre à jour l'aperçuconst previewContainer = document.getElementById(`preview-\${field}`);if (file.type.startsWith('image/')) {const reader = new FileReader();reader.onload = function(readerEvent) {previewContainer.innerHTML = `<img src=\"\${readerEvent.target.result}\" alt=\"Aperçu\" class=\"w-full h-full object-contain p-1\">`;}reader.readAsDataURL(file);} else {// Pour les PDF, afficher une icône PDFpreviewContainer.innerHTML = `<div class=\"flex flex-col items-center justify-center text-slate-400\"><i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i><span class=\"text-xs\">PDF sélectionné</span></div>`;}}});});});</script><style>.upload-area {transition: all 0.3s ease;cursor: pointer;}.upload-area:hover {box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.1);}.preview-container {transition: all 0.2s ease;}.upload-area:hover .preview-container {background-color: rgba(79, 70, 229, 0.05);}/* Style pour le cadre d'aperçu */.bg-slate-50 {background-color: #f8fafc;}.object-contain {object-fit: contain;}</style>";$__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);$__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);}public function getTemplateName(){return "partials/_document_upload.html.twig";}public function isTraitable(){return false;}public function getDebugInfo(){return array ( 168 => 64, 159 => 60, 151 => 55, 148 => 54, 145 => 53, 139 => 49, 135 => 48, 131 => 46, 128 => 44, 126 => 43, 125 => 41, 124 => 40, 123 => 38, 118 => 35, 111 => 31, 108 => 30, 101 => 25, 99 => 24, 97 => 23, 91 => 20, 86 => 19, 84 => 18, 80 => 17, 73 => 13, 69 => 11, 66 => 10, 64 => 9, 61 => 8, 58 => 7, 55 => 6, 53 => 5, 49 => 4, 45 => 2, 43 => 1,);}public function getSourceContext(){return new Source("{% set input_class = input_class|default('w-full px-4 py-2 rounded-lg border border-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition') %}<div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8\">{% for field, config in document_labels %}{# Récupération du nom du fichier via le getter #}{% set fileName = attribute(candidature, field) %}{% set fileExists = fileName is not null and fileName != '' %}{% set isImage = fileName matches '/\\\\.(jpg|jpeg|png|gif|webp|svg)\$/i' %}{# Déterminer l'URL du fichier existant - à adapter selon votre configuration #}{% set fileUrl = asset('media/' ~ candidature.numero ~ '/' ~ fileName) %}<div class=\"transform transition-all duration-300 hover:-translate-y-1\"><div class=\"bg-white rounded-xl p-5 border-2 border-dashed border-slate-200 hover:border-indigo-400 hover:bg-indigo-50/30 transition-all group cursor-pointer upload-area\" data-field=\"{{ field }}\"><div class=\"flex flex-col items-center text-center\"><!-- Cadre d'aperçu (toujours visible) --><div class=\"w-full mb-3 bg-slate-50 rounded-lg border border-slate-200 overflow-hidden\" style=\"height: 120px;\"><div class=\"w-full h-full flex items-center justify-center preview-container\" id=\"preview-{{ field }}\">{% if fileExists and isImage %}<img src=\"{{ fileUrl }}\"alt=\"Aperçu {{ config.text }}\"class=\"w-full h-full object-contain p-1\"onerror=\"this.parentElement.innerHTML = '<i class=\\'fas fa-exclamation-triangle text-red-500 text-2xl\\'></i><span class=\\'text-xs text-red-500 ml-1\\'>Erreur</span>'\">{% elseif fileExists and not isImage %}{# Pour les PDF, afficher une icône avec lien #}<div class=\"flex flex-col items-center justify-center text-slate-400\"><i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i><span class=\"text-xs\">PDF</span></div>{% else %}<div class=\"flex flex-col items-center justify-center text-slate-400\"><i class=\"fas fa-{{ config.icon }} text-3xl mb-1\"></i><span class=\"text-xs\">Aucun fichier</span></div>{% endif %}</div></div>{{ form_widget(attribute(form, field), {'attr': {'class': 'hidden file-input','data-field': field,'accept': config.accept,'data-max-size': '10485760','data-current-file': fileName ?? ''}}) }}{# 10 Mo (à ajuster selon votre limite) #}<label class=\"block text-sm font-semibold text-slate-700 mb-1\">{{ config.text }}<span class=\"text-xs font-normal text-slate-500 ml-1\">({{ config.formats }})</span></label>{# Lien de téléchargement pour le fichier existant (si PDF ou autre) #}{% if fileExists %}<div class=\"mt-4 w-full\"><a href=\"{{ fileUrl }}\" target=\"_blank\" class=\"inline-flex items-center justify-center w-full sm:w-auto px-4 py-2.5 rounded-lg bg-indigo-600 text-white text-sm font-semibold hover:bg-indigo-700 transition shadow-sm hover:shadow focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2\"><i class=\"fas fa-download mr-2\"></i> Télécharger</a></div>{% endif %}</div></div></div>{% endfor %}</div><script>document.addEventListener('DOMContentLoaded', function() {// Gestion du clic sur la zone d'uploaddocument.querySelectorAll('.upload-area').forEach(area => {area.addEventListener('click', function(e) {// Ne pas déclencher si on clique sur un lien (comme le téléchargement)if (e.target.tagName === 'A' || e.target.closest('a')) {return;}const field = this.dataset.field;const fileInput = document.querySelector(`.file-input[data-field=\"\${field}\"]`);if (fileInput) {fileInput.click();}});});// Gestion du changement de fichierdocument.querySelectorAll('.file-input').forEach(input => {input.addEventListener('change', function(e) {const field = this.dataset.field;const file = e.target.files[0];// Vérifier la taille du fichierif (file && file.size > parseInt(this.dataset.maxSize)) {alert('Le fichier dépasse la limite de ' + (parseInt(this.dataset.maxSize) / 1048576) + ' Mo.');this.value = '';return;}if (file) {// Mettre à jour l'aperçuconst previewContainer = document.getElementById(`preview-\${field}`);if (file.type.startsWith('image/')) {const reader = new FileReader();reader.onload = function(readerEvent) {previewContainer.innerHTML = `<img src=\"\${readerEvent.target.result}\" alt=\"Aperçu\" class=\"w-full h-full object-contain p-1\">`;}reader.readAsDataURL(file);} else {// Pour les PDF, afficher une icône PDFpreviewContainer.innerHTML = `<div class=\"flex flex-col items-center justify-center text-slate-400\"><i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i><span class=\"text-xs\">PDF sélectionné</span></div>`;}}});});});</script><style>.upload-area {transition: all 0.3s ease;cursor: pointer;}.upload-area:hover {box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.1);}.preview-container {transition: all 0.2s ease;}.upload-area:hover .preview-container {background-color: rgba(79, 70, 229, 0.05);}/* Style pour le cadre d'aperçu */.bg-slate-50 {background-color: #f8fafc;}.object-contain {object-fit: contain;}</style>", "partials/_document_upload.html.twig", "/home/daip/temporaire/templates/partials/_document_upload.html.twig");}}