=head1 DESCRIPTION
this script is the main page for acqui/
-It presents the budget's dashboard, another table about differents currency with
-their rates and the pending suggestions.
=head1 CGI PARAMETERS
=cut
use strict;
+use warnings;
use Number::Format;
use CGI;
my $count = scalar @results;
my $branchname = GetBranchName($homebranch);
-#my $count = scalar @results;
my $classlist = '';
my $total = 0;
my $totspent = 0;
+my $totordered = 0;
my $totcomtd = 0;
my $totavail = 0;
my @loop_budget = ();
# ---------------------------------------------------
# currencies
my $cur;
-my @rates = GetCurrencies();
-$count = scalar @rates;
my $active_currency = GetCurrency;
my $num;
);
}
-my @loop_currency = ();
-for ( my $i = 0 ; $i < $count ; $i++ ) {
- my %line;
- $line{currency} = $rates[$i]->{'currency'} ;
- $line{currency_symbol} = $rates[$i]->{'symbol'};
- $line{rate} = sprintf ( '%.2f', $rates[$i]->{'rate'} );
- push @loop_currency, \%line;
-}
-
# suggestions
my $status = $query->param('status') || "ASKED";
my $suggestion = CountSuggestion($status);
my $r = GetBranchName( $result->{'budget_owner_id'} );
$result->{'budget_branchname'} = GetBranchName( $result->{'budget_branchcode'} );
- my $member = GetMember( $result->{'budget_owner_id'} );
- my $member_full = $member->{'firstname'} . ' ' . $member->{'surname'};
+ my $member = GetMember( borrowernumber => $result->{budget_owner_id} );
+ my $member_full = $member->{'firstname'} . ' ' . $member->{'surname'} if $member;
+ # as we are going to treat these as numbers let's ensure they are not NULL
+ if (!defined $result->{budget_amount} ) {
+ $result->{budget_amount} = 0;
+ }
+ if (!defined $result->{budget_spent} ) {
+ $result->{budget_spent} = 0;
+ }
+ if (!defined $result->{budget_ordered} ) {
+ $result->{budget_ordered} = 0;
+ }
- $result->{'budget_owner'} = $member_full;
- $result->{'budget_avail'} = $result->{'budget_amount'} - $result->{'budget_spent'};
- $result->{'budget_spent'} = GetBudgetSpent( $result->{'budget_id'} );
+ $result->{'budget_owner'} = $member_full;
+ $result->{'budget_ordered'} = GetBudgetOrdered( $result->{'budget_id'} );
+ $result->{'budget_spent'} = GetBudgetSpent( $result->{'budget_id'} );
+ $result->{'budget_avail'} = $result->{'budget_amount'} - $result->{'budget_spent'} - $result->{'budget_ordered'};
- $total += $result->{'budget_amount'};
- $totspent += $result->{'budget_spent'};
- $totavail += $result->{'budget_avail'};
+ $total += $result->{'budget_amount'};
+ $totspent += $result->{'budget_spent'};
+ $totordered += $result->{'budget_ordered'};
+ $totavail += $result->{'budget_avail'};
- $result->{'budget_amount'} = $num->format_price( $result->{'budget_amount'} );
- $result->{'budget_spent'} = $num->format_price( $result->{'budget_spent'} );
- $result->{'budget_avail'} = $num->format_price( $result->{'budget_avail'} );
+ $result->{'budget_amount'} = $num->format_price( $result->{'budget_amount'} );
+ $result->{'budget_spent'} = $num->format_price( $result->{'budget_spent'} );
+ $result->{'budget_ordered'} = $num->format_price( $result->{'budget_ordered'} );
+ $result->{'budget_avail'} = $num->format_price( $result->{'budget_avail'} );
# my $spent_percent = ( $result->{'budget_spent'} / $result->{'budget_amount'} ) * 100;
# $result->{'budget_spent_percent'} = sprintf( "%00d", $spent_percent );
- my $borrower = &GetMember( $result->{budget_owner_id} );
- $result->{budget_owner_name} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
+ if ($member) {
+ $result->{budget_owner_name} = $member->{'firstname'} . ' ' . $member->{'surname'};
+ }
push( @loop_budget, { %{$result}, toggle => $toggle++ % 2, } );
}
classlist => $classlist,
type => 'intranet',
loop_budget => \@loop_budget,
- loop_currency => \@loop_currency,
active_symbol => $active_currency->{'symbol'},
branchname => $branchname,
budget => $period->{budget_name},
total => $num->format_price( $total ),
- totspent => $num->format_price($totspent ),
+ totspent => $num->format_price( $totspent ),
+ totordered => $num->format_price( $totordered ),
totcomtd => $num->format_price( $totcomtd ),
totavail => $num->format_price( $totavail ),
suggestion => $suggestion,