<check if="{{@base_settings['balance']<=0}}">
<div class="popup" id="balance_error_wait">
	<div class="popup_area" align="center">
		<h1>Ограниченная версия</h1>
		<p class="false">Пополните баланс.</p>
		<p>
			<small>Для пополнения баланса нажмите кнопку Агорта и пункт меню Лицензия.</small>
		</p>
		<p>Оплата будет доступна через <span class="balance_error_time">15</span> сек.</p>
		<div class="agorta_loading"><div class="big_square"><div class="small_square"></div></div></div>
	</div>
</div>
<script type="text/javascript">
balance_error_wait(15);
</script>
</check>
<table width="100%" class="paymentmethod_slip {{@receipt['slip']==''?'hide':''}}">
	<tr>
		<td align="center">
			<h1>Чек уже оплачен</h1>
		</td>
	</tr>
	<tr>
		<td class="show_slip">
			{{@receipt['slip']|raw}}
		</td>
	</tr>
	<tr>
		<td align="center">
			<input type="button" class="receipt_pay_ok" value="Готово">
		</td>
	</tr>
</table>
<table width="100%" class="paymentmethod_table {{@receipt['slip']!=''?'hide':''}}">
	<tr>
		<td width="50%" align="left">
			<p>
				К оплате<br><big class="punctir">{{number_format(@sum, 2, '.', '')}}</big>
				<check if="{{@receipt['bonus_pay']>0}}">
				<br>
				<small>Оплачено бонусами: {{@receipt['bonus_pay']}}</small>
				</check>
				<check if="{{@partner_bonus!=0}}">
                <br><small>К {{@partner_bonus>0?'начислению':'возврату'}} баллов: {{@partner_bonus}}</small>
                </check>
			</p>
		</td>
		<td align="right">
			<p id="pay_change">
				Сдача<br><big class="punctir true">0.00</big>
			</p>
			<p id="mixed_pay_add">
				Осталось<br><big class="punctir true">{{number_format(@sum, 2, '.', '')}}</big>
			</p>
		</td>
	</tr>
</table>

<table width="100%" class="paymentmethod_table">
	<tr>
		<td valign="bottom" align="left" rowspan="{{@base_settings['executor']?4:3}}">
			<ul class="tabs">
				<repeat group="{{@paymentmethods}}" key="{{@n}}" value="{{@p}}">
				<li class="tab{{(@n==0 && count(@receipt['pays'])==0) || (count(@receipt['pays'])==1 && @receipt['pays'][0]['method']==@p.id)?' tab_select':''}}" for=".tab_{{@n}}" cash="{{@p.cash}}" select-epay="{{@p.cash?0:1}}">
					<check if="{{@p.cash}}">
						<true>
					<i class="fas fa-money-bill"></i>
						</true>
						<false>
					<i class="far fa-credit-card"></i>
						</false>
					</check>
					<br>
					{{@p.title}}
				</li>
				</repeat>
				<li class="tab {{count(@receipt['pays'])>1?'tab_select':''}}" for=".tab_{{@n+1}}" cash="1" select-epay="1">
					<i class="fas fa-money-bill"></i>
					<i class="far fa-credit-card"></i>
					<br>
					Смешанная
				</li>
				<li>
					<img src="/ui/css/img/android-chrome-192x192.png" title="Агорта.Касса">
				</li>
			</ul>
		</td>
		<td valign="top" align="left" class="client_0_td">
			<form>
				<input type="text" class="client_0" placeholder="E-mail или телефон" autocomplete="off" value="{{@receipt['client']}}">
				<div class="virtual_keyboard virtual_keyboard_hide virtual_keyboard_client_0 full_keyboard">
					{~@keys='1234567890-|QWERTYUIOP_|ASDFGHJKL@+|ZXCVBNM.'~}
					<loop from="{{@i=0}}" to="{{@i<mb_strlen(@keys)}}" step="{{@i++}}">
						<check if="{{@keys[@i]=='|'}}">
							<true>
					<br>
							</true>
							<false>
					<input type="button" class="virtual_key" value="{{@keys[@i]}}" for="client_0">
							</false>
						</check>
					</loop>
					<button type="button" class="virtual_key_bks" for='client_0'>
						<i class="fas fa-long-arrow-alt-left"></i>
					</button>
					<input type="button" class="virtual_key_delete" for='client_0' value="CE">
					<input type="button" class="virtual_key_ok" value="OK">
				</div>
			</form>
		</td>
		<td valign="bottom" align="right" rowspan="{{@base_settings['executor']?4:3}}">
			<div id="payment_checkbox">
				<check if="{{@fr==1}}">
				<input type="checkbox" class="custom-checkbox" name="fr_print_0" id="fr_print_0" {{!@base_settings['ticket_print_default']?'checked="checked"':''}}>
				<label for="fr_print_0"><br>Печатать<br>чек</label>
				</check>

				<check if="{{@type==1}}">
				<input id="sales_receipts" type="checkbox" class="custom-checkbox" value="1" name="sales_receipts_0" {{@base_settings['auto_sales_receipts']?'checked="checked"':''}}>
				<label for="sales_receipts"><br>Товарный<br>чек</label>
				</check>

				<check if="{{@fr==1 && in_array('receipts/fr_no', @authorization_user.module)}}">
				<input type="checkbox" class="custom-checkbox" name="fr_no_0" id="fr_no_0">
				<label for="fr_no_0"><br>Тестовая<br>операция</label>
				</check>

				<input type="button" id="receipt_pay_ok" value="Готово">
			</div>
		</td>
	</tr>
	<tr class="{{count(@fr_settings['sno_types'])<=1 && count(@fr_settings['psr'])<=1?'hide':''}}">
		<td>
			<select name="sno" class="sno_0 {{count(@fr_settings['sno_types'])<=1?'hide':''}}">
				<repeat group="{{@fr_settings['sno_types']}}" value="{{@sno_type}}">
					<check if="{{@sno[@sno_type]}}">
				<option value="{{@sno_type}}" {{@sno_type==@sno_select?'selected="selected"':''}}>{{@sno[@sno_type]}}</option>
					</check>
				</repeat>
			</select>
			{{count(@fr_settings['sno_types'])>1?'<br>':''}}
			<select name="psr" class="psr_0 {{count(@fr_settings['psr'])<=1?'hide':''}}">
				<repeat group="{{@fr_settings['psr']}}" value="{{@p}}">
					<check if="{{@psr[@p]}}">
				<option value="{{@p}}" {{@p==@psr_select?'selected="selected"':''}}>{{@psr[@p]}}</option>
					</check>
				</repeat>
			</select>
		</td>
	</tr>
	<check if="{{@base_settings['executor']}}">
	<tr>
		<td valign="top" align="left" class="client_0_td">
			<select class="executor_0">
				<option disabled="disabled" selected="selected">Исполнитель</option>
				<repeat group="{{@users}}" value="{{@u}}">
				<option value="{{@u['id']}}">{{@u['short_name']}}</option>
				</repeat>
			</select>
		</td>
	</tr>
	</check>
	<tr>
		<td valign="bottom" align="right">

			<div class="paymentmethods">

				<repeat group="{{@paymentmethods}}" key="{{@n}}" value="{{@p}}">
				{~ @pay_sum=@sum~}
				{~if(count(@receipt['pays'])==1 && @receipt['pays'][0]['method']==@p.id) @pay_sum=@receipt['pays'][0]['sum']~}
				<div class="tab_page tab_{{@n}} {{(@n==0 && count(@receipt['pays'])==0) || (count(@receipt['pays'])==1 && @receipt['pays'][0]['method']==@p.id)?'tab_page_select':''}}">
					<check if="{{@p.cash}}">
						<true>
							<form name="receipt_pay_form_{{@p.id}}" class="receipt_pay_form" method="POST" action="/receipts/sales">
								Принято от покупателя
								<br>
								<input type="text" inputmode="numeric" min="0" step="0.01" name="client_sum[{{@p.id}}]" class="client_sum client_sum_{{@p.id}}" value="{{number_format(@pay_sum, 2, '.', '')}}" autocomplete="off" pattern="\d+(\.\d{2})?">
								<input type="hidden" name="paymentmethod[]" value="{{@p.id}}">
								<input type="hidden" name="writeoff" value="">
								<input type="hidden" name="type" value="{{@type}}">
								<input type="hidden" name="fpd" value="{{@GET.fpd}}">
								<input type="hidden" name="correct2" value="{{@GET.correct2}}">
								<input type="hidden" name="sales_receipts" class="sales_receipts" value="{{@base_settings['auto_sales_receipts']?1:0}}">
								<input type="hidden" name="client" class="client" value="{{@receipt['client']}}">
								<input type="hidden" name="executor" class="executor" value="">
								<input type="hidden" name="sno" class="sno" value="{{@sno_select}}">
								<input type="hidden" name="psr" class="psr" value="{{@psr_select}}">
								<input type="hidden" name="discount" value="{{@receipt['discount']}}">
								<input type="hidden" name="partner_id" value="{{@receipt['partner_id']}}">
								<check if="{{in_array('receipts/hold', @authorization_user.module)}}">
								<input type="hidden" name="hold" class="hold" value="0">
								<input type="hidden" name="nofr" class="nofr" value="0">
								</check>
								<input type="hidden" name="no_egais" class="no_egais" value="0">
								<input type="hidden" name="epay" class="epay_cash" value="0">
								<input type="hidden" name="nobt" class="nobt" value="0">
								<input type="hidden" name="fr_print" class="fr_print" value="{{!@base_settings['ticket_print_default']?1:0}}">
								<div class="virtual_keyboard">
									<input type="button" class="virtual_key" value='7' for='client_sum_{{@p.id}}'>
									<input type="button" class="virtual_key" value='8' for='client_sum_{{@p.id}}'>
									<input type="button" class="virtual_key" value='9' for='client_sum_{{@p.id}}'>
									<br>
									<input type="button" class="virtual_key" value='4' for='client_sum_{{@p.id}}'>
									<input type="button" class="virtual_key" value='5' for='client_sum_{{@p.id}}'>
									<input type="button" class="virtual_key" value='6' for='client_sum_{{@p.id}}'>
									<br>
									<input type="button" class="virtual_key" value='1' for='client_sum_{{@p.id}}'>
									<input type="button" class="virtual_key" value='2' for='client_sum_{{@p.id}}'>
									<input type="button" class="virtual_key" value='3' for='client_sum_{{@p.id}}'>
									<br>
									<input type="button" class="virtual_key virtual_point" value='.' for='client_sum_{{@p.id}}'>
									<input type="button" class="virtual_key" value='0' for='client_sum_{{@p.id}}'>
									<button type="button" class="virtual_key_bks" for='client_sum_{{@p.id}}'>
										<i class="fas fa-long-arrow-alt-left"></i>
									</button>
								</div>
							</form>
						</true>
						<false>
							<br>
							<p align="center" class="epay_title">{{@epays[array_search(1, array_column(@epays, 'selected'))]['title']?@epays[array_search(1, array_column(@epays, 'selected'))]['title']:'<br>'}}</p>
							<p align="center">
								<i class="far fa-credit-card very_big"></i>
							</p>
							<form name="receipt_pay_form_{{@p.id}}" class="receipt_pay_form" method="POST" action="/receipts/sales">
								<input type="hidden" name="client_sum[{{@p.id}}]" class="client_sum" value="{{number_format(@sum, 2, '.', '')}}">
								<input type="hidden" name="paymentmethod[]" value="{{@p.id}}">
								<input type="hidden" name="writeoff" value="">
								<input type="hidden" name="type" value="{{@type}}">
								<input type="hidden" name="fpd" value="{{@GET.fpd}}">
								<input type="hidden" name="correct2" value="{{@GET.correct2}}">
								<input type="hidden" name="sales_receipts" class="sales_receipts" value="{{@base_settings['auto_sales_receipts']?1:0}}">
								<input type="hidden" name="client" class="client" value="{{@receipt['client']}}">
								<input type="hidden" name="executor" class="executor" value="">
								<input type="hidden" name="sno" class="sno" value="{{@sno_select}}">
								<input type="hidden" name="psr" class="psr" value="{{@psr_select}}">
								<input type="hidden" name="discount" value="{{@receipt['discount']}}">
								<input type="hidden" name="partner_id" value="{{@receipt['partner_id']}}">
								<check if="{{in_array('receipts/hold', @authorization_user.module)}}">
								<input type="hidden" name="hold" class="hold" value="0">
								<input type="hidden" name="nofr" class="nofr" value="0">
								</check>
								<input type="hidden" name="no_egais" class="no_egais" value="0">
								<input type="hidden" name="epay" class="epay" value="0">
								<input type="hidden" name="fr_print" class="fr_print" value="{{!@base_settings['ticket_print_default']?1:0}}">
							</form>
						</false>
					</check>
				</div>
				</repeat>
				<div class="tab_page tab_{{@n+1}} {{count(@receipt['pays'])>1?'tab_page_select':''}}">
					<form name="receipt_pay_form_0" class="receipt_pay_form" method="POST" action="/receipts/sales">
						<input type="hidden" name="type" value="{{@type}}">
						<input type="hidden" name="writeoff" value="">
						<input type="hidden" name="fpd" value="{{@GET.fpd}}">
						<input type="hidden" name="correct2" value="{{@GET.correct2}}">
						<input type="hidden" name="sales_receipts" class="sales_receipts" value="{{@base_settings['auto_sales_receipts']?1:0}}">
						<input type="hidden" name="client" class="client" value="">
						<input type="hidden" name="executor" class="executor" value="">
						<input type="hidden" name="sno" class="sno" value="{{@sno_select}}">
						<input type="hidden" name="psr" class="psr" value="{{@psr_select}}">
						<input type="hidden" name="discount" value="{{@receipt['discount']}}">
						<input type="hidden" name="partner_id" value="{{@receipt['partner_id']}}">
						<input type="hidden" name="epay" class="epay" value="0">
						<check if="{{in_array('receipts/hold', @authorization_user.module)}}">
						<input type="hidden" name="hold" class="hold" value="0">
						<input type="hidden" name="nofr" class="nofr" value="0">
						</check>
						<input type="hidden" name="no_egais" class="no_egais" value="0">
						<input type="hidden" name="nobt" class="nobt" value="0">
						<input type="hidden" name="fr_print" class="fr_print" value="{{!@base_settings['ticket_print_default']?1:0}}">
						{~@pays=array_column(@receipt['pays'], 'method')~}
						<repeat group="{{@paymentmethods}}" key="{{@n}}" value="{{@p}}">
						<div class="paymentmethod_mix_title {{@p['id']==count(@paymentmethods)?'m_right':''}}">
							{{@p.title}}<br>
							{~@pay_sum=0~}
							{~@pm=array_search(@p.id, @pays)~}
							{~if(@pm!==false) @pay_sum=@receipt['pays'][$pm]['sum']~}
							<input type="text" name="client_sum[{{@p.id}}]" inputmode="numeric" min="0" step="0.01" class="client_sum mixed_pay mixed_pay_{{@p.id}}" pid={{@p.id}} value="{{@pay_sum?number_format(@pay_sum, 2, '.', ''):''}}" autocomplete="off"  pattern="\d+(\.\d{2})?">
							<input type="hidden" name="paymentmethod[]" value="{{@p.id}}">
						</div>
						{{(@n+1)%2==0?'<br>':''}}
						</repeat>
						<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"]}}'>
							<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 virtual_point" value='.' for='mixed_pay_{{@paymentmethods[0]["id"]}}'>
							<input type="button" class="virtual_key" value='0' 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>
					</form>
				</div>
					
			</div>
		</td>
	</tr>
</table>

<div id="select_epay">
	<p align="center"><br><big>Выберите способ оплаты</big></p>
		<repeat group="{{@epays}}" value="{{@e}}">
		<span class="epay_span">
			<input type="radio" class="custom-checkbox" name="epay_0" id="epay_{{@e['id']}}" value="{{@e['id']}}" {{@e['selected']?'checked="checked"':''}}>
			<label for="epay_{{@e['id']}}" data-title="{{@e['title']}}"><br>{{@e['title']}}</label>
		</span>
	</repeat>
</div>

<script type="text/javascript">
var receipt_sum={{max(0, number_format(round(@sum, 2), 2, '.', ''))}};
if($('body').width()>=961) {
	$('.client_sum_{{@paymentmethods[0]["id"]}}').focus();
	$('.client_sum_{{@paymentmethods[0]["id"]}}').select();
	$('.client_sum_{{@paymentmethods[0]["id"]}}').blur();
}
$('.tab_page_select .client_sum').trigger('change');
$('.tab_select').trigger('click');
check_epay();
</script>
<check if="{{count(@receipt['pays'])==0 && array_sum(array_column(@epays, 'selected'))>0}}">
<script type="text/javascript">
$('.tab[cash="0"]').trigger('click');
$('.receipt_pay_form .epay').val($('input[name="epay_0"]:checked').val());
$('#select_epay').hide();
</script>
</check>
<check if="{{@type==@receipt_writeoff}}">
<p align="center">
	Укажите причину списания
	<br>
	<select name="TypeWriteOff">
		<option value="Порча">Порча</option>
		<option value="Приготовление">Приготовление</option>
		<option value="Пересортица">Пересортица</option>
		<option value="Недостача">Недостача</option>
		<option value="Уценка">Уценка</option>
		<option value="Потери">Потери</option>
		<option value="Проверки">Проверки</option>
		<option value="Арест">Арест</option>
		<option value="Производственные потери" selected="selected">Производственные потери</option>
		<option value="Иные цели">Иные цели</option>
	</select>
	<br>
	<input type="button" id="writeoff_ok" value="Списать">
</p>

<style>
.paymentmethod_table {
	display: none;
}
</style>
</check>