Bug 18810: Update Font Awesome to 4.7.0
[koha.git] / acqui / acqui-home.pl
blob4da1eaf2dcdf8c2e80c421053d8aa2f98d629c28
1 #!/usr/bin/perl
3 # Copyright 2008 - 2009 BibLibre SARL
4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19 =head1 NAME
21 acqui-home.pl
23 =head1 DESCRIPTION
25 this script is the main page for acqui
27 =cut
29 use strict;
30 use warnings;
32 use CGI qw ( -utf8 );
33 use C4::Auth;
34 use C4::Output;
35 use C4::Acquisition;
36 use C4::Budgets;
37 use C4::Members;
38 use C4::Debug;
39 use C4::Suggestions;
40 use Koha::Acquisition::Currencies;
41 use Koha::Patrons;
43 my $query = CGI->new;
44 my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
45 { template_name => 'acqui/acqui-home.tt',
46 query => $query,
47 type => 'intranet',
48 authnotrequired => 0,
49 flagsrequired => { acquisition => '*' },
50 debug => 1,
54 my $status = $query->param('status') || "ASKED";
55 my $suggestions_count = CountSuggestion($status);
57 my $budget_arr = GetBudgetHierarchy;
59 my $total = 0;
60 my $totspent = 0;
61 my $totordered = 0;
62 my $totcomtd = 0;
63 my $totavail = 0;
65 my $total_active = 0;
66 my $totspent_active = 0;
67 my $totordered_active = 0;
68 my $totavail_active = 0;
70 my @budget_loop;
71 foreach my $budget ( @{$budget_arr} ) {
72 next unless (CanUserUseBudget($loggedinuser, $budget, $userflags));
74 my $patron = Koha::Patrons->find( $budget->{budget_owner_id} );
75 if ( $patron ) {
76 # FIXME should pass the entire object into budget_owner
77 $budget->{budget_owner_firstname} = $patron->firstname;
78 $budget->{budget_owner_surname} = $patron->surname;
79 $budget->{budget_owner_borrowernumber} = $patron->borrowernumber;
82 if ( !defined $budget->{budget_amount} ) {
83 $budget->{budget_amount} = 0;
86 $budget->{'budget_ordered'} = GetBudgetOrdered( $budget->{'budget_id'} );
87 $budget->{'budget_spent'} = GetBudgetSpent( $budget->{'budget_id'} );
88 if ( !defined $budget->{budget_spent} ) {
89 $budget->{budget_spent} = 0;
91 if ( !defined $budget->{budget_ordered} ) {
92 $budget->{budget_ordered} = 0;
94 $budget->{'budget_avail'} =
95 $budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} );
97 $total += $budget->{'budget_amount'};
98 $totspent += $budget->{'budget_spent'};
99 $totordered += $budget->{'budget_ordered'};
100 $totavail += $budget->{'budget_avail'};
102 if ($budget->{budget_period_active}){
103 $total_active += $budget->{'budget_amount'};
104 $totspent_active += $budget->{'budget_spent'};
105 $totordered_active += $budget->{'budget_ordered'};
106 $totavail_active += $budget->{'budget_avail'};
109 push @budget_loop, $budget;
112 $template->param(
113 type => 'intranet',
114 loop_budget => \@budget_loop,
115 total => $total,
116 totspent => $totspent,
117 totordered => $totordered,
118 totcomtd => $totcomtd,
119 totavail => $totavail,
120 total_active => $total_active,
121 totspent_active => $totspent_active,
122 totordered_active => $totordered_active,
123 totavail_active => $totavail_active,
124 suggestions_count => $suggestions_count,
127 my $cur = Koha::Acquisition::Currencies->get_active;
128 if ( $cur ) {
129 $template->param(
130 currency => $cur->currency,
134 output_html_with_http_headers $query, $cookie, $template->output;