tiki-accounting_entry.tpl 5.72 KB
Newer Older
1
{* $Id$ *}
2 3 4 5 6 7 8 9 10
{literal}
<script language="javascript">

function setAmount() {
	document.getElementById('debitAmount').value=document.getElementById('totalAmount').value;
	document.getElementById('creditAmount').value=document.getElementById('totalAmount').value;
}

function splitDebit() {
11 12 13 14 15
	document.getElementById('Row_SplitCredit').style.display = "none";
	var tbl = document.getElementById('tbl_debit');
	var lastRow = tbl.rows.length;
	var row = tbl.insertRow(lastRow-1);
	row.innerHTML=document.getElementById('Row_StartDebit').innerHTML;
16 17 18
}

function splitCredit() {
19 20 21 22 23
	document.getElementById('Row_SplitDebit').style.display = "none";
	var tbl = document.getElementById('tbl_credit');
	var lastRow = tbl.rows.length;
	var row = tbl.insertRow(lastRow-1);
	row.innerHTML=document.getElementById('Row_StartCredit').innerHTML;
24 25 26 27 28
}

function setAccount(v) {
	account.value=v;
}
29

30 31 32 33 34 35 36
var account='';
</script>
{/literal}
{title help="accounting"}
	{$book.bookName}: {tr}Book a transaction{/tr}
{/title}
{if !empty($errors)}
37
	<div class="alert alert-warning">
lindonb's avatar
lindonb committed
38
		{icon name='error' alt="{tr}Error{/tr}" style="vertical-align:middle" align="left"}
39 40
		{foreach from=$errors item=m name=errors}
			{$m}
41
			{if !$smarty.foreach.errors.last}<br>{/if}
42 43 44 45 46 47 48
		{/foreach}
	</div>
{/if}


<div id="accountlist" style="float:right; max-height=400px; overflow: scroll;">
	<table>
49 50 51 52
		<tr><th colspan="2">{tr}Accounts{/tr}</th></tr>
		{if $tiki_p_account_manage=='y'}
			<tr><td colspan="2"><a href="tiki-accounting_account.php?bookId={$bookId}&action=new">{tr}Create account{/tr}</a></td></tr>{/if}
			{foreach from=$accounts item=a}
53
				<tr class="{cycle values="odd,even"} tips" {popup caption="{tr}Notes{/tr}" text=$a.accountNotes}>
54 55 56 57 58 59 60 61 62 63 64 65
					<td class="accompactlist">
						{if $tiki_p_account_manage=='y'}
							<a href="tiki-accounting_account.php?bookId={$bookId}&action=edit&accountId={$a.accountId}"><img src="img/icons/edit.gif" alt="edit" border="0"></a>
							<a href="tiki-accounting_account.php?bookId={$bookId}&action=delete&accountId={$a.accountId}"><img src="img/icons/del.gif" alt="delete" border="0"></a>
						{/if}
						<a href="javascript:setAccount({$a.accountId})">{$a.accountId}</a>
					</td>
					<td class="accompactlist">
						{$a.accountName}
					</td>
				</tr>
			{/foreach}
66 67 68 69
	</table>
</div>
<div id="mask" style="float:left;">
	<form method="post" action="tiki-accounting_entry.php">
70 71 72
		{if $firstid}<input type="hidden" name="firstid" value="{$firstid}">{/if}
		{if $statementId}<input type="hidden" name="statementId" value="{$statementId}">{/if}
		<input type="hidden" name="bookId" value="{$bookId}">
73 74 75 76
		<fieldset>
			<legend>{tr}Post{/tr}</legend>
			<div>
				<label class="aclabel">{tr}booking date{/tr}</label>
77
				<input name="journalDate" id="journalDate" value="{$journalDate|default:$smarty.now|date_format:"%Y-%m-%d"}">
78 79 80 81 82 83 84
			</div>
			<div>
				<label class="aclabel">{tr}Description{/tr}</label>
				<textarea name="journalDescription" id="journalDescription" cols="40" rows="3">{$journalDescription}</textarea>
			</div>
			<div>
				<label class="aclabel">{tr}Amount{/tr}</label>
85
				<input name="totalAmount" id="totalAmount" value="{$totalAmount}" onchange="javascript:setAmount()">
86
			</div>
87
		</fieldset>
88 89 90
		<fieldset>
			<legend>{tr}Debit{/tr}</legend>
			<table id="tbl_debit">
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
				{section name=debit loop=$debitAccount}{assign var='i' value=$smarty.section.debit.iteration-1}
					<tr {if $i==0}id="Row_StartDebit" {/if}>
						<td>
							<label>{tr}Text{/tr}</label>
							<input type="text" name="debitText[]" value="{$debitText[$i]}">
						</td>
						<td>
							<label>{tr}Account{/tr}</label>
							<select name="debitAccount[]" style="width:180px" onfocus="account=this">
							{foreach from=$accounts item=a}
								<option value="{$a.accountId}"{if $a.accountId==$debitAccount[$i]} selected="selected"{/if}>{$a.accountId} {$a.accountName}</option>
							{/foreach}
							</select>
						</td>
						<td>
							<label>{tr}Amount{/tr}</label>
							<input name="debitAmount[]" {if $i==0}id="debitAmount" {/if}size="10" value="{$debitAmount[$i]}">
						</td>
					</tr>
				{/section}
111 112
				<tr id="Row_SplitDebit"{if count($creditAccount)>1} style="display:none;"{/if}>
					<td colspan="3">
113
						<input type="button" value="{tr}Add entry{/tr}" id="SplitDebit" onclick="javascript:splitDebit()">
114 115
					</td>
				</tr>
116
			</table>
117 118 119 120
		</fieldset>
		<fieldset>
			<legend>{tr}Credit{/tr}</legend>
			<table id="tbl_credit">
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
				{section name=credit loop=$creditAccount}{assign var='i' value=$smarty.section.credit.iteration-1}
					<tr {if $i==0}id="Row_StartCredit" {/if}>
						<td>
							<label>{tr}Text{/tr}</label>
							<input type="text" name="creditText[]" value="{$creditText[$i]}">
						</td>
						<td>
							<label>{tr}Account{/tr}</label>
							<select name="creditAccount[]" style="width:180px" onfocus="account=this">
								{foreach from=$accounts item=a}
									<option value="{$a.accountId}"{if $a.accountId==$creditAccount[$i]} selected="selected"{/if}>{$a.accountId} {$a.accountName}</option>
								{/foreach}
							</select>
						</td>
						<td>
							<label>{tr}Amount{/tr}</label>
							<input name="creditAmount[]" {if $i==0}id="creditAmount" {/if}size="10" value="{$creditAmount[$i]}">
						</td>
					</tr>
				{/section}
				<tr id="Row_SplitCredit"{if count($creditAccount)>1} style="display:none;"{/if}>
					<td colspan="3">
						<input type="button" value="{tr}Add entry{/tr}" id="SplitCredit" onclick="javascript:splitCredit()">
144
					</td>
145 146
				</tr>
			</table>
147
		</fieldset>
148
		<input type="submit" class="btn btn-default btn-sm" name="book" id="book" value="{tr}Book{/tr}">
149 150 151 152
		{button href="tiki-accounting.php?bookId=$bookId" _text="{tr}Back to book page{/tr}"}
	</form>
</div>
<div id="journal" style="clear: both;">
153
	{include file='tiki-accounting_journal.tpl'}
154
</div>