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
26 this script is the main page for acqui/
27 It presents the budget's dashboard, another table about differents currency with
28 their rates and the pending suggestions.
35 C<$status> is the status a suggestion could has. Default value is 'ASKED'.
36 thus, it can be REJECTED, ACCEPTED, ORDERED, ASKED, AVAIBLE
54 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
56 template_name
=> "acqui/acqui-home.tmpl",
60 flagsrequired
=> { acquisition
=> 1 },
66 my $borrower= GetMember
($loggedinuser);
67 my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
69 my @results = GetBookFunds
($homebranch);
70 my $count = scalar @results;
79 for (my $i=0; $i<$count; $i++){
80 my ($spent,$comtd)=GetBookFundBreakdown
($results[$i]->{'bookfundid'},$results[$i]->{'startdate'},$results[$i]->{'enddate'});
81 my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
83 $line{bookfundname
} = $results[$i]->{'bookfundname'};
84 $line{budgetamount
} = $results[$i]->{'budgetamount'};
85 $line{aqbudgetid
} = $results[$i]->{'aqbudgetid'};
86 $line{bookfundid
} = $results[$i]->{'bookfundid'};
87 $line{sdate
} = $results[$i]->{'startdate'};
88 $line{edate
} = $results[$i]->{'enddate'};
89 $line{spent
} = sprintf ("%.2f", $spent);
90 $line{comtd
} = sprintf ("%.2f",$comtd);
91 $line{avail
} = sprintf ("%.2f",$avail);
92 push @loop_budget, \
%line;
93 $total+=$results[$i]->{'budgetamount'};
100 my @rates = GetCurrencies
();
101 $count = scalar @rates;
103 my @loop_currency = ();
104 for ( my $i = 0 ; $i < $count ; $i++ ) {
106 $line{currency
} = $rates[$i]->{'currency'};
107 $line{rate
} = $rates[$i]->{'rate'};
108 push @loop_currency, \
%line;
112 my $status = $query->param('status') || "ASKED";
113 my $suggestion = CountSuggestion
($status);
114 my $suggestions_loop = &SearchSuggestion
( '', '', '', '', $status, '' );
117 classlist
=> $classlist,
119 loop_budget
=> \
@loop_budget,
120 loop_currency
=> \
@loop_currency,
121 total
=> sprintf( "%.2f", $total ),
122 suggestion
=> $suggestion,
123 suggestions_loop
=> $suggestions_loop,
124 totspent
=> sprintf( "%.2f", $totspent ),
125 totcomtd
=> sprintf( "%.2f", $totcomtd ),
126 totavail
=> sprintf( "%.2f", $totavail ),
127 nobudget
=> $#results == -1 ?
1 : 0
130 output_html_with_http_headers
$query, $cookie, $template->output;