{~@type=array(@receipt_sales=>'ПРИХОД' , @receipt_return=>'ВОЗВРАТ ПРИХОДА', @receipt_correct_sales=>'КОРРЕКЦИЯ/ПРИХОД' , @receipt_correct_return=>'КОРРЕКЦИЯ/ВОЗВРАТ ПРИХОДА', @receipt_cashin=>'ВНЕСЕНИЕ В КАССУ', @receipt_cashout=>'ИЗЪЯТИЕ ИЗ КАССЫ', @receipt_change_open=>'ОТКРЫТИЕ СМЕНЫ', @receipt_change_close=>'ЗАКРЫТИЕ СМЕНЫ', @receipt_chpok=>'ВСКРЫТИЕ ТАРЫ', @receipt_writeoff=>'СПИСАНИЕ', @receipt_keg_connection=>'ПОДКЛЮЧЕНИЕ КЕГА')~}
<h1>{{@page_data.title}} № {{@receipt.id}} {{@receipt.nofr?'(тест)':''}}</h1>
<div align="center">
	<div class="ticket">
		<check if="{{@receipt.description!=''}}">
		{{@receipt.description|raw}}
		</check>
		<p align="center">КАССОВЫЙ ЧЕК</p>
		<p>{{@type[@receipt.type]}}</p>
		<table width="100%">
			<check if="{{@receipt.type==@receipt_correct_sales || @receipt.type==@receipt_correct_return}}">
			<tr>
				<td colspan="3">
					Тип коррекции
				</td>
				<td colspan="3" align="right">
					{{@receipt.correct_type==0?'Самостоятельно':'По предписанию'}}
				</td>
			</tr>
				<check if="{{@receipt.correct_type==1}}">
					<true>
			<tr>
				<td colspan="2">
					Осн. коррекции 
				</td>
				<td colspan="4" align="right">
					{{@receipt.osn_number}} от {{date('d.m.Y', strtotime(@receipt.osn_date))}}
				</td>
			</tr>
					</true>
					<false>
			<tr>
				<td colspan="3">
					Дата перв-го рассчета
				</td>
				<td colspan="3" align="right">
					{{date('d.m.Y', strtotime(@receipt.osn_date))}}
				</td>
			</tr>
					</false>
				</check>
			</check>
		<check if="{{is_array(@receipt.receiptlines) && count(@receipt.receiptlines)>0}}">
			{~@discount_sum=0~}
			<repeat group="{{@receipt.receiptlines}}" value="{{@line}}">
			<tr>
				<td>
					{{@line.product_title}}
				</td>
				<td width="25" align="right">				
					{{numberformat(@line.count, 3, '.', '')}}
				</td>
				<td width="5" align="right">
					X
				</td>
				<td width="25" align="right">
					{~if(@line.loyalty) @line.discount=0~}
					{~@price=@line.price+(@line.price*(@line.vat/100))*max(0, @line.vat_type)~}
					{~@price=round(@price, 2)~}
					{~@d_sum=round(@price*(@line.discount/100), 2)~}
					{~@price-=@d_sum~}
					{~if(@line.line_discount):~}
					{~@price0=@line.price0+(@line.price0*(@line.vat/100))*max(0, @line.vat_type)~}
					{~@d_sum=@price0*(@line.line_discount/100)~}
					{~endif~}
					{{number_format(@price, 2, '.', '')}}
					{~@discount_sum+=@d_sum*@line.count~}
				</td>
				<td width="5" align="right">
					&equiv;
				</td>
				<td width="25" align="right">
					{~@total=@price*@line.count~}
					{{number_format(@total, 2, '.', '')}}
				</td>
			</tr>
				<check if="{{@line.vat_type!=0}}">
			<tr>
				<td colspan="3">
					НДС
				</td>
				<td align="right">
					{{number_format(@line.vat, 2, '.', '')}}%
				</td>
				<td align="right">
					&equiv;
				</td>
				<td align="right">
					{~@vp=((@price/(100+@line.vat*abs(min(0, @line.vat_type))))*@line.vat)*@line.count~}
					{~@vp=round(@vp, 2)~}
					{{number_format(@vp, 2, '.', '')}}
					{~@vat[@line.vat]+=@vp~}
				</td>
			</tr>
				</check>
			</repeat>
		</check>
		<check if="{{@receipt.type!=@receipt_chpok}}">
			<tr>
				<td colspan="4">
					Всего
				</td>
				<td width="5" align="right">
					&equiv;
				</td>
				<td width="25" align="right">
					{{number_format(abs(@receipt.sum), 2, '.', '')}}
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<big>ИТОГ</big>
				</td>
				<td width="5" align="right">
					<big>&equiv;</big>
				</td>
				<td width="25" align="right">
					<big>{{number_format(abs(@receipt.sum), 2, '.', '')}}</big>
				</td>
			</tr>
		</check>
		</table>
		<check if="{{@receipt.type!=@receipt_chpok && @receipt.type!=@receipt_writeoff}}">
		<p>ОПЛАТА</p>
		{~@cash=0~}
		<table width="100%">
		<repeat group="{{@receipt['paymentmethods']}}" value="{{@method}}">
			<tr>
				<td>
					{{@paymentmethods[@method.method]['title']}}
					<check if="{{@paymentmethods[@method.method]['cash']!=1 && @epays[@receipt.epay]['title']}}">
					<br>
					 - {{@epays[@receipt.epay]['title']}}
					 <br>
					 <br>
					</check>
				</td>
				<td width="5" align="right">
					&equiv;
				</td>
				<td width="25" align="right">
					{{number_format(abs(@method.sum), 2, '.', '')}}
					{~@cash+=abs(@method.sum)~}
				</td>
			</tr>
		</repeat>
			<tr>
				<td>
					ПОЛУЧЕНО
				</td>
				<td width="5" align="right">
					&equiv;
				</td>
				<td width="25" align="right">
					{~@cash=round(@cash, 2)~}
					{{number_format(@cash, 2, '.', '')}}
				</td>
			</tr>
			<tr>
				<td>
					СДАЧА
				</td>
				<td width="5" align="right">
					&equiv;
				</td>
				<td width="25" align="right">
					{~@receipt.sum=round(@receipt.sum, 2)~}
					{{number_format(@cash-abs(@receipt.sum), 2, '.', '')}}
				</td>
			</tr>
		</table>
		</check>
		<table width="100%">
			<tr>
				<td width="40">
					СНО
				</td>
				<td align="right">
					{{@sno[@receipt['sno']]}}
				</td>
			</tr>
		<check if="{{@vat}}">
			<tr>
				<td width="40">
					НДС
				</td>
				<td align="right">
					<repeat group="{{@vat}}" key="{{@p}}" value="{{@v}}">
					{{number_format(@p, 2, '.', '')}}% = {{number_format(@v, 2, '.', '')}}
					</repeat>
				</td>
			</tr>
		</check>
		</table>
		<p>
			Кассир {{@receipt.short_name}}
		</p>
		<p>
			Смена {{@receipt.changes}}
		</p>
		<table width="100%">
			<check if="{{@receipt.client}}">
			<tr>
				<td>
					{{mb_strpos(@receipt.client, '@')>0?'Адрес':'Телефон'}} покупателя
				</td>
				<td align="right">
					{{@receipt.client}}
				</td>
			</tr>
			</check>
			<tr>
				<td>
					Позиций
				</td>
				<td align="right">
					{{is_array(@receipt.receiptlines)?count(@receipt.receiptlines):0}}
				</td>
			</tr>
			<check if="{{@discount_sum>0}}">
			<tr>
				<td>
					Скидка
				</td>
				<td align="right">
					{{number_format(@discount_sum, 2, '.', '')}}
				</td>
			</tr>
			</check>
			<check if="{{@receipt.bonus_pay>0}}">
			<tr>
				<td>
					Оплата баллами
				</td>
				<td width="25" align="right">
					{{number_format(@receipt.bonus_pay, 2, '.', '')}}
				</td>
			</tr>
			</check>
			<check if="{{@receipt.bonus_add>0}}">
			<tr>
				<td>
					Зачисленно баллов
				</td>
				<td width="25" align="right">
					{{number_format(@receipt.bonus_add, 2, '.', '')}}
				</td>
			</tr>
			</check>
			<tr>
				<td>
					Чек №
				</td>
				<td align="right">
					{{@receipt.id}}
				</td>
			</tr>
		</table>
		<p>{{date('d-m-Y H:i', @receipt.time)}}</p>
		<check if="{{(@receipt['fd'] || @receipt['fp']) && @receipt['fn']}}">
		<div>
			<p align="center">
				<a class="show_slip">QR-код чека</a>
			</p>
			<p align="center" class="slip">
				{~@receipt['kkm_time']?@receipt_time=@receipt['kkm_time']:@receipt_time=@receipt['time']~}
				<img src="/qr/gen?url={{urlencode('t='.date('Ymd', @receipt_time).'T'.date('His', @receipt_time).'&s='.number_format(@receipt['sum'], 2, '.', '').'&fn='.@receipt['fn'].'&i='.@receipt['fd'].'&fp='.@receipt['fp'].'&n='.@receipt['type'])}}">
			</p>
		</div>
		</check>
		<check if="{{@receipt.slip!=''}}">
		<div>
			<p align="center">
				<a class="show_slip">слип чек</a>
			</p>
			<div class="slip">
				<pre>{{@receipt.slip|raw}}</pre>
			</div>
		</div>
		</check>
	</div>
</div>
<br>
<check if="{{@receipt.type==@receipt_sales || @receipt.type==@receipt_correct_sales || @receipt.type==@receipt_correct_return}}">
	<check if="{{in_array('receipts/return', @authorization_user.module)}}">
		<check if="{{@receipt.type==@receipt_sales || @receipt.type==@receipt_correct_sales}}">
<p align="center">
	<a href="/receipts/return?receipt_id={{@receipt.id}}"><input type="button" value="Создать Возвратный чек"></a>
</p>
		</check>
	</check>
	<check if="{{@fr['active']==1}}">
<p align="center">
	<button type="button" class="show_window" href="/receipts/print?id={{@receipt.id}}">
		Товарный чек
	</button>
	<check if="{{@fr['type']==1}}">
	<button type="button" class="show_window" href="/receipts/print?id={{@receipt.id}}&copy=1">
		Копия чека
	</button>
	</check>
</p>
	</check>
</check>
<check if="{{(@fr_settings.version=='1.2' || @fr_settings.driver=='drivers/printers/php_mspos') && (@receipt.type==@receipt_sales || @receipt.type==@receipt_return || @receipt.type==@receipt_correct_sales || @receipt.type==@receipt_correct_return) && in_array('receipts/correct', @authorization_user.module)}}">
<p align="center">
	<a href="/receipts/correct1?id={{@receipt.id}}"><input type="button" value="Создать чек коррекции"></a>
</p>
</check>
