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
47 use C4::Interface::CGI::Output;
56 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
58 template_name => "acqui/acqui-home.tmpl",
62 flagsrequired => { acquisition => 1 },
68 my $borrower= GetBorrower($loggedinuser);
69 my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
71 my @results = GetBookFunds($homebranch);
72 my $count = scalar @results;
81 for (my $i=0; $i<$count; $i++){
82 my ($spent,$comtd)=GetBookFundBreakdown($results[$i]->{'bookfundid'});
83 my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
85 $line{bookfundname} = $results[$i]->{'bookfundname'};
86 $line{budgetamount} = $results[$i]->{'budgetamount'};
87 $line{spent} = sprintf ("%.2f", $spent);
88 $line{comtd} = sprintf ("%.2f",$comtd);
89 $line{avail} = sprintf ("%.2f",$avail);
90 push @loop_budget, \%line;
91 $total+=$results[$i]->{'budgetamount'};
98 my @rates = GetCurrencies();
99 $count = scalar @rates;
101 my @loop_currency = ();
102 for ( my $i = 0 ; $i < $count ; $i++ ) {
104 $line{currency} = $rates[$i]->{'currency'};
105 $line{rate} = $rates[$i]->{'rate'};
106 push @loop_currency, \%line;
110 my $status = $query->param('status') || "ASKED";
111 my $suggestion = CountSuggestion($status);
112 my $suggestions_loop = &SearchSuggestion( '', '', '', '', $status, '' );
115 classlist => $classlist,
117 loop_budget => \@loop_budget,
118 loop_currency => \@loop_currency,
119 total => sprintf( "%.2f", $total ),
120 suggestion => $suggestion,
121 suggestions_loop => $suggestions_loop,
122 totspent => sprintf( "%.2f", $totspent ),
123 totcomtd => sprintf( "%.2f", $totcomtd ),
124 totavail => sprintf( "%.2f", $totavail ),
125 nobudget => $#results == -1 ? 1 : 0
128 output_html_with_http_headers $query, $cookie, $template->output;