<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
{literal}
@page {
  size: auto;
  odd-header-name: html_Header;
}

#MainTable {
  width: 100%;
  font-size: 8pt;
  border-collapse: collapse;
}
  
#MainTable .text-left {
	text-align: left;
}

#MainTable .text-right {
	text-align: right;
}

#MainTable .border-bottom {
	border-collapse: collapse;
	border-bottom: 1px solid black;
}

#MainTable .border-top {
	border-collapse: collapse;
	border-top: 1px solid black;
}

{/literal}
</style>
</head>
<body>
<htmlpageheader name="Header">
<div style="text-align: left;  font-weight: bold; font-size: 10pt;">
<table style="width: 100%">
<tr><td style="width: 50%">
	<table>
		<tr>
			<td style="font-size: 12px; font-weight: bold">{$COMPANY_NAME}</td>
		</tr>
		<tr>
			<td style="font-size: 12px; font-weight: bold">Data wydruku: {$CUR_DATE}</td>
		</tr>
		<tr>
			<td style="font-size: 12px; font-weight: bold">Rejestr sprzedaży VAT za okres od {$DATE_FROM} do {$DATE_TO}</td>
		</tr>
		<tr>
			<td style="font-size: 12px; font-weight: bold">Strona {literal}{PAGENO} z {nbpg}{/literal}</td>
		</tr>
	</table>
</td><td style="text-align: right; vertical-align: top; font-size: 8pt;">
Ustawienia raportu:<br>
Magazyn: {$S_STOCK}<br>
Rodzaj: {$S_KIND}<br>
Kategoria: {$S_CATEGORY}<br>
Typ: {$S_TYPE}
</td></tr>
</table>
</div>
</htmlpageheader>
<div>
{foreach from=$PAGES item=PAGE name=page"}
{assign var=pagesCount value=$PAGES|@count}

{assign var=vatColSize value=0}
{math 
  assign="vatColSize"
  equation="round(57/($vatsCount))"
 }
<table id="MainTable">
	<thead>
		<tr>
			<th class="border-top border-bottom" style="width: 3%;" rowspan="2">Lp.</th>
			<th class="text-left border-top" style="width: 20%;">Nr dok.</th>
			<th class="text-left border-top" style="width: 10%;">Data wyst.</th>
			<th class="text-left border-top" colspan="{$vatsCount+2}">Odbiorca - NIP,Konto KS, Nazwa, Adres</th>
		</tr>
		<tr>
			<th class="text-right border-bottom" style="width: 10%;">Sprz. brutto</th>
			<th class="text-right border-bottom" style="width: 10%;">Sprz. netto</th>
			{foreach from=$VATS key=vat_name item=i}
				<th class="text-right border-bottom" style="width: {$vatColSize}%;">Netto {$vat_name}</th>
				{if $i=='2'}
				<th class="text-right border-bottom" style="width: {$vatColSize}%;">VAT {$vat_name}</th>
				{/if}
			{/foreach}
			<th class="text-right border-bottom" style="width: 10%;">VAT Razem</th>
			<th class="text-right border-bottom" style="width: 10%;">Koszt</th>
		</tr>
	</thead>
	<tbody>
		{foreach from=$PAGE.rows item=row}
		{if $row.is_summary!=1}
			<tr>
				<td class="text-left border-bottom" rowspan="2">{$row.lp}</td>
				<td class="text-left">{$row.document_no}</td>
				<td class="text-left">{$row.register_date}</td>
				<td class="text-left" colspan="{$vatsCount+2}">{$row.parent_info}</td>
			</tr>
			<tr>
				<td class="text-right border-bottom">{$row.brutto|number_format:2:",":"."}</td>
				<td class="text-right border-bottom">{$row.netto|number_format:2:",":"."}</td>
				{foreach from=$row.vats item=v key=k}
					<td class="text-right border-bottom">{$v[0]|number_format:2:",":"."}</td>
					{if $VATS.$k == '2'}
						<td class="text-right border-bottom">{$v[1]|number_format:2:",":"."}</td>
					{/if}
				{/foreach}
				<td class="text-right border-bottom">{$row.vat|number_format:2:",":"."}</td>
				<td class="text-right border-bottom">{$row.purchase|number_format:2:",":"."}</td>
			</tr>
		{else}
			<tr>
				<td class="text-left" colspan="{$vatsCount+5}"><b>Razem - {$row.index}</b></td>
			</tr>
			<tr>
				<td class="text-right border-bottom">&nbsp;</td>
				<td class="text-right border-bottom" >{$row.total_brutto|number_format:2:",":"."}</td>
				<td class="text-right border-bottom" >{$row.total_netto|number_format:2:",":"."}</td>
				{foreach from=$row.vats item=v key=k}
					<td class="text-right border-bottom">{$v[0]|number_format:2:",":"."}</td>
					{if $VATS.$k == '2'}
						<td class="text-right border-bottom">{$v[1]|number_format:2:",":"."}</td>
					{/if}
				{/foreach}
				<td class="text-right border-bottom" >{$row.total_vat|number_format:2:",":"."}</td>
				<td class="text-right border-bottom" >{$row.total_purchase|number_format:2:",":"."}</td>
			</tr>
		{/if}
		{/foreach}
		<tr>
			<td class="text-left" colspan="{$vatsCount+6}">Suma strony:</td>
		</tr>
		<tr>
			<td class="border-bottom">&nbsp;</td>
			<td class="text-right border-bottom">{$PAGE.site_brutto|number_format:2:",":"."}</td>
			<td class="text-right border-bottom">{$PAGE.site_netto|number_format:2:",":"."}</td>
			{foreach from=$PAGE.site_vats item=v key=k}
				<td class="text-right border-bottom">{$v[0]|number_format:2:",":"."}</td>
				{if $VATS.$k == '2'}
					<td class="text-right border-bottom">{$v[1]|number_format:2:",":"."}</td>
				{/if}
			{/foreach}
			<td class="text-right border-bottom">{$PAGE.site_vat|number_format:2:",":"."}</td>
			<td class="text-right border-bottom">{$PAGE.site_purchase|number_format:2:",":"."}</td>
		</tr>
		<tr>
			<td class="text-left" colspan="{$vatsCount+6}">Suma z przeniesienia:</td>
		</tr>
		<tr>
			<td class="border-bottom">&nbsp;</td>
			<td class="text-right border-bottom">{$PAGE.moved_brutto|number_format:2:",":"."}</td>
			<td class="text-right border-bottom">{$PAGE.moved_netto|number_format:2:",":"."}</td>
			{foreach from=$PAGE.moved_vats item=v key=k}
				<td class="text-right border-bottom">{$v[0]|number_format:2:",":"."}</td>
				{if $VATS.$k == '2'}
					<td class="text-right border-bottom">{$v[1]|number_format:2:",":"."}</td>
				{/if}
			{/foreach}
			<td class="text-right border-bottom">{$PAGE.moved_vat|number_format:2:",":"."}</td>
			<td class="text-right border-bottom">{$PAGE.moved_purchase|number_format:2:",":"."}</td>
		</tr>
		<tr>
			<td class="text-left" colspan="{$vatsCount+6}">Suma razem:</td>
		</tr>
		<tr>
			<td class="border-bottom">&nbsp;</td>
			<td class="text-right border-bottom">{$PAGE.total_brutto|number_format:2:",":"."}</td>
			<td class="text-right border-bottom">{$PAGE.total_netto|number_format:2:",":"."}</td>
			{foreach from=$PAGE.total_vats item=v key=k}
				<td class="text-right border-bottom">{$v[0]|number_format:2:",":"."}</td>
				{if $VATS.$k == '2'}
					<td class="text-right border-bottom">{$v[1]|number_format:2:",":"."}</td>
				{/if}
			{/foreach}
			<td class="text-right border-bottom">{$PAGE.total_vat|number_format:2:",":"."}</td>
			<td class="text-right border-bottom">{$PAGE.total_purchase|number_format:2:",":"."}</td>
		</tr>
	</tbody>
</table>
{if $smarty.foreach.page.index != $pagesCount-1 }
	<newpage>
{/if}
{/foreach}
<p style="font-size: 8pt;">
KONIEC WYDRUKU
</p>
</div>
</body>
</html>