<h1>{{@page_data['title']}}</h1>
<form name="add_marking_cocktail_form" class="add_marking_form add_marking_form_{{@positions?count(@positions):0}}" action="/receipts/add_cocktail_line" method="POST">
	<input type="hidden" name="receipttype" value="">
	<input type="hidden" name="product_id" value="{{@product['id']}}">
	<input type="hidden" name="count" value="1">
	<table width="100%" class="table_border">
		<tr>
			<th colspan="3" align="center">
				Алкогольные ингридиенты для "{{@product['short_title']}}"
			</th>
		</tr>
		<tr>
			<th align="center">
				Наименование
			</th>
			<th width="100" align="center">
				Добавлено
			</th>
			<th width="100" align="center">
				Кол-во
			</th>
		</tr>
	<repeat group="{{@product['components']}}" value="{{@component}}">
		<tr class="{{@add_product[$component['product_id']]==@component['quantity']?'complite':''}}">
			<td>
				<check if="{{@add_product[$component['product_id']]['count']==@component['quantity']}}">
				<b>&check;</b>
				</check>
				{{@component['title']}}
			</td>
			<td align="center">
				{{round(@add_product[$component['product_id']]['count'])??0}}
			</td>
			<td align="center">
				{{@component['quantity']}}
			</td>
		</tr>
		<check if="{{@add_product[$component['product_id']]['marks']}}">
			<repeat group="{{@add_product[$component['product_id']]['marks']}}" value="{{@mark}}">
		<tr>
			<td align="right">
				<i class="fas fa-qrcode"></i>
				{{mb_substr(@mark['mark'], 3, 3)}}
				{{mb_substr(@mark['mark'], 6, 8)}}
			</td>
			<td align="center">
				{{round(@mark['count'])}}
			</td>
			<td align="center">
				<a class="delete_cocktail_mark" data-mark="{{@mark['mark']}}">
					удалить
				</a>
			</td>
		</tr>
			</repeat>
		</check>
	</repeat>
	</table>
	<repeat group="{{@positions}}" key="{{@n}}" value="{{@position}}">

	<input type="hidden" name="positions[{{@n}}][product_id]" class="input_{{@position['mark']}}" value="{{@position['product_id']}}">
	<input type="hidden" name="positions[{{@n}}][title]" class="input_{{@position['mark']}}" value="{{@position['title']}}">
	<input type="hidden" name="positions[{{@n}}][count]" class="input_{{@position['mark']}}" value="{{@position['count']}}">
	<input type="hidden" name="positions[{{@n}}][mark]" class="input_{{@position['mark']}}" value="{{@position['mark']}}">
	</repeat>

	<p align="center">
		<b>Отсканируйте марку</b><br>
		<i class="fas icon fa-qrcode"></i>
		<input type="text" class="marking_input" name="mark" autocomplete="off">
		<input type="hidden" name="caps_on" class="caps_on" value="0">
		<input type="submit" value="Отправить">
	</p>
	<check if="{{@bottles}}">
		<p align="center">
			<b>Или выберите открытую бутылку</b>
		</p>
	</check>
	<div class="select_open_bottle_div">
		<repeat group="{{@bottles}}" value="{{@product}}">
		<div align="center" class="select_open_bottle_product">
			<p align="center"><b>{{@product['title']}}</b></p>
			<repeat group="{{@product['bottles']}}" value="{{@bottle}}">
			<button type="button" class="select_open_bottle {{isset(@add_marks) && in_array(@bottle['mark'], @add_marks)?'hide':''}}" data-mark="{{@bottle['mark']}}">
				<i class="fas fa-qrcode left"></i>
				{{$bottle['serial']}} {{$bottle['number']}}<br>
				<small>{{@bottle['current_volume']}} / {{@bottle['capacity']*1000}}мл</small>
			</button>
			</repeat>
		</div>
		</repeat>
	</div>
</form>
<br><br>
<p align="center">
	<button type="button" class="close">Отменить</button>
</p>

<script type="text/javascript">
if($('.add_marking_form').length>1) {
	$('.add_marking_form').eq(0).closest('.popup').remove();
}
$('.marking_input').eq(0).focus();
$('input[name="receipttype"]').val($('input[name="type"]').val());
$('.close_button', $('form[name="add_marking_cocktail_form"]').closest('.popup')).remove();
</script>
<script>
window_open_alarm();
</script>