From 7a3f77de8c76f877ff86be85eefe50757f3fd91d Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Sat, 5 Nov 2011 15:05:48 +0530 Subject: [PATCH] Bug 5358: Show cancelled orders in basket page Signed-off-by: Christophe Croullebois Signed-off-by: Paul Poulain --- C4/Acquisition.pm | 37 ++++++++++++++++ acqui/basket.pl | 6 +++ .../prog/en/modules/acqui/basket.tt | 44 +++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 7127f24ba5..2814977575 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -54,6 +54,7 @@ BEGIN { &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber &SearchOrder &GetHistory &GetRecentAcqui &ModReceiveOrder &ModOrderBiblioitemNumber + &GetCancelledOrders &NewOrderItem &ModOrderItem @@ -1041,6 +1042,42 @@ sub ModOrderBiblioitemNumber { $sth->execute( $biblioitemnumber, $ordernumber, $biblionumber ); } +=head3 GetCancelledOrders + + my @orders = GetCancelledOrders($basketno, $orderby); + +Returns cancelled orders for a basket + +=cut + +sub GetCancelledOrders { + my ( $basketno, $orderby ) = @_; + + return () unless $basketno; + + my $dbh = C4::Context->dbh; + my $query = " + SELECT biblio.*, biblioitems.*, aqorders.*, aqbudgets.* + FROM aqorders + LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id + LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber + LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber + WHERE basketno = ? + AND (datecancellationprinted IS NOT NULL + AND datecancellationprinted <> '0000-00-00') + "; + + $orderby = "aqorders.datecancellationprinted desc, aqorders.timestamp desc" + unless $orderby; + $query .= " ORDER BY $orderby"; + my $sth = $dbh->prepare($query); + $sth->execute($basketno); + my $results = $sth->fetchall_arrayref( {} ); + + return @$results; +} + + #------------------------------------------------------------# =head3 ModReceiveOrder diff --git a/acqui/basket.pl b/acqui/basket.pl index b83628029e..c528156157 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -343,6 +343,11 @@ my $total_est_gste; last; } + my @cancelledorders = GetCancelledOrders($basketno); + foreach (@cancelledorders) { + $_->{'line_total'} = sprintf("%.2f", $_->{'ecost'} * $_->{'quantity'}); + } + $template->param( basketno => $basketno, basketname => $basket->{'basketname'}, @@ -359,6 +364,7 @@ my $total_est_gste; name => $bookseller->{'name'}, entrydate => C4::Dates->new($results[0]->{'entrydate'},'iso')->output, books_loop => \@books_loop, + cancelledorders_loop => \@cancelledorders, gist_rate => sprintf( "%.2f", $gist * 100 ) . '%', total_rrp_gste => sprintf( "%.2f", $total_rrp_gste ), total_est_gste => sprintf( "%.2f", $total_est_gste ), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index 7bf1843b11..aaea6c0ff5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -12,6 +12,7 @@ 10: { sorter: false } } }); + $("#cancelledorderst").tablesorter(); }); function confirm_close() { var is_confirmed = confirm(_('Are you sure you want to close this basket?')); @@ -332,6 +333,49 @@ [% IF ( listincgst ) %]** Vendor's listings already include tax. [% END %] + [% IF (cancelledorders_loop) %] +
+

Cancelled orders

+ + + + + + + + + + + + + [% FOREACH order IN cancelledorders_loop %] + + + + + + + + + [% END %] + +
OrderRRPEst.Qty.TotalFund
+

+ [% IF ( order.order_received ) %] (rcvd)[% END %] + [% IF (order.title) %] + [% order.title |html %] by [% order.author %]
+ [% ELSE %] + Deleted bibliographic record, can't find title
+ [% END %] + [% IF ( order.notes ) %] [% order.notes %][% END %] + [% IF ( order.isbn ) %] - [% order.isbn %][% END %] + [% IF ( order.issn ) %] - [% order.issn %][% END %] + [% IF ( order.publishercode ) %], [% order.publishercode %][% END %] + [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %] +

+

[% order.rrp %]

[% order.ecost %]

[% order.quantity %]

[% order.line_total %]

[% order.budget_name %]

+
+ [% END %]
[% UNLESS ( closedate ) %] [% INCLUDE 'acquisitions-add-to-basket.inc' %] -- 2.39.5