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
55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
57 template_name => "acqui/acqui-home.tmpl",
61 flagsrequired => { acquisition => 1 },
67 my $borrower= GetMember($loggedinuser);
68 my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
70 my @results = GetBookFunds($homebranch);
71 my $count = scalar @results;
80 for (my $i=0; $i<$count; $i++){
81 my ($spent,$comtd)=GetBookFundBreakdown($results[$i]->{'bookfundid'},$results[$i]->{'startdate'},$results[$i]->{'enddate'});
82 my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
84 $line{bookfundname} = $results[$i]->{'bookfundname'};
85 $line{budgetamount} = $results[$i]->{'budgetamount'};
86 $line{spent} = sprintf ("%.2f", $spent);
87 $line{comtd} = sprintf ("%.2f",$comtd);
88 $line{avail} = sprintf ("%.2f",$avail);
89 push @loop_budget, \%line;
90 $total+=$results[$i]->{'budgetamount'};
97 my @rates = GetCurrencies();
98 $count = scalar @rates;
100 my @loop_currency = ();
101 for ( my $i = 0 ; $i < $count ; $i++ ) {
103 $line{currency} = $rates[$i]->{'currency'};
104 $line{rate} = $rates[$i]->{'rate'};
105 push @loop_currency, \%line;
109 my $status = $query->param('status') || "ASKED";
110 my $suggestion = CountSuggestion($status);
111 my $suggestions_loop = &SearchSuggestion( '', '', '', '', $status, '' );
114 classlist => $classlist,
116 loop_budget => \@loop_budget,
117 loop_currency => \@loop_currency,
118 total => sprintf( "%.2f", $total ),
119 suggestion => $suggestion,
120 suggestions_loop => $suggestions_loop,
121 totspent => sprintf( "%.2f", $totspent ),
122 totcomtd => sprintf( "%.2f", $totcomtd ),
123 totavail => sprintf( "%.2f", $totavail ),
124 nobudget => $#results == -1 ? 1 : 0
127 output_html_with_http_headers $query, $cookie, $template->output;