<?php

use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
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;
use Twig\TemplateWrapper;

/* processing/upload_form.html.twig */
class __TwigTemplate_0fe2ff8693baa25dd91f3fc3be9ce8b8 extends Template
{
    private Source $source;
    /**
     * @var array<string, Template>
     */
    private array $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->blocks = [
            'page_title' => [$this, 'block_page_title'],
            'page_content' => [$this, 'block_page_content'],
            'javascripts' => [$this, 'block_javascripts'],
        ];
    }

    protected function doGetParent(array $context): bool|string|Template|TemplateWrapper
    {
        // line 1
        return "@AdminLTE/layout/mesodd-layout.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        $this->parent = $this->load("@AdminLTE/layout/mesodd-layout.html.twig", 1);
        yield from $this->parent->unwrap()->yield($context, array_merge($this->blocks, $blocks));
    }

    // line 3
    /**
     * @return iterable<null|scalar|\Stringable>
     */
    public function block_page_title(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        yield $this->env->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->trans("upload.title", [], "messages");
        yield from [];
    }

    // line 6
    /**
     * @return iterable<null|scalar|\Stringable>
     */
    public function block_page_content(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        // line 7
        yield "
    ";
        // line 8
        if ((($tmp = ($context["autorisation"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
            // line 9
            yield "        <div class=\"alert alert-danger\" role=\"alert\">
            Vous avez déjà soumis votre PTA à la validation du ";
            // line 10
            yield (((($tmp = ($context["showCommune"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) ? ("SE") : ("DPAF"));
            yield " de votre commune. Pour toute modification, veuillez vous rapprochez de ce dernier.
        </div>
    ";
        } else {
            // line 13
            yield "
    ";
            // line 14
            yield from $this->load("processing/upload_form.html.twig", 14, 1946383108)->unwrap()->yield($context);
            // line 36
            yield "    ";
        }
        // line 37
        yield "

    <!-- Modale de confirmation -->
    <div class=\"modal fade\" id=\"confirmationModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"confirmationModalLabel\" aria-hidden=\"true\">
    <div class=\"modal-dialog modal-lg\" role=\"document\">
        <div class=\"modal-content\">
        <div class=\"modal-header bg-danger text-light\">
            <h5 class=\"modal-title\" id=\"confirmationModalLabel\">";
        // line 44
        yield $this->env->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->trans("Confirmation de chargement", [], "messages");
        yield "</h5>
            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">
            <span aria-hidden=\"true\">&times;</span>
            </button>
        </div>
        <div class=\"modal-body\">
            ";
        // line 50
        yield $this->env->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->trans("Êtes-vous sûr de vouloir charger ce PTA ? Toutes les anciennes données liéès à un précédent programme seront perdues.", [], "messages");
        // line 51
        yield "        </div>
        <div class=\"modal-footer\">
            <button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">";
        // line 53
        yield $this->env->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->trans("Annuler", [], "messages");
        yield "</button>
            <button type=\"button\" class=\"btn btn-primary\" id=\"confirm-submit\">";
        // line 54
        yield $this->env->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->trans("Charger", [], "messages");
        yield "</button>
        </div>
        </div>
    </div>
    </div>

";
        yield from [];
    }

    // line 62
    /**
     * @return iterable<null|scalar|\Stringable>
     */
    public function block_javascripts(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        // line 63
        yield "<script>
        let \$type = \$('#upload_type');

        \$type.change(function() {
            let \$form = \$type.closest('form');

            let data = {};
            data[\$type.attr('name')] = \$type.val();

            \$.ajax({
                url: \$form.attr('action'),
                type: \$form.attr('method'),
                data: data,
                success: function(html) {
                    \$('#upload_entite').replaceWith(
                        \$(html).find('#upload_entite')
                    );
                }
            });
        });


    \$(document).on('change', '.custom-file-input', function() {
        let fileName = \$(this).val().replace(/\\\\/g, '/').replace(/.*\\//, '');
        \$(this).parent('.custom-file').find('.custom-file-label').text(fileName);
    });
</script>

<script>
    document.addEventListener('DOMContentLoaded', function () {
        // Bouton \"Soumettre\" qui affiche la modale
        const submitButton = document.getElementById('submit-button');
        const confirmButton = document.getElementById('confirm-submit');
        const form = document.getElementById('my-form');

        if (submitButton && confirmButton && form) {
            // Affiche la modale quand le bouton est cliqué
            submitButton.addEventListener('click', function () {
                const modal = new bootstrap.Modal(document.getElementById('confirmationModal'), {});
                modal.show();
            });

            // Soumet le formulaire après confirmation
            confirmButton.addEventListener('click', function () {
                form.submit(); // Soumet le formulaire
            });
        }
    });
</script>

<script>
document.addEventListener('DOMContentLoaded', function() {
    // Pour tous les inputs de type file
    document.querySelectorAll('input[type=\"file\"]').forEach(function(input) {
        input.addEventListener('change', function(e) {
            var fileName = e.target.files[0] ? e.target.files[0].name : 'Aucun fichier choisi';
            
            // Cherche le label ou crée un élément pour afficher le nom
            var label = e.target.nextElementSibling;
            if (label && label.classList.contains('custom-file-label')) {
                label.textContent = fileName;
            } else {
                // Crée un élément pour afficher le nom du fichier
                var fileNameDisplay = document.createElement('small');
                fileNameDisplay.className = 'form-text text-muted file-name-display';
                fileNameDisplay.textContent = fileName;
                
                // Supprime l'ancien affichage s'il existe
                var oldDisplay = e.target.parentNode.querySelector('.file-name-display');
                if (oldDisplay) {
                    oldDisplay.remove();
                }
                
                // Ajoute le nouvel affichage
                e.target.parentNode.appendChild(fileNameDisplay);
            }
        });
    });
});
</script>

";
        yield from [];
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName(): string
    {
        return "processing/upload_form.html.twig";
    }

    /**
     * @codeCoverageIgnore
     */
    public function isTraitable(): bool
    {
        return false;
    }

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo(): array
    {
        return array (  140 => 63,  133 => 62,  121 => 54,  117 => 53,  113 => 51,  111 => 50,  102 => 44,  93 => 37,  90 => 36,  88 => 14,  85 => 13,  79 => 10,  76 => 9,  74 => 8,  71 => 7,  64 => 6,  53 => 3,  42 => 1,);
    }

    public function getSourceContext(): Source
    {
        return new Source("", "processing/upload_form.html.twig", "/var/www/html/templates/processing/upload_form.html.twig");
    }
}


/* processing/upload_form.html.twig */
class __TwigTemplate_0fe2ff8693baa25dd91f3fc3be9ce8b8___1946383108 extends Template
{
    private Source $source;
    /**
     * @var array<string, Template>
     */
    private array $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->blocks = [
            'box_body' => [$this, 'block_box_body'],
        ];
    }

    protected function doGetParent(array $context): bool|string|Template|TemplateWrapper
    {
        // line 14
        return "@AdminLTE/Widgets/box-widget.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        $this->parent = $this->load("@AdminLTE/Widgets/box-widget.html.twig", 14);
        yield from $this->parent->unwrap()->yield($context, array_merge($this->blocks, $blocks));
    }

    // line 15
    /**
     * @return iterable<null|scalar|\Stringable>
     */
    public function block_box_body(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        // line 16
        yield "            ";
        yield         $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->renderBlock(($context["form"] ?? null), 'form_start', ["attr" => ["id" => "my-form"]]);
        yield "
                <div class=\"card-body\">    
                    ";
        // line 18
        if (($this->extensions['Symfony\Bridge\Twig\Extension\SecurityExtension']->isGranted("ROLE_MANAGER") || $this->extensions['Symfony\Bridge\Twig\Extension\SecurityExtension']->isGranted("ROLE_DDD"))) {
            // line 19
            yield "                        ";
            if ((($tmp = $this->extensions['Symfony\Bridge\Twig\Extension\SecurityExtension']->isGranted("ROLE_MANAGER")) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
                // line 20
                yield "                            ";
                yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["form"] ?? null), "type", [], "any", false, false, false, 20), 'row');
                yield "
                        ";
            }
            // line 22
            yield "                    ";
            yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["form"] ?? null), "entite", [], "any", false, false, false, 22), 'row');
            yield "
                ";
        }
        // line 24
        yield "                ";
        yield $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->searchAndRenderBlock(CoreExtension::getAttribute($this->env, $this->source, ($context["form"] ?? null), "attachment", [], "any", false, false, false, 24), 'row');
        yield "

                    <div class=\"form-group row\">
                        <div class=\"col-sm-2\"></div>
                        <div class=\"col-sm-offset-2 col-sm-10\">
                            <button type=\"button\" class=\"btn btn-block btn-primary\" id=\"submit-button\">";
        // line 29
        yield $this->env->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->trans("basics.charge", [], "messages");
        yield "</button>
                        </div>
                    </div>
                </div>
            ";
        // line 33
        yield         $this->env->getRuntime('Symfony\Component\Form\FormRenderer')->renderBlock(($context["form"] ?? null), 'form_end');
        yield "
        ";
        yield from [];
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName(): string
    {
        return "processing/upload_form.html.twig";
    }

    /**
     * @codeCoverageIgnore
     */
    public function isTraitable(): bool
    {
        return false;
    }

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo(): array
    {
        return array (  336 => 33,  329 => 29,  320 => 24,  314 => 22,  308 => 20,  305 => 19,  303 => 18,  297 => 16,  290 => 15,  279 => 14,  140 => 63,  133 => 62,  121 => 54,  117 => 53,  113 => 51,  111 => 50,  102 => 44,  93 => 37,  90 => 36,  88 => 14,  85 => 13,  79 => 10,  76 => 9,  74 => 8,  71 => 7,  64 => 6,  53 => 3,  42 => 1,);
    }

    public function getSourceContext(): Source
    {
        return new Source("", "processing/upload_form.html.twig", "/var/www/html/templates/processing/upload_form.html.twig");
    }
}
