{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!-- $Id$ -->
<H1>{$layout.pagetitle}</H1>
<TABLE class="lmsbox lms-ui-background-cycle">
	<COLGROUP>
		<COL style="width: 1%;">
		<COL style="width: 95%;">
		<COL style="width: 1%;">
		<COL style="width: 1%;">
		<COL style="width: 1%;">
		<COL style="width: 1%;">
	</COLGROUP>
    <THEAD>
	<TR>
		<TD>
			<IMG SRC="img/payment.gif" ALT=""><BR>
			<IMG SRC="img/creditor.gif" ALT="">
		</TD>
		<TD class="text-left">
			<B>{trans("Name:")}</B><BR>
			{trans("Creditor:")}
		</TD>
		<TD class="text-right">
			{trans("ID:")}
		</TD>
		<TD class="text-right">
			{trans("Value:")}
		</TD>
		<TD class="text-right nobr">
			{trans("Payment day:")}
		</TD>
		<TD class="bold text-right nobr">
			{button icon="add" label="New Payment" href="?m=paymentadd"}
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	{foreach $paymentlist as $payment}
	<TR class="highlight" data-target-url="?m=paymentinfo&id={$payment.id}" data-name="{$payment.name}">
		<FORM NAME="addbalance{$payment@index}" METHOD="POST" ACTION="?m=balanceadd">
		<TD>
			<IMG SRC="img/payment.gif" ALT=""><BR>
			<IMG SRC="img/creditor.gif" ALT="">
		</TD>
		<TD>
			<B>{$payment.name}</B><BR>
			{$payment.creditor}
		</TD>
		<TD class="text-right">
			({$payment.id|string_format:"%04d"})
		</TD>
		<TD class="text-right nobr">
			{$payment.value|money_format}
		</TD>
		<TD class="text-right nobr">
			{$payment.payday}
		</TD>
		<TD class="lms-ui-buttons text-right nobr">
			<INPUT type="submit" class="hiddenbtn">
			<INPUT TYPE="HIDDEN" NAME="m" VALUE="balanceadd">
			<INPUT TYPE="HIDDEN" NAME="addbalance[value]" VALUE="{math equation="x*-1" x=$payment.value}">
			<INPUT TYPE="HIDDEN" NAME="addbalance[comment]" VALUE="{$payment.name} / {$payment.creditor}">
			<A HREF="javascript:document.addbalance{$payment@index}.submit();"><IMG src="img/pay.gif" alt="{trans("Account payment")}" title="{trans("Account payment")}"></A>
			<A class="delete-payment" HREF="?m=paymentdel&id={$payment.id}"><IMG src="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></A>
			<A HREF="?m=paymentedit&id={$payment.id}"><IMG SRC="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}"></A>
			<A HREF="?m=paymentinfo&id={$payment.id}"><IMG SRC="img/info.gif" alt="{trans("Info")}" title="{trans("Info")}"></A>&nbsp;
		</TD>
		</FORM>
	</TR>
	{foreachelse}
	<tr>
		<td colspan="6" class="empty-table">
			{trans("No such standing payments in database.")}
		</td>
	</tr>
	{/foreach}
    </TBODY>
    <TFOOT>
	<TR>
		<TD COLSPAN="3">
			&nbsp;
		</TD>
		<TD class="bold text-right">
			<IMG SRC="img/info2.gif" ALT="">&nbsp;<B>{trans("Total:")}</B>
		</TD>
		<TD class="bold text-left">
			{$listdata.total}
		</TD>
		<td class="bold text-right">
			{t a=$listdata.total}Total: $a{/t}
		</td>
	</TR>
    </TFOOT>
</TABLE>
	<script>
		$('.delete-payment').click(function() {
			var name = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to delete payment '$a'?", name), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
