bug 4182: add emailLibrarianWhenHoldIsPlaced to preferences editor
[koha_gimpoz] / acqui / acqui-home.pl
index 63e913a..f8cb78e 100755 (executable)
@@ -25,8 +25,6 @@ acqui-home.pl
 =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
 
@@ -74,7 +72,6 @@ my @results = GetBudgets($homebranch);
 my $count = scalar @results;
 my $branchname = GetBranchName($homebranch);
 
-#my $count = scalar @results;
 my $classlist   = '';
 my $total       = 0;
 my $totspent    = 0;
@@ -86,8 +83,6 @@ my @loop_budget = ();
 # ---------------------------------------------------
 # currencies
 my $cur;
-my @rates = GetCurrencies();
-$count = scalar @rates;
 
 my $active_currency = GetCurrency;
 my $num;
@@ -110,15 +105,6 @@ if ( $cur_format eq 'FR' ) {
     );
 }
 
-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);
@@ -147,8 +133,18 @@ foreach my $result (@results) {
     my $r = GetBranchName( $result->{'budget_owner_id'} );
     $result->{'budget_branchname'} = GetBranchName( $result->{'budget_branchcode'} );
 
-    my $member      = GetMember( $result->{'budget_owner_id'} );
+    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_ordered'} = GetBudgetOrdered( $result->{'budget_id'} );
@@ -168,8 +164,9 @@ foreach my $result (@results) {
     #        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 $borrower;
+    if ($member) {
+        $result->{budget_owner_name} = $member->{'firstname'} . ' ' . $member->{'surname'};
+    }
 
     push( @loop_budget, { %{$result}, toggle => $toggle++ % 2, } );
 }
@@ -178,7 +175,6 @@ $template->param(
     classlist     => $classlist,
     type          => 'intranet',
     loop_budget   => \@loop_budget,
-    loop_currency => \@loop_currency,
     active_symbol => $active_currency->{'symbol'},
     branchname    => $branchname,
     budget        => $period->{budget_name},