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 under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with Koha; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 this script is the main page for acqui
44 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
45 { template_name
=> 'acqui/acqui-home.tmpl',
49 flagsrequired
=> { acquisition
=> '*' },
54 my $user = GetMember
( 'borrowernumber' => $loggedinuser );
55 my $branchname = GetBranchName
($user->{branchcode
});
60 my $cur_format = C4
::Context
->preference("CurrencyFormat");
61 if ( $cur_format eq 'FR' ) {
62 $num_formatter = Number
::Format
->new(
63 'decimal_fill' => '2',
64 'decimal_point' => ',',
65 'int_curr_symbol' => '',
66 'mon_thousands_sep' => ' ',
67 'thousands_sep' => ' ',
68 'mon_decimal_point' => ','
70 } else { # US by default..
71 $num_formatter = Number
::Format
->new(
72 'int_curr_symbol' => '',
73 'mon_thousands_sep' => ',',
74 'mon_decimal_point' => '.'
78 my $status = $query->param('status') || "ASKED";
79 my $suggestions_count = CountSuggestion
($status);
82 GetBudgetHierarchy
( '', $user->{branchcode
},
83 $template->{param_map
}->{'USER_INFO'}[0]->{'borrowernumber'} );
91 foreach my $budget ( @
{$budget_arr} ) {
93 $budget->{budget_code_indent
} =~ s/\ /\ \;/g;
95 $budget->{'budget_branchname'} =
96 GetBranchName
( $budget->{'budget_branchcode'} );
98 my $member = GetMember
( borrowernumber
=> $budget->{budget_owner_id
} );
100 $budget->{budget_owner
} =
101 $member->{'firstname'} . ' ' . $member->{'surname'};
104 if ( !defined $budget->{budget_amount
} ) {
105 $budget->{budget_amount
} = 0;
108 $budget->{'budget_ordered'} = GetBudgetOrdered
( $budget->{'budget_id'} );
109 $budget->{'budget_spent'} = GetBudgetSpent
( $budget->{'budget_id'} );
110 if ( !defined $budget->{budget_spent
} ) {
111 $budget->{budget_spent
} = 0;
113 if ( !defined $budget->{budget_ordered
} ) {
114 $budget->{budget_ordered
} = 0;
116 $budget->{'budget_avail'} =
117 $budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} );
119 $total += $budget->{'budget_amount'};
120 $totspent += $budget->{'budget_spent'};
121 $totordered += $budget->{'budget_ordered'};
122 $totavail += $budget->{'budget_avail'};
124 for my $field (qw( budget_amount budget_spent budget_ordered budget_avail ) ) {
125 $budget->{$field} = $num_formatter->format_price( $budget->{$field} );
131 loop_budget
=> $budget_arr,
132 branchname
=> $branchname,
133 total
=> $num_formatter->format_price($total),
134 totspent
=> $num_formatter->format_price($totspent),
135 totordered
=> $num_formatter->format_price($totordered),
136 totcomtd
=> $num_formatter->format_price($totcomtd),
137 totavail
=> $num_formatter->format_price($totavail),
138 suggestions_count
=> $suggestions_count,
141 output_html_with_http_headers
$query, $cookie, $template->output;