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