3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
27 this script is the main page for acqui/
28 It presents the budget's dashboard, another table about differents currency with
29 their rates and the pending suggestions.
36 C<$status> is the status a suggestion could has. Default value is 'ASKED'.
37 thus, it can be REJECTED, ACCEPTED, ORDERED, ASKED, AVAIBLE
46 use C4::Interface::CGI::Output;
54 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
56 template_name => "acqui/acqui-home.tmpl",
60 flagsrequired => { acquisition => 1 },
66 my ( $flags, $homebranch ) = GetFlagsAndBranchFromBorrower($loggedinuser);
68 my @results = GetBookFunds($homebranch);
69 my $count = scalar @results;
78 for (my $i=0; $i<$count; $i++){
79 my ($spent,$comtd)=GetBookFundBreakdown($results[$i]->{'bookfundid'});
80 my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
82 $line{bookfundname} = $results[$i]->{'bookfundname'};
83 $line{budgetamount} = $results[$i]->{'budgetamount'};
84 $line{spent} = sprintf ("%.2f", $spent);
85 $line{comtd} = sprintf ("%.2f",$comtd);
86 $line{avail} = sprintf ("%.2f",$avail);
87 push @loop_budget, \%line;
88 $total+=$results[$i]->{'budgetamount'};
95 my @rates = GetCurrencies();
96 my $count = scalar @rates;
98 my @loop_currency = ();
99 for ( my $i = 0 ; $i < $count ; $i++ ) {
101 $line{currency} = @rates[$i]->{'currency'};
102 $line{rate} = @rates[$i]->{'rate'};
103 push @loop_currency, \%line;
107 my $status = $query->param('status') || "ASKED";
108 my $suggestion = CountSuggestion($status);
109 my $suggestions_loop = &SearchSuggestion( '', '', '', '', $status, '' );
112 classlist => $classlist,
114 loop_budget => \@loop_budget,
115 loop_currency => \@loop_currency,
116 total => sprintf( "%.2f", $total ),
117 suggestion => $suggestion,
118 suggestions_loop => $suggestions_loop,
119 totspent => sprintf( "%.2f", $totspent ),
120 totcomtd => sprintf( "%.2f", $totcomtd ),
121 totavail => sprintf( "%.2f", $totavail ),
122 nobudget => $#results == -1 ? 1 : 0
125 output_html_with_http_headers $query, $cookie, $template->output;