Commit 041387c1 authored by lindonb's avatar lindonb

[FIX] Eliminate currency smarty modifier and replace with pre-existing...

[FIX] Eliminate currency smarty modifier and replace with pre-existing number_format modifier, since they both call the same php function and neither one does currency formatting.
parent 7e473235
......@@ -3028,7 +3028,6 @@ lib/smarty_tiki/modifier.avatarize.php -text
lib/smarty_tiki/modifier.breakline.php -text
lib/smarty_tiki/modifier.compactisodate.php -text
lib/smarty_tiki/modifier.countryflag.php -text
lib/smarty_tiki/modifier.currency.php -text
lib/smarty_tiki/modifier.dbg.php -text
lib/smarty_tiki/modifier.div.php -text
lib/smarty_tiki/modifier.duration.php -text
......
<?php
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: currency
* Purpose: formats a number as currency using number_format
* -------------------------------------------------------------
*/
function smarty_modifier_currency($string, $dec_point=',', $thousands='.')
{
return number_format($string, 2, $dec_point, $thousands);
}
......@@ -26,7 +26,7 @@
* @param thousands: thousands separator
* @return number
*/
function smarty_modifier_number_format($number, $decimals, $dec_point = null, $thousands = null) {
function smarty_modifier_number_format($number, $decimals = 2, $dec_point = '.', $thousands = ',') {
$dec_point = separator($dec_point);
$thousands = separator($thousands);
return number_format($number, $decimals, $dec_point, $thousands);
......@@ -35,9 +35,15 @@ function smarty_modifier_number_format($number, $decimals, $dec_point = null, $t
function separator($sep) {
switch ($sep) {
case 'c':
case ',':
$sep = ',';
break;
case 'd':
case '.':
$sep = '.';
break;
case 's':
case ' ':
$sep = ' ';
break;
}
......
......@@ -22,6 +22,9 @@
<div><div class="aclabel">{tr}End date{/tr}</div>{$book.bookEndDate}</div>
<div><div class="aclabel">{tr}Closed{/tr}</div>{if $book.bookClosed=='y'}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}</div>
<div><div class="aclabel">{tr}Currency{/tr}</div>{$book.bookCurrency} ({if $book.bookCurrencyPos==-1}{tr}before{/tr}{elseif $book.bookCurrencyPos==1}{tr}after{/tr}{else}{tr}don't display{/tr}{/if})</div>
<div><div class="aclabel">{tr}Decimals{/tr}</div>{$book.bookDecimals}</div>
<div><div class="aclabel">{tr}Decimal Point{/tr}</div>{$book.bookDecPoint}</div>
<div><div class="aclabel">{tr}Thousands Separator{/tr}</div>{$book.bookThousand}</div>
<div><div class="aclabel">{tr}Auto Tax{/tr}</div>{if $book.bookAutoTax=='y'}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}</div>
</div>
</div>
......
......@@ -18,18 +18,18 @@
<td>{$a.accountNotes|escape}</td>
<td style="text-align:right">
{if $book.bookCurrencyPos==-1}{$book.bookCurrency}{/if}
{$a.accountBudget|currency:$book.bookDecPoint:$book.bookThousand}
{$a.accountBudget|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}
{if $book.bookCurrencyPos==1}{$book.bookCurrency}{/if}
</td>
<td>{if $a.accountLocked==1}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}</td>
<td style="text-align:right">
{if $book.bookCurrencyPos==-1}{$book.bookCurrency}{/if}
{$a.debit|currency:$book.bookDecPoint:$book.bookThousand}
{$a.debit|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}
{if $book.bookCurrencyPos==1}{$book.bookCurrency}{/if}
</td>
<td style="text-align:right">
{if $book.bookCurrencyPos==-1}{$book.bookCurrency}{/if}
{$a.credit|currency:$book.bookDecPoint:$book.bookThousand}
{$a.credit|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}
{if $book.bookCurrencyPos==1}{$book.bookCurrency}{/if}
</td>
<td>{$a.accountTax}</td>
......
......@@ -20,7 +20,7 @@
<div><div class="aclabel">{tr}Notes{/tr}</div>
{$account.accountNotes}</div>
<div><div class="aclabel">{tr}Budget{/tr}</div>
{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$account.accountBudget|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</div>
{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$account.accountBudget|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</div>
<div><div class="aclabel">{tr}Locked{/tr}</div>
{if $account.accountLocked==1}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}</div>
{button href="tiki-accounting.php?bookId=$bookId" _text="Back to book page"}
......
{* $Id$ *}{$quote}{tr}Account{/tr}{$quote}{$separator}{$quote}{tr}Account name{/tr}{$quote}{$separator}{$quote}{tr}Notes{/tr}{$quote}{$separator}{$quote}{tr}Currency{/tr}{$quote}{$separator}{$quote}{tr}Budget{/tr}{$quote}{$separator}{$quote}{tr}Locked{/tr}{$quote}{$separator}{$quote}{tr}Debit{/tr}{$quote}{$separator}{$quote}{tr}Credit{/tr}{$quote}{$separator}{$quote}{tr}Tax{/tr}{$quote}{$eol}{foreach from=$accounts item=a}{$a.accountId}{$separator}{$quote}{$a.accountName|escape}{$quote}{$separator}{$quote}{$a.accountNotes|escape}{$quote}{$separator}{$quote}{$book.bookCurrency}{$quote}{$separator}{$a.accountBudget|currency}{$separator}{$quote}{if $a.accountLocked==1}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}{$quote}{$separator}{$a.debit|currency}{$separator}{$a.credit|currency}{$eol}{/foreach}
{* $Id$ *}{$quote}{tr}Account{/tr}{$quote}{$separator}{$quote}{tr}Account name{/tr}{$quote}{$separator}{$quote}{tr}Notes{/tr}{$quote}{$separator}{$quote}{tr}Currency{/tr}{$quote}{$separator}{$quote}{tr}Budget{/tr}{$quote}{$separator}{$quote}{tr}Locked{/tr}{$quote}{$separator}{$quote}{tr}Debit{/tr}{$quote}{$separator}{$quote}{tr}Credit{/tr}{$quote}{$separator}{$quote}{tr}Tax{/tr}{$quote}{$eol}{foreach from=$accounts item=a}{$a.accountId}{$separator}{$quote}{$a.accountName|escape}{$quote}{$separator}{$quote}{$a.accountNotes|escape}{$quote}{$separator}{$quote}{$book.bookCurrency}{$quote}{$separator}{$a.accountBudget|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{$separator}{$quote}{if $a.accountLocked==1}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}{$quote}{$separator}{$a.debit|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{$separator}{$a.credit|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{$eol}{/foreach}
......@@ -70,9 +70,19 @@
<div><label class="aclabel">{tr}Decimals{/tr}</label>
<input type="text" name="bookDecimals" id="bookDecimals" value="{$bookDecimals}" /></div>
<div><label class="aclabel">{tr}Decimal point{/tr}</label>
<input type="text" name="bookDecPoint" id="bookDecPoint" value="{$bookDecPoint}" /></div>
<select name="bookDecPoint" id="bookDecPoint">
<option value="," {if $bookDecPoint eq ','}selected="selected"{/if}>{tr}Comma{/tr}</option>
<option value="." {if empty($bookDecPoint) or $bookDecPoint eq '.'}selected="selected"{/if}>{tr}Decimal{/tr}</option>
<option value=" " {if $bookDecPoint eq ' '}selected="selected"{/if}>{tr}Space{/tr}</option>
</select></div>
{*<input type="text" name="bookDecPoint" id="bookDecPoint" value="{$bookDecPoint}" /></div>*}
<div><label class="aclabel">{tr}Thousands separator{/tr}</label>
<input type="text" name="bookThousand" id="bookThousand" value="{$bookThousand}" /></div>
<select name="bookThousand" id="bookThousand" >
<option value="," {if empty($bookThousand) or $bookThousand eq ','}selected="selected"{/if}>{tr}Comma{/tr}</option>
<option value="." {if $bookThousand eq '.'}selected="selected"{/if}>{tr}Decimal point{/tr}</option>
<option value=" " {if $bookThousand eq ' '}selected="selected"{/if}>{tr}Space{/tr}</option>
</select></div>
{*<input type="text" name="bookThousand" id="bookThousand" value="{$bookThousand}" /></div>*}
</fieldset>
<fieldset>
<legend>CSV export settings</legend>
......
......@@ -35,7 +35,7 @@
<td>{$d.itemAccountId}</td>
<td>
{if $book.bookCurrencyPos==-1}{$book.bookCurrency}{/if}
{$d.itemAmount|currency:$book.bookDecPoint:$book.bookThousand}
{$d.itemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}
{if $book.bookCurrencyPos==1}{$book.bookCurrency}{/if}
</td>
</tr>
......@@ -52,7 +52,7 @@
<td>{$c.itemAccountId}</td>
<td>
{if $book.bookCurrencyPos==-1}{$book.bookCurrency}{/if}
{$c.itemAmount|currency:$book.bookDecPoint:$book.bookThousand}
{$c.itemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}
{if $book.bookCurrencyPos==1}{$book.bookCurrency}{/if}
</td>
</tr>
......
......@@ -26,10 +26,10 @@
{section name=posts loop=$j.maxcount}{assign var='i' value=$smarty.section.posts.iteration-1}
{if !$smarty.section.posts.first}<tr class="{$style}">{/if}
<td class="journal{if $j.journalCancelled==1}deleted{/if}" style="text-align:right">{if $i<$j.debitcount}{$j.debit[$i].itemAccountId}{/if}&nbsp;</td>
<td class="journal{if $j.journalCancelled==1}deleted{/if}" style="text-align:right">{if $i<$j.debitcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$j.debit[$i].itemAmount|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal{if $j.journalCancelled==1}deleted{/if}" style="text-align:right">{if $i<$j.debitcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$j.debit[$i].itemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal{if $j.journalCancelled==1}deleted{/if}">{if $i<$j.debitcount}{$j.debit[$i].itemText|escape}{/if}&nbsp;</td>
<td class="journal{if $j.journalCancelled==1}deleted{/if}" style="text-align:right">{if $i<$j.creditcount}{$j.credit[$i].itemAccountId}{/if}&nbsp;</td>
<td class="journal{if $j.journalCancelled==1}deleted{/if}" style="text-align:right">{if $i<$j.creditcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$j.credit[$i].itemAmount|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal{if $j.journalCancelled==1}deleted{/if}" style="text-align:right">{if $i<$j.creditcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$j.credit[$i].itemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal{if $j.journalCancelled==1}deleted{/if}">{if $i<$j.creditcount}{$j.credit[$i].itemText|escape}{/if}&nbsp;</td>
{if $smarty.section.posts.first}<td rowspan="{$j.maxcount}">{if $j.journalCancelled==1}&nbsp;{else}
<a class="icon" href="tiki-accounting_cancel.php?bookId={$bookId}&journalId={$j.journalId}">{icon _id="delete" alt="{tr}cancel this transaction{/tr}" _confirm="{tr}Are you sure you want to cancel this transaction{/tr}"}</a>{/if}
......@@ -42,13 +42,13 @@
{if isset($totals)}
<tr>
<td class="journal"><b>{tr}Balance{/tr}</b></td>
<td class="journal" style="text-align:right"><b>{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$totals.total|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</b></td>
<td class="journal" style="text-align:right"><b>{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$totals.total|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</b></td>
<td class="journal">&nbsp;</td>
<td class="journal"><b>{tr}Debit{/tr}</b></td>
<td class="journal" style="text-align:right"><b>{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$totals.debit|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</b></td>
<td class="journal" style="text-align:right"><b>{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$totals.debit|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</b></td>
<td class="journal">&nbsp;</td>
<td class="journal"><b>{tr}Credit{/tr}</b></td>
<td class="journal" style="text-align:right"><b>{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$totals.credit|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</b></td>
<td class="journal" style="text-align:right"><b>{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$totals.credit|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}</b></td>
<td class="journal">&nbsp;</td>
</tr>
{/if}
......
{* $Id$ *}{$quote}{tr}Id{/tr}{$quote}{$separator}{$quote}{tr}Date{/tr}{$quote}{$separator}{$quote}{tr}Description{/tr}{$quote}{$separator}{$quote}{tr}Deleted{/tr}{$quote}{$separator}{$quote}{tr}Currency{/tr}{$quote}{$separator}{$quote}{tr}Debit Account{/tr}{$quote}{$separator}{$quote}{tr}Debit Amount{/tr}{$quote}{$separator}{$quote}{tr}Debit Text{/tr}{$quote}{$separator}{$quote}{tr}Credit Account{/tr}{$quote}{$separator}{$quote}{tr}Credit Amount{/tr}{$quote}{$separator}{$quote}{tr}Credit Text{/tr}{$quote}{$eol}{foreach from=$journal item="j"}{$j.journalId}{$separator}{$j.journalDate|date_format:"%Y-%m-%d"}{$separator}{$quote}{$j.journalDescription|escape}{$quote}{$separator}{$quote}{if $j.journalCancelled==1}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}{$quote}{$separator}{$quote}{$book.bookCurrency}{$quote}{$separator}{section name=posts loop=$j.maxcount}{assign var='i' value=$smarty.section.posts.iteration-1}{if !$smarty.section.posts.first}{$j.journalId}{$separator}{$separator}{$separator}{$separator}{$separator}{/if}{if $i<$j.debitcount}{$j.debit[$i].itemAccountId}{/if}{$separator}{if $i<$j.debitcount}{$j.debit[$i].itemAmount|currency}{/if}{$separator}{if $i<$j.debitcount}{$quote}{$j.debit[$i].itemText|escape}{$quote}{/if}{$separator}{if $i<$j.creditcount}{$j.credit[$i].itemAccountId}{/if}{$separator}{if $i<$j.creditcount}{$j.credit[$i].itemAmount|currency}{/if}{$separator}{if $i<$j.creditcount}{$quote}{$j.credit[$i].text|escape}{$quote}{/if}{$eol}{/section}{/foreach}
{* $Id$ *}{$quote}{tr}Id{/tr}{$quote}{$separator}{$quote}{tr}Date{/tr}{$quote}{$separator}{$quote}{tr}Description{/tr}{$quote}{$separator}{$quote}{tr}Deleted{/tr}{$quote}{$separator}{$quote}{tr}Currency{/tr}{$quote}{$separator}{$quote}{tr}Debit Account{/tr}{$quote}{$separator}{$quote}{tr}Debit Amount{/tr}{$quote}{$separator}{$quote}{tr}Debit Text{/tr}{$quote}{$separator}{$quote}{tr}Credit Account{/tr}{$quote}{$separator}{$quote}{tr}Credit Amount{/tr}{$quote}{$separator}{$quote}{tr}Credit Text{/tr}{$quote}{$eol}{foreach from=$journal item="j"}{$j.journalId}{$separator}{$j.journalDate|date_format:"%Y-%m-%d"}{$separator}{$quote}{$j.journalDescription|escape}{$quote}{$separator}{$quote}{if $j.journalCancelled==1}{tr}Yes{/tr}{else}{tr}No{/tr}{/if}{$quote}{$separator}{$quote}{$book.bookCurrency}{$quote}{$separator}{section name=posts loop=$j.maxcount}{assign var='i' value=$smarty.section.posts.iteration-1}{if !$smarty.section.posts.first}{$j.journalId}{$separator}{$separator}{$separator}{$separator}{$separator}{/if}{if $i<$j.debitcount}{$j.debit[$i].itemAccountId}{/if}{$separator}{if $i<$j.debitcount}{$j.debit[$i].itemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{/if}{$separator}{if $i<$j.debitcount}{$quote}{$j.debit[$i].itemText|escape}{$quote}{/if}{$separator}{if $i<$j.creditcount}{$j.credit[$i].itemAccountId}{/if}{$separator}{if $i<$j.creditcount}{$j.credit[$i].itemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{/if}{$separator}{if $i<$j.creditcount}{$quote}{$j.credit[$i].text|escape}{$quote}{/if}{$eol}{/section}{/foreach}
......@@ -28,10 +28,10 @@
{section name=posts loop=$s.maxcount}{assign var='i' value=$smarty.section.posts.iteration-1}
{if !$smarty.section.posts.first}<tr class="{$style}">{/if}
<td class="journal" style="text-align:right">{if $i<$s.debitcount}{$j.debit[$i].stackItemAccountId}{/if}&nbsp;</td>
<td class="journal" style="text-align:right">{if $i<$s.debitcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$s.debit[$i].stackItemAmount|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal" style="text-align:right">{if $i<$s.debitcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$s.debit[$i].stackItemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal">{if $i<$j.debitcount}{$j.debit[$i].stackItemText|escape}{/if}&nbsp;</td>
<td class="journal" style="text-align:right">{if $i<$s.creditcount}{$j.credit[$i].stackItemAccountId}{/if}&nbsp;</td>
<td class="journal" style="text-align:right">{if $i<$s.creditcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$s.credit[$i].stackItemAmount|currency}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal" style="text-align:right">{if $i<$s.creditcount}{if $book.bookCurrencyPos==-1}{$book.bookCurrency} {/if}{$s.credit[$i].stackItemAmount|number_format:$book.bookDecimals:$book.bookDecPoint:$book.bookThousand}{if $book.bookCurrencyPos==1} {$book.bookCurrency}{/if}&nbsp;{/if}</td>
<td class="journal">{if $i<$j.creditcount}{$j.credit[$i].stackItemText|escape}{/if}&nbsp;</td>
{if $smarty.section.posts.first}<td rowspan="{$s.maxcount}">
<a class="icon" href="tiki-accounting_stack.php?action=delete&bookId={$bookId}&stackId={$s.stackId}">{icon _id="delete" alt="{tr}delete this transaction from the stack{/tr}" _confirm="{tr}Are you sure you want to delete this transaction from stack?{/tr}"}</a><br />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment