<?php

/* products.variation.form.tpl */
class __TwigTemplate_eb0e7edd63a0493833c980d0c8937609 extends Twig_Template
{
    public function display(array $context)
    {
        // line 1
        echo "<form enctype=\"multipart/form-data\" action=\"index.php?ToDo=";
        echo twig_safe_filter((isset($context['FormAction']) ? $context['FormAction'] : null));
        echo "\" id=\"frmVariation\" method=\"post\">
<input type=\"hidden\" name=\"variationId\" id=\"productId\" value=\"";
        // line 2
        echo twig_safe_filter((isset($context['VariationId']) ? $context['VariationId'] : null));
        echo "\">
<div class=\"BodyContainer\">
\t<div class=\"row\">
\t\t<div class=\"col-sm-12\">
\t\t\t<h4 class=\"page-title\">";
        // line 6
        echo twig_safe_filter((isset($context['Title']) ? $context['Title'] : null));
        echo "</h4>
\t\t\t<p>";
        // line 7
        echo getLang("ViewVariationsIntro");
        echo "</p>
\t\t\t";
        // line 8
        echo twig_safe_filter((isset($context['Message']) ? $context['Message'] : null));
        echo "
\t\t\t<div class=\"alert alert-warning\" style=\"display: ";
        // line 9
        echo twig_safe_filter((isset($context['HideVariationTestDataWarning']) ? $context['HideVariationTestDataWarning'] : null));
        echo ";\">";
        echo getLang("ProductVariationTestDataWarning");
        echo "</div>
\t\t</div>
\t</div>

\t<div class=\"row\">
\t\t<div class=\"col-sm-12\">
\t\t\t<input type=\"button\" value=\"";
        // line 15
        echo getLang("SaveAndExit");
        echo "\" class=\"btn btn-primary\" onclick=\"SaveVariationForm()\" />
\t\t\t<input type=\"button\" value=\"";
        // line 16
        echo twig_safe_filter((isset($context['SaveAndAddAnother']) ? $context['SaveAndAddAnother'] : null));
        echo "\" onclick=\"SaveVariationForm(true)\" class=\"btn btn-primary\" />
\t\t\t<input type=\"reset\" value=\"";
        // line 17
        echo getLang("Cancel");
        echo "\" class=\"btn btn-default\" onclick=\"ConfirmCancel()\" />
\t\t</div>
\t</div>
\t<br />

\t<div class=\"row\">
\t\t<div class=\"col-sm-12\">
\t\t\t<div class=\"panel panel-default\">
\t\t\t\t<div class=\"panel-heading\"> 
\t\t\t\t\t<h3 class=\"panel-title\">";
        // line 26
        echo getLang("VariationDetails");
        echo "</h3> 
\t\t\t\t</div> 

\t\t\t\t<div class=\"panel-body\">
\t\t\t\t\t<div class=\"form-group row\" style=\"";
        // line 30
        echo twig_safe_filter((isset($context['HideVendorOption']) ? $context['HideVendorOption'] : null));
        echo "\">
\t\t\t\t\t\t<label class=\"col-md-2 control-label\">
\t\t\t\t\t\t\t";
        // line 32
        echo getLang("Vendor");
        echo ":
\t\t\t\t\t\t</label>
\t\t\t\t\t\t<div class=\"col-md-10\">
\t\t\t\t\t\t\t<span style=\"";
        // line 35
        echo twig_safe_filter((isset($context['HideVendorLabel']) ? $context['HideVendorLabel'] : null));
        echo "\">";
        echo twig_safe_filter((isset($context['CurrentVendor']) ? $context['CurrentVendor'] : null));
        echo "</span>
\t\t\t\t\t\t\t<select name=\"vendor\" id=\"vendor\" class=\"form-control\" style=\"";
        // line 36
        echo twig_safe_filter((isset($context['HideVendorSelect']) ? $context['HideVendorSelect'] : null));
        echo "\">
\t\t\t\t\t\t\t\t";
        // line 37
        echo twig_safe_filter((isset($context['VendorList']) ? $context['VendorList'] : null));
        echo "
\t\t\t\t\t\t\t</select>
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>

\t\t\t\t\t<div class=\"form-group row\">
\t\t\t\t\t\t<label class=\"col-md-2 control-label\">
\t\t\t\t\t\t\t";
        // line 44
        echo getLang("VariationName");
        echo ":
\t\t\t\t\t\t</label>
\t\t\t\t\t\t<div class=\"col-md-10\">
\t\t\t\t\t\t\t<input type=\"text\" id=\"vname\" name=\"vname\" class=\"form-control\" value=\"";
        // line 47
        echo twig_safe_filter((isset($context['VariationName']) ? $context['VariationName'] : null));
        echo "\">
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>

\t\t\t\t\t<div class=\"form-group row\">
\t\t\t\t\t\t<label class=\"col-md-2 control-label\">
\t\t\t\t\t\t\t";
        // line 53
        echo getLang("VariationOptions");
        echo ":
\t\t\t\t\t\t</label>
\t\t\t\t\t\t<div class=\"col-md-10\">
\t\t\t\t\t\t\t<ul id=\"ProductVariationBox\">
\t\t\t\t\t\t\t\t";
        // line 57
        echo twig_safe_filter((isset($context['Variations']) ? $context['Variations'] : null));
        echo "
\t\t\t\t\t\t\t</ul>
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t</div>
\t\t</div>
\t</div>
\t<div class=\"row\">
\t\t<div class=\"col-sm-12\">
\t\t\t<input type=\"button\" value=\"";
        // line 67
        echo getLang("SaveAndExit");
        echo "\" class=\"btn btn-primary\" onclick=\"SaveVariationForm()\" />
\t\t\t<input type=\"button\" value=\"";
        // line 68
        echo twig_safe_filter((isset($context['SaveAndAddAnother']) ? $context['SaveAndAddAnother'] : null));
        echo "\" onclick=\"SaveVariationForm(true)\" class=\"btn btn-primary\" />
\t\t\t<input type=\"reset\" value=\"";
        // line 69
        echo getLang("Cancel");
        echo "\" class=\"btn btn-default\" onclick=\"ConfirmCancel()\" />
\t\t</div>
\t</div>
</div>
</form>

<script type=\"text/javascript\">

\tvar variationForm = document.getElementById('frmVariation');
\tvar affectedVariations = [";
        // line 78
        echo twig_safe_filter((isset($context['AffectedVariations']) ? $context['AffectedVariations'] : null));
        echo "];

\tfunction SaveVariationForm(addAnother) {
\t\tif (!CheckVariationForm()) {
\t\t\treturn;
\t\t}

\t\tif (addAnother == true) {
\t\t\tvar f = g('frmVariation');
\t\t\tvar d = document.createElement('input');
\t\t\td.type = 'hidden';
\t\t\td.name = 'addanother';
\t\t\td.value = '1';
\t\t\tf.appendChild(d);
\t\t}

\t\tvariationForm.submit();
\t}

\tfunction ConfirmCancel() {
\t\tif(confirm(\"";
        // line 98
        echo getLang("ConfirmCancelVariation");
        echo "\"))
\t\t\tdocument.location.href = \"index.php?ToDo=viewProductVariations\";
\t}

\tfunction CheckVariationForm() {
\t\tif(\$('#vname').val() == '') {
\t\t\talert('";
        // line 104
        echo getLang("ProductVariationErrorNoVariationName");
        echo "');
\t\t\t\$('#vname').focus();
\t\t\treturn false;
\t\t}

\t\tvar rowCount = 0;
\t\tvar rowPass = true;

\t\t\$(\"#ProductVariationBox .VariationRow\").each(function() {

\t\t\tvar valueCount = 0;
\t\t\tvar valuePass = true;

\t\t\tif (\$(\".VariationOptionName\", this).val() == '') {
\t\t\t\talert(('";
        // line 118
        echo getLang("ProductVariationErrorNoOptionName");
        echo "').replace(/%d/, (rowCount+1)));
\t\t\t\t\$(\".VariationOptionName\").focus();
\t\t\t\trowPass = false;
\t\t\t\treturn false;
\t\t\t}

\t\t\t\$(\".VariationValueName\", this).each(function() {
\t\t\t\tif (\$(this).val() == '') {
\t\t\t\t\talert(('";
        // line 126
        echo getLang("ProductVariationErrorNoOptionValue");
        echo "').replace(/%d/, (rowCount+1)));
\t\t\t\t\t\$(this).focus();
\t\t\t\t\tvaluePass = false;
\t\t\t\t\treturn false;
\t\t\t\t}

\t\t\t\tif (\$(this).val().search(\"#\") != -1) {
\t\t\t\t\talert(('";
        // line 133
        echo getLang("ProductVariationErrorHash");
        echo "').replace(/%d/, (rowCount+1)));
\t\t\t\t\t\$(this).focus();
\t\t\t\t\tvaluePass = false;
\t\t\t\t\treturn false;
\t\t\t\t}

\t\t\t\tvalueCount++;
\t\t\t});

\t\t\tif (!valuePass) {
\t\t\t\trowPass = false;
\t\t\t\treturn false;
\t\t\t}

\t\t\tif (valueCount <= 1) {
\t\t\t\talert(('";
        // line 148
        echo getLang("ProductVariationErrorInvalidOptions");
        echo "').replace(/%d/, (rowCount+1)));
\t\t\t\t\$(\".VariationValueName:first\", this).focus();
\t\t\t\trowPass = false;
\t\t\t\treturn false;
\t\t\t}

\t\t\trowCount++;
\t\t});

\t\tif (!rowPass) {
\t\t\treturn false;
\t\t}

\t\tif (rowCount == 0) {
\t\t\talert('";
        // line 162
        echo getLang("ProductVariationErrorNoData");
        echo "');
\t\t\treturn false;
\t\t}

\t\treturn true;
\t}

\tfunction GetNextColumnID()
\t{
\t\tvar matches, nextId = 0;

\t\t\$(\"#ProductVariationBox .VariationColumn .VariationOptionName\").each(
\t\t\tfunction() {
\t\t\t\tmatches = this.name.match(/variationOptionName\\[([0-9]+)\\]/);
\t\t\t\tif (matches) {
\t\t\t\t\tnextId = Math.max(nextId, matches[1]);
\t\t\t\t}
\t\t\t}
\t\t);

\t\tnextId++;

\t\treturn nextId;
\t}

\tfunction getNextValueID(valueRow)
\t{
\t\tvar matches, parentId, nextId = 0;

\t\t\$(\".VariationValue .VariationValueName\", valueRow).each(
\t\t\tfunction() {
\t\t\t\tmatches = this.name.match(/variationOptionValue\\[([0-9]+)\\]\\[([0-9]+)\\]/);
\t\t\t\tif (matches) {
\t\t\t\t\tparentId = matches[1];
\t\t\t\t\tnextId = Math.max(nextId, matches[2]);
\t\t\t\t}
\t\t\t}
\t\t);

\t\tnextId++;

\t\treturn {\"nextId\": nextId, \"parentId\": parentId};
\t}

\tfunction AddVariationRow(addButton) {
\t\t\$(\"#ProductVariationBox .VariationRowDel\").each(function() { \$(this).show(); });

\t\tvar row = \$(addButton.parentNode.parentNode).clone();
\t\tvar next = GetNextColumnID();

\t\tvar box = \$(\".VariationValues .VariationValue:first\", row).clone();
\t\t\$(\".VariationDel\", box).each(function() { \$(this).hide(); });
\t\t\$(\".VariationValues\", row).empty();
\t\t\$(\".VariationValues\", row).append(box);

\t\t\$(\".VariationColumn .VariationOptionName\", row).attr(\"name\", \"variationOptionName[\" + next + \"]\");
\t\t\$(\".VariationColumn .VariationOptionName\", row).attr(\"id\", \"variationOptionName_\" + next);
\t\t\$(\".VariationColumn .VariationOptionName\", row).val(\"\");

\t\t\$(\".VariationValues .VariationValue .VariationValueName\", row).attr(\"name\", \"variationOptionValue[\" + next + \"][0]\");
\t\t\$(\".VariationValues .VariationValue .VariationValueName\", row).attr(\"id\", \"variationOptionValue_\" + next + \"_0\");
\t\t\$(\".VariationValues .VariationValue .VariationValueName\", row).val(\"\");
\t\t\$(\".VariationValues .VariationValue .VariationValueId\", row).attr(\"name\", \"variationOptionValueId[\" + next + \"][0]\");
\t\t\$(\".VariationValues .VariationValue .VariationValueId\", row).attr(\"id\", \"variationOptionValueId_\" + next + \"_0\");
\t\t\$(\".VariationValues .VariationValue .VariationValueId\", row).val(\"\");
\t\t\$(\".VariationValuesRank\", row).attr(\"name\", \"variationOptionValuesRank[\" + next + \"]\");
\t\t\$(\".VariationValuesRank\", row).attr(\"id\", \"variationOptionValuesRank_\" + next);

\t\tAddSortableToValuesDiv(\$(\".VariationValues\", row));

\t\t\$(addButton.parentNode.parentNode).after(row);
\t\t\$(\".VariationColumn .VariationOptionName\", row).focus();
\t}

\tfunction DelVariationRow(delButton) {
\t\tvar parent = delButton.parentNode.parentNode.parentNode;
\t\tvar child = delButton.parentNode.parentNode;
\t\tvar total = 0;

\t\t\$(\".VariationRow\", parent).each(function() { total++; });
\t\tif (total <= 1) {
\t\t\treturn false;
\t\t}

\t\tparent.removeChild(child);

\t\tif (total == 2) {
\t\t\t\$(\".VariationRow .VariationRowDel\", parent).each(function() { \$(this).hide(); });
\t\t}
\t}

\tfunction AddVariationValue(addButton) {
\t\t\$(\".VariationValue .VariationDel\", addButton.parentNode.parentNode).each(function() { \$(this).show(); });

\t\tvar box = \$(addButton.parentNode).clone();
\t\tvar next = getNextValueID(addButton.parentNode.parentNode);

\t\t\$(\".VariationValueName\", box).attr(\"name\", \"variationOptionValue[\" + next.parentId + \"][\" + next.nextId + \"]\");
\t\t\$(\".VariationValueName\", box).attr(\"id\", \"variationOptionValue_\" + next.parentId + \"_\" + next.nextId);
\t\t\$(\".VariationValueId\", box).attr(\"name\", \"variationOptionValueId[\" + next.parentId + \"][\" + next.nextId + \"]\");
\t\t\$(\".VariationValueId\", box).attr(\"id\", \"variationOptionValueId_\" + next.parentId + \"_\" + next.nextId);
\t\t\$(\"input\", box).val(\"\");

\t\t\$(addButton.parentNode).after(box);
\t\t\$(\"#variationOptionValue_\" + next.parentId + \"_\" + next.nextId).focus();
\t}

\tfunction DelVariationValue(delButton) {
\t\tvar parent = delButton.parentNode.parentNode;
\t\tvar child = delButton.parentNode;
\t\tvar total = 0;

\t\t\$(\".VariationValue\", parent).each(function() { total++; });
\t\tif (total <= 1) {
\t\t\treturn false;
\t\t}

\t\tparent.removeChild(child);

\t\tif (total == 2) {
\t\t\t\$(\".VariationValue .VariationDel\", parent).each(function() { \$(this).hide(); });
\t\t}
\t}

\tfunction AddSortableToValuesDiv(div) {
\t\t\$(div).sortable({\"container\": \"parent\"});
\t}

\tfunction AddSortableToContainer() {
\t\t\$(\"#ProductVariationBox\").sortable({\"container\": \"parent\"});
\t}

\t\$(document).ready(
\t\tfunction() {
\t\t\t\$(\"#ProductVariationBox .VariationValues\").each(function() { AddSortableToValuesDiv(this); });
\t\t\tAddSortableToContainer();
\t\t}
\t);
</script>";
    }

}
