<?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;

/* intervention/popup_validation_technique.html.twig */
class __TwigTemplate_4746e04db7e35903aa739c5b1f79abcd0651879998e510865525812d1ea60fad extends 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_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "intervention/popup_validation_technique.html.twig"));

        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "intervention/popup_validation_technique.html.twig"));

        // line 1
        yield "<div id=\"popup-validation-technique\" class=\"popup-validation-technique\" style=\"display:none;\">
    <form id=\"form-validation-technique-popup\" class=\"form form-ajax\" method=\"post\" action=\"";
        // line 2
        yield $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("validation_technique");
        yield "\" data-target-html=\"#target-show-intervention\" data-js=\"if(window.refreshAfterValidationTechnique)window.refreshAfterValidationTechnique();\">
        <input type=\"hidden\" name=\"intervention\" value=\"";
        // line 3
        yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, (isset($context["intervention"]) || array_key_exists("intervention", $context) ? $context["intervention"] : (function () { throw new RuntimeError('Variable "intervention" does not exist.', 3, $this->source); })()), "id", [], "any", false, false, false, 3), "html", null, true);
        yield "\">
        <input type=\"hidden\" name=\"utilisateur\" value=\"";
        // line 4
        yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, (isset($context["app"]) || array_key_exists("app", $context) ? $context["app"] : (function () { throw new RuntimeError('Variable "app" does not exist.', 4, $this->source); })()), "user", [], "any", false, false, false, 4), "id", [], "any", false, false, false, 4), "html", null, true);
        yield "\">
    <div class=\"font-size-13\">
        <div class=\"d-flex flex-column align-items-center mb-2\">
            <div class=\"d-flex align-items-center w-100 mb-2\">
                <label style=\"width:112px;\">Type de validation</label>
                <select name=\"interventionTypeValidation\" id=\"select-type-validation-technique\" class=\"form-control\" style=\"width:245px;\" required>
                    ";
        // line 10
        $context['_parent'] = $context;
        $context['_seq'] = CoreExtension::ensureTraversable((isset($context["typeValidations"]) || array_key_exists("typeValidations", $context) ? $context["typeValidations"] : (function () { throw new RuntimeError('Variable "typeValidations" does not exist.', 10, $this->source); })()));
        foreach ($context['_seq'] as $context["_key"] => $context["typeValidation"]) {
            // line 11
            yield "                        <option value=\"";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["typeValidation"], "id", [], "any", false, false, false, 11), "html", null, true);
            yield "\" ";
            if (((CoreExtension::getAttribute($this->env, $this->source, $context["typeValidation"], "libelleTechnique", [], "any", false, false, false, 11) === "Sensibilisation faite") || (CoreExtension::getAttribute($this->env, $this->source, $context["typeValidation"], "libelleTechnique", [], "any", false, false, false, 11) === "Sensibilisation à faire"))) {
                yield " data-show-points-controle=\"1\"";
            }
            if ((CoreExtension::getAttribute($this->env, $this->source, $context["typeValidation"], "libelleTechnique", [], "any", false, false, false, 11) === "En attente de résolution")) {
                yield " data-commentaire-required=\"1\"";
            }
            yield ">";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["typeValidation"], "libelleTechnique", [], "any", false, false, false, 11), "html", null, true);
            yield "</option>
                    ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['typeValidation'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 13
        yield "                </select>
            </div>
            ";
        // line 16
        yield "            <div id=\"block-points-controle-validation\" class=\"w-100 mb-2\" style=\"display:none;\">
                <div id=\"scrollview-points-controle\" style=\"height: 488px;\">
                <table class=\"table table-sm table-inverse-color-datagrid table-bordered mb-0 font-size-13\">
                    <thead class=\"table-light\">
                        <tr>
                            <th style=\"width:13%;\">Classification</th>
                            <th>Point de contrôle</th>
                            <th style=\"width:50px;\" class=\"text-center\"></th>
                        </tr>
                    </thead>
                    <tbody>
                        ";
        // line 27
        $context['_parent'] = $context;
        $context['_seq'] = CoreExtension::ensureTraversable(((array_key_exists("pointControlesByClassification", $context)) ? (Twig\Extension\CoreExtension::default((isset($context["pointControlesByClassification"]) || array_key_exists("pointControlesByClassification", $context) ? $context["pointControlesByClassification"] : (function () { throw new RuntimeError('Variable "pointControlesByClassification" does not exist.', 27, $this->source); })()), [])) : ([])));
        $context['_iterated'] = false;
        foreach ($context['_seq'] as $context["_key"] => $context["classification"]) {
            // line 28
            yield "                            ";
            $context['_parent'] = $context;
            $context['_seq'] = CoreExtension::ensureTraversable(CoreExtension::getAttribute($this->env, $this->source, $context["classification"], "validationTechniquePdcs", [], "any", false, false, false, 28));
            $context['loop'] = [
              'parent' => $context['_parent'],
              'index0' => 0,
              'index'  => 1,
              'first'  => true,
            ];
            if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof \Countable)) {
                $length = count($context['_seq']);
                $context['loop']['revindex0'] = $length - 1;
                $context['loop']['revindex'] = $length;
                $context['loop']['length'] = $length;
                $context['loop']['last'] = 1 === $length;
            }
            foreach ($context['_seq'] as $context["_key"] => $context["pdc"]) {
                // line 29
                yield "                                <tr>
                                    ";
                // line 30
                if (CoreExtension::getAttribute($this->env, $this->source, $context["loop"], "first", [], "any", false, false, false, 30)) {
                    // line 31
                    yield "                                        <td rowspan=\"";
                    yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(Twig\Extension\CoreExtension::length($this->env->getCharset(), CoreExtension::getAttribute($this->env, $this->source, $context["classification"], "validationTechniquePdcs", [], "any", false, false, false, 31)), "html", null, true);
                    yield "\" class=\"align-top\">";
                    yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["classification"], "libelle", [], "any", false, false, false, 31), "html", null, true);
                    yield "</td>
                                    ";
                }
                // line 33
                yield "                                    <td>
                                        ";
                // line 34
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["pdc"], "annotation", [], "any", false, false, false, 34), "html", null, true);
                yield "
                                        ";
                // line 35
                if (CoreExtension::getAttribute($this->env, $this->source, $context["pdc"], "complement", [], "any", false, false, false, 35)) {
                    // line 36
                    yield "                                            <div class=\"text-danger small mt-1\"><i class=\"fa fa-exclamation-triangle me-1\"></i>";
                    yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["pdc"], "complement", [], "any", false, false, false, 36), "html", null, true);
                    yield "</div>
                                        ";
                }
                // line 38
                yield "                                    </td>
                                    <td class=\"text-center align-middle\">
                                        <input type=\"checkbox\" name=\"point_controle_ids[]\" value=\"";
                // line 40
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["pdc"], "id", [], "any", false, false, false, 40), "html", null, true);
                yield "\" class=\"form-check-input\" aria-label=\"Sélectionner\">
                                    </td>
                                </tr>
                            ";
                ++$context['loop']['index0'];
                ++$context['loop']['index'];
                $context['loop']['first'] = false;
                if (isset($context['loop']['length'])) {
                    --$context['loop']['revindex0'];
                    --$context['loop']['revindex'];
                    $context['loop']['last'] = 0 === $context['loop']['revindex0'];
                }
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['pdc'], $context['_parent'], $context['loop']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 44
            yield "                        ";
            $context['_iterated'] = true;
        }
        if (!$context['_iterated']) {
            // line 45
            yield "                            <tr><td colspan=\"3\" class=\"text-muted\">Aucun point de contrôle configuré.</td></tr>
                        ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['classification'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 47
        yield "                    </tbody>
                </table>
                </div>
            </div>
            <div class=\"d-flex align-items-center w-100\">
                <label for=\"commentaire-validation-technique\" style=\"width:112px;\">Commentaires</label>
                <textarea id=\"commentaire-validation-technique\" name=\"commentaire_technique\" style=\"height:85px;min-width:489px;width:100%;text-align: left\" class=\"form-control\" aria-describedby=\"commentaire-required-hint\"></textarea>
            </div>
        </div>
        <div class=\"row\">
            <div class=\"col-12 d-flex justify-content-center\">
                <button type=\"button\" class=\"btn btn-outline-danger me-3 btn-close-popup\"  data-dxpopup-id=\"popup-validation-technique\" style=\"width: 164px;\">Annuler</button>
                <button type=\"submit\" class=\"btn btn-outline-success\" id=\"btn-valider-technique\" style=\"width: 164px;\">Valider</button>
            </div>
        </div>
    </div>
    </form>
</div>
<script>
(function() {
    var pictoValideUrl = ";
        // line 67
        yield json_encode($this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("build/images/picto-intervention-valide.png"));
        yield ";
    var pictoSensibilisationUrl = ";
        // line 68
        yield json_encode($this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("build/images/picto-intervention-sensibilisation.png"));
        yield ";
    var pictoWarningUrl = ";
        // line 69
        yield json_encode($this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("build/images/picto-intervention-warning.png"));
        yield ";
    window._lastValidationTechniqueLabel = window._lastValidationTechniqueLabel || null;
    window.refreshAfterValidationTechnique = function() {
        var \$a = \$('.list-group-item.show_validation.active');
        var \$p = \$('#popup-validation-technique');
        if (\$p.data('dxPopup')) { \$p.dxPopup('instance').hide(); }
        if (\$a.length) {
            var libelle = window._lastValidationTechniqueLabel;
            var pictoUrl = pictoValideUrl;
            if (libelle === 'Sensibilisation à faire') {
                pictoUrl = pictoSensibilisationUrl;
            } else if (libelle === 'En attente de résolution') {
                pictoUrl = pictoWarningUrl;
            }
            \$a.find('img[src*=\\\"picto-intervention-\\\"]').attr('src', pictoUrl);
            \$a.trigger('click');
        }
    };
})();
(function() {
    var select = document.getElementById('select-type-validation-technique');
    var block = document.getElementById('block-points-controle-validation');
    if (select && block) {
        var scrollViewContainer = document.getElementById('scrollview-points-controle');
        var commentaireTextarea = document.getElementById('commentaire-validation-technique');
        function togglePointsControle() {
            var opt = select.options[select.selectedIndex];
            window._lastValidationTechniqueLabel = opt ? (opt.text || '').trim() : null;
            var show = opt && opt.getAttribute('data-show-points-controle') === '1';
            var commentaireRequired = opt && opt.getAttribute('data-commentaire-required') === '1';
            block.style.display = show ? 'block' : 'none';
            if (commentaireTextarea) {
                commentaireTextarea.required = !!commentaireRequired;
            }
            var \$scrollView = \$('#scrollview-points-controle');
            if (show && scrollViewContainer) {
                if (!\$scrollView.data('dxScrollView')) {
                    \$scrollView.dxScrollView({
                        height: 488,
                        scrollByContent: true,
                        scrollByThumb: true,
                        useNative: false,
                        width: '100%'
                    });
                }
            }
            /* Ne pas disposer le ScrollView au masquage : DevExtreme vide le conteneur et les points de contrôle ne réapparaissent plus au retour sur \"Sensibilisation à faire\". On garde le widget et on se contente de masquer le bloc. */
            var \$popup = \$('#popup-validation-technique');
            if (\$popup.length && \$popup.data('dxPopup')) {
                var popup = \$popup.dxPopup('instance');
                popup.option('width', 'auto');
                popup.option('maxWidth', show ? 1274 : undefined);
                popup.repaint();
                if (show) {
                    requestAnimationFrame(function() {
                        requestAnimationFrame(function() { popup.repaint(); });
                    });
                }
            }
        }
        select.addEventListener('change', togglePointsControle);
        togglePointsControle();
    }
})();
</script>";
        
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);

        
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);

        return; yield '';
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName()
    {
        return "intervention/popup_validation_technique.html.twig";
    }

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

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo()
    {
        return array (  218 => 69,  214 => 68,  210 => 67,  188 => 47,  181 => 45,  176 => 44,  158 => 40,  154 => 38,  148 => 36,  146 => 35,  142 => 34,  139 => 33,  131 => 31,  129 => 30,  126 => 29,  108 => 28,  103 => 27,  90 => 16,  86 => 13,  68 => 11,  64 => 10,  55 => 4,  51 => 3,  47 => 2,  44 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("<div id=\"popup-validation-technique\" class=\"popup-validation-technique\" style=\"display:none;\">
    <form id=\"form-validation-technique-popup\" class=\"form form-ajax\" method=\"post\" action=\"{{ path('validation_technique') }}\" data-target-html=\"#target-show-intervention\" data-js=\"if(window.refreshAfterValidationTechnique)window.refreshAfterValidationTechnique();\">
        <input type=\"hidden\" name=\"intervention\" value=\"{{ intervention.id }}\">
        <input type=\"hidden\" name=\"utilisateur\" value=\"{{ app.user.id }}\">
    <div class=\"font-size-13\">
        <div class=\"d-flex flex-column align-items-center mb-2\">
            <div class=\"d-flex align-items-center w-100 mb-2\">
                <label style=\"width:112px;\">Type de validation</label>
                <select name=\"interventionTypeValidation\" id=\"select-type-validation-technique\" class=\"form-control\" style=\"width:245px;\" required>
                    {% for typeValidation in typeValidations %}
                        <option value=\"{{ typeValidation.id }}\" {% if typeValidation.libelleTechnique is same as('Sensibilisation faite') or typeValidation.libelleTechnique is same as('Sensibilisation à faire') %} data-show-points-controle=\"1\"{% endif %}{% if typeValidation.libelleTechnique is same as('En attente de résolution') %} data-commentaire-required=\"1\"{% endif %}>{{ typeValidation.libelleTechnique }}</option>
                    {% endfor %}
                </select>
            </div>
            {# Liste des points de contrôle (affichée uniquement pour \"Sensibilisation à faire\") #}
            <div id=\"block-points-controle-validation\" class=\"w-100 mb-2\" style=\"display:none;\">
                <div id=\"scrollview-points-controle\" style=\"height: 488px;\">
                <table class=\"table table-sm table-inverse-color-datagrid table-bordered mb-0 font-size-13\">
                    <thead class=\"table-light\">
                        <tr>
                            <th style=\"width:13%;\">Classification</th>
                            <th>Point de contrôle</th>
                            <th style=\"width:50px;\" class=\"text-center\"></th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for classification in pointControlesByClassification|default([]) %}
                            {% for pdc in classification.validationTechniquePdcs %}
                                <tr>
                                    {% if loop.first %}
                                        <td rowspan=\"{{ classification.validationTechniquePdcs|length }}\" class=\"align-top\">{{ classification.libelle }}</td>
                                    {% endif %}
                                    <td>
                                        {{ pdc.annotation }}
                                        {% if pdc.complement %}
                                            <div class=\"text-danger small mt-1\"><i class=\"fa fa-exclamation-triangle me-1\"></i>{{ pdc.complement }}</div>
                                        {% endif %}
                                    </td>
                                    <td class=\"text-center align-middle\">
                                        <input type=\"checkbox\" name=\"point_controle_ids[]\" value=\"{{ pdc.id }}\" class=\"form-check-input\" aria-label=\"Sélectionner\">
                                    </td>
                                </tr>
                            {% endfor %}
                        {% else %}
                            <tr><td colspan=\"3\" class=\"text-muted\">Aucun point de contrôle configuré.</td></tr>
                        {% endfor %}
                    </tbody>
                </table>
                </div>
            </div>
            <div class=\"d-flex align-items-center w-100\">
                <label for=\"commentaire-validation-technique\" style=\"width:112px;\">Commentaires</label>
                <textarea id=\"commentaire-validation-technique\" name=\"commentaire_technique\" style=\"height:85px;min-width:489px;width:100%;text-align: left\" class=\"form-control\" aria-describedby=\"commentaire-required-hint\"></textarea>
            </div>
        </div>
        <div class=\"row\">
            <div class=\"col-12 d-flex justify-content-center\">
                <button type=\"button\" class=\"btn btn-outline-danger me-3 btn-close-popup\"  data-dxpopup-id=\"popup-validation-technique\" style=\"width: 164px;\">Annuler</button>
                <button type=\"submit\" class=\"btn btn-outline-success\" id=\"btn-valider-technique\" style=\"width: 164px;\">Valider</button>
            </div>
        </div>
    </div>
    </form>
</div>
<script>
(function() {
    var pictoValideUrl = {{ asset('build/images/picto-intervention-valide.png')|json_encode|raw }};
    var pictoSensibilisationUrl = {{ asset('build/images/picto-intervention-sensibilisation.png')|json_encode|raw }};
    var pictoWarningUrl = {{ asset('build/images/picto-intervention-warning.png')|json_encode|raw }};
    window._lastValidationTechniqueLabel = window._lastValidationTechniqueLabel || null;
    window.refreshAfterValidationTechnique = function() {
        var \$a = \$('.list-group-item.show_validation.active');
        var \$p = \$('#popup-validation-technique');
        if (\$p.data('dxPopup')) { \$p.dxPopup('instance').hide(); }
        if (\$a.length) {
            var libelle = window._lastValidationTechniqueLabel;
            var pictoUrl = pictoValideUrl;
            if (libelle === 'Sensibilisation à faire') {
                pictoUrl = pictoSensibilisationUrl;
            } else if (libelle === 'En attente de résolution') {
                pictoUrl = pictoWarningUrl;
            }
            \$a.find('img[src*=\\\"picto-intervention-\\\"]').attr('src', pictoUrl);
            \$a.trigger('click');
        }
    };
})();
(function() {
    var select = document.getElementById('select-type-validation-technique');
    var block = document.getElementById('block-points-controle-validation');
    if (select && block) {
        var scrollViewContainer = document.getElementById('scrollview-points-controle');
        var commentaireTextarea = document.getElementById('commentaire-validation-technique');
        function togglePointsControle() {
            var opt = select.options[select.selectedIndex];
            window._lastValidationTechniqueLabel = opt ? (opt.text || '').trim() : null;
            var show = opt && opt.getAttribute('data-show-points-controle') === '1';
            var commentaireRequired = opt && opt.getAttribute('data-commentaire-required') === '1';
            block.style.display = show ? 'block' : 'none';
            if (commentaireTextarea) {
                commentaireTextarea.required = !!commentaireRequired;
            }
            var \$scrollView = \$('#scrollview-points-controle');
            if (show && scrollViewContainer) {
                if (!\$scrollView.data('dxScrollView')) {
                    \$scrollView.dxScrollView({
                        height: 488,
                        scrollByContent: true,
                        scrollByThumb: true,
                        useNative: false,
                        width: '100%'
                    });
                }
            }
            /* Ne pas disposer le ScrollView au masquage : DevExtreme vide le conteneur et les points de contrôle ne réapparaissent plus au retour sur \"Sensibilisation à faire\". On garde le widget et on se contente de masquer le bloc. */
            var \$popup = \$('#popup-validation-technique');
            if (\$popup.length && \$popup.data('dxPopup')) {
                var popup = \$popup.dxPopup('instance');
                popup.option('width', 'auto');
                popup.option('maxWidth', show ? 1274 : undefined);
                popup.repaint();
                if (show) {
                    requestAnimationFrame(function() {
                        requestAnimationFrame(function() { popup.repaint(); });
                    });
                }
            }
        }
        select.addEventListener('change', togglePointsControle);
        togglePointsControle();
    }
})();
</script>", "intervention/popup_validation_technique.html.twig", "/builds/dev/refonte_sav/templates/intervention/popup_validation_technique.html.twig");
    }
}
