{{function name="countPages" iPages=1 iPageNumber=1 sUrl="" sUrl2=""}}
	{{if $iPageNumber > 1}}
		<a href="{{$sUrl}}{{if $iPageNumber > 2}}&amp;iPage={{$iPageNumber - 1}}{{/if}}{{$sUrl2}}">&laquo;&nbsp;{{$lang.pages_prev}}</a>
	{{/if}}
	{{$iPaginationSpacer = false}}
	{{section name=pages start=1 loop=$iPages+1 step=1}}
		{{if $smarty.section.pages.index != $iPageNumber && (abs($smarty.section.pages.index - $iPageNumber) <= $config.pagination_counter_admin || $smarty.section.pages.index <= $config.pagination_counter_admin || $smarty.section.pages.index >=  + $iPages - $config.pagination_counter_admin + 1)}}
			<a href="{{$sUrl}}{{if $smarty.section.pages.index > 1}}&amp;iPage={{$smarty.section.pages.index}}{{/if}}{{$sUrl2}}">{{$smarty.section.pages.index}}</a>
		{{$iPaginationSpacer = false}}
		{{elseif $smarty.section.pages.index == $iPageNumber}}
			<strong>{{$smarty.section.pages.index}}</strong>
		{{else}}
			{{if $iPaginationSpacer === false}}
			<strong>...</strong>
			{{$iPaginationSpacer = true}}
			{{/if}}
		{{/if}}
	{{/section}}
	{{if $iPageNumber < $iPages}}
		<a href="{{$sUrl}}&amp;iPage={{$iPageNumber + 1}}{{$sUrl2}}">{{$lang.pages_next}}&nbsp;&raquo;</a>
	{{/if}}
{{/function}}

<a href="admin.php?p=discount-coupons-generate" class="new_element">{{$lang.Discount_add_generate}}</a>
<form id="search_discounts" method="get">
	<input type="hidden" name="p" value="{{$_GET.p}}" />
	<input name="sPhrase" value="{{$_GET.sPhrase}}" />
	<input type="submit" class="submit" value="{{$lang.search}}" />
</form>
{{if count($aDiscounts) > 0}}
<form id="delete_discounts" method="get"><input type="hidden" name="p" value="discount-coupons-delete" />
	<fieldset>
		<table class="list" id="discount-coupons">
			{{capture "sUrl"}}?p={{$_GET.p}}{{if !empty( $_GET.sPhrase )}}&amp;sPhrase={{$_GET.sPhrase}}{{/if}}{{/capture}}
			<thead>
				<tr><td colspan="5" class="pages" style="text-align: left;">{{$lang.Pages}}: {{countPages iPages=$aPagesCountData.iCount iPageNumber=$aPagesCountData.iPageNumber sUrl=$smarty.capture.sUrl}}</td></tr>
				<tr><th class="del"><input type="checkbox" id="select-all" />{{$lang.Delete}}</th><th class="name">{{$lang.Discount_cupon}}</th><th class="value">{{$lang.Discount_value}}</th><th class="date">{{$lang.Discount_time}}</th><th>{{$lang.Producers}}</th><th>{{$lang.Actions}}</th></tr>
			</thead>
			<tfoot>
				<tr><td colspan="5" class="pages" style="text-align: left;">{{$lang.Pages}}: {{countPages iPages=$aPagesCountData.iCount iPageNumber=$aPagesCountData.iPageNumber sUrl=$smarty.capture.sUrl}}</td></tr>
			</tfoot>
			<tbody>
				{{foreach from=$aDiscounts item=aDiscount}}
					<tr><td class="delete"><input type="checkbox" name="iDiscountCoupon[{{$aDiscount.iDiscountCoupon}}]" value="1" /></td><td class="name">{{$aDiscount.sCode}}</td><td>{{$aDiscount.sDiscountValue}}</td><td>{{$aDiscount.sTimeTo}}</td><td>Produkty: {{$aDiscount.sProducer}}</td><td><a href="?p={{$aActions.f}}-coupons-delete&amp;iDiscountCoupon={{$aDiscount.iDiscountCoupon}}" class="delete"><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td></tr>
				{{/foreach}}
			</tbody>
		</table>

		<div class="save float">
		<div class="save floatcontainer"><input type="submit" class="submit" name="sDeleteOption" value="{{$lang.delete_selected}}" /></div>
		</div>

	</fieldset>
</form>
{{/if}}