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