Lines 794-822
sub GetBasketgroups {
Link Here
|
794 |
|
794 |
|
795 |
=head3 GetPendingOrders |
795 |
=head3 GetPendingOrders |
796 |
|
796 |
|
797 |
$orders = &GetPendingOrders($booksellerid, $grouped, $owner); |
797 |
$orders = &GetPendingOrders($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean); |
798 |
|
798 |
|
799 |
Finds pending orders from the bookseller with the given ID. Ignores |
799 |
Finds pending orders from the bookseller with the given ID. Ignores |
800 |
completed and cancelled orders. |
800 |
completed and cancelled orders. |
801 |
|
801 |
|
802 |
C<$booksellerid> contains the bookseller identifier |
802 |
C<$booksellerid> contains the bookseller identifier |
803 |
C<$grouped> contains 0 or 1. 0 means returns the list, 1 means return the total |
|
|
804 |
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself. |
803 |
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself. |
805 |
|
|
|
806 |
C<$orders> is a reference-to-array; each element is a |
807 |
reference-to-hash with the following fields: |
808 |
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket |
804 |
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket |
809 |
in a single result line |
805 |
in a single result line |
|
|
806 |
C<$orders> is a reference-to-array; each element is a reference-to-hash. |
810 |
|
807 |
|
811 |
=over |
808 |
Used also by the filter in parcel.pl |
812 |
|
809 |
I have added: |
813 |
=item C<authorizedby> |
|
|
814 |
|
810 |
|
815 |
=item C<entrydate> |
811 |
C<$ordernumber> |
816 |
|
812 |
C<$search> |
817 |
=item C<basketno> |
813 |
C<$ean> |
818 |
|
|
|
819 |
=back |
820 |
|
814 |
|
821 |
These give the value of the corresponding field in the aqorders table |
815 |
These give the value of the corresponding field in the aqorders table |
822 |
of the Koha database. |
816 |
of the Koha database. |
Lines 826-866
Results are ordered from most to least recent.
Link Here
|
826 |
=cut |
820 |
=cut |
827 |
|
821 |
|
828 |
sub GetPendingOrders { |
822 |
sub GetPendingOrders { |
829 |
my ($supplierid,$grouped,$owner,$basketno) = @_; |
823 |
my ($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean) = @_; |
830 |
my $dbh = C4::Context->dbh; |
824 |
my $dbh = C4::Context->dbh; |
831 |
my $strsth = " |
825 |
my $strsth = " |
832 |
SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, |
826 |
SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, |
833 |
surname,firstname,biblio.*,biblioitems.isbn, |
827 |
surname,firstname,biblio.*,biblioitems.isbn, |
834 |
aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, |
828 |
aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, |
835 |
aqorders.* |
829 |
aqorders.* |
836 |
FROM aqorders |
830 |
FROM aqorders |
837 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
831 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
838 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
832 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
839 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
833 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
840 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
834 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
841 |
WHERE booksellerid=? |
835 |
WHERE (quantity > quantityreceived OR quantityreceived is NULL) |
842 |
AND (quantity > quantityreceived OR quantityreceived is NULL) |
836 |
AND datecancellationprinted IS NULL"; |
843 |
AND datecancellationprinted IS NULL"; |
837 |
my @query_params; |
844 |
my @query_params = ( $supplierid ); |
|
|
845 |
my $userenv = C4::Context->userenv; |
838 |
my $userenv = C4::Context->userenv; |
846 |
if ( C4::Context->preference("IndependantBranches") ) { |
839 |
if ( C4::Context->preference("IndependantBranches") ) { |
847 |
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) { |
840 |
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) { |
848 |
$strsth .= " and (borrowers.branchcode = ? |
841 |
$strsth .= " AND (borrowers.branchcode = ? |
849 |
or borrowers.branchcode = '')"; |
842 |
or borrowers.branchcode = '')"; |
850 |
push @query_params, $userenv->{branch}; |
843 |
push @query_params, $userenv->{branch}; |
851 |
} |
844 |
} |
852 |
} |
845 |
} |
853 |
if ($owner) { |
846 |
if ($supplierid) { |
854 |
$strsth .= " AND aqbasket.authorisedby=? "; |
847 |
$strsth .= " AND aqbasket.booksellerid = ?"; |
855 |
push @query_params, $userenv->{'number'}; |
848 |
push @query_params, $supplierid; |
|
|
849 |
} |
850 |
if($ordernumber){ |
851 |
$strsth .= " AND (aqorders.ordernumber=?)"; |
852 |
push @query_params, $ordernumber; |
853 |
} |
854 |
if($search){ |
855 |
$strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; |
856 |
push @query_params, ("%$search%","%$search%","%$search%"); |
857 |
} |
858 |
if ($ean) { |
859 |
$strsth .= " AND biblioitems.ean = ?"; |
860 |
push @query_params, $ean; |
856 |
} |
861 |
} |
857 |
if ($basketno) { |
862 |
if ($basketno) { |
858 |
$strsth .= " AND aqbasket.basketno=? "; |
863 |
$strsth .= " AND aqbasket.basketno=? "; |
859 |
push @query_params, $basketno; |
864 |
push @query_params, $basketno; |
860 |
} |
865 |
} |
|
|
866 |
if ($owner) { |
867 |
$strsth .= " AND aqbasket.authorisedby=? "; |
868 |
push @query_params, $userenv->{'number'}; |
869 |
} |
861 |
$strsth .= " group by aqbasket.basketno" if $grouped; |
870 |
$strsth .= " group by aqbasket.basketno" if $grouped; |
862 |
$strsth .= " order by aqbasket.basketno"; |
871 |
$strsth .= " order by aqbasket.basketno"; |
863 |
|
|
|
864 |
my $sth = $dbh->prepare($strsth); |
872 |
my $sth = $dbh->prepare($strsth); |
865 |
$sth->execute( @query_params ); |
873 |
$sth->execute( @query_params ); |
866 |
my $results = $sth->fetchall_arrayref({}); |
874 |
my $results = $sth->fetchall_arrayref({}); |