Lines 53-61
BEGIN {
Link Here
|
53 |
&ModBasketgroup &NewBasketgroup &DelBasketgroup &GetBasketgroup &CloseBasketgroup |
53 |
&ModBasketgroup &NewBasketgroup &DelBasketgroup &GetBasketgroup &CloseBasketgroup |
54 |
&GetBasketgroups &ReOpenBasketgroup |
54 |
&GetBasketgroups &ReOpenBasketgroup |
55 |
|
55 |
|
56 |
&NewOrder &DelOrder &ModOrder &GetPendingOrders &GetOrder &GetOrders &GetOrdersByBiblionumber |
56 |
&NewOrder &DelOrder &ModOrder &GetOrder &GetOrders &GetOrdersByBiblionumber |
|
|
57 |
&NewOrder &DelOrder &ModOrder &GetOrder &GetOrders |
57 |
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber |
58 |
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber |
58 |
&SearchOrder &GetHistory &GetRecentAcqui |
59 |
&SearchOrders &GetHistory &GetRecentAcqui |
59 |
&ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber |
60 |
&ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber |
60 |
&GetCancelledOrders |
61 |
&GetCancelledOrders |
61 |
&GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid |
62 |
&GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid |
Lines 822-917
sub GetBasketgroups {
Link Here
|
822 |
|
823 |
|
823 |
=head2 FUNCTIONS ABOUT ORDERS |
824 |
=head2 FUNCTIONS ABOUT ORDERS |
824 |
|
825 |
|
825 |
=cut |
|
|
826 |
|
827 |
#------------------------------------------------------------# |
828 |
|
829 |
=head3 GetPendingOrders |
830 |
|
831 |
$orders = &GetPendingOrders($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean); |
832 |
|
833 |
Finds pending orders from the bookseller with the given ID. Ignores |
834 |
completed and cancelled orders. |
835 |
|
836 |
C<$booksellerid> contains the bookseller identifier |
837 |
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself. |
838 |
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket |
839 |
in a single result line |
840 |
C<$orders> is a reference-to-array; each element is a reference-to-hash. |
841 |
|
842 |
Used also by the filter in parcel.pl |
843 |
I have added: |
844 |
|
845 |
C<$ordernumber> |
846 |
C<$search> |
847 |
C<$ean> |
848 |
|
849 |
These give the value of the corresponding field in the aqorders table |
850 |
of the Koha database. |
851 |
|
852 |
Results are ordered from most to least recent. |
853 |
|
854 |
=cut |
855 |
|
856 |
sub GetPendingOrders { |
857 |
my ($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean) = @_; |
858 |
my $dbh = C4::Context->dbh; |
859 |
my $strsth = " |
860 |
SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, |
861 |
surname,firstname,biblio.*,biblioitems.isbn, |
862 |
aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, |
863 |
aqorders.* |
864 |
FROM aqorders |
865 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
866 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
867 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
868 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
869 |
WHERE (quantity > quantityreceived OR quantityreceived is NULL) |
870 |
AND datecancellationprinted IS NULL"; |
871 |
my @query_params; |
872 |
my $userenv = C4::Context->userenv; |
873 |
if ( C4::Context->preference("IndependentBranches") ) { |
874 |
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) { |
875 |
$strsth .= " AND (borrowers.branchcode = ? |
876 |
or borrowers.branchcode = '')"; |
877 |
push @query_params, $userenv->{branch}; |
878 |
} |
879 |
} |
880 |
if ($supplierid) { |
881 |
$strsth .= " AND aqbasket.booksellerid = ?"; |
882 |
push @query_params, $supplierid; |
883 |
} |
884 |
if($ordernumber){ |
885 |
$strsth .= " AND (aqorders.ordernumber=?)"; |
886 |
push @query_params, $ordernumber; |
887 |
} |
888 |
if($search){ |
889 |
$strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; |
890 |
push @query_params, ("%$search%","%$search%","%$search%"); |
891 |
} |
892 |
if ($ean) { |
893 |
$strsth .= " AND biblioitems.ean = ?"; |
894 |
push @query_params, $ean; |
895 |
} |
896 |
if ($basketno) { |
897 |
$strsth .= " AND aqbasket.basketno=? "; |
898 |
push @query_params, $basketno; |
899 |
} |
900 |
if ($owner) { |
901 |
$strsth .= " AND aqbasket.authorisedby=? "; |
902 |
push @query_params, $userenv->{'number'}; |
903 |
} |
904 |
$strsth .= " group by aqbasket.basketno" if $grouped; |
905 |
$strsth .= " order by aqbasket.basketno"; |
906 |
my $sth = $dbh->prepare($strsth); |
907 |
$sth->execute( @query_params ); |
908 |
my $results = $sth->fetchall_arrayref({}); |
909 |
$sth->finish; |
910 |
return $results; |
911 |
} |
912 |
|
913 |
#------------------------------------------------------------# |
914 |
|
915 |
=head3 GetOrders |
826 |
=head3 GetOrders |
916 |
|
827 |
|
917 |
@orders = &GetOrders($basketnumber, $orderby); |
828 |
@orders = &GetOrders($basketnumber, $orderby); |
Lines 1572-1651
sub CancelReceipt {
Link Here
|
1572 |
|
1483 |
|
1573 |
#------------------------------------------------------------# |
1484 |
#------------------------------------------------------------# |
1574 |
|
1485 |
|
1575 |
=head3 SearchOrder |
1486 |
=head3 SearchOrders |
1576 |
|
1487 |
|
1577 |
@results = &SearchOrder($search, $biblionumber, $complete); |
1488 |
@results = &SearchOrders({ |
|
|
1489 |
ordernumber => $ordernumber, |
1490 |
search => $search, |
1491 |
biblionumber => $biblionumber, |
1492 |
ean => $ean, |
1493 |
booksellerid => $booksellerid, |
1494 |
basketno => $basketno, |
1495 |
owner => $owner, |
1496 |
pending => $pending |
1497 |
}); |
1578 |
|
1498 |
|
1579 |
Searches for orders. |
1499 |
Searches for orders. |
1580 |
|
1500 |
|
1581 |
C<$search> may take one of several forms: if it is an ISBN, |
1501 |
C<$owner> Finds order for the logged in user. |
1582 |
C<&ordersearch> returns orders with that ISBN. If C<$search> is an |
1502 |
C<$pending> Finds pending orders. Ignores completed and cancelled orders. |
1583 |
order number, C<&ordersearch> returns orders with that order number |
|
|
1584 |
and biblionumber C<$biblionumber>. Otherwise, C<$search> is considered |
1585 |
to be a space-separated list of search terms; in this case, all of the |
1586 |
terms must appear in the title (matching the beginning of title |
1587 |
words). |
1588 |
|
1589 |
If C<$complete> is C<yes>, the results will include only completed |
1590 |
orders. In any case, C<&ordersearch> ignores cancelled orders. |
1591 |
|
1592 |
C<&ordersearch> returns an array. |
1593 |
C<@results> is an array of references-to-hash with the following keys: |
1594 |
|
1595 |
=over 4 |
1596 |
|
1597 |
=item C<author> |
1598 |
|
1503 |
|
1599 |
=item C<seriestitle> |
|
|
1600 |
|
1504 |
|
1601 |
=item C<branchcode> |
1505 |
C<@results> is an array of references-to-hash with the keys are fields |
1602 |
|
1506 |
from aqorders, biblio, biblioitems and aqbasket tables. |
1603 |
=item C<budget_id> |
|
|
1604 |
|
1605 |
=back |
1606 |
|
1507 |
|
1607 |
=cut |
1508 |
=cut |
1608 |
|
1509 |
|
1609 |
sub SearchOrder { |
1510 |
sub SearchOrders { |
1610 |
#### -------- SearchOrder------------------------------- |
1511 |
my ( $params ) = @_; |
1611 |
my ( $ordernumber, $search, $ean, $supplierid, $basket ) = @_; |
1512 |
my $ordernumber = $params->{ordernumber}; |
|
|
1513 |
my $search = $params->{search}; |
1514 |
my $ean = $params->{ean}; |
1515 |
my $booksellerid = $params->{booksellerid}; |
1516 |
my $basketno = $params->{basketno}; |
1517 |
my $basketname = $params->{basketname}; |
1518 |
my $basketgroupname = $params->{basketgroupname}; |
1519 |
my $owner = $params->{owner}; |
1520 |
my $pending = $params->{pending}; |
1612 |
|
1521 |
|
1613 |
my $dbh = C4::Context->dbh; |
1522 |
my $dbh = C4::Context->dbh; |
1614 |
my @args = (); |
1523 |
my @args = (); |
1615 |
my $query = |
1524 |
my $query = q{ |
1616 |
"SELECT * |
1525 |
SELECT aqbasket.basketno, |
1617 |
FROM aqorders |
1526 |
borrowers.surname, |
|
|
1527 |
borrowers.firstname, |
1528 |
biblio.*, |
1529 |
biblioitems.isbn, |
1530 |
biblioitems.biblioitemnumber, |
1531 |
aqbasket.closedate, |
1532 |
aqbasket.creationdate, |
1533 |
aqbasket.basketname, |
1534 |
aqorders.* |
1535 |
FROM aqorders |
1536 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1537 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid = aqbasketgroups.id |
1538 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
1618 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
1539 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
1619 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
1540 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
1620 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1541 |
WHERE (datecancellationprinted is NULL) |
1621 |
WHERE (datecancellationprinted is NULL)"; |
1542 |
}; |
|
|
1543 |
|
1544 |
$query .= q{ |
1545 |
AND (quantity > quantityreceived OR quantityreceived is NULL) |
1546 |
}; |
1547 |
|
1548 |
my $userenv = C4::Context->userenv; |
1549 |
if ( C4::Context->preference("IndependantBranches") ) { |
1550 |
if ( ( $userenv ) and ( $userenv->{flags} != 1 ) ) { |
1551 |
$query .= q{ |
1552 |
AND ( |
1553 |
borrowers.branchcode = ? |
1554 |
OR borrowers.branchcode = '' |
1555 |
) |
1556 |
}; |
1557 |
push @args, $userenv->{branch}; |
1558 |
} |
1559 |
} |
1622 |
|
1560 |
|
1623 |
if($ordernumber){ |
1561 |
if ( $ordernumber ) { |
1624 |
$query .= " AND (aqorders.ordernumber=?)"; |
1562 |
$query .= ' AND (aqorders.ordernumber=?)'; |
1625 |
push @args, $ordernumber; |
1563 |
push @args, $ordernumber; |
1626 |
} |
1564 |
} |
1627 |
if($search){ |
1565 |
if( $search ) { |
1628 |
$query .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; |
1566 |
$query .= ' AND (biblio.title LIKE ? OR biblio.author LIKE ? OR biblioitems.isbn LIKE ?)'; |
1629 |
push @args, ("%$search%","%$search%","%$search%"); |
1567 |
push @args, ("%$search%","%$search%","%$search%"); |
1630 |
} |
1568 |
} |
1631 |
if ($ean) { |
1569 |
if ( $ean ) { |
1632 |
$query .= " AND biblioitems.ean = ?"; |
1570 |
$query .= ' AND biblioitems.ean = ?'; |
1633 |
push @args, $ean; |
1571 |
push @args, $ean; |
1634 |
} |
1572 |
} |
1635 |
if ($supplierid) { |
1573 |
if ( $booksellerid ) { |
1636 |
$query .= "AND aqbasket.booksellerid = ?"; |
1574 |
$query .= 'AND aqbasket.booksellerid = ?'; |
1637 |
push @args, $supplierid; |
1575 |
push @args, $booksellerid; |
1638 |
} |
1576 |
} |
1639 |
if($basket){ |
1577 |
if( $basketno ) { |
1640 |
$query .= "AND aqorders.basketno = ?"; |
1578 |
$query .= 'AND aqbasket.basketno = ?'; |
1641 |
push @args, $basket; |
1579 |
push @args, $basketno; |
1642 |
} |
1580 |
} |
|
|
1581 |
if( $basketname ) { |
1582 |
$query .= 'AND aqbasket.basketname LIKE ?'; |
1583 |
push @args, "%$basketname%"; |
1584 |
} |
1585 |
if( $basketgroupname ) { |
1586 |
$query .= ' AND aqbasketgroups.name LIKE ?'; |
1587 |
push @args, "%$basketgroupname%"; |
1588 |
} |
1589 |
|
1590 |
if ( $owner ) { |
1591 |
$query .= ' AND aqbasket.authorisedby=? '; |
1592 |
push @args, $userenv->{'number'}; |
1593 |
} |
1594 |
|
1595 |
$query .= ' ORDER BY aqbasket.basketno'; |
1643 |
|
1596 |
|
1644 |
my $sth = $dbh->prepare($query); |
1597 |
my $sth = $dbh->prepare($query); |
1645 |
$sth->execute(@args); |
1598 |
$sth->execute(@args); |
1646 |
my $results = $sth->fetchall_arrayref({}); |
1599 |
return $sth->fetchall_arrayref({}); |
1647 |
$sth->finish; |
|
|
1648 |
return $results; |
1649 |
} |
1600 |
} |
1650 |
|
1601 |
|
1651 |
#------------------------------------------------------------# |
1602 |
#------------------------------------------------------------# |
Lines 2448-2455
sub GetInvoiceDetails {
Link Here
|
2448 |
my $invoice = $sth->fetchrow_hashref; |
2399 |
my $invoice = $sth->fetchrow_hashref; |
2449 |
|
2400 |
|
2450 |
$query = qq{ |
2401 |
$query = qq{ |
2451 |
SELECT aqorders.*, biblio.* |
2402 |
SELECT aqorders.*, biblio.*, |
|
|
2403 |
aqbasket.basketname |
2452 |
FROM aqorders |
2404 |
FROM aqorders |
|
|
2405 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
2453 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
2406 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
2454 |
WHERE invoiceid = ? |
2407 |
WHERE invoiceid = ? |
2455 |
}; |
2408 |
}; |