[Koha-bugs] [Bug 4078] Display active currency symbol on currency output and input

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Feb 21 14:31:05 CET 2012


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=4078

Paul Poulain <paul.poulain at biblibre.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paul.poulain at biblibre.com

--- Comment #3 from Paul Poulain <paul.poulain at biblibre.com> 2012-02-21 13:31:05 UTC ---
Hi Aleksa,

The more I look at your patch, the more I think it's the *perfect* candidate
for Template::Toolkit plugins.
Something similar to what has been made for displaying dates:
see : http://wiki.koha-community.org/wiki/Coding_Guidelines#Displaying_dates

Look at Koha/Template/Plugin/KohaDates/KohaDates.pm, create a KohaCurrencies.pm
that could be (untested)

use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );

use C4::Dates;

sub filter {
    my ($self,$amount) = @_;
    my $curr_symbol = GetCurrency()->{symbol};
    if ($curr_symbol && $amount) {
        if ($amount =~ /^\-/) {
            $amount =~ s/^\-/\-$curr_symbol/;
        } else {
            $amount = $curr_symbol.$amount;
        }
    }
    return $amount;
}

and just update all template to display currencies:
[% USE KohaCurrencies %]

and
[% totspent | $KohaCurrencies %] 
...

thanks for your feedback on this
1;

-- 
Configure bugmail: http://bugs.koha-community.org/bugzilla3/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.


More information about the Koha-bugs mailing list