var/cache/dev/twig/0f/0f3df1a455e94db56dfae3d739ee91e6.php line 62

  1. <?php
  2. use Twig\Environment;
  3. use Twig\Error\LoaderError;
  4. use Twig\Error\RuntimeError;
  5. use Twig\Extension\SandboxExtension;
  6. use Twig\Markup;
  7. use Twig\Sandbox\SecurityError;
  8. use Twig\Sandbox\SecurityNotAllowedTagError;
  9. use Twig\Sandbox\SecurityNotAllowedFilterError;
  10. use Twig\Sandbox\SecurityNotAllowedFunctionError;
  11. use Twig\Source;
  12. use Twig\Template;
  13. /* partials/_document_upload.html.twig */
  14. class __TwigTemplate_eb73f4d32b77ae0e816878de4093ad13 extends \Twig\Template
  15. {
  16.     private $source;
  17.     private $macros = [];
  18.     public function __construct(Environment $env)
  19.     {
  20.         parent::__construct($env);
  21.         $this->source $this->getSourceContext();
  22.         $this->parent false;
  23.         $this->blocks = [
  24.         ];
  25.     }
  26.     protected function doDisplay(array $context, array $blocks = [])
  27.     {
  28.         $macros $this->macros;
  29.         $__internal_5a27a8ba21ca79b61932376b2fa922d2 $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  30.         $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template""partials/_document_upload.html.twig"));
  31.         $__internal_6f47bbe9983af81f1e7450e9a3e3768f $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  32.         $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template""partials/_document_upload.html.twig"));
  33.         // line 1
  34.         $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"));
  35.         // line 2
  36.         echo "
  37. <div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8\">
  38.     ";
  39.         // line 4
  40.         $context['_parent'] = $context;
  41.         $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); })()));
  42.         foreach ($context['_seq'] as $context["field"] => $context["config"]) {
  43.             // line 5
  44.             echo "        ";
  45.             // line 6
  46.             echo "        ";
  47.             $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"falsefalsefalse6);
  48.             // line 7
  49.             echo "        ";
  50.             $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); })()) != ""));
  51.             // line 8
  52.             echo "        ";
  53.             $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); })()));
  54.             // line 9
  55.             echo "        ";
  56.             // line 10
  57.             echo "        ";
  58.             $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"falsefalsefalse10)) . "/") . (isset($context["fileName"]) || array_key_exists("fileName"$context) ? $context["fileName"] : (function () { throw new RuntimeError('Variable "fileName" does not exist.'10$this->source); })())));
  59.             // line 11
  60.             echo "        
  61.         <div class=\"transform transition-all duration-300 hover:-translate-y-1\">
  62.             <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=\"";
  63.             // line 13
  64.             echo twig_escape_filter($this->env$context["field"], "html"nulltrue);
  65.             echo "\">
  66.                 <div class=\"flex flex-col items-center text-center\">
  67.                     <!-- Cadre d'aperçu (toujours visible) -->
  68.                     <div class=\"w-full mb-3 bg-slate-50 rounded-lg border border-slate-200 overflow-hidden\" style=\"height: 120px;\">
  69.                         <div class=\"w-full h-full flex items-center justify-center preview-container\" id=\"preview-";
  70.             // line 17
  71.             echo twig_escape_filter($this->env$context["field"], "html"nulltrue);
  72.             echo "\">
  73.                             ";
  74.             // line 18
  75.             if (((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); })()))) {
  76.                 // line 19
  77.                 echo "                                <img src=\"";
  78.                 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"nulltrue);
  79.                 echo "\" 
  80.                                      alt=\"Aperçu ";
  81.                 // line 20
  82.                 echo twig_escape_filter($this->envtwig_get_attribute($this->env$this->source$context["config"], "text", [], "any"falsefalsefalse20), "html"nulltrue);
  83.                 echo "\" 
  84.                                      class=\"w-full h-full object-contain p-1\"
  85.                                      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>'\">
  86.                             ";
  87.             } elseif ((            // line 23
  88. (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); })()))) {
  89.                 // line 24
  90.                 echo "                                ";
  91.                 // line 25
  92.                 echo "                                <div class=\"flex flex-col items-center justify-center text-slate-400\">
  93.                                     <i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i>
  94.                                     <span class=\"text-xs\">PDF</span>
  95.                                 </div>
  96.                             ";
  97.             } else {
  98.                 // line 30
  99.                 echo "                                <div class=\"flex flex-col items-center justify-center text-slate-400\">
  100.                                     <i class=\"fas fa-";
  101.                 // line 31
  102.                 echo twig_escape_filter($this->envtwig_get_attribute($this->env$this->source$context["config"], "icon", [], "any"falsefalsefalse31), "html"nulltrue);
  103.                 echo " text-3xl mb-1\"></i>
  104.                                     <span class=\"text-xs\">Aucun fichier</span>
  105.                                 </div>
  106.                             ";
  107.             }
  108.             // line 35
  109.             echo "                        </div>
  110.                     </div>
  111.                     
  112.                 ";
  113.             // line 38
  114.             echo $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"falsefalsefalse38), 'widget', ["attr" => ["class" => "hidden file-input""data-field" =>             // line 40
  115. $context["field"], "accept" => twig_get_attribute($this->env$this->source,             // line 41
  116. $context["config"], "accept", [], "any"falsefalsefalse41), "data-max-size" => "10485760""data-current-file" => ((            // line 43
  117. $context["fileName"]) ?? (""))]]);
  118.             // line 44
  119.             echo "
  120.                 ";
  121.             // line 46
  122.             echo "                    
  123.                     <label class=\"block text-sm font-semibold text-slate-700 mb-1\">
  124.                         ";
  125.             // line 48
  126.             echo twig_escape_filter($this->envtwig_get_attribute($this->env$this->source$context["config"], "text", [], "any"falsefalsefalse48), "html"nulltrue);
  127.             echo "
  128.                         <span class=\"text-xs font-normal text-slate-500 ml-1\">(";
  129.             // line 49
  130.             echo twig_escape_filter($this->envtwig_get_attribute($this->env$this->source$context["config"], "formats", [], "any"falsefalsefalse49), "html"nulltrue);
  131.             echo ")</span>
  132.                     </label>
  133.                     ";
  134.             // line 53
  135.             echo "                    ";
  136.             if ((isset($context["fileExists"]) || array_key_exists("fileExists"$context) ? $context["fileExists"] : (function () { throw new RuntimeError('Variable "fileExists" does not exist.'53$this->source); })())) {
  137.                 // line 54
  138.                 echo "                        <div class=\"mt-4 w-full\">
  139.                             <a href=\"";
  140.                 // line 55
  141.                 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.'55$this->source); })()), "html"nulltrue);
  142.                 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\">
  143.                                 <i class=\"fas fa-download mr-2\"></i> Télécharger
  144.                             </a>
  145.                         </div>
  146.                     ";
  147.             }
  148.             // line 60
  149.             echo "                </div>
  150.             </div>
  151.         </div>
  152.     ";
  153.         }
  154.         $_parent $context['_parent'];
  155.         unset($context['_seq'], $context['_iterated'], $context['field'], $context['config'], $context['_parent'], $context['loop']);
  156.         $context array_intersect_key($context$_parent) + $_parent;
  157.         // line 64
  158.         echo "</div>
  159. <script>
  160. document.addEventListener('DOMContentLoaded', function() {
  161.     // Gestion du clic sur la zone d'upload
  162.     document.querySelectorAll('.upload-area').forEach(area => {
  163.         area.addEventListener('click', function(e) {
  164.             // Ne pas déclencher si on clique sur un lien (comme le téléchargement)
  165.             if (e.target.tagName === 'A' || e.target.closest('a')) {
  166.                 return;
  167.             }
  168.             
  169.             const field = this.dataset.field;
  170.             const fileInput = document.querySelector(`.file-input[data-field=\"\${field}\"]`);
  171.             if (fileInput) {
  172.                 fileInput.click();
  173.             }
  174.         });
  175.     });
  176.     // Gestion du changement de fichier
  177.     document.querySelectorAll('.file-input').forEach(input => {
  178.         input.addEventListener('change', function(e) {
  179.             const field = this.dataset.field;
  180.             const file = e.target.files[0];
  181.             
  182.             // Vérifier la taille du fichier
  183.             if (file && file.size > parseInt(this.dataset.maxSize)) {
  184.                 alert('Le fichier dépasse la limite de ' + (parseInt(this.dataset.maxSize) / 1048576) + ' Mo.');
  185.                 this.value = '';
  186.                 return;
  187.             }
  188.             
  189.             if (file) {
  190.                 // Mettre à jour l'aperçu
  191.                 const previewContainer = document.getElementById(`preview-\${field}`);
  192.                 
  193.                 if (file.type.startsWith('image/')) {
  194.                     const reader = new FileReader();
  195.                     reader.onload = function(readerEvent) {
  196.                         previewContainer.innerHTML = `<img src=\"\${readerEvent.target.result}\" alt=\"Aperçu\" class=\"w-full h-full object-contain p-1\">`;
  197.                     }
  198.                     reader.readAsDataURL(file);
  199.                 } else {
  200.                     // Pour les PDF, afficher une icône PDF
  201.                     previewContainer.innerHTML = `
  202.                         <div class=\"flex flex-col items-center justify-center text-slate-400\">
  203.                             <i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i>
  204.                             <span class=\"text-xs\">PDF sélectionné</span>
  205.                         </div>
  206.                     `;
  207.                 }
  208.             }
  209.         });
  210.     });
  211. });
  212. </script>
  213. <style>
  214. .upload-area {
  215.     transition: all 0.3s ease;
  216.     cursor: pointer;
  217. }
  218. .upload-area:hover {
  219.     box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.1);
  220. }
  221. .preview-container {
  222.     transition: all 0.2s ease;
  223. }
  224. .upload-area:hover .preview-container {
  225.     background-color: rgba(79, 70, 229, 0.05);
  226. }
  227. /* Style pour le cadre d'aperçu */
  228. .bg-slate-50 {
  229.     background-color: #f8fafc;
  230. }
  231. .object-contain {
  232.     object-fit: contain;
  233. }
  234. </style>";
  235.         
  236.         $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  237.         
  238.         $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  239.     }
  240.     public function getTemplateName()
  241.     {
  242.         return "partials/_document_upload.html.twig";
  243.     }
  244.     public function isTraitable()
  245.     {
  246.         return false;
  247.     }
  248.     public function getDebugInfo()
  249.     {
  250.         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,);
  251.     }
  252.     public function getSourceContext()
  253.     {
  254.         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') %}
  255. <div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8\">
  256.     {% for field, config in document_labels %}
  257.         {# Récupération du nom du fichier via le getter #}
  258.         {% set fileName = attribute(candidature, field) %}
  259.         {% set fileExists = fileName is not null and fileName != '' %}
  260.         {% set isImage = fileName matches '/\\\\.(jpg|jpeg|png|gif|webp|svg)\$/i' %}
  261.         {# Déterminer l'URL du fichier existant - à adapter selon votre configuration #}
  262.         {% set fileUrl = asset('media/' ~ candidature.numero ~ '/' ~ fileName) %}
  263.         
  264.         <div class=\"transform transition-all duration-300 hover:-translate-y-1\">
  265.             <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 }}\">
  266.                 <div class=\"flex flex-col items-center text-center\">
  267.                     <!-- Cadre d'aperçu (toujours visible) -->
  268.                     <div class=\"w-full mb-3 bg-slate-50 rounded-lg border border-slate-200 overflow-hidden\" style=\"height: 120px;\">
  269.                         <div class=\"w-full h-full flex items-center justify-center preview-container\" id=\"preview-{{ field }}\">
  270.                             {% if fileExists and isImage %}
  271.                                 <img src=\"{{ fileUrl }}\" 
  272.                                      alt=\"Aperçu {{ config.text }}\" 
  273.                                      class=\"w-full h-full object-contain p-1\"
  274.                                      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>'\">
  275.                             {% elseif fileExists and not isImage %}
  276.                                 {# Pour les PDF, afficher une icône avec lien #}
  277.                                 <div class=\"flex flex-col items-center justify-center text-slate-400\">
  278.                                     <i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i>
  279.                                     <span class=\"text-xs\">PDF</span>
  280.                                 </div>
  281.                             {% else %}
  282.                                 <div class=\"flex flex-col items-center justify-center text-slate-400\">
  283.                                     <i class=\"fas fa-{{ config.icon }} text-3xl mb-1\"></i>
  284.                                     <span class=\"text-xs\">Aucun fichier</span>
  285.                                 </div>
  286.                             {% endif %}
  287.                         </div>
  288.                     </div>
  289.                     
  290.                 {{ form_widget(attribute(form, field), {'attr': {
  291.                     'class': 'hidden file-input',
  292.                     'data-field': field,
  293.                     'accept': config.accept,
  294.                     'data-max-size': '10485760',
  295.                     'data-current-file': fileName ?? ''
  296.                 }}) }}
  297.                 {# 10 Mo (à ajuster selon votre limite) #}
  298.                     
  299.                     <label class=\"block text-sm font-semibold text-slate-700 mb-1\">
  300.                         {{ config.text }}
  301.                         <span class=\"text-xs font-normal text-slate-500 ml-1\">({{ config.formats }})</span>
  302.                     </label>
  303.                     {# Lien de téléchargement pour le fichier existant (si PDF ou autre) #}
  304.                     {% if fileExists %}
  305.                         <div class=\"mt-4 w-full\">
  306.                             <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\">
  307.                                 <i class=\"fas fa-download mr-2\"></i> Télécharger
  308.                             </a>
  309.                         </div>
  310.                     {% endif %}
  311.                 </div>
  312.             </div>
  313.         </div>
  314.     {% endfor %}
  315. </div>
  316. <script>
  317. document.addEventListener('DOMContentLoaded', function() {
  318.     // Gestion du clic sur la zone d'upload
  319.     document.querySelectorAll('.upload-area').forEach(area => {
  320.         area.addEventListener('click', function(e) {
  321.             // Ne pas déclencher si on clique sur un lien (comme le téléchargement)
  322.             if (e.target.tagName === 'A' || e.target.closest('a')) {
  323.                 return;
  324.             }
  325.             
  326.             const field = this.dataset.field;
  327.             const fileInput = document.querySelector(`.file-input[data-field=\"\${field}\"]`);
  328.             if (fileInput) {
  329.                 fileInput.click();
  330.             }
  331.         });
  332.     });
  333.     // Gestion du changement de fichier
  334.     document.querySelectorAll('.file-input').forEach(input => {
  335.         input.addEventListener('change', function(e) {
  336.             const field = this.dataset.field;
  337.             const file = e.target.files[0];
  338.             
  339.             // Vérifier la taille du fichier
  340.             if (file && file.size > parseInt(this.dataset.maxSize)) {
  341.                 alert('Le fichier dépasse la limite de ' + (parseInt(this.dataset.maxSize) / 1048576) + ' Mo.');
  342.                 this.value = '';
  343.                 return;
  344.             }
  345.             
  346.             if (file) {
  347.                 // Mettre à jour l'aperçu
  348.                 const previewContainer = document.getElementById(`preview-\${field}`);
  349.                 
  350.                 if (file.type.startsWith('image/')) {
  351.                     const reader = new FileReader();
  352.                     reader.onload = function(readerEvent) {
  353.                         previewContainer.innerHTML = `<img src=\"\${readerEvent.target.result}\" alt=\"Aperçu\" class=\"w-full h-full object-contain p-1\">`;
  354.                     }
  355.                     reader.readAsDataURL(file);
  356.                 } else {
  357.                     // Pour les PDF, afficher une icône PDF
  358.                     previewContainer.innerHTML = `
  359.                         <div class=\"flex flex-col items-center justify-center text-slate-400\">
  360.                             <i class=\"fas fa-file-pdf text-4xl text-red-500 mb-1\"></i>
  361.                             <span class=\"text-xs\">PDF sélectionné</span>
  362.                         </div>
  363.                     `;
  364.                 }
  365.             }
  366.         });
  367.     });
  368. });
  369. </script>
  370. <style>
  371. .upload-area {
  372.     transition: all 0.3s ease;
  373.     cursor: pointer;
  374. }
  375. .upload-area:hover {
  376.     box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.1);
  377. }
  378. .preview-container {
  379.     transition: all 0.2s ease;
  380. }
  381. .upload-area:hover .preview-container {
  382.     background-color: rgba(79, 70, 229, 0.05);
  383. }
  384. /* Style pour le cadre d'aperçu */
  385. .bg-slate-50 {
  386.     background-color: #f8fafc;
  387. }
  388. .object-contain {
  389.     object-fit: contain;
  390. }
  391. </style>""partials/_document_upload.html.twig""/home/daip/temporaire/templates/partials/_document_upload.html.twig");
  392.     }
  393. }