{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<H1>{$layout.pagetitle}</H1>
<SCRIPT type="text/javascript">
<!--
	function show(n)
	{
		document.getElementById(n).style.display = '';
		if (n == 'tab_return')
		{
			document.getElementById('tab_settle').style.display = 'none';
		}
		else
		{
			document.getElementById('tab_return').style.display = 'none';
		}
	}

	function savereceipt(print)
	{
		var which = 0;
		$('form[name="receipt"] [name^="which"]:checked').each(function() {
			which += parseInt($(this).val());
		});

		document.receipt.action = "?m=receiptadv&id={$receipt.id}&which=" + which;

		if (print == 1) {
			document.receipt.action += "&print=1";
		}
		document.receipt.submit();
	}
//-->
</SCRIPT>
{$default_printpage = ConfigHelper::getConfig('receipts.default_printpage')}
<FORM NAME="receipt" METHOD="POST" ACTION="?m=receiptadv&id={$receipt.id}">
<INPUT type="submit" class="hiddenbtn">
<INPUT type="hidden" name="receipt[id]" value="{$receipt.id}">
<input type="hidden" name="receipt[currency]" value="{$receipt.currency}">
<TABLE WIDTH="100%" CELLPADDING="3">
	<TR CLASS="light">
		<TD width="100%" CLASS="ftopu">
			<label>
				<INPUT type="radio" name="receipt[type]" value="return" id="radio_return" onclick="show('tab_return')" checked>
				<strong>{trans("return")}</strong>
			</label>
			<BR>
			    <TABLE width="100%" id="tab_return" style="margin-left: 40px;{if isset($receipt.type) && $receipt.type!="return"} display: none;{/if}">
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Cash-in receipt number:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receipt[number]" VALUE="{if $receipt.number}{$receipt.number}{/if}" SIZE="10" {tip text="Enter receipt number. WARNING! Changing this number can be DANGEROUS! (leave this field empty to obtain next number)" trigger="number"}>
					{if $receipt.extnumber || $receipt.in_extended}
					    {trans("Additional number:")}
					    <INPUT TYPE="TEXT" NAME="receipt[extnumber]" VALUE="{$receipt.extnumber}" SIZE="40" {tip text="Enter additional document number" trigger="extnumber"}>
					{/if}
				    </TD>
				</TR>
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Settlement date:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receiptr[cdate]" VALUE="{if $receipt.cdate}{$receipt.cdate|date_format:"Y/m/d"}{/if}" SIZE="10" placeholder="{trans("yyyy/mm/dd")}" {tip class="lms-ui-date" text="Enter date of settlement in YYYY/MM/DD format (empty field means current date) or click to select it from calendar" trigger="cdate"}>
					{if $receipt.cdatewarning}
					<INPUT TYPE="HIDDEN" NAME="receiptr[cdatewarning]" VALUE="1">
					{/if}
				    </TD>
				</TR>
			    </TABLE>
			<label>
				<INPUT type="radio" name="receipt[type]" value="settle" id="radio_settle" onclick="show('tab_settle')" {if $receipt.type=="settle"} checked{/if}>
				<strong>{trans("settlement")}</strong>
			</label>
			<BR>
			    <TABLE width="100%" id="tab_settle" style="margin-left: 40px;{if $receipt.type!="settle"} display: none;{/if}">
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Cash-in receipt number:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receipt[in_number]" VALUE="{if $receipt.in_number}{$receipt.in_number}{/if}" SIZE="10" {tip text="Enter receipt number. WARNING! Changing this number can be DANGEROUS! (leave this field empty to obtain next number)" trigger="in_number"}>
					{if $receipt.in_extnumber || $receipt.in_extended}
					    {trans("Additional number:")}
    					    <INPUT TYPE="TEXT" NAME="receipt[in_extnumber]" VALUE="{$receipt.in_extnumber}" SIZE="40" {tip text="Enter additional document number" trigger="in_extnumber"}>
					{/if}
				    </TD>
				</TR>
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Cash-out receipt number:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receipt[out_number]" VALUE="{if $receipt.out_number}{$receipt.out_number}{/if}" SIZE="10" {tip text="Enter receipt number. WARNING! Changing this number can be DANGEROUS! (leave this field empty to obtain next number)" trigger="out_number"}>
					{if $receipt.out_extnumber || $receipt.out_extended}
					    {trans("Additional number:")}
    					    <INPUT TYPE="TEXT" NAME="receipt[out_extnumber]" VALUE="{$receipt.out_extnumber}" SIZE="40" {tip text="Enter additional document number" trigger="out_extnumber"}>
					{/if}
				    </TD>
				</TR>
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Settlement date:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receipt[cdate]" VALUE="{if $receipt.cdate}{$receipt.cdate|date_format:"Y/m/d"}{/if}" SIZE="10" placeholder="{trans("yyyy/mm/dd")}" {tip class="lms-ui-date" text="Enter date of settlement in YYYY/MM/DD format (empty field means current date) or click to select it from calendar" trigger="cdate"}>
					{if $receipt.cdatewarning}
					<INPUT TYPE="HIDDEN" NAME="receipt[cdatewarning]" VALUE="1">
					{/if}
				    </TD>
				</TR>
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Value:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receipt[value]" VALUE="{if $receipt.value}{$receipt.value|string_format:"%.2f"}{/if}" SIZE="10" {tip text="Enter real amount of expense" trigger="value"}>
				    </TD>
				</TR>
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Recipient:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receipt[name]" VALUE="{$receipt.name}" SIZE="70" {tip text="Enter recipient" trigger="name"}>
				    </TD>
				</TR>
				<TR>
				    <TD WIDTH="1%" NOWRAP>
					{trans("Description:")}
				    </TD>
				    <TD WIDTH="99%" NOWRAP>
					<INPUT TYPE="TEXT" NAME="receipt[description]" VALUE="{$receipt.description}" SIZE="70" {tip text="Enter receipt description" trigger="description"}>
				    </TD>
				</TR>
			</TABLE>
		</TD>
	</TR>
	<TR CLASS="light">
		<TD WIDTH="100%" ALIGN="right" CLASS="fbottomu">
			<label>
				<INPUT type="checkbox" name="which[{$smarty.const.DOC_ENTITY_ORIGINAL}]"
						value="{$smarty.const.DOC_ENTITY_ORIGINAL}"
						{if preg_match('/copy/i', $default_printpage)} checked{/if}>
				{$_DOCENTITIES[$smarty.const.DOC_ENTITY_ORIGINAL]}
			</label>
			<label>
				<INPUT type="checkbox" name="which[{$smarty.const.DOC_ENTITY_ORIGINAL}]"
						value="{$smarty.const.DOC_ENTITY_ORIGINAL}"
						{if preg_match('/copy/i', $default_printpage)} checked{/if}>
				{$_DOCENTITIES[$smarty.const.DOC_ENTITY_COPY]}
			</label>
			<A HREF="?m=receiptlist&regid={$receipt.regid}">{trans("Cancel")} <IMG SRC="img/cancel.gif" alt=""></A>&nbsp;
			<A HREF="javascript: savereceipt(0);">{trans("Save")} <IMG SRC="img/save.gif" ALT=""></A>&nbsp;
			<A HREF="javascript: savereceipt(1);">{trans("Save & Print")} <IMG SRC="img/print.gif" ALT=""></A>
		</TD>
	</TR>
</TABLE>
</FORM>
<SCRIPT type="text/javascript">
<!--
$(function() {
	$('form[name="receipt"] [name="receipt[name]"]').focus();
});
//-->
</SCRIPT>
{/block}
