<?php

/* discounts.manage.tpl */
class __TwigTemplate_67edc37eb90e56503e502ab187a23f8c extends Twig_Template
{
    public function display(array $context)
    {
        // line 1
        echo "<div class=\"row\">
\t<div class=\"col-sm-12\">
\t\t<h4 class=\"page-title\">";
        // line 3
        echo getLang("ViewDiscounts");
        echo "</h4>
\t\t<p>";
        // line 4
        echo twig_safe_filter((isset($context['DiscountIntro']) ? $context['DiscountIntro'] : null));
        echo "</p>
\t\t<div id=\"DiscountStatus\">";
        // line 5
        echo twig_safe_filter((isset($context['Message']) ? $context['Message'] : null));
        echo "</div>
\t</div>
</div>

<div class=\"row\">
\t<div class=\"col-sm-12\">
\t\t<input type=\"button\" name=\"IndexAddButton\" value=\"";
        // line 11
        echo getLang("CreateDiscount");
        echo "...\" id=\"IndexCreateButton\" class=\"btn btn-primary\" onclick=\"document.location.href='index.php?ToDo=createDiscount'\" /> 
\t\t<input type=\"button\" name=\"IndexDeleteButton\" value=\"";
        // line 12
        echo getLang("DeleteSelected");
        echo "\" id=\"IndexDeleteButton\" class=\"btn btn-danger\" onclick=\"ConfirmDeleteSelected()\" ";
        echo twig_safe_filter((isset($context['DisableDelete']) ? $context['DisableDelete'] : null));
        echo " />
\t</div>
</div>
<br />

<div class=\"panel panel-default\" style=\"display: ";
        // line 17
        echo twig_safe_filter((isset($context['DisplayGrid']) ? $context['DisplayGrid'] : null));
        echo "\">
\t<div class=\"panel-body pn\">
\t\t<div class=\"table-responsive\">
\t\t\t<form name=\"frmDiscounts\" id=\"frmDiscounts\" method=\"post\" action=\"index.php?ToDo=deleteDiscounts\">
\t\t\t\t<div class=\"GridContainer\">
\t\t\t\t\t";
        // line 22
        echo twig_safe_filter((isset($context['DiscountsDataGrid']) ? $context['DiscountsDataGrid'] : null));
        echo "
\t\t\t\t</div>

\t\t\t\t<div id=\"SeeMoreDiscountBox\" style=\"display: ";
        // line 25
        echo twig_safe_filter((isset($context['HideSeeMoreDiscountBox']) ? $context['HideSeeMoreDiscountBox'] : null));
        echo "\">
\t\t\t\t\t<a href=\"#\" onclick=\"seeMoreDiscountItems(); return false;\">";
        // line 26
        echo twig_safe_filter((isset($context['DiscountShowNextBatchItems']) ? $context['DiscountShowNextBatchItems'] : null));
        echo "</a>
\t\t\t\t</div>
\t\t\t</form>
\t\t</div>
\t</div>
</div>
\t<script type=\"text/javascript\">

\t\tfunction ConfirmDeleteSelected()
\t\t{
\t\t\tvar fp = document.getElementById(\"frmDiscounts\").elements;
\t\t\tvar c = 0;

\t\t\tfor(i = 0; i < fp.length; i++)
\t\t\t{
\t\t\t\tif(fp[i].type == \"checkbox\" && fp[i].checked)
\t\t\t\t\tc++;
\t\t\t}

\t\t\tif(c > 0)
\t\t\t{
\t\t\t\tif(confirm(\"";
        // line 47
        echo getLang("ConfirmDeleteDiscounts");
        echo "\"))
\t\t\t\t\tdocument.getElementById(\"frmDiscounts\").submit();
\t\t\t}
\t\t\telse
\t\t\t{
\t\t\t\talert(\"";
        // line 52
        echo getLang("ChooseDiscounts");
        echo "\");
\t\t\t}
\t\t}

\t\tfunction ToggleDeleteBoxes(Status)
\t\t{
\t\t\tvar fp = document.getElementById(\"frmDiscounts\").elements;

\t\t\tfor(i = 0; i < fp.length; i++)
\t\t\t\tfp[i].checked = Status;
\t\t}

\t\tfunction DiscountClipboard(Data)
\t\t{
\t\t\tif (window.clipboardData)
\t\t\t{
\t\t\t\twindow.clipboardData.setData(\"Text\", Data);
\t\t\t\talert(\"";
        // line 69
        echo getLang("CopiedClipboard");
        echo "\");
\t\t\t}
\t\t\telse
\t\t\t{
\t\t\t\talert(\"";
        // line 73
        echo getLang("FeatureOnlyInIE");
        echo "\");
\t\t\t}
\t\t}

\t\tvar updatingSortables = false;
\t\tvar updateTimeout = null;

\t\tfunction CreateSortableList() {

\t\t\t\$('#DiscountList').sortable({
\t\t\t\taccept: 'SortableRow',
\t\t\t\tcontainment: '#DiscountList',
\t\t\t\thandler: '.sort-handle',
\t\t\t\topacity: .8,
\t\t\t\tplaceholder: 'SortableRowHelper',
\t\t\t\tforcePlaceholderSize: true,
\t\t\t\titems: 'li',
\t\t\t\ttolerance: 'pointer',
\t\t\t\tupdate: function(event, ui) {
\t\t\t\t\t\$(this).find('.GridRow').removeClass('RowDown');

\t\t\t\t\tvar idx = [];

\t\t\t\t\t\$('input.DiscountsIdx').each(
\t\t\t\t\t\tfunction()
\t\t\t\t\t\t{
\t\t\t\t\t\t\tidx[idx.length] = \$(this).val();
\t\t\t\t\t\t}
\t\t\t\t\t);

\t\t\t\t\t\$.ajax({
\t\t\t\t\t\turl: 'remote.php',
\t\t\t\t\t\ttype: 'post',
\t\t\t\t\t\tdataType: 'xml',
\t\t\t\t\t\tdata: {
\t\t\t\t\t\t\t\t'remoteSection': 'discounts',
\t\t\t\t\t\t\t\t'w': 'updateDiscountOrder',
\t\t\t\t\t\t\t\t'sortorder': idx.join(',')
\t\t\t\t\t\t\t},
\t\t\t\t\t\tsuccess: function(response) {

\t\t\t\t\t\t\tvar status = \$('status', response).text();
\t\t\t\t\t\t\tvar message = \$('message', response).text();
\t\t\t\t\t\t\tif(status == 0) {
\t\t\t\t\t\t\t\tdisplay_error('DiscountStatus', message);
\t\t\t\t\t\t\t}
\t\t\t\t\t\t\telse {
\t\t\t\t\t\t\t\tdisplay_success('DiscountStatus', message);
\t\t\t\t\t\t\t}
\t\t\t\t\t\t}
\t\t\t\t\t});
\t\t\t\t}
\t\t\t});
\t\t}

\t\tfunction seeMoreDiscountItems()
\t\t{
\t\t\tvar lastSortOrder = 1;

\t\t\t\$(\".DiscountSortOrder\").each(
\t\t\t\tfunction()
\t\t\t\t{
\t\t\t\t\tif (\$(this).val() > lastSortOrder) {
\t\t\t\t\t\tlastSortOrder = parseInt(\$(this).val());
\t\t\t\t\t}
\t\t\t\t}
\t\t\t);

\t\t\t\$.ajax({
\t\t\t\turl: 'remote.php',
\t\t\t\ttype: 'post',
\t\t\t\tdata: {
\t\t\t\t\t\t'remoteSection': 'discounts',
\t\t\t\t\t\t'w': 'getMoreDiscounts',
\t\t\t\t\t\t'lastSortOrder': lastSortOrder
\t\t\t\t\t},
\t\t\t\tsuccess: seeMoreDiscountItemsCallback
\t\t\t});
\t\t}

\t\tfunction seeMoreDiscountItemsCallback(data)
\t\t{
\t\t\tif (\$(\"items\", data).text() !== '') {
\t\t\t\t\$(\"#DiscountList\").append(\$(\"items\", data).text());
\t\t\t\tCreateSortableList();
\t\t\t}

\t\t\tif (\$(\"more\", data).text() == \"0\") {
\t\t\t\t\$(\"#SeeMoreDiscountBox\").hide();
\t\t\t}
\t\t}

\t\t\$(document).ready(function()
\t\t{
\t\t\tCreateSortableList();
\t\t});

\t</script>";
    }

}
