Lines 3-9
Link Here
|
3 |
# script to show a breakdown of committed and spent budgets |
3 |
# script to show a breakdown of committed and spent budgets |
4 |
|
4 |
|
5 |
# Copyright 2002-2009 Katipo Communications Limited |
5 |
# Copyright 2002-2009 Katipo Communications Limited |
6 |
# Copyright 2010 Catalyst IT Limited |
6 |
# Copyright 2010,2011 Catalyst IT Limited |
7 |
# This file is part of Koha. |
7 |
# This file is part of Koha. |
8 |
# |
8 |
# |
9 |
# Koha is free software; you can redistribute it and/or modify it under the |
9 |
# Koha is free software; you can redistribute it and/or modify it under the |
Lines 14-20
Link Here
|
14 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
14 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
15 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
15 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
16 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
16 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
17 |
# |
17 |
# |
18 |
# You should have received a copy of the GNU General Public License along |
18 |
# You should have received a copy of the GNU General Public License along |
19 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
19 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Lines 29-39
this script is designed to show the spent amount in budges
Link Here
|
29 |
|
29 |
|
30 |
=cut |
30 |
=cut |
31 |
|
31 |
|
32 |
|
|
|
33 |
use C4::Context; |
32 |
use C4::Context; |
34 |
use C4::Auth; |
33 |
use C4::Auth; |
35 |
use C4::Output; |
34 |
use C4::Output; |
|
|
35 |
use C4::Dates; |
36 |
use strict; |
36 |
use strict; |
|
|
37 |
use warnings; |
37 |
use CGI; |
38 |
use CGI; |
38 |
|
39 |
|
39 |
my $dbh = C4::Context->dbh; |
40 |
my $dbh = C4::Context->dbh; |
Lines 82-90
WHERE
Link Here
|
82 |
GROUP BY aqorders.ordernumber |
83 |
GROUP BY aqorders.ordernumber |
83 |
EOQ |
84 |
EOQ |
84 |
my $sth = $dbh->prepare($query); |
85 |
my $sth = $dbh->prepare($query); |
85 |
$sth->execute( $bookfund); |
86 |
$sth->execute($bookfund); |
86 |
if ($sth->err) { |
87 |
if ( $sth->err ) { |
87 |
die "An error occurred fetching records: ".$sth->errstr; |
88 |
die "An error occurred fetching records: " . $sth->errstr; |
88 |
} |
89 |
} |
89 |
my $total = 0; |
90 |
my $total = 0; |
90 |
my $toggle; |
91 |
my $toggle; |
Lines 92-122
my @spent;
Link Here
|
92 |
while ( my $data = $sth->fetchrow_hashref ) { |
93 |
while ( my $data = $sth->fetchrow_hashref ) { |
93 |
my $recv = $data->{'quantityreceived'}; |
94 |
my $recv = $data->{'quantityreceived'}; |
94 |
if ( $recv > 0 ) { |
95 |
if ( $recv > 0 ) { |
95 |
my $subtotal = $recv * ($data->{'unitprice'} + $data->{'freight'}); |
96 |
my $subtotal = $recv * ( $data->{'unitprice'} + $data->{'freight'} ); |
96 |
$data->{'subtotal'} = sprintf ("%.2f", $subtotal); |
97 |
$data->{'subtotal'} = sprintf( "%.2f", $subtotal ); |
97 |
$data->{'freight'} = sprintf ("%.2f", $data->{'freight'}); |
98 |
$data->{'freight'} = sprintf( "%.2f", $data->{'freight'} ); |
98 |
$data->{'unitprice'} = sprintf ("%.2f", $data->{'unitprice'} ); |
99 |
$data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} ); |
99 |
$total += $subtotal; |
100 |
$total += $subtotal; |
100 |
|
101 |
my $entrydate = C4::Dates->new( $data->{'entrydate'}, 'iso' ); |
101 |
if ($toggle) { |
102 |
$data->{'entrydate'} = $entrydate->output("syspref"); |
102 |
$toggle = 0; |
103 |
my $datereceived = C4::Dates->new( $data->{'datereceived'}, 'iso' ); |
103 |
} |
104 |
$data->{'datereceived'} = $datereceived->output("syspref"); |
104 |
else { |
|
|
105 |
$toggle = 1; |
106 |
} |
107 |
$data->{'toggle'} = $toggle; |
108 |
push @spent, $data; |
105 |
push @spent, $data; |
109 |
} |
106 |
} |
110 |
|
107 |
|
111 |
} |
108 |
} |
112 |
$total = sprintf ("%.2f", $total); |
109 |
$total = sprintf( "%.2f", $total ); |
113 |
|
110 |
|
114 |
$template->param( |
111 |
$template->{VARS}->{'fund'} = $bookfund; |
115 |
spent => \@spent, |
112 |
$template->{VARS}->{'spent'} = \@spent; |
116 |
total => $total |
113 |
$template->{VARS}->{'total'} = $total; |
117 |
); |
|
|
118 |
$template->{VARS}->{'fund'} = $bookfund; |
119 |
$sth->finish; |
114 |
$sth->finish; |
120 |
|
115 |
|
121 |
$dbh->disconnect; |
|
|
122 |
output_html_with_http_headers $input, $cookie, $template->output; |
116 |
output_html_with_http_headers $input, $cookie, $template->output; |