{include file="clearheader.html" landscape=true}
<!--// $Id$ //-->
{$report_type = ConfigHelper::getConfig('phpui.report_type')}
{$colspan = 6 + $taxescount}
{$colspan2 = 4}
{if $printextid}
	{$colspan = $colspan + 1}
	{$colspan2 = $colspan2 + 1}
{/if}
{foreach $pages as $item}{assign var=previtem value=$item-1}
{if $report_type == 'pdf'}
{if $item > 1}<page>{/if}
{else}
<DIV{if $item > 1} style="page-break-before: always; border-style: none;"{/if}>
{/if}
<TABLE WIDTH="100%" CELLPADDING="3" ALIGN="CENTER">
	<TR>
		<TD WIDTH="800" ALIGN="LEFT">
			<span class="hdf"><B>{$layout.pagetitle}</B></span><span class="sdr">{if $pagescount} ({t a=$item b=$pagescount}Page $a from $b{/t}){/if}</span>
		</TD>
		<TD WIDTH="200" ALIGN="RIGHT" NOWRAP>
			LMS {$layout.lmsv} @ {$layout.hostname}<BR>
			{t a=trans($smarty.now|date_format:"l") b=$smarty.now|date_format:"Y-m-d"}<!date-format>$a, $b{/t}
			<br>
			{t a=$layout.logname}Created by: $a{/t}
		</TD>
	</TR>
</TABLE>
<BR>
<TABLE WIDTH="100%" CELLPADDING="3" BORDER="1" ALIGN="CENTER">
	<TR>
		<TD WIDTH="25" CLASS="HEAD" ALIGN="CENTER">
			{trans("No.")}
		</TD>
		<TD WIDTH="100" CLASS="HEAD" ALIGN="CENTER">
			{if in_array(DOC_DNOTE, $doctypes)}{trans("Debit Note No.")}{else}{trans("Invoice No.")}{/if}<BR>
			{trans("Draw-up date")}
		</TD>
		<TD WIDTH="100" CLASS="HEAD" ALIGN="CENTER">
			{trans("Sale date")}<BR>
			{trans("Deadline")}
		</TD>
		<TD WIDTH="520" CLASS="HEAD" ALIGN="CENTER">
			{trans("Contractor")}
		</TD>
		{if $printextid}
			<td width="25" class="HEAD" align="center">
				{trans("Document external ID")}
			</td>
		{/if}
		{if !in_array(DOC_DNOTE, $doctypes)}
		{foreach $taxes as $tax}
		<TD WIDTH="50" CLASS="HEAD" ALIGN="CENTER">
			{trans("Net value")} {$tax.label}
		</TD>
		{if $tax.value}
		<TD WIDTH="50" CLASS="HEAD" ALIGN="CENTER">
			{trans("Tax value")} {$tax.label}
		</TD>
		{/if}
		{/foreach}
		{/if}
		<TD WIDTH="50" CLASS="HEAD" ALIGN="CENTER">
			{if in_array(DOC_DNOTE, $doctypes)}{trans("Value")}{else}{trans("Gross value")}{/if}
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		<TD WIDTH="50" CLASS="HEAD" ALIGN="CENTER">
			{trans("Total Tax")}
		</TD>
		{/if}
	</TR>
	{if !$printonlysummary}
	{cycle values="grey,white" print=false}
	{math assign=start equation="(x-1)*y" x=$item y=$rows}
	{section name=invoicelist loop=$invoicelist start=$start max=$rows}
	{$invoice = $invoicelist[invoicelist]}
	<TR class="{cycle}">
		<TD ALIGN="CENTER">
			{counter}.
		</TD>
		<TD ALIGN="RIGHT">
			<B>{$invoicelist[invoicelist].number}</B><BR>
			{$invoicelist[invoicelist].cdate|date_format:"d.m.Y"}
		</TD>
		<TD ALIGN="RIGHT">
			{if $invoicelist[invoicelist].sdate}{$invoicelist[invoicelist].sdate|date_format:"d.m.Y"}{else}{$invoicelist[invoicelist].cdate|date_format:"d.m.Y"}{/if}<BR>
			{$invoicelist[invoicelist].pdate|date_format:"d.m.Y"}
		</TD>
		<TD>
			{strip}
			<strong>{$invoicelist[invoicelist].custname}</strong>
			{if !$printcustomerid}&nbsp;(#{$invoicelist[invoicelist].customerid}){/if}
			{if $invoicelist[invoicelist].ctype == $smarty.const.CTYPES_COMPANY || !$printcustomerssn}
				{if $invoicelist[invoicelist].ten}, {$invoicelist[invoicelist].ten}{/if}
			{/if}
			<br>
			{$invoicelist[invoicelist].custaddress}
			{/strip}
		</TD>
		{if $printextid}
			<td width="25" class="head" align="center">
				{$invoice.extid}
			</td>
		{/if}
		{if !in_array(DOC_DNOTE, $doctypes)}
		{foreach $taxes as $tax}
		{assign var=taxid value=$tax.id}
		<TD ALIGN="RIGHT">
			{($invoice.$taxid.val * $invoice.currencyvalue)|string_format:"%01.2f"}
			{if $invoice.currency != Localisation::getCurrentCurrency()}<br>({moneyf($invoice.$taxid.val, $invoice.currency)}){/if}
		</TD>
		{if $tax.value}
		<TD ALIGN="RIGHT">
			{($invoice.$taxid.tax * $invoice.currencyvalue)|string_format:"%01.2f"}
			{if $invoice.currency != Localisation::getCurrentCurrency()}<br>({moneyf($invoice.$taxid.tax, $invoice.currency)}){/if}
		</TD>
		{/if}
		{/foreach}
		{/if}
		<TD ALIGN="RIGHT">
			{($invoice.brutto * $invoice.currencyvalue)|string_format:"%01.2f"}
			{if $invoice.currency != Localisation::getCurrentCurrency()}<br>({moneyf($invoice.brutto, $invoice.currency)}){/if}
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		<TD ALIGN="RIGHT">
			{($invoice.tax * $invoice.currencyvalue)|string_format:"%01.2f"}
			{if $invoice.currency != Localisation::getCurrentCurrency()}<br>({moneyf($invoice.tax, $invoice.currency)}){/if}
		</TD>
		{/if}
	</TR>
	{/section}
	{/if}
	<TR>
		<TD COLSPAN="{$colspan2}" ALIGN="RIGHT" class="HEADGREY">
			<B>{trans("Page total")}</B>
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		{foreach $taxes as $tax}
		{assign var=taxid value=$tax.id}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.val.$taxid|string_format:"%01.2f"}</B>
		</TD>
		{if $tax.value}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.tax.$taxid|string_format:"%01.2f"}</B>
		</TD>
		{/if}
		{/foreach}
		{/if}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.total|string_format:"%01.2f"}</B>
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.sumtax|string_format:"%01.2f"}</B>
		</TD>
		{/if}
	</TR>
	<TR>
		<TD COLSPAN="{$colspan2}" ALIGN="RIGHT" class="HEADGREY">
			<B>{trans("Transfered from previous page")}</B>
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		{foreach $taxes as $tax}
		{assign var=taxid value=$tax.id}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$previtem.allval.$taxid|string_format:"%01.2f"}</B>
		</TD>
		{if $tax.value}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$previtem.alltax.$taxid|string_format:"%01.2f"}</B>
		</TD>
		{/if}
		{/foreach}
		{/if}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$previtem.alltotal|string_format:"%01.2f"}</B>
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$previtem.allsumtax|string_format:"%01.2f"}</B>
		</TD>
		{/if}
	</TR>
	<TR>
		<TD COLSPAN="{$colspan2}" ALIGN="RIGHT" class="HEADGREY">
			<B>{trans("Total from start of period (invoices with receipt)")}</B>
		</TD>
		{foreach item=tax from=$taxes}
			{assign var=taxid value=$tax.id}
			<TD ALIGN="RIGHT" class="HEADGREY">
				<B>{$totals.$item.allval_receipt.$taxid|string_format:"%01.2f"}</B>
			</TD>
			{if $tax.value}
				<TD ALIGN="RIGHT" class="HEADGREY">
					<B>{$totals.$item.alltax_receipt.$taxid|string_format:"%01.2f"}</B>
				</TD>
			{/if}
		{/foreach}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.alltotal_receipt|string_format:"%01.2f"}</B>
		</TD>
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.allsumtax_receipt|string_format:"%01.2f"}</B>
		</TD>
	</TR>
	<TR>
		<TD COLSPAN="{$colspan2}" ALIGN="RIGHT" class="HEADGREY">
			<B>{trans("Total from start of period (correction notes with receipt)")}</B>
		</TD>
		{foreach item=tax from=$taxes}
			{assign var=taxid value=$tax.id}
			<TD ALIGN="RIGHT" class="HEADGREY">
				<B>{$totals.$item.allval_correction_note_receipt.$taxid|string_format:"%01.2f"}</B>
			</TD>
			{if $tax.value}
				<TD ALIGN="RIGHT" class="HEADGREY">
					<B>{$totals.$item.alltax_correction_note_receipt.$taxid|string_format:"%01.2f"}</B>
				</TD>
			{/if}
		{/foreach}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.alltotal_correction_note_receipt|string_format:"%01.2f"}</B>
		</TD>
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.allsumtax_correction_note_receipt|string_format:"%01.2f"}</B>
		</TD>
	</TR>
	<TR>
		<TD COLSPAN="{$colspan2}" ALIGN="RIGHT" class="HEADGREY">
			<B>{trans("Total from start of period (without receipt)")}</B>
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		{foreach $taxes as $tax}
		{assign var=taxid value=$tax.id}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.allval.$taxid|string_format:"%01.2f"}</B>
		</TD>
		{if $tax.value}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.alltax.$taxid|string_format:"%01.2f"}</B>
		</TD>
		{/if}
		{/foreach}
		{/if}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.alltotal|string_format:"%01.2f"}</B>
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{$totals.$item.allsumtax|string_format:"%01.2f"}</B>
		</TD>
		{/if}
	</TR>
	<TR>
		<TD COLSPAN="{$colspan2}" ALIGN="RIGHT" class="HEADGREY">
			<B>{trans("Total from start of period")}</B>
		</TD>
		{foreach item=tax from=$taxes}
			{assign var=taxid value=$tax.id}
			<TD ALIGN="RIGHT" class="HEADGREY">
				<B>{($totals.$item.allval.$taxid + $totals.$item.allval_receipt.$taxid + $totals.$item.allval_correction_note_receipt.$taxid)|string_format:"%01.2f"}</B>
			</TD>
			{if $tax.value}
				<TD ALIGN="RIGHT" class="HEADGREY">
					<B>{($totals.$item.alltax.$taxid + $totals.$item.alltax_receipt.$taxid + $totals.$item.alltax_correction_note_receipt.$taxid)|string_format:"%01.2f"}</B>
				</TD>
			{/if}
			{/foreach}
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{($totals.$item.alltotal + $totals.$item.alltotal_receipt + $totals.$item.alltotal_correction_note_receipt)|string_format:"%01.2f"}</B>
		</TD>
		<TD ALIGN="RIGHT" class="HEADGREY">
			<B>{($totals.$item.allsumtax + $totals.$item.allsumtax_receipt + $totals.$item.allsumtax_correction_note_receipt)|string_format:"%01.2f"}</B>
		</TD>
	</TR>
</TABLE>
{if $report_type == 'pdf'}
{if $item > 1}</page>{/if}
{else}
</DIV>
{/if}
{foreachelse}
<TABLE WIDTH="100%" CELLPADDING="3" ALIGN="CENTER">
	<TR style="border-style: none;">
		<TD WIDTH="800" ALIGN="LEFT">
			<B><span class="sdr">{$layout.pagetitle}</span></B>
		</TD>
		<TD WIDTH="200" ALIGN="RIGHT" NOWRAP>
			LMS {$layout.lmsv} @ {$layout.hostname}<BR>
			{t a=trans($smarty.now|date_format:"l") b=$smarty.now|date_format:"Y-m-d"}<!date-format>$a, $b{/t}
			<br>
			{t a=$layout.logname}Created by: $a{/t}
		</TD>
	</TR>
</TABLE>
<BR>
<TABLE WIDTH="100%" CELLPADDING="3" BORDER="1" ALIGN="CENTER">
	<TR>
		<TD WIDTH="25" CLASS="HEAD" ALIGN="CENTER">
			{trans("No.")}
		</TD>
		<TD WIDTH="125" CLASS="HEAD" ALIGN="CENTER">
			{if in_array(DOC_DNOTE, $doctypes)}{trans("Debit Note No.")}{else}{trans("Invoice No.")}{/if}<BR>
			{trans("Draw-up date")}
		</TD>
		<TD WIDTH="125" CLASS="HEAD" ALIGN="CENTER">
			{trans("Sale date")}<BR>
			{trans("Deadline")}
		</TD>
		<TD WIDTH="520" CLASS="HEAD" ALIGN="CENTER">
			{trans("Contractor")}
		</TD>
		{if $printextid}
			<td width="25" class="HEAD" align="center">
				{trans("Document external ID")}
			</td>
		{/if}
		{if !in_array(DOC_DNOTE, $doctypes)}
		{foreach $taxes as $tax}
		<TD WIDTH="50" CLASS="HEAD" ALIGN="CENTER">
			{trans("Net value")} {$tax.label}
		</TD>
		{if $tax.value}
		<TD WIDTH="50" CLASS="HEAD" ALIGN="CENTER">
			{trans("Tax value")} {$tax.label}
		</TD>
		{/if}
		{/foreach}
		{/if}
		<TD WIDTH="100" CLASS="HEAD" ALIGN="CENTER">
			{if in_array(DOC_DNOTE, $doctypes)}{trans("Value")}{else}{trans("Gross value")}{/if}
		</TD>
		{if !in_array(DOC_DNOTE, $doctypes)}
		<TD WIDTH="100" CLASS="HEAD" ALIGN="CENTER">
			{trans("Total Tax")}
		</TD>
		{/if}
	</TR>
	<tr>
		<td colspan="{$colspan}" class="empty-table">
			{trans("No such invoices in selected time period.")}
		</td>
	</tr>
</TABLE>
{/foreach}
{include file="clearfooter.html"}
