7 use C4::Interface::CGI::Output;
14 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
16 template_name => "acqui/acqui-home.tmpl",
20 flagsrequired => { acquisition => 1 },
26 my $dbh = C4::Context->dbh;
29 "Select flags, branchcode from borrowers where borrowernumber = ?");
30 $sthtemp->execute($loggedinuser);
31 my ( $flags, $homebranch ) = $sthtemp->fetchrow;
33 my ( $count, @results ) = bookfunds($homebranch);
40 for ( my $i = 0 ; $i < $count ; $i++ ) {
48 my ( $spent, $comtd ) = bookfundbreakdown( $results[$i]->{'bookfundid'} );
49 my $avail = $results[$i]->{'budgetamount'} - ( $spent + $comtd );
52 $line{bookfundname} = $results[$i]->{'bookfundname'};
53 $line{budgetamount} = $results[$i]->{'budgetamount'};
54 $line{spent} = sprintf( "%.2f", $spent );
55 $line{comtd} = sprintf( "%.2f", $comtd );
56 $line{avail} = sprintf( "%.2f", $avail );
57 $line{'toggle'} = $toggle;
58 push @loop_budget, \%line;
59 $total += $results[$i]->{'budgetamount'};
67 ( $count, $rates ) = getcurrencies();
68 my @loop_currency = ();
69 for ( my $i = 0 ; $i < $count ; $i++ ) {
71 $line{currency} = $rates->[$i]->{'currency'};
72 $line{rate} = $rates->[$i]->{'rate'};
73 push @loop_currency, \%line;
77 my $suggestion = countsuggestion("ASKED");
79 classlist => $classlist,
81 loop_budget => \@loop_budget,
82 loop_currency => \@loop_currency,
83 total => sprintf( "%.2f", $total ),
84 suggestion => $suggestion,
85 totspent => sprintf( "%.2f", $totspent ),
86 totcomtd => sprintf( "%.2f", $totcomtd ),
87 totavail => sprintf( "%.2f", $totavail ),
88 nobudget => $#results == -1 ? 1 : 0
91 output_html_with_http_headers $query, $cookie, $template->output;