<?php

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

/* extension/light_attribute_helper_category.twig */
class __TwigTemplate_cc8c1d1b4ceaa83a3b5b0c2c33ff00c5 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;
        // line 1
        echo "<li><a href=\"#tab-ah-attributes\" data-toggle=\"tab\">";
        echo ($context["entry_ah_attributes"] ?? null);
        echo "</a></li>
<div class=\"tab-pane\" id=\"tab-ah-attributes\">
\t<div class=\"table-responsive\">
\t<input type=\"hidden\" name=\"ah_attributes[0][attribute_id]\" value=\"\">
\t<table id=\"ah-attribute\" class=\"table table-striped table-bordered table-hover\">
\t\t<thead>
\t\t\t<tr>
\t\t\t\t<td class=\"text-left\">";
        // line 8
        echo ($context["entry_ah_attribute"] ?? null);
        echo "</td>
\t\t\t\t<td class=\"text-left\">";
        // line 9
        echo ($context["entry_ah_default_text"] ?? null);
        echo "</td>
\t\t\t\t<td></td>
\t\t\t</tr>
\t\t</thead>
\t\t<tbody>
\t\t";
        // line 14
        $context["attribute_row"] = 1;
        // line 15
        echo "\t\t";
        $context['_parent'] = $context;
        $context['_seq'] = twig_ensure_traversable(($context["ah_attributes"] ?? null));
        foreach ($context['_seq'] as $context["_key"] => $context["product_attribute"]) {
            // line 16
            echo "\t\t\t<tr id=\"attribute-row";
            echo ($context["attribute_row"] ?? null);
            echo "\" data-row=\"";
            echo ($context["attribute_row"] ?? null);
            echo "\">
\t\t\t\t<td class=\"text-left\" style=\"width: 40%;\"><input type=\"text\" id=\"ah_attributes[";
            // line 17
            echo ($context["attribute_row"] ?? null);
            echo "][name]\" value=\"";
            echo twig_get_attribute($this->env, $this->source, $context["product_attribute"], "name", [], "any", false, false, false, 17);
            echo "\" placeholder=\"";
            echo ($context["entry_ah_attribute"] ?? null);
            echo "\" class=\"form-control\"/> <input type=\"hidden\" name=\"ah_attributes[";
            echo ($context["attribute_row"] ?? null);
            echo "][attribute_id]\" value=\"";
            echo twig_get_attribute($this->env, $this->source, $context["product_attribute"], "attribute_id", [], "any", false, false, false, 17);
            echo "\"/></td>
\t\t\t\t<td class=\"text-left\">";
            // line 18
            $context['_parent'] = $context;
            $context['_seq'] = twig_ensure_traversable(($context["languages"] ?? null));
            foreach ($context['_seq'] as $context["_key"] => $context["language"]) {
                // line 19
                echo "\t\t\t\t\t<div class=\"input-group\"><span class=\"input-group-addon\"><img src=\"language/";
                echo twig_get_attribute($this->env, $this->source, $context["language"], "code", [], "any", false, false, false, 19);
                echo "/";
                echo twig_get_attribute($this->env, $this->source, $context["language"], "code", [], "any", false, false, false, 19);
                echo ".png\" title=\"";
                echo twig_get_attribute($this->env, $this->source, $context["language"], "name", [], "any", false, false, false, 19);
                echo "\"/></span> <textarea name=\"ah_attributes[";
                echo ($context["attribute_row"] ?? null);
                echo "][description][";
                echo twig_get_attribute($this->env, $this->source, $context["language"], "language_id", [], "any", false, false, false, 19);
                echo "][text]\" rows=\"5\" placeholder=\"";
                echo ($context["entry_ah_default_text"] ?? null);
                echo "\" class=\"form-control\">";
                echo (((($__internal_compile_0 = twig_get_attribute($this->env, $this->source, $context["product_attribute"], "description", [], "any", false, false, false, 19)) && is_array($__internal_compile_0) || $__internal_compile_0 instanceof ArrayAccess ? ($__internal_compile_0[twig_get_attribute($this->env, $this->source, $context["language"], "language_id", [], "any", false, false, false, 19)] ?? null) : null)) ? (twig_get_attribute($this->env, $this->source, (($__internal_compile_1 = twig_get_attribute($this->env, $this->source, $context["product_attribute"], "description", [], "any", false, false, false, 19)) && is_array($__internal_compile_1) || $__internal_compile_1 instanceof ArrayAccess ? ($__internal_compile_1[twig_get_attribute($this->env, $this->source, $context["language"], "language_id", [], "any", false, false, false, 19)] ?? null) : null), "text", [], "any", false, false, false, 19)) : (""));
                echo "</textarea>
\t\t\t\t\t</div>
\t\t\t\t\t";
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['language'], $context['_parent'], $context['loop']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 21
            echo "</td>
\t\t\t\t<td class=\"text-left\"><button type=\"button\" onclick=\"\$('#attribute-row";
            // line 22
            echo ($context["attribute_row"] ?? null);
            echo "').remove();\" data-toggle=\"tooltip\" title=\"";
            echo ($context["button_remove"] ?? null);
            echo "\" class=\"btn btn-danger\"><i class=\"fa fa-minus-circle\"></i></button></td>
\t\t\t</tr>
\t\t\t";
            // line 24
            $context["attribute_row"] = (($context["attribute_row"] ?? null) + 1);
            // line 25
            echo "\t\t";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['product_attribute'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 26
        echo "\t\t</tbody>
\t\t<tfoot>
\t\t\t<tr>
\t\t\t\t<td colspan=\"2\"></td>
\t\t\t\t<td class=\"text-left\"><button type=\"button\" onclick=\"addAttribute();\" data-toggle=\"tooltip\" title=\"";
        // line 30
        echo ($context["button_attribute_add"] ?? null);
        echo "\" class=\"btn btn-primary\"><i class=\"fa fa-plus-circle\"></i></button></td>
\t\t\t</tr>
\t\t</tfoot>
\t</table>
\t</div>
</div>

";
        // line 37
        echo ($context["ah_css"] ?? null);
        echo "

<script type=\"text/javascript\"><!--
var attribute_row = ";
        // line 40
        echo ($context["attribute_row"] ?? null);
        echo ";

function addAttribute() {
\thtml = '<tr id=\"attribute-row' + attribute_row + '\" data-row=\"' + attribute_row + '\">';
\thtml += '\t<td class=\"text-left\" style=\"width: 20%;\"><input type=\"text\" id=\"ah_attributes[' + attribute_row + '][name]\" value=\"\" placeholder=\"";
        // line 44
        echo ($context["entry_ah_attribute"] ?? null);
        echo "\" class=\"form-control\" /><input type=\"hidden\" name=\"ah_attributes[' + attribute_row + '][attribute_id]\" value=\"\" /></td>';
\thtml += '\t<td class=\"text-left\">';
\t";
        // line 46
        $context['_parent'] = $context;
        $context['_seq'] = twig_ensure_traversable(($context["languages"] ?? null));
        foreach ($context['_seq'] as $context["_key"] => $context["language"]) {
            // line 47
            echo "\thtml += '<div class=\"input-group\"><span class=\"input-group-addon\"><img src=\"language/";
            echo twig_get_attribute($this->env, $this->source, $context["language"], "code", [], "any", false, false, false, 47);
            echo "/";
            echo twig_get_attribute($this->env, $this->source, $context["language"], "code", [], "any", false, false, false, 47);
            echo ".png\" title=\"";
            echo twig_get_attribute($this->env, $this->source, $context["language"], "name", [], "any", false, false, false, 47);
            echo "\" /></span><textarea name=\"ah_attributes[' + attribute_row + '][description][";
            echo twig_get_attribute($this->env, $this->source, $context["language"], "language_id", [], "any", false, false, false, 47);
            echo "][text]\" rows=\"5\" placeholder=\"";
            echo ($context["entry_ah_default_text"] ?? null);
            echo "\" class=\"form-control\"></textarea></div>';
\t";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['language'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 49
        echo "\thtml += '\t</td>';
\thtml += '\t<td class=\"text-left\"><button type=\"button\" onclick=\"\$(\\'#attribute-row' + attribute_row + '\\').remove();\" data-toggle=\"tooltip\" title=\"";
        // line 50
        echo ($context["button_remove"] ?? null);
        echo "\" class=\"btn btn-danger\"><i class=\"fa fa-minus-circle\"></i></button></td>';
\thtml += '</tr>';
\t\$('#ah-attribute tbody').append(html);
\tattributeautocomplete(attribute_row);
\tattribute_row++;
}

function attributeautocomplete(attribute_row) {
\t\$('input[id=\\'ah_attributes[' + attribute_row + '][name]\\']').autocomplete({
\t\t'source': function(request, response) {
\t\t\t\$.ajax({
\t\t\t\turl: 'index.php?route=catalog/attribute/autocomplete&";
        // line 61
        echo ($context["token_name"] ?? null);
        echo "=";
        echo ($context["user_token"] ?? null);
        echo "&filter_name=' + encodeURIComponent(request),
\t\t\t\tdataType: 'json',
\t\t\t\tsuccess: function(json) {
\t\t\t\t\tresponse(\$.map(json, function(item) {
\t\t\t\t\t\treturn {
\t\t\t\t\t\t\tcategory: item.attribute_group,
\t\t\t\t\t\t\tlabel: item.name,
\t\t\t\t\t\t\tvalue: item.attribute_id
\t\t\t\t\t\t}
\t\t\t\t\t}));
\t\t\t\t}
\t\t\t});
\t\t},
\t\t'select': function(item) {
\t\t\t\$('input[id=\\'ah_attributes[' + attribute_row + '][name]\\']').val(item['label']);
\t\t\t\$('input[name=\\'ah_attributes[' + attribute_row + '][attribute_id]\\']').val(item['value']);
\t\t}
\t});
}
setTimeout(function() {
\t\$('a[href=\"#tab-data\"]').closest('li').before(\$('a[href=\"#tab-ah-attributes\"]').closest('li').detach());
\t\$('#tab-data').before(\$('#tab-ah-attributes').detach());

\t\$('#ah-attribute tbody tr').each(function(index, element) {
\t\tattributeautocomplete(\$(this).attr('data-row'));
\t});
}, 100);
//--></script>";
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName()
    {
        return "extension/light_attribute_helper_category.twig";
    }

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

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo()
    {
        return array (  202 => 61,  188 => 50,  185 => 49,  168 => 47,  164 => 46,  159 => 44,  152 => 40,  146 => 37,  136 => 30,  130 => 26,  124 => 25,  122 => 24,  115 => 22,  112 => 21,  90 => 19,  86 => 18,  74 => 17,  67 => 16,  62 => 15,  60 => 14,  52 => 9,  48 => 8,  37 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("", "extension/light_attribute_helper_category.twig", "");
    }
}
