From 7185eedf1dffd2fac41b991c27b201b6b66fae2f Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Thu, 29 Dec 2011 09:08:40 +1300 Subject: [PATCH] Bug 929 : Last follow up, implementing the last of Katrins suggestions Date formatting Links Nomenclature changes --- acqui/ordered.pl | 37 +++++++++------- acqui/spent.pl | 46 +++++++++----------- .../intranet-tmpl/prog/en/modules/acqui/ordered.tt | 15 ++++-- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/acqui/ordered.pl b/acqui/ordered.pl index 5796f07..97a4da5 100755 --- a/acqui/ordered.pl +++ b/acqui/ordered.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl # Copyright 2008 - 2009 BibLibre SARL -# Copyright 2010 Catalyst IT Limited +# Copyright 2010,2011 Catalyst IT Limited # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the @@ -27,19 +27,19 @@ this script is to show orders ordered but not yet received =cut - use C4::Context; use strict; use warnings; use CGI; use C4::Auth; use C4::Output; +use C4::Dates; -my $dbh = C4::Context->dbh; -my $input = new CGI; +my $dbh = C4::Context->dbh; +my $input = new CGI; my $fund_id = $input->param('fund'); -my $start = $input->param('start'); -my $end = $input->param('end'); +my $start = $input->param('start'); +my $end = $input->param('end'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -56,7 +56,7 @@ my $query = < quantityreceived OR quantityreceived IS NULL) + GROUP BY aqorders.ordernumber EOQ my $sth = $dbh->prepare($query); -$sth->execute( $fund_id); -if ($sth->err) { - die "Error occurred fetching records: ".$sth->errstr; +$sth->execute($fund_id); +if ( $sth->err ) { + die "Error occurred fetching records: " . $sth->errstr; } my @ordered; @@ -91,18 +92,20 @@ while ( my $data = $sth->fetchrow_hashref ) { } if ( $left && $left > 0 ) { my $subtotal = $left * $data->{'ecost'}; - $data->{subtotal} = sprintf ("%.2f", $subtotal); + $data->{subtotal} = sprintf( "%.2f", $subtotal ); $data->{'left'} = $left; push @ordered, $data; $total += $subtotal; } + my $entrydate = C4::Dates->new( $data->{'entrydate'}, 'iso' ); + $data->{'entrydate'} = $entrydate->output("syspref"); } -$total = sprintf ("%.2f", $total); -$template->param( - ordered => \@ordered, - total => $total -); +$total = sprintf( "%.2f", $total ); + +$template->{VARS}->{'fund'} = $fund_id; +$template->{VARS}->{'ordered'} = \@ordered; +$template->{VARS}->{'total'} = $total; + $sth->finish; -$dbh->disconnect; output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/spent.pl b/acqui/spent.pl index 8108401..4058b59 100755 --- a/acqui/spent.pl +++ b/acqui/spent.pl @@ -3,7 +3,7 @@ # script to show a breakdown of committed and spent budgets # Copyright 2002-2009 Katipo Communications Limited -# Copyright 2010 Catalyst IT Limited +# Copyright 2010,2011 Catalyst IT Limited # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the @@ -14,7 +14,7 @@ # Koha is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License along # with Koha; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -29,11 +29,12 @@ this script is designed to show the spent amount in budges =cut - use C4::Context; use C4::Auth; use C4::Output; +use C4::Dates; use strict; +use warnings; use CGI; my $dbh = C4::Context->dbh; @@ -82,9 +83,9 @@ WHERE GROUP BY aqorders.ordernumber EOQ my $sth = $dbh->prepare($query); -$sth->execute( $bookfund); -if ($sth->err) { - die "An error occurred fetching records: ".$sth->errstr; +$sth->execute($bookfund); +if ( $sth->err ) { + die "An error occurred fetching records: " . $sth->errstr; } my $total = 0; my $toggle; @@ -92,31 +93,24 @@ my @spent; while ( my $data = $sth->fetchrow_hashref ) { my $recv = $data->{'quantityreceived'}; if ( $recv > 0 ) { - my $subtotal = $recv * ($data->{'unitprice'} + $data->{'freight'}); - $data->{'subtotal'} = sprintf ("%.2f", $subtotal); - $data->{'freight'} = sprintf ("%.2f", $data->{'freight'}); - $data->{'unitprice'} = sprintf ("%.2f", $data->{'unitprice'} ); - $total += $subtotal; - - if ($toggle) { - $toggle = 0; - } - else { - $toggle = 1; - } - $data->{'toggle'} = $toggle; + my $subtotal = $recv * ( $data->{'unitprice'} + $data->{'freight'} ); + $data->{'subtotal'} = sprintf( "%.2f", $subtotal ); + $data->{'freight'} = sprintf( "%.2f", $data->{'freight'} ); + $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} ); + $total += $subtotal; + my $entrydate = C4::Dates->new( $data->{'entrydate'}, 'iso' ); + $data->{'entrydate'} = $entrydate->output("syspref"); + my $datereceived = C4::Dates->new( $data->{'datereceived'}, 'iso' ); + $data->{'datereceived'} = $datereceived->output("syspref"); push @spent, $data; } } -$total = sprintf ("%.2f", $total); +$total = sprintf( "%.2f", $total ); -$template->param( - spent => \@spent, - total => $total -); -$template->{VARS}->{'fund'} = $bookfund; +$template->{VARS}->{'fund'} = $bookfund; +$template->{VARS}->{'spent'} = \@spent; +$template->{VARS}->{'total'} = $total; $sth->finish; -$dbh->disconnect; output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt index 7c72cb1..29e78ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt @@ -6,7 +6,7 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'acquisitions-search.inc' %] - +
@@ -14,18 +14,19 @@
-

Budgets & Bookfunds

-

Ordered

+

Bookfunds

+

Ordered - [% fund %]

+ - + @@ -43,6 +44,9 @@ [% order.ordernumber %] + + -- 1.7.5.4
Title Order Vendor Itemtype Left on Order Estimated cost per unit Budget Date Date Ordered Subtotal
+ [% order.booksellerid %] + [% order.itype %] @@ -52,7 +56,7 @@ [% order.ecost %] - [% order.budgetdate %] + [% order.entrydate %] [% order.subtotal %] @@ -68,6 +72,7 @@ [% total %]