<!--// $Id$ //-->
<DIV{if !$note.last} STYLE="page-break-after: always"{/if}>
<DIV align="right" class="sdr">
{trans("Draw-up date:")} {$note.cdate|date_format:"Y-m-d"}{if $note.division_cplace != ""}, {$note.division_cplace}{/if}
<BR>
{trans("Deadline:")} {$note.pdate|date_format:"Y-m-d"}
<BR>
{if !ConfigHelper::checkConfig('notes.hide_payment_type', ConfigHelper::checkConfig('invoices.hide_payment_type'))}
	{trans("Payment type:")}
	{trans($note.paytypename)}
{/if}
{trans("Expositor:")}
{if $note.issuer}
	{$note.issuer|escape}
{elseif $note.user}
	{$note.user|escape}
{elseif $note.division_author}
	{$note.division_author|escape}
{else}
	{trans("system")}
{/if}
</DIV>

<H2 align="center" class="hdf">
{number number=$note.number template=$note.template time=$note.cdate assign=number}
<B>{t a=$number}Debit Note No. $a{/t}</B>
{if $note.dontpublish}
<BR><B>{trans("NO ACCOUNTANT DOCUMENT")}</B>
{/if}
</H2>
<BR>

<TABLE WIDTH="100%" CELLSPACING="3" class="sdr">
	<TR>
		<TD WIDTH="54%" class="sdr valign-top">
			<B>{trans("Note drawer:")}</B><BR>
			{if !ConfigHelper::checkConfig('invoices.show_only_alternative_accounts')
				|| empty($note.bankccounts)}
				{$accounts = array(bankaccount($note.customerid, $note.account))}
			{else}
				{$accounts = array()}
			{/if}
			{if ConfigHelper::checkConfig('invoices.show_all_accounts')
				|| ConfigHelper::checkConfig('invoices.show_only_alternative_accounts')}
				{$accounts = array_merge($accounts, $note.bankaccounts)}
			{/if}
			{foreach $accounts as $accountidx => $account}
				{$accounts[$accountidx] = format_bankaccount($account)}
			{/foreach}
			{textformat assign="account_text" wrap=5000}
				{if $use_alert_color}<span style="color:red">{/if}{implode('<br>', $accounts)}{if $use_alert_color}</span>{/if}
			{/textformat}
			{$tmp = $note.division_header}
			{$tmp = str_replace("\n", '<br>', $tmp)}
			{$tmp = str_replace('%bankaccount', $account_text, $tmp)}
			{$tmp = str_replace('%bankname', $note.div_bank, $tmp)}

			{if ConfigHelper::checkConfig('invoices.customer_bankaccount', true)}
				{textformat assign="tmp" wrap=5000}
					{$tmp}<br>{trans('Bank account:')}<br><strong>{$account_text}</strong>
				{/textformat}
			{/if}

			{$tmp}
			<BR>
			<BR>
			<BR>
			<B>{trans("Note recipient:")}</B><BR>
			{$note.name}<BR>
			{$note.address}<BR>
			{$note.zip} {$note.city}
			{if $note.ten}
				<BR>{t a=$note.ten}TEN $a{/t}
			{elseif !ConfigHelper::checkConfig('invoices.hide_ssn', true) && $note.ssn}
				<br>{t a=$note.ssn}SSN $a{/t}
			{/if}
			{if ConfigHelper::checkConfig('invoices.customer_credentials', true)}
				{if $note.customerpin}
					<BR>
					<strong>{trans("Customer ID:")} {$note.customerid|string_format:"%04d"}<BR>
					PIN: {$note.customerpin|string_format:"%04d"}</strong>
					<BR>
				{/if}
			{/if}
		</TD>
		<TD WIDTH="46%" class="mdf bold valign-top">
			{if ConfigHelper::checkConfig('invoices.post_address', true)}
				<BR>
				<BR>
				<B>
				{if $note.post_name || $note.post_address}
					{if $note.post_name}{$name=$note.post_name}{else}{$name=$note.name}{/if}
					{document_address name=$name address=$note.post_address street=$note.post_street zip=$note.post_zip postoffice=$note.post_postoffice city=$note.post_city}
				{else}
					{$note.name}<BR>
					{$note.address}<BR>
					{$note.zip} {$note.city}
				{/if}</B>
			{/if}
		</TD>
	</TR>
</TABLE>
<BR>
<TABLE WIDTH="100%" CELLPADDING="3">
    <TR CLASS="fall">
	<TD WIDTH="1%" CLASS="head" ALIGN="CENTER">
		<B>{trans("No.")}</B>
	</TD>
	<TD WIDTH="80%" CLASS="head" ALIGN="CENTER">
		<B>{trans("Title:")}</B>
	</TD>
	<TD WIDTH="19%" CLASS="head" ALIGN="CENTER">
		<B>{trans("Value:")}</B>
	</TD>
    </TR>
{cycle values="grey,white" print=false name=cycle2}
{counter start=0 print=false}
{foreach from=$note.content item=item}
    <TR class="{cycle name=cycle2}">
	<TD CLASS="flr" ALIGN="RIGHT">{counter}.</TD>
	<TD CLASS="flr">
		{$item.description}
	</TD>
	<TD CLASS="flr" ALIGN="RIGHT" NOWRAP>
		{$item.value|string_format:"%01.2f"}
	</TD>
    </TR>
    {/foreach}
    <TR>
	<TD COLSPAN="2" ALIGN="RIGHT" CLASS="ftop">
		<P ALIGN="RIGHT"><B>{trans("Total:")}</B></P>
	</TD>
	<TD CLASS="fall" ALIGN="RIGHT" NOWRAP>
		{$note.value|string_format:"%01.2f"}
	</TD>
    </TR>
</TABLE>
<BR>
<TABLE WIDTH="100%" CELLPADDING="3">
	<TR>
		<TD WIDTH="50%" ALIGN="RIGHT" CLASS="hdf">
			{t a=moneyf($note.value, $note.currency)}To pay: $a{/t}
		</TD>
	</TR>
	<TR>
		<TD WIDTH="50%" ALIGN="RIGHT" CLASS="sdr">
			{trans("In words:")}
			{moneyf_in_words($note.value, $note.currency)}
		</TD>
	</TR>
	<TR>
		<TD WIDTH="100%" COLSPAN="2">
			&nbsp;
		</TD>
	</TR>
	<TR>
		<TD WIDTH="100%" ALIGN="center">
			{$note.division_footer}
		</TD>
	</TR>
</TABLE>
</TD>
</TR>

{*
customer's balance: {$note.customerbalancelist.balance}
*}

{if $note.customerbalancelist.list}
<TABLE cellpadding="5" cellspacing="0" width="100%">
	<TR>
    		<TD width="1%" class="fleftu">{trans("Date:")}</TD>
	        <TD width="1%" class="fbt" align="right">{trans("Value:")}</TD>
    		<TD width="1%" class="fbt" align="right">{trans("Tax:")}</TD>
	        <TD width="1%" class="fbt" align="center">&raquo;</TD>
	        <TD width="1%" class="fbt" align="right">{trans("After:")}</TD>
	        <TD width="93%" class="frightu">{trans("Description:")}</TD>
	</TR>
	{if $note.customerbalancelistlimit >= $note.customerbalancelist.total}
		{assign var="startloop" value="0"}
	{else}
		{math assign="startloop" equation="x-y" x=$note.customerbalancelist.total y=$note.customerbalancelistlimit}
	{/if}
	{section name=balancelist loop=$note.customerbalancelist.list start=$startloop max=$note.customerbalancelistlimit}
	{* section name=balancelist loop=$note.customerbalancelist.list start=$note.customerbalancelistlimit step=-1 *}
	{$item=$note.customerbalancelist.list[balancelist]}
	<TR>
		<TD width="1%" class="nobr">{$item.date}</TD>
		<TD width="1%" align="right" class="nobr">{if $item.value > 0}+{/if}{moneyf($item.value, $item.currency)}</TD>
		<TD width="1%" align="right" class="nobr">{$item.tax}</TD>
		<TD width="1%" align="center">&raquo;</TD>
		<TD width="1%" align="right" class="nobr">
			{if $item.after < 0}<STRONG>{/if}
			    {moneyf($item.after)}
			{if $item.after < 0}</STRONG>{/if}
		</TD>
		<TD width="93%">{$item.comment}</TD>
        </TR>
	{/section}
</TABLE>
{/if}

{if !ConfigHelper::checkConfig('notes.issuer_signature')}
<table width="100%" style="margin-top:12em;">
	<tbody>
		<tr>
			<td width="50%"></td>
			<td width="27%" align="center" style="border-bottom:1px dotted #000;"></td>
		</tr>
		<tr>
			<td width="50%"></td>
			<td width="27%" align="center" class="sdr">{trans("issuer's signature")}</td>
		</tr>
	</tbody>
</table>
{/if}
</DIV>
