{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: 1%;">
        <COL style="width: 1%;">
        <COL style="width: 1%;">
        <COL style="width: 95%;">
        <COL style="width: 1%;">
    </COLGROUP>
    <THEAD>
	<TR>
		<TH scope="col" class="nobr">
                        <IMG src="img/queue.gif" ALT=""> {trans("Name:")}
		</TH>
		<TH scope="col" class="nobr lighter">
                        {trans("ID:")}
		</TH>
		<TH scope="col" class="text-right nobr lighter">
			{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_summaries')}
			{trans("Cash state:")}
			{/if}
		</TH>
		<TH scope="col" class="text-right lighter nobr">
                        {trans("Cash-in receipt numbering plan:")}<BR>
                        {trans("Cash-out receipt numbering plan:")}
		</TH>
		<TH scope="col" class="nobr lighter">
                	{trans("Description:")}
		</TH>
		<TH scope="col" class="text-right lighter nobr">
                        <A href="?m=cashregadd">{trans("Add registry")} <IMG src="img/save.gif" alt=""></A>
		</TH>
	</TR>
    </THEAD>
    <TBODY>
	{foreach $reglist as $reg}
	<TR class="highlight {if $reg.disabled} blend{/if}" data-target-url="?m=receiptlist&regid={$reg.id}" data-name="{$reg.name}">
		<TD class="nobr bold">
			<IMG src="img/queue.gif" ALT=""> {$reg.name}
		</TD>
		<TD class="text-right">
			({$reg.id|string_format:"%04d"})
		</TD>
		<TD class="nobr text-right{if $reg.balance < 0} lms-ui-alert{/if}">
			{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_summaries')}
			{$reg.balance|money_format}
			{/if}
		</TD>
		<TD class="text-right">
			{$reg.in_template|default:"%N/LMS/%Y"}<BR>
			{$reg.out_template|default:"%N/LMS/%Y"}
		</TD>
		<TD>
			{$reg.description}
		</TD>
		<TD class="lms-ui-buttons text-right nobr">
			<A HREF="?m=receiptadd&type=in&action=init&regid={$reg.id}"><IMG SRC="img/kp.png" alt="New Cash-in Receipt")}" title="{trans("New Cash-in Receipt")}"></A>
			<A HREF="?m=receiptadd&type=out&action=init&regid={$reg.id}"><IMG SRC="img/kw.png" alt="New Cash-out Receipt")}" title="{trans("New Cash-out Receipt")}"></A>
			<A HREF="?m=receiptlist&amp;regid={$reg.id}"><IMG SRC="img/view.gif" alt="{trans("Browse")}" title="{trans("Browse")}"></A>
			<A class="delete-cashreg" HREF="?m=cashregdel&id={$reg.id}"><IMG SRC="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></A>
			<A HREF="?m=cashregedit&amp;id={$reg.id}"><IMG SRC="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}"></A>
			<A HREF="?m=cashreginfo&amp;id={$reg.id}"><IMG SRC="img/info.gif" alt="{trans("Info")}" title="{trans("Info")}"></A>
		</TD>
	</TR>
	{foreachelse}
	<tr>
		<td colspan="6" class="empty-table">
			{trans("There are no cash registries.")}
		</td>
	</tr>
	{/foreach}
    </TBODY>
    <TFOOT>
	<TR>
		<TD COLSPAN="2" class="text-right bold nobr">
			{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_summaries')}
			<IMG src="img/info2.gif" ALT=""> {trans("Total:")}
			{/if}
		</TD>
		<TD class="text-right bold nobr">
			{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_summaries')}
			{$listdata.sum|money_format}
			{/if}
		</TD>
		<TD COLSPAN="2"></TD>
		<TD class="text-right nobr">
			<A href="?m=cashregadd">{trans("Add registry")} <IMG src="img/save.gif" alt=""></A>
		</TD>
	</TR>
    </TFOOT>
</TABLE>
	<script>
		$('.delete-cashreg').click(function() {
			var name = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to remove registry '$a' and all assigned receipts?", name), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
