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{aqbudgetid} = $results[$i]->{'aqbudgetid'};
87 $line{bookfundid} = $results[$i]->{'bookfundid'};
88 $line{sdate} = $results[$i]->{'startdate'};
89 $line{edate} = $results[$i]->{'enddate'};
90 $line{spent} = sprintf ("%.2f", $spent);
91 $line{comtd} = sprintf ("%.2f",$comtd);
92 $line{avail} = sprintf ("%.2f",$avail);
93 push @loop_budget, \%line;
94 $total+=$results[$i]->{'budgetamount'};
101 my @rates = GetCurrencies();
102 $count = scalar @rates;
104 my @loop_currency = ();
105 for ( my $i = 0 ; $i < $count ; $i++ ) {
107 $line{currency} = $rates[$i]->{'currency'};
108 $line{rate} = $rates[$i]->{'rate'};
109 push @loop_currency, \%line;
113 my $status = $query->param('status') || "ASKED";
114 my $suggestion = CountSuggestion($status);
115 my $suggestions_loop = &SearchSuggestion( '', '', '', '', $status, '' );
118 classlist => $classlist,
120 loop_budget => \@loop_budget,
121 loop_currency => \@loop_currency,
122 total => sprintf( "%.2f", $total ),
123 suggestion => $suggestion,
124 suggestions_loop => $suggestions_loop,
125 totspent => sprintf( "%.2f", $totspent ),
126 totcomtd => sprintf( "%.2f", $totcomtd ),
127 totavail => sprintf( "%.2f", $totavail ),
128 nobudget => $#results == -1 ? 1 : 0
131 output_html_with_http_headers $query, $cookie, $template->output;