<form name="receipts_return_form" method="POST" action="/receipts/return">
	<input type="hidden" name="id" value="{{@GET.id}}">
	<input type="hidden" name="type" value="{{@receipt_return}}">
	<input type="hidden" name="discount" value="0">
	<input type="hidden" name="partner_id" value="{{@receipt.partner_id}}">
	<input type="hidden" name="sbp_order_id" value="{{@receipt.sbp_order_id}}">
	<input type="hidden" name="pan" value="{{@receipt.pan}}">
	<input type="hidden" name="transid" value="{{@receipt.transid}}">
	<input type="hidden" name="authcode" value="{{@receipt.authcode}}">
	<input type="hidden" name="changes" value="{{@receipt.changes}}">
	<input type="hidden" name="sum0" value="{{@receipt.sum}}">
	<input type="hidden" name="epay" value="{{@receipt.epay}}">
	<input type="hidden" name="sno" value="{{@receipt.sno}}">
	<div id="return_paymentmethods" class="return_paymentmethods_{{count(@receipt.paymentmethods)}}">
		<div class="popup_area">
			<div class="close_button">
				<i class="fa fa-times" aria-hidden="true"></i>
			</div>
			<p align="center">
				<big>Способ возврата денег <big class="noshow_2">- <span>{{@paymentmethods[@receipt['paymentmethods'][0]['method']]['title']}}{{@receipt['epay']>0?' ('.@receipt['epay_title'].')':''}}</span></big></big>
			</p>
			<p class="right noshow_1">Осталось <big id="return_add_pay">0.00</big></p>
			<p>К возврату: <big class="return_sum">0.00</big></p>
			<table class="noshow_1">
				{~@beznal=0;~}
			<repeat group="{{@receipt.paymentmethods}}" value="{{@p}}">
				<tr>
					<td width="150">
						{~if(@p['method']==@e_paymethod)@beznal=1;~}
						{~@p['sum']=round(@p['sum'], 2)~}
						{{@paymentmethods[@p['method']]['title']}}:<br>
						{{@receipt['epay']>0 && @paymentmethods[@p['method']]['cash']==0?'('.@receipt['epay_title'].')<br>':''}}
						<span class="error_{{@p['method']}}">Максимально {{number_format(@p['sum'], 2, '.', '')}}</span>
					</td>
					<td>
						<input type="text" min="0" step="0.01" name="client_sum[{{@p['method']}}]" class="client_sum mixed_pay mixed_pay_{{@p['method']}}" pid={{@p['method']}} autocomplete="off" value="" max="{{number_format(@p['sum'], 2, '.', '')}}" pattern="\d+(\.\d{2})?">
						<input type="hidden" name="paymentmethod[]" value="{{@p['method']}}">
					</td>
				</tr>
			</repeat>
			</table>
			<p class="false" align="center">Верните деньги клиенту и нажмите "Готово"</p>
			<div align="center" class="noshow_1">
				<div class="virtual_keyboard">
					<input type="button" class="virtual_key" value='7' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="button" class="virtual_key" value='8' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="button" class="virtual_key" value='9' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="submit" value="Готово" disabled="true">
					<br>
					<input type="button" class="virtual_key" value='4' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="button" class="virtual_key" value='5' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="button" class="virtual_key" value='6' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<br>
					<input type="button" class="virtual_key" value='1' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="button" class="virtual_key" value='2' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="button" class="virtual_key" value='3' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<br>
					<input type="button" class="virtual_key_delete" for='mixed_pay_{{@paymentmethods[0]["id"]}}' value="CE">
					<input type="button" class="virtual_key" value='0' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<input type="button" class="virtual_key" value='.' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
					<button type="button" class="virtual_key_bks" for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
						<i class="fas fa-long-arrow-alt-left"></i>
					</button>
				</div>
			</div>
			<p align="center" class="noshow_2">
				<input type="submit" value="Готово" disabled="true">
			</p>
			<check if="{{@fr==1 && @beznal==0 && in_array('receipts/fr_no', @authorization_user.module) && !@base_settings.autonomous}}">
			<br>
			<input type="checkbox" name="hold" id="hold" value="1" class="custom-checkbox">
			<label for="hold">Тестовая операция</label>
			</check>
		</div>
	</div>
<table class="content2" width="100%">
	<tr>
		<th width="50%" colspan="4">
			Чек № {{@receipt.id}}
		</th>
		<th colspan="4">
			Подлежит возврату
		</th>
	</tr>
	<tr>
		<td colspan="4" class="receiptlines" valign="top">
			<table class="work_table order_hide">
				<tr>
					<th>
						Наименование
					</th>
					<th width="100">
						Цена
					</th>
					<th width="100">
						Кол-во
					</th>
					<th width="100">
						Итого
					</th>
				</tr>
			</table>
			<div class="receiptlines_div">
				<table class="work_table big_table">
					<repeat group="{{@receipt.receiptlines}}" key="{{@n}}" value="{{@line}}">
						<tr class="line {{@n==0?'select_line':''}}" id="line_{{@line.id}}">
							<td>
								{~@price=@line.price+(@line.price*(@line.vat/100))*max(0, @line.vat_type)~}
								{~@price-=@price*(@line.discount/100)~}
								{~@price=round(@price, 2)~}
								{~if(@partner['ignore_max_discount']) @line.max_discount=100;~}
								<input type="radio" name="line" value="{{@line.id}}" count="{{@line.count}}" vprice="{{number_format(@price, 2, '.', '')}}" price="{{number_format(@line.price, 2, '.', '')}}" discount="{{@line.discount}}" vat="{{@line.vat}}" mark="{{@line.mark!=''?1:0}}" egais="{{@line.egais}}" barcode="{{@line.barcode}}" vat_type="{{@line.vat_type}}" loyalty="{{@line.loyalty}}" max_discount="{{@line.max_discount}}" product_id="{{@line.product_id}}" units_fr="{{@line.units_fr}}" {{@n==0?"checked=checked":''}}>
								<span class="small product_title">{{@line.product_title}}</span>
								<check if="{{@line.mark!=''}}">
								[M]
								</check>
								{~@total=@price*@line.count~}
								{~@sum+=@total~}
								<div class="order_show small">
									<div class="small" align="right">
										{{number_format(@price, 2, '.', '')}} X {{numberformat(@line.count, 3, '.', '')}} = {{number_format(@total, 2, '.', '')}}
									</div>
								</div>
							</td>
							<td align="center" width="100">
								{{number_format(@price, 2, '.', '')}}
							</td>
							<td align="center" width="100">
								{~@count+=@line.count~}
								{{numberformat(@line.count, 3, '.', '')}}
							</td>
							<td align="right" width="100">
								{{number_format(@total, 2, '.', '')}}
							</td>
						</tr>
					</repeat>
				</table>
			</div>
			<table class="work_table total_table">
				<tr>
					<td height="30">
						<b>Итого</b>
					</td>
					<td align="center" width="100">
						<b>{{numberformat(@count, 3, '.', '')}}</b>
					</td>
					<td align="right" width="100">
						<b>{{number_format(@sum, 2, '.', '')}}</b>
					</td>
				</tr>
			</table>
		</td>
		<td valign="top" class="receiptlines">
			<table class="work_table order_hide">
				<tr>
					<th>
						Наименование
					</th>
					<th width="100">
						Цена
					</th>
					<th width="100">
						Кол-во
					</th>
					<th width="100">
						Итого
					</th>
					<td width="25">
					</td>
				</tr>
			</table>
			<div class="receiptlines_div">
				<table class="work_table big_table">
					<tr id="return_add"></tr>
				</table>
			</div>
			<table class="work_table total_table">
				<tr>
					<td>
						<b>Итого</b>
					</td>
					<td align="center" width="100">
						<b id="return_count">0.000</b>
					</td>
					<td align="right" width="100">
						<b class="return_sum">0.00</b>
					</td>
					<td width="25" align="center" height="30">
						<button type="button" class="line_control remove_return" for=".line_return">
							<i class="fas fa-times"></i>
						</button>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<input type="text" inputmode="numeric" class="return_count_input order_hide" autocomplete="off" placeholder="Кол-во">
<input type="button" class="return_ok order_hide"  value="OK">

<input type="button" class="right" name="save_return" value="Готово">
<input type="button" name="return_1" value="Вернуть +1">
<input type="button" name="return_str" value="Вернуть строку">
<input type="button" name="return_all" value="Вернуть всё">

</form>
<div class="virtual_keyboard virtual_keyboard_hide virtual_keyboard_return_count_input">
	<input type="button" class="virtual_key" value="7" for="return_count_input">
	<input type="button" class="virtual_key" value="8" for="return_count_input">
	<input type="button" class="virtual_key" value="9" for="return_count_input">
	<br>
	<input type="button" class="virtual_key" value="4" for="return_count_input">
	<input type="button" class="virtual_key" value="5" for="return_count_input">
	<input type="button" class="virtual_key" value="6" for="return_count_input">
	<br>
	<input type="button" class="virtual_key" value="1" for="return_count_input">
	<input type="button" class="virtual_key" value="2" for="return_count_input">
	<input type="button" class="virtual_key" value="3" for="return_count_input">
	<br>
	<input type="button" class="virtual_key virtual_null" value="0" for="return_count_input">
	<input type="button" class="virtual_key" value="." for="return_count_input">
	<button type="button" class="virtual_key_bks" for='return_count_input'>
		<i class="fas fa-long-arrow-alt-left"></i>
	</button>
</div>
