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

/* produit/_produit_photos.html.twig */
class __TwigTemplate_b9ce26c990add19e3aa8b53325d4379c17b28e5f49eb05f07c4016f1290f4c37 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", "produit/_produit_photos.html.twig"));

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

        // line 1
        yield "
<div class=\"p-3\">

    <div class=\"messages\">
        ";
        // line 5
        if (array_key_exists("message", $context)) {
            // line 6
            yield "            ";
            // line 7
            yield "            <div class=\"alert alert-dismissible alert-success fade show\" role=\"alert\">
                ";
            // line 8
            yield (isset($context["message"]) || array_key_exists("message", $context) ? $context["message"] : (function () { throw new RuntimeError('Variable "message" does not exist.', 8, $this->source); })());
            yield "
                <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\" style=\"opacity:1\"></button>
            </div>
        ";
        }
        // line 12
        yield "    </div>
    <div class=\"col pb-4\" style=\"padding-right:2rem;position:relative\">
        <div class=\"progress mb-2 hide\" >
            <div class=\"progress-bar progress-bar-striped\" style=\"min-width: 20px;\"></div>
        </div>
        ";
        // line 17
        if ( !Twig\Extension\CoreExtension::testEmpty((isset($context["datas"]) || array_key_exists("datas", $context) ? $context["datas"] : (function () { throw new RuntimeError('Variable "datas" does not exist.', 17, $this->source); })()))) {
            // line 18
            yield "            <table class=\"table table-lg table-bordered\" style=\"min-width:400px\">
                <thead>
                <th>Nom Fichier</th>
                <th>Photo Principale?</th>
                <th>Action</th>
                </thead>
                <tbody>
                ";
            // line 25
            $context['_parent'] = $context;
            $context['_seq'] = CoreExtension::ensureTraversable((isset($context["datas"]) || array_key_exists("datas", $context) ? $context["datas"] : (function () { throw new RuntimeError('Variable "datas" does not exist.', 25, $this->source); })()));
            foreach ($context['_seq'] as $context["_key"] => $context["data"]) {
                // line 26
                yield "                    <tr>
                        <td><a data-popup-id=\"popup_photo\" data-poppup-container=\"body\" data-popup-title=\"Photo\" data-popup-width =\"auto\" data-dxpopup=\"\"  data-content-template-ajax=\"/produit_photos/photo/";
                // line 27
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["data"], "id", [], "any", false, false, false, 27), "html", null, true);
                yield "\">";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["data"], "nom", [], "any", false, false, false, 27), "html", null, true);
                yield "</a></td>
                        <td align=\"middle\"> <i class=\"produit-photo-principale fas fa-lg fa-check ";
                // line 28
                yield (((0 === CoreExtension::compare(CoreExtension::getAttribute($this->env, $this->source, $context["data"], "photoprincipale", [], "any", false, false, false, 28), 0))) ? ("fa-unselected") : ("selected"));
                yield "\" data-id=\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["data"], "id", [], "any", false, false, false, 28), "html", null, true);
                yield "\" style=\"cursor: pointer\"></i></td>
                        <td align=\"middle\"><i class=\"produit-photo-delete fas fa-trash fa-lg\" data-id=\"";
                // line 29
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["data"], "id", [], "any", false, false, false, 29), "html", null, true);
                yield "\"></i></td>
                    </tr>
                ";
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['data'], $context['_parent'], $context['loop']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 32
            yield "                </tbody>
            </table>
        ";
        }
        // line 35
        yield "        <div id=\"upload-photo\" class=\"btn btn-success\" style=\"width: 300px;\"></div>
    </div>
    <div class=\"form-group d-flex justify-content-center mt-4\">
        <div class=\"form-actions-row\">
            <button class=\"btn btn-danger btn-close-popup\" data-dxpopup-id=\"popup_cell\" style=\"background-color: white;color: #e74c3c;\">Fermer</button>
        </div>
    </div>
</div>
<script type=\"module\">
    var idProduit = '";
        // line 44
        yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(((array_key_exists("id", $context)) ? (Twig\Extension\CoreExtension::default((isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 44, $this->source); })()), null)) : (null)), "html", null, true);
        yield "';
    var url =\"/produit_photos/\" +idProduit;
    \$('#upload-photo').dxFileUploader({
        multiple: false,
        accept: \"image/*\",
        uploadMode: \"instantly\",
        uploadMethod: 'POST',
        labelText : '',
        progress: 1,
        showFileList: false,
        selectButtonText : \"+ Ajouter un ou plusieurs fichiers\",
        uploadUrl:  \"/patch/produit_type/\" +idProduit,
        onUploaded: function (e) {
            \$('.progress').addClass('hide').removeClass('show');
            e.component.__uploadedFilesCount++;
            if (e.component.option(\"value\").length === e.component.__uploadedFilesCount) {
                e.component.reset();
                e.component.__uploadedFilesCount = null;
                \$('#popup_cell').dxPopup(\"instance\").option(\"contentTemplate\", e.request.response);
            }
           var linkParent = \$('a[data-content-template-ajax=\"'+url+'\"]');
            if (\$(linkParent).children('i').hasClass('fa-plus-circle')) {
                \$(linkParent).children('i').removeClass('fa-plus-circle').addClass('fa-edit');
            }
        },
        onProgress: function(e) {
            var percent = e.component.option(\"progress\");
            \$('.progress').addClass('show').removeClass('hide');
            \$(\".progress-bar\").css(\"width\", percent + \"%\").text(percent + \"%\");
        },
        onUploadStarted: function (e) {
            if (!e.component.__uploadedFilesCount) {   //this is just a custom option that is not used by dxFileUploader
                e.component.__uploadedFilesCount = 0;
            }
        },
        onUploadError: function (e) {
             let xhttp = e.request;
             console.log(e.error.responseText);
             if (xhttp.status === 400) {
                 e.message = e.error.responseText;
             }
             if (xhttp.readyState === 4 && xhttp.status === 0) {
                 e.message = \"Connection refused\";
             }
        }
 }).dxFileUploader(\"instance\");
</script>";
        
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);

        
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);

        return; yield '';
    }

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

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

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo()
    {
        return array (  126 => 44,  115 => 35,  110 => 32,  101 => 29,  95 => 28,  89 => 27,  86 => 26,  82 => 25,  73 => 18,  71 => 17,  64 => 12,  57 => 8,  54 => 7,  52 => 6,  50 => 5,  44 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("
<div class=\"p-3\">

    <div class=\"messages\">
        {% if message is defined %}
            {# Bootstrap alert, see https://getbootstrap.com/docs/3.4/components/#alerts #}
            <div class=\"alert alert-dismissible alert-success fade show\" role=\"alert\">
                {{ message|raw }}
                <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\" style=\"opacity:1\"></button>
            </div>
        {% endif %}
    </div>
    <div class=\"col pb-4\" style=\"padding-right:2rem;position:relative\">
        <div class=\"progress mb-2 hide\" >
            <div class=\"progress-bar progress-bar-striped\" style=\"min-width: 20px;\"></div>
        </div>
        {% if datas is not empty %}
            <table class=\"table table-lg table-bordered\" style=\"min-width:400px\">
                <thead>
                <th>Nom Fichier</th>
                <th>Photo Principale?</th>
                <th>Action</th>
                </thead>
                <tbody>
                {% for data in datas %}
                    <tr>
                        <td><a data-popup-id=\"popup_photo\" data-poppup-container=\"body\" data-popup-title=\"Photo\" data-popup-width =\"auto\" data-dxpopup=\"\"  data-content-template-ajax=\"/produit_photos/photo/{{ data.id}}\">{{ data.nom }}</a></td>
                        <td align=\"middle\"> <i class=\"produit-photo-principale fas fa-lg fa-check {{ (data.photoprincipale == 0) ? 'fa-unselected' : 'selected' }}\" data-id=\"{{ data.id }}\" style=\"cursor: pointer\"></i></td>
                        <td align=\"middle\"><i class=\"produit-photo-delete fas fa-trash fa-lg\" data-id=\"{{ data.id }}\"></i></td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
        <div id=\"upload-photo\" class=\"btn btn-success\" style=\"width: 300px;\"></div>
    </div>
    <div class=\"form-group d-flex justify-content-center mt-4\">
        <div class=\"form-actions-row\">
            <button class=\"btn btn-danger btn-close-popup\" data-dxpopup-id=\"popup_cell\" style=\"background-color: white;color: #e74c3c;\">Fermer</button>
        </div>
    </div>
</div>
<script type=\"module\">
    var idProduit = '{{ id|default(null) }}';
    var url =\"/produit_photos/\" +idProduit;
    \$('#upload-photo').dxFileUploader({
        multiple: false,
        accept: \"image/*\",
        uploadMode: \"instantly\",
        uploadMethod: 'POST',
        labelText : '',
        progress: 1,
        showFileList: false,
        selectButtonText : \"+ Ajouter un ou plusieurs fichiers\",
        uploadUrl:  \"/patch/produit_type/\" +idProduit,
        onUploaded: function (e) {
            \$('.progress').addClass('hide').removeClass('show');
            e.component.__uploadedFilesCount++;
            if (e.component.option(\"value\").length === e.component.__uploadedFilesCount) {
                e.component.reset();
                e.component.__uploadedFilesCount = null;
                \$('#popup_cell').dxPopup(\"instance\").option(\"contentTemplate\", e.request.response);
            }
           var linkParent = \$('a[data-content-template-ajax=\"'+url+'\"]');
            if (\$(linkParent).children('i').hasClass('fa-plus-circle')) {
                \$(linkParent).children('i').removeClass('fa-plus-circle').addClass('fa-edit');
            }
        },
        onProgress: function(e) {
            var percent = e.component.option(\"progress\");
            \$('.progress').addClass('show').removeClass('hide');
            \$(\".progress-bar\").css(\"width\", percent + \"%\").text(percent + \"%\");
        },
        onUploadStarted: function (e) {
            if (!e.component.__uploadedFilesCount) {   //this is just a custom option that is not used by dxFileUploader
                e.component.__uploadedFilesCount = 0;
            }
        },
        onUploadError: function (e) {
             let xhttp = e.request;
             console.log(e.error.responseText);
             if (xhttp.status === 400) {
                 e.message = e.error.responseText;
             }
             if (xhttp.readyState === 4 && xhttp.status === 0) {
                 e.message = \"Connection refused\";
             }
        }
 }).dxFileUploader(\"instance\");
</script>", "produit/_produit_photos.html.twig", "/builds/dev/refonte_sav/templates/produit/_produit_photos.html.twig");
    }
}
