Lines 632-638
sub GetBasketsInfosByBookseller {
Link Here
|
632 |
return unless $supplierid; |
632 |
return unless $supplierid; |
633 |
|
633 |
|
634 |
my $dbh = C4::Context->dbh; |
634 |
my $dbh = C4::Context->dbh; |
635 |
my $query = qq{ |
635 |
my $query = q{ |
636 |
SELECT aqbasket.*, |
636 |
SELECT aqbasket.*, |
637 |
SUM(aqorders.quantity) AS total_items, |
637 |
SUM(aqorders.quantity) AS total_items, |
638 |
SUM( |
638 |
SUM( |
Lines 648-661
sub GetBasketsInfosByBookseller {
Link Here
|
648 |
FROM aqbasket |
648 |
FROM aqbasket |
649 |
LEFT JOIN aqorders ON aqorders.basketno = aqbasket.basketno |
649 |
LEFT JOIN aqorders ON aqorders.basketno = aqbasket.basketno |
650 |
WHERE booksellerid = ?}; |
650 |
WHERE booksellerid = ?}; |
651 |
if(!$allbaskets) { |
651 |
|
|
|
652 |
unless ( $allbaskets ) { |
652 |
$query.=" AND (closedate IS NULL OR (aqorders.quantity > aqorders.quantityreceived AND datecancellationprinted IS NULL))"; |
653 |
$query.=" AND (closedate IS NULL OR (aqorders.quantity > aqorders.quantityreceived AND datecancellationprinted IS NULL))"; |
653 |
} |
654 |
} |
654 |
$query.=" GROUP BY aqbasket.basketno"; |
655 |
$query.=" GROUP BY aqbasket.basketno"; |
655 |
|
656 |
|
656 |
my $sth = $dbh->prepare($query); |
657 |
my $sth = $dbh->prepare($query); |
657 |
$sth->execute($supplierid); |
658 |
$sth->execute($supplierid); |
658 |
return $sth->fetchall_arrayref({}); |
659 |
my $baskets = $sth->fetchall_arrayref({}); |
|
|
660 |
|
661 |
# Retrieve the number of biblios cancelled |
662 |
my $cancelled_biblios = $dbh->selectall_hashref( q| |
663 |
SELECT COUNT(DISTINCT(biblionumber)) AS total_biblios_cancelled, aqbasket.basketno |
664 |
FROM aqbasket |
665 |
LEFT JOIN aqorders ON aqorders.basketno = aqbasket.basketno |
666 |
WHERE booksellerid = ? |
667 |
AND aqorders.orderstatus = 'cancelled' |
668 |
GROUP BY aqbasket.basketno |
669 |
|, 'basketno', {}, $supplierid ); |
670 |
map { |
671 |
$_->{total_biblios_cancelled} = $cancelled_biblios->{$_->{basketno}}{total_biblios_cancelled} || 0 |
672 |
} @$baskets; |
673 |
|
674 |
return $baskets; |
659 |
} |
675 |
} |
660 |
|
676 |
|
661 |
=head3 GetBasketUsers |
677 |
=head3 GetBasketUsers |