From 7ca91683854127be5f15d083d7c7e55a44325b74 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Nov 2013 10:12:00 +0100 Subject: [PATCH] Bug 11243: update vendor list to also display canceled bib counts Same as previous patch but for the biblios count. Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 22 ++++++++++++++++--- .../prog/en/modules/acqui/booksellers.tt | 7 +++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index dbc2714733..4bb3c6ee50 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -632,7 +632,7 @@ sub GetBasketsInfosByBookseller { return unless $supplierid; my $dbh = C4::Context->dbh; - my $query = qq{ + my $query = q{ SELECT aqbasket.*, SUM(aqorders.quantity) AS total_items, SUM( @@ -648,14 +648,30 @@ sub GetBasketsInfosByBookseller { FROM aqbasket LEFT JOIN aqorders ON aqorders.basketno = aqbasket.basketno WHERE booksellerid = ?}; - if(!$allbaskets) { + + unless ( $allbaskets ) { $query.=" AND (closedate IS NULL OR (aqorders.quantity > aqorders.quantityreceived AND datecancellationprinted IS NULL))"; } $query.=" GROUP BY aqbasket.basketno"; my $sth = $dbh->prepare($query); $sth->execute($supplierid); - return $sth->fetchall_arrayref({}); + my $baskets = $sth->fetchall_arrayref({}); + + # Retrieve the number of biblios cancelled + my $cancelled_biblios = $dbh->selectall_hashref( q| + SELECT COUNT(DISTINCT(biblionumber)) AS total_biblios_cancelled, aqbasket.basketno + FROM aqbasket + LEFT JOIN aqorders ON aqorders.basketno = aqbasket.basketno + WHERE booksellerid = ? + AND aqorders.orderstatus = 'cancelled' + GROUP BY aqbasket.basketno + |, 'basketno', {}, $supplierid ); + map { + $_->{total_biblios_cancelled} = $cancelled_biblios->{$_->{basketno}}{total_biblios_cancelled} || 0 + } @$baskets; + + return $baskets; } =head3 GetBasketUsers diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt index 1e90ebff06..e6527a5af3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt @@ -122,7 +122,12 @@ $(document).ready(function() { ([% basket.total_items_cancelled %] cancelled) [% END %] - [% basket.total_biblios %] + + [% basket.total_biblios %] + [% IF basket.total_biblios_cancelled %] + ([% basket.total_biblios_cancelled %] cancelled) + [% END %] + [% basket.expected_items %] [% basket.authorisedby_firstname %] -- 2.39.5