From 4a4c16877ec72d361bc551292f81ae5d280bd242 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Thu, 16 Jan 2020 19:22:28 -0300 Subject: [PATCH] Bug 24454: Add Currencies.pm template plugin and currency.inc files This patch adds a new TT plugin called Currencies which retrieves information about the active currency. It also adds a currency.inc file in both opac and intranet, which if included in your TT, you will have the $currency function available in JS. The $currency function formats numbers into the configured active currency format. For example: $currency(12322.4532) //Returns '$12,322.45' if currency format is 'US' and active currency has '$' symbol and no space separation. To test you must implement and test bug 20212, where it will be used --- Koha/Template/Plugin/Currencies.pm | 48 +++++++++++++++++++ .../prog/en/includes/currency.inc | 35 ++++++++++++++ .../bootstrap/en/includes/currency.inc | 35 ++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 Koha/Template/Plugin/Currencies.pm create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/currency.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/currency.inc diff --git a/Koha/Template/Plugin/Currencies.pm b/Koha/Template/Plugin/Currencies.pm new file mode 100644 index 0000000000..2e25321d17 --- /dev/null +++ b/Koha/Template/Plugin/Currencies.pm @@ -0,0 +1,48 @@ +package Koha::Template::Plugin::Currencies; + + +# Copyright 2013-2014 BibLibre +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Template::Plugin; +use base qw( Template::Plugin ); + +use Koha::Acquisition::Currencies; + +=head1 NAME + +Koha::Template::Plugin::Currencies - TT Plugin for currencies + +=head1 SYNOPSIS + +[% USE Currencies %] + +[% Currencies.get_active() %] + +=head1 ROUTINES + +=head2 get_active + +In a template, you can get the active currency with +the following TT code: [% Currencies.get_active() %] + +=cut +sub get_active { + return Koha::Acquisition::Currencies->get_active; +} + +1; \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/currency.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/currency.inc new file mode 100644 index 0000000000..eadf7f78d6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/currency.inc @@ -0,0 +1,35 @@ +[% USE Koha %] +[% USE Currencies %] + + \ No newline at end of file diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/currency.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/currency.inc new file mode 100644 index 0000000000..eadf7f78d6 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/currency.inc @@ -0,0 +1,35 @@ +[% USE Koha %] +[% USE Currencies %] + + \ No newline at end of file -- 2.17.1