<div class="content2">
	<h1>{{@page_data.title}}</h1>
	<form name="egais_declaration_form" action="/egais/declaration" method="GET" class="no_ajax">
		<p class="false">{{@error}}</p>
		<b>Квартал</b>
		<select name="period">
			<loop from="{{@i=0}}" to="{{@i<4}}" step="{{@i++}}">
				{~@time=@i>0?strtotime((-@i*3).' month'):time()~}
				{~@n=ceil(date('n', @time)/3)~}
			<option value="{{@n}}-{{date('Y', @time)}}-{{@period[@n]['start'].'.'.date('Y', @time)}}-{{@period[@n]['end'].'.'.date('Y', @time)}}" {{(!@GET.period && @i==1) || (@GET.period==@n.'-'.date('Y', @time).'-'.@period[@n]['start'].'.'.date('Y', @time).'-'.@period[@n]['end'].'.'.date('Y', @time))?'selected="selected"':''}}>Q{{@n}} {{date('Y', @time)}} ({{@period[@n]['start'].'.'.date('Y', @time)}} - {{@period[@n]['end'].'.'.date('Y', @time)}})</option>
			</loop>
		</select>
		<b>Данные из</b>
		<select name="from">
			<option value="agorta">Агорта</option>
			<option value="utm" {{@GET.from=='utm'?'selected="selected"':''}}>УТМ ЕГАИС</option>
		</select>
		<button type="submit">Сформировать</button>
	</form>
	<form name="egais_send_declaration_form" class="form_with_disabled_check" action="/egais/declaration" method="POST">
		<input type="hidden" name="q" value="{{@Q}}">
		<input type="hidden" name="year" value="{{@year}}">
		<check if="{{@products}}">
		<table class="work_table">
			<tr>
				<th rowspan="2">

				</th>
				<th rowspan="2">
					Наименование / Алкокод / Код продукции
				</th>
				<th rowspan="2">
					Импортер
				</th>
				<th rowspan="2">
					Емкость (л)
				</th>
				<th rowspan="2">
					Начальный остаток
				</th>
				<th colspan="4">
					Поступления
				</th>
				<th colspan="3">
					Расходы
				</th>
				<th rowspan="2">
					Конечный остаток
				</th>
			</tr>
			<tr>
				<th>
					Закупка
				</th>
				<th>
					Возвраты
				</th>
				<th>
					Перемещения между складами (прием)
				</th>
				<th>
					Прочее
				</th>
				<th>
					Продажа
				</th>
				<th>
					Перемещения между складами (отгрузка)
				</th>
				<th>
					Прочее
				</th>
			</tr>
			<repeat group="{{@products}}" key="{{@alcocode}}" value="{{@p}}">
			<tr class="declaration_product">
				<td>
					<input type="checkbox" checked="checked">
				</td>
				<td>
					{{@p['title']}}
					<br>
					<input type="{{@alcocode>0?'hidden':'text'}}" name="product[{{@alcocode}}][alcocode]" value="{{@alcocode>0?@alcocode:''}}" placeholder="Алкокод" required="true">
					<input type="hidden" name="product[{{@alcocode}}][egais]" value="{{@p['egais']}}">
					<small>{{@alcocode>0?'Алкокод :'.@alcocode:''}}</small>
					<br>
					<input type="{{@products_info[@alcocode]['productType_Code']!=''?'hidden':'text'}}" name="product[{{@alcocode}}][productType_Code]" value="{{@products_info[@alcocode]['productType_Code']}}" placeholder="Код продукции" required="true">
					<small>{{@products_info[@alcocode]['productType_Code']?'Код продукции: '.@products_info[@alcocode]['productType_Code']:''}}</small>
				</td>
				<td align="left">
					<input type="{{@products_info[@alcocode]['owner_id']!=''?'hidden':'text'}}" name="product[{{@alcocode}}][owner_id]" value="{{@products_info[@alcocode]['owner_id']}}" placeholder="ФСРАР ИД" required="true">
					<small>{{@products_info[@alcocode]['owner_id']?'ФСРАР ИД: '.@products_info[@alcocode]['owner_id']:''}}</small>
					<br>
					<input type="{{@owners[@products_info[@alcocode]['owner_id']]['full_Name']!=''?'hidden':'text'}}" name="product[{{@alcocode}}][full_Name]" value="{{@owners[@products_info[@alcocode]['owner_id']]['full_Name']}}" placeholder="Наименование" required="true">
					<small>{{@owners[@products_info[@alcocode]['owner_id']]['full_Name']?'Наименование: '.@owners[@products_info[@alcocode]['owner_id']]['full_Name']:''}}</small>
					<br>
					<input type="{{@owners[@products_info[@alcocode]['owner_id']]['inn']!=''?'hidden':'text'}}" name="product[{{@alcocode}}][inn]" value="{{@owners[@products_info[@alcocode]['owner_id']]['inn']}}" placeholder="ИНН" required="true">
					<small>{{@owners[@products_info[@alcocode]['owner_id']]['inn']?'ИНН: '.@owners[@products_info[@alcocode]['owner_id']]['inn']:''}}</small>
					<br>
					<input type="{{@owners[@products_info[@alcocode]['owner_id']]['kpp']!=''?'hidden':'text'}}" name="product[{{@alcocode}}][kpp]" value="{{@owners[@products_info[@alcocode]['owner_id']]['kpp']}}" placeholder="КПП">
					<small>{{@owners[@products_info[@alcocode]['owner_id']]['kpp']?'КПП: '.@owners[@products_info[@alcocode]['owner_id']]['kpp']:''}}</small>
					<check if="{{(!@products_info[@alcocode]['owner_id'] || !@owners[@products_info[@alcocode]['owner_id']]['full_Name'] || !@owners[@products_info[@alcocode]['owner_id']]['inn'] || !@owners[@products_info[@alcocode]['owner_id']]['kpp']) && @alcocode>0}}">
						<button type="button" class="show_window" href="/egais/searchindocs?alcocode={{@alcocode}}">Поискать в документах</button>
					</check>
				</td>
				<td align="center">
					<input type="{{@products_info[@alcocode]['capacity']>0?'hidden':'number'}}" step="0.001" min="0" name="product[{{@alcocode}}][capacity]" value="{{numberformat(@products_info[@alcocode]['capacity'], 3, '.', '')}}" placeholder="Емкость" required="true">
					<small>{{@products_info[@alcocode]['capacity']>0?numberformat(@products_info[@alcocode]['capacity'], 3, '.', ''):''}}</small>
				</td>

				<td align="center">
					<input type="number" class="goods" name="product[{{@alcocode}}][stock0]" value="{{numberformat(@p['stock0'], 3, '.', '')}}" step="0.001" min="0">
				</td>
				<td align="center">
					<input type="number" class="goods" name="product[{{@alcocode}}][goods]" value="{{numberformat(@p['goods'], 3, '.', '')}}" step="0.001" min="0">
				</td>
				<td align="center">
					<input type="number" class="goods" name="product[{{@alcocode}}][returns]" value="{{numberformat(@p['returns'], 3, '.', '')}}" step="0.001" min="0">
				</td>
				<td align="center">
					<input type="number" class="goods" name="product[{{@alcocode}}][movein]" value="{{numberformat(@p['movein'], 3, '.', '')}}" step="0.001" min="0">
				</td>
				<td align="center">
					<input type="number" class="goods" name="product[{{@alcocode}}][other_in]" value="{{numberformat(@p['other_in'], 3, '.', '')}}" step="0.001" min="0">
				</td>

				<td align="center">
					<input type="number" class="writeoff" name="product[{{@alcocode}}][sales]" value="{{numberformat(@p['sales'], 3, '.', '')}}" step="0.001" min="0">
				</td>
				<td align="center">
					<input type="number" class="writeoff" name="product[{{@alcocode}}][moveout]" value="{{numberformat(@p['moveout'], 3, '.', '')}}" step="0.001" min="0">
				</td>
				<td align="center">
					<input type="number" class="other_out" name="product[{{@alcocode}}][other_out]" value="{{numberformat(@p['other_out'], 3, '.', '')}}" step="0.001" min="0">
				</td>
				<td align="center">
					<input type="number" class="stock1" name="product[{{@alcocode}}][stock1]" value="{{numberformat(@p['stock1'], 3, '.', '')}}" step="0.001" min="0">
				</td>
			</tr>
			</repeat>
			<tr>
				<td align="center" colspan="13">
					<input type="button" id="declaration_writeoff_all" value="Списать все">
					<input type="submit" value="Отправить">
				</td>
			</tr>
		</table>
		</check>
	</form>
</div>