Lines 717-745
sub GetBasketgroups {
Link Here
|
717 |
|
717 |
|
718 |
=head3 GetPendingOrders |
718 |
=head3 GetPendingOrders |
719 |
|
719 |
|
720 |
$orders = &GetPendingOrders($booksellerid, $grouped, $owner); |
720 |
$orders = &GetPendingOrders($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean); |
721 |
|
721 |
|
722 |
Finds pending orders from the bookseller with the given ID. Ignores |
722 |
Finds pending orders from the bookseller with the given ID. Ignores |
723 |
completed and cancelled orders. |
723 |
completed and cancelled orders. |
724 |
|
724 |
|
725 |
C<$booksellerid> contains the bookseller identifier |
725 |
C<$booksellerid> contains the bookseller identifier |
726 |
C<$grouped> contains 0 or 1. 0 means returns the list, 1 means return the total |
|
|
727 |
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself. |
726 |
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself. |
728 |
|
|
|
729 |
C<$orders> is a reference-to-array; each element is a |
730 |
reference-to-hash with the following fields: |
731 |
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket |
727 |
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket |
732 |
in a single result line |
728 |
in a single result line |
|
|
729 |
C<$orders> is a reference-to-array; each element is a reference-to-hash. |
733 |
|
730 |
|
734 |
=over |
731 |
Used also by the filter in parcel.pl |
735 |
|
732 |
I have added: |
736 |
=item C<authorizedby> |
|
|
737 |
|
733 |
|
738 |
=item C<entrydate> |
734 |
C<$ordernumber> |
739 |
|
735 |
C<$search> |
740 |
=item C<basketno> |
736 |
C<$ean> |
741 |
|
|
|
742 |
=back |
743 |
|
737 |
|
744 |
These give the value of the corresponding field in the aqorders table |
738 |
These give the value of the corresponding field in the aqorders table |
745 |
of the Koha database. |
739 |
of the Koha database. |
Lines 749-789
Results are ordered from most to least recent.
Link Here
|
749 |
=cut |
743 |
=cut |
750 |
|
744 |
|
751 |
sub GetPendingOrders { |
745 |
sub GetPendingOrders { |
752 |
my ($supplierid,$grouped,$owner,$basketno) = @_; |
746 |
my ($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean) = @_; |
753 |
my $dbh = C4::Context->dbh; |
747 |
my $dbh = C4::Context->dbh; |
754 |
my $strsth = " |
748 |
my $strsth = " |
755 |
SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, |
749 |
SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, |
756 |
surname,firstname,biblio.*,biblioitems.isbn, |
750 |
surname,firstname,biblio.*,biblioitems.isbn, |
757 |
aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, |
751 |
aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, |
758 |
aqorders.* |
752 |
aqorders.* |
759 |
FROM aqorders |
753 |
FROM aqorders |
760 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
754 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
761 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
755 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
762 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
756 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
763 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
757 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
764 |
WHERE booksellerid=? |
758 |
WHERE (quantity > quantityreceived OR quantityreceived is NULL) |
765 |
AND (quantity > quantityreceived OR quantityreceived is NULL) |
759 |
AND datecancellationprinted IS NULL"; |
766 |
AND datecancellationprinted IS NULL"; |
760 |
my @query_params; |
767 |
my @query_params = ( $supplierid ); |
|
|
768 |
my $userenv = C4::Context->userenv; |
761 |
my $userenv = C4::Context->userenv; |
769 |
if ( C4::Context->preference("IndependantBranches") ) { |
762 |
if ( C4::Context->preference("IndependantBranches") ) { |
770 |
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) { |
763 |
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) { |
771 |
$strsth .= " and (borrowers.branchcode = ? |
764 |
$strsth .= " AND (borrowers.branchcode = ? |
772 |
or borrowers.branchcode = '')"; |
765 |
or borrowers.branchcode = '')"; |
773 |
push @query_params, $userenv->{branch}; |
766 |
push @query_params, $userenv->{branch}; |
774 |
} |
767 |
} |
775 |
} |
768 |
} |
776 |
if ($owner) { |
769 |
if ($supplierid) { |
777 |
$strsth .= " AND aqbasket.authorisedby=? "; |
770 |
$strsth .= " AND aqbasket.booksellerid = ?"; |
778 |
push @query_params, $userenv->{'number'}; |
771 |
push @query_params, $supplierid; |
|
|
772 |
} |
773 |
if($ordernumber){ |
774 |
$strsth .= " AND (aqorders.ordernumber=?)"; |
775 |
push @query_params, $ordernumber; |
776 |
} |
777 |
if($search){ |
778 |
$strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; |
779 |
push @query_params, ("%$search%","%$search%","%$search%"); |
780 |
} |
781 |
if ($ean) { |
782 |
$strsth .= " AND biblioitems.ean = ?"; |
783 |
push @query_params, $ean; |
779 |
} |
784 |
} |
780 |
if ($basketno) { |
785 |
if ($basketno) { |
781 |
$strsth .= " AND aqbasket.basketno=? "; |
786 |
$strsth .= " AND aqbasket.basketno=? "; |
782 |
push @query_params, $basketno; |
787 |
push @query_params, $basketno; |
783 |
} |
788 |
} |
|
|
789 |
if ($owner) { |
790 |
$strsth .= " AND aqbasket.authorisedby=? "; |
791 |
push @query_params, $userenv->{'number'}; |
792 |
} |
784 |
$strsth .= " group by aqbasket.basketno" if $grouped; |
793 |
$strsth .= " group by aqbasket.basketno" if $grouped; |
785 |
$strsth .= " order by aqbasket.basketno"; |
794 |
$strsth .= " order by aqbasket.basketno"; |
786 |
|
|
|
787 |
my $sth = $dbh->prepare($strsth); |
795 |
my $sth = $dbh->prepare($strsth); |
788 |
$sth->execute( @query_params ); |
796 |
$sth->execute( @query_params ); |
789 |
my $results = $sth->fetchall_arrayref({}); |
797 |
my $results = $sth->fetchall_arrayref({}); |