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'} );
50 my $avail = $results[$i]->{'budgetamount'} - ( $spent + $comtd );
52 $line{bookfundname} = $results[$i]->{'bookfundname'};
53 $line{budgetamount} = $results[$i]->{'budgetamount'};
54 $line{bookfundid} = $results[$i]->{'bookfundid'};
55 $line{sdate} = $results[$i]->{'startdate'};
56 $line{edate} = $results[$i]->{'enddate'};
57 $line{aqbudgetid} = $results[$i]->{'aqbudgetid'};
58 $line{spent} = sprintf( "%.2f", $spent );
59 $line{comtd} = sprintf( "%.2f", $comtd );
60 $line{avail} = sprintf( "%.2f", $avail );
61 $line{'toggle'} = $toggle;
62 push @loop_budget, \%line;
63 $total += $results[$i]->{'budgetamount'};
71 ( $count, $rates ) = getcurrencies();
72 my @loop_currency = ();
73 for ( my $i = 0 ; $i < $count ; $i++ ) {
75 $line{currency} = $rates->[$i]->{'currency'};
76 $line{rate} = $rates->[$i]->{'rate'};
77 push @loop_currency, \%line;
81 my $status = $query->param('status') || "ASKED";
82 my $suggestion = countsuggestion($status);
83 my $suggestions_loop = &searchsuggestion( '', '', '', '', $status, '' );
86 classlist => $classlist,
88 loop_budget => \@loop_budget,
89 loop_currency => \@loop_currency,
90 total => sprintf( "%.2f", $total ),
91 suggestion => $suggestion,
92 suggestions_loop => $suggestions_loop,
93 totspent => sprintf( "%.2f", $totspent ),
94 totcomtd => sprintf( "%.2f", $totcomtd ),
95 totavail => sprintf( "%.2f", $totavail ),
96 nobudget => $#results == -1 ? 1 : 0
99 output_html_with_http_headers $query, $cookie, $template->output;