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;
54 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
56 template_name => "acqui/acqui-home.tmpl",
60 flagsrequired => { acquisition => 1 },
66 my $me= C4::Context->userenv;
67 my $homebranch=$me->{'branch'} ;
68 my @results = GetBookFunds($homebranch);
69 my $count = scalar @results;
77 for (my $i=0; $i<$count; $i++){
78 my ($spent,$comtd)=GetBookFundBreakdown($results[$i]->{'bookfundid'});
79 my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
81 $line{bookfundname} = $results[$i]->{'bookfundname'};
82 $line{budgetamount} = $results[$i]->{'budgetamount'};
83 $line{spent} = sprintf ("%.2f", $spent);
84 $line{comtd} = sprintf ("%.2f",$comtd);
85 $line{avail} = sprintf ("%.2f",$avail);
86 push @loop_budget, \%line;
87 $total+=$results[$i]->{'budgetamount'};
94 my @rates = GetCurrencies();
95 my $count = scalar @rates;
97 my @loop_currency = ();
98 for ( my $i = 0 ; $i < $count ; $i++ ) {
100 $line{currency} = $rates[$i]->{'currency'};
101 $line{rate} = $rates[$i]->{'rate'};
102 push @loop_currency, \%line;
106 my $status = $query->param('status') || "ASKED";
107 my $suggestion = CountSuggestion($status);
108 my $suggestions_loop = &SearchSuggestion( '', '', '', '', $status, '' );
111 classlist => $classlist,
113 loop_budget => \@loop_budget,
114 loop_currency => \@loop_currency,
115 total => sprintf( "%.2f", $total ),
116 suggestion => $suggestion,
117 suggestions_loop => $suggestions_loop,
118 totspent => sprintf( "%.2f", $totspent ),
119 totcomtd => sprintf( "%.2f", $totcomtd ),
120 totavail => sprintf( "%.2f", $totavail ),
121 nobudget => $#results == -1 ? 1 : 0
124 output_html_with_http_headers $query, $cookie, $template->output;