App-Office-Contacts-Donations
view release on metacpan or search on metacpan
lib/App/Office/Contacts/Donations/View/Donations.pm view on Meta::CPAN
package App::Office::Contacts::Donations::View::Donations;
use Scalar::Util 'looks_like_number';
use Moose;
extends 'App::Office::Contacts::View::Base';
use namespace::autoclean;
our $VERSION = '1.10';
# -----------------------------------------------
sub build_donations_js
{
my($self, $context) = @_;
$self -> log(debug => 'Entered build_donations_js');
my($js) = $self -> load_tmpl('update.donations.js');
$js -> param(context => $context);
$js -> param(form_action => $self -> script_name);
return $js -> output;
} # End of build_donations_js.
# -----------------------------------------------
sub display
{
my($self, $id, $entity, $donation, $entity_type, $report) = @_;
$self -> log(debug => 'Entered display');
my($currency_code) = ${$self -> config}{'default_currency_code'};
my($currency_id) = $self -> db -> util -> get_currency_id_via_code($currency_code);
my($template) = $self -> load_tmpl('update.donations.tmpl');
my($total) = 0;
my($amount);
my($motive_name, $motive_text);
my($project_name, $project_text);
$template -> param
(
donations_loop =>
[
map
{
$motive_name = $self -> db -> util -> get_donation_motive_name_via_id($$_{'donation_motive_id'});
$motive_text = $$_{'motive_text'};
if ($motive_name ne '-')
{
$motive_text = "$motive_name $motive_text";
}
$amount = $$_{'amount_input'};
$project_name = $self -> db -> util -> get_donation_project_name_via_id($$_{'donation_project_id'});
$project_text = $$_{'project_text'};
if (looks_like_number($amount) )
{
$total += $amount;
}
( run in 1.513 second using v1.01-cache-2.11-cpan-5a3173703d6 )