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 |
56 |
&NewOrder &DelOrder &ModOrder &GetOrder &GetOrders |
57 |
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber |
57 |
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber |
58 |
&SearchOrder &GetHistory &GetRecentAcqui |
58 |
&SearchOrders &GetHistory &GetRecentAcqui |
59 |
&ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber |
59 |
&ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber |
60 |
&GetCancelledOrders |
60 |
&GetCancelledOrders |
61 |
&GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid |
61 |
&GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid |
Lines 819-914
sub GetBasketgroups {
Link Here
|
819 |
|
819 |
|
820 |
=head2 FUNCTIONS ABOUT ORDERS |
820 |
=head2 FUNCTIONS ABOUT ORDERS |
821 |
|
821 |
|
822 |
=cut |
|
|
823 |
|
824 |
#------------------------------------------------------------# |
825 |
|
826 |
=head3 GetPendingOrders |
827 |
|
828 |
$orders = &GetPendingOrders($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean); |
829 |
|
830 |
Finds pending orders from the bookseller with the given ID. Ignores |
831 |
completed and cancelled orders. |
832 |
|
833 |
C<$booksellerid> contains the bookseller identifier |
834 |
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself. |
835 |
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket |
836 |
in a single result line |
837 |
C<$orders> is a reference-to-array; each element is a reference-to-hash. |
838 |
|
839 |
Used also by the filter in parcel.pl |
840 |
I have added: |
841 |
|
842 |
C<$ordernumber> |
843 |
C<$search> |
844 |
C<$ean> |
845 |
|
846 |
These give the value of the corresponding field in the aqorders table |
847 |
of the Koha database. |
848 |
|
849 |
Results are ordered from most to least recent. |
850 |
|
851 |
=cut |
852 |
|
853 |
sub GetPendingOrders { |
854 |
my ($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean) = @_; |
855 |
my $dbh = C4::Context->dbh; |
856 |
my $strsth = " |
857 |
SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, |
858 |
surname,firstname,biblio.*,biblioitems.isbn, |
859 |
aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, |
860 |
aqorders.* |
861 |
FROM aqorders |
862 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
863 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
864 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
865 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
866 |
WHERE (quantity > quantityreceived OR quantityreceived is NULL) |
867 |
AND datecancellationprinted IS NULL"; |
868 |
my @query_params; |
869 |
my $userenv = C4::Context->userenv; |
870 |
if ( C4::Context->preference("IndependantBranches") ) { |
871 |
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) { |
872 |
$strsth .= " AND (borrowers.branchcode = ? |
873 |
or borrowers.branchcode = '')"; |
874 |
push @query_params, $userenv->{branch}; |
875 |
} |
876 |
} |
877 |
if ($supplierid) { |
878 |
$strsth .= " AND aqbasket.booksellerid = ?"; |
879 |
push @query_params, $supplierid; |
880 |
} |
881 |
if($ordernumber){ |
882 |
$strsth .= " AND (aqorders.ordernumber=?)"; |
883 |
push @query_params, $ordernumber; |
884 |
} |
885 |
if($search){ |
886 |
$strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; |
887 |
push @query_params, ("%$search%","%$search%","%$search%"); |
888 |
} |
889 |
if ($ean) { |
890 |
$strsth .= " AND biblioitems.ean = ?"; |
891 |
push @query_params, $ean; |
892 |
} |
893 |
if ($basketno) { |
894 |
$strsth .= " AND aqbasket.basketno=? "; |
895 |
push @query_params, $basketno; |
896 |
} |
897 |
if ($owner) { |
898 |
$strsth .= " AND aqbasket.authorisedby=? "; |
899 |
push @query_params, $userenv->{'number'}; |
900 |
} |
901 |
$strsth .= " group by aqbasket.basketno" if $grouped; |
902 |
$strsth .= " order by aqbasket.basketno"; |
903 |
my $sth = $dbh->prepare($strsth); |
904 |
$sth->execute( @query_params ); |
905 |
my $results = $sth->fetchall_arrayref({}); |
906 |
$sth->finish; |
907 |
return $results; |
908 |
} |
909 |
|
910 |
#------------------------------------------------------------# |
911 |
|
912 |
=head3 GetOrders |
822 |
=head3 GetOrders |
913 |
|
823 |
|
914 |
@orders = &GetOrders($basketnumber, $orderby); |
824 |
@orders = &GetOrders($basketnumber, $orderby); |
Lines 1531-1610
sub CancelReceipt {
Link Here
|
1531 |
|
1441 |
|
1532 |
#------------------------------------------------------------# |
1442 |
#------------------------------------------------------------# |
1533 |
|
1443 |
|
1534 |
=head3 SearchOrder |
1444 |
=head3 SearchOrders |
1535 |
|
1445 |
|
1536 |
@results = &SearchOrder($search, $biblionumber, $complete); |
1446 |
@results = &SearchOrders({ |
|
|
1447 |
ordernumber => $ordernumber, |
1448 |
search => $search, |
1449 |
biblionumber => $biblionumber, |
1450 |
ean => $ean, |
1451 |
booksellerid => $booksellerid, |
1452 |
basketno => $basketno, |
1453 |
owner => $owner, |
1454 |
pending => $pending |
1455 |
}); |
1537 |
|
1456 |
|
1538 |
Searches for orders. |
1457 |
Searches for orders. |
1539 |
|
1458 |
|
1540 |
C<$search> may take one of several forms: if it is an ISBN, |
1459 |
C<$owner> Finds order for the logged in user. |
1541 |
C<&ordersearch> returns orders with that ISBN. If C<$search> is an |
1460 |
C<$pending> Finds pending orders. Ignores completed and cancelled orders. |
1542 |
order number, C<&ordersearch> returns orders with that order number |
|
|
1543 |
and biblionumber C<$biblionumber>. Otherwise, C<$search> is considered |
1544 |
to be a space-separated list of search terms; in this case, all of the |
1545 |
terms must appear in the title (matching the beginning of title |
1546 |
words). |
1547 |
|
1548 |
If C<$complete> is C<yes>, the results will include only completed |
1549 |
orders. In any case, C<&ordersearch> ignores cancelled orders. |
1550 |
|
1551 |
C<&ordersearch> returns an array. |
1552 |
C<@results> is an array of references-to-hash with the following keys: |
1553 |
|
1554 |
=over 4 |
1555 |
|
1556 |
=item C<author> |
1557 |
|
1461 |
|
1558 |
=item C<seriestitle> |
|
|
1559 |
|
1462 |
|
1560 |
=item C<branchcode> |
1463 |
C<@results> is an array of references-to-hash with the keys are fields |
1561 |
|
1464 |
from aqorders, biblio, biblioitems and aqbasket tables. |
1562 |
=item C<budget_id> |
|
|
1563 |
|
1564 |
=back |
1565 |
|
1465 |
|
1566 |
=cut |
1466 |
=cut |
1567 |
|
1467 |
|
1568 |
sub SearchOrder { |
1468 |
sub SearchOrders { |
1569 |
#### -------- SearchOrder------------------------------- |
1469 |
my ( $params ) = @_; |
1570 |
my ( $ordernumber, $search, $ean, $supplierid, $basket ) = @_; |
1470 |
my $ordernumber = $params->{ordernumber}; |
|
|
1471 |
my $search = $params->{search}; |
1472 |
my $ean = $params->{ean}; |
1473 |
my $booksellerid = $params->{booksellerid}; |
1474 |
my $basketno = $params->{basketno}; |
1475 |
my $basketname = $params->{basketname}; |
1476 |
my $basketgroupname = $params->{basketgroupname}; |
1477 |
my $owner = $params->{owner}; |
1478 |
my $pending = $params->{pending}; |
1571 |
|
1479 |
|
1572 |
my $dbh = C4::Context->dbh; |
1480 |
my $dbh = C4::Context->dbh; |
1573 |
my @args = (); |
1481 |
my @args = (); |
1574 |
my $query = |
1482 |
my $query = q{ |
1575 |
"SELECT * |
1483 |
SELECT aqbasket.basketno, |
1576 |
FROM aqorders |
1484 |
borrowers.surname, |
|
|
1485 |
borrowers.firstname, |
1486 |
biblio.*, |
1487 |
biblioitems.isbn, |
1488 |
biblioitems.biblioitemnumber, |
1489 |
aqbasket.closedate, |
1490 |
aqbasket.creationdate, |
1491 |
aqbasket.basketname, |
1492 |
aqorders.* |
1493 |
FROM aqorders |
1494 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1495 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid = aqbasketgroups.id |
1496 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
1577 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
1497 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
1578 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
1498 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
1579 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1499 |
WHERE (datecancellationprinted is NULL) |
1580 |
WHERE (datecancellationprinted is NULL)"; |
1500 |
}; |
|
|
1501 |
|
1502 |
$query .= q{ |
1503 |
AND (quantity > quantityreceived OR quantityreceived is NULL) |
1504 |
}; |
1505 |
|
1506 |
my $userenv = C4::Context->userenv; |
1507 |
if ( C4::Context->preference("IndependantBranches") ) { |
1508 |
if ( ( $userenv ) and ( $userenv->{flags} != 1 ) ) { |
1509 |
$query .= q{ |
1510 |
AND ( |
1511 |
borrowers.branchcode = ? |
1512 |
OR borrowers.branchcode = '' |
1513 |
) |
1514 |
}; |
1515 |
push @args, $userenv->{branch}; |
1516 |
} |
1517 |
} |
1581 |
|
1518 |
|
1582 |
if($ordernumber){ |
1519 |
if ( $ordernumber ) { |
1583 |
$query .= " AND (aqorders.ordernumber=?)"; |
1520 |
$query .= ' AND (aqorders.ordernumber=?)'; |
1584 |
push @args, $ordernumber; |
1521 |
push @args, $ordernumber; |
1585 |
} |
1522 |
} |
1586 |
if($search){ |
1523 |
if( $search ) { |
1587 |
$query .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; |
1524 |
$query .= ' AND (biblio.title LIKE ? OR biblio.author LIKE ? OR biblioitems.isbn LIKE ?)'; |
1588 |
push @args, ("%$search%","%$search%","%$search%"); |
1525 |
push @args, ("%$search%","%$search%","%$search%"); |
1589 |
} |
1526 |
} |
1590 |
if ($ean) { |
1527 |
if ( $ean ) { |
1591 |
$query .= " AND biblioitems.ean = ?"; |
1528 |
$query .= ' AND biblioitems.ean = ?'; |
1592 |
push @args, $ean; |
1529 |
push @args, $ean; |
1593 |
} |
1530 |
} |
1594 |
if ($supplierid) { |
1531 |
if ( $booksellerid ) { |
1595 |
$query .= "AND aqbasket.booksellerid = ?"; |
1532 |
$query .= 'AND aqbasket.booksellerid = ?'; |
1596 |
push @args, $supplierid; |
1533 |
push @args, $booksellerid; |
1597 |
} |
1534 |
} |
1598 |
if($basket){ |
1535 |
if( $basketno ) { |
1599 |
$query .= "AND aqorders.basketno = ?"; |
1536 |
$query .= 'AND aqbasket.basketno = ?'; |
1600 |
push @args, $basket; |
1537 |
push @args, $basketno; |
1601 |
} |
1538 |
} |
|
|
1539 |
if( $basketname ) { |
1540 |
$query .= 'AND aqbasket.basketname LIKE ?'; |
1541 |
push @args, "%$basketname%"; |
1542 |
} |
1543 |
if( $basketgroupname ) { |
1544 |
$query .= ' AND aqbasketgroups.name LIKE ?'; |
1545 |
push @args, "%$basketgroupname%"; |
1546 |
} |
1547 |
|
1548 |
if ( $owner ) { |
1549 |
$query .= ' AND aqbasket.authorisedby=? '; |
1550 |
push @args, $userenv->{'number'}; |
1551 |
} |
1552 |
|
1553 |
$query .= ' ORDER BY aqbasket.basketno'; |
1602 |
|
1554 |
|
1603 |
my $sth = $dbh->prepare($query); |
1555 |
my $sth = $dbh->prepare($query); |
1604 |
$sth->execute(@args); |
1556 |
$sth->execute(@args); |
1605 |
my $results = $sth->fetchall_arrayref({}); |
1557 |
return $sth->fetchall_arrayref({}); |
1606 |
$sth->finish; |
|
|
1607 |
return $results; |
1608 |
} |
1558 |
} |
1609 |
|
1559 |
|
1610 |
#------------------------------------------------------------# |
1560 |
#------------------------------------------------------------# |
Lines 2406-2413
sub GetInvoiceDetails {
Link Here
|
2406 |
my $invoice = $sth->fetchrow_hashref; |
2356 |
my $invoice = $sth->fetchrow_hashref; |
2407 |
|
2357 |
|
2408 |
$query = qq{ |
2358 |
$query = qq{ |
2409 |
SELECT aqorders.*, biblio.* |
2359 |
SELECT aqorders.*, biblio.*, |
|
|
2360 |
aqbasket.basketname |
2410 |
FROM aqorders |
2361 |
FROM aqorders |
|
|
2362 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
2411 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
2363 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
2412 |
WHERE invoiceid = ? |
2364 |
WHERE invoiceid = ? |
2413 |
}; |
2365 |
}; |