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 |
&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 1489-1568
sub CancelReceipt {
Link Here
|
1489 |
|
1399 |
|
1490 |
#------------------------------------------------------------# |
1400 |
#------------------------------------------------------------# |
1491 |
|
1401 |
|
1492 |
=head3 SearchOrder |
1402 |
=head3 SearchOrders |
1493 |
|
1403 |
|
1494 |
@results = &SearchOrder($search, $biblionumber, $complete); |
1404 |
@results = &SearchOrders({ |
|
|
1405 |
ordernumber => $ordernumber, |
1406 |
search => $search, |
1407 |
biblionumber => $biblionumber, |
1408 |
ean => $ean, |
1409 |
booksellerid => $booksellerid, |
1410 |
basketno => $basketno, |
1411 |
owner => $owner, |
1412 |
pending => $pending |
1413 |
}); |
1495 |
|
1414 |
|
1496 |
Searches for orders. |
1415 |
Searches for orders. |
1497 |
|
1416 |
|
1498 |
C<$search> may take one of several forms: if it is an ISBN, |
1417 |
C<$owner> Finds order for the logged in user. |
1499 |
C<&ordersearch> returns orders with that ISBN. If C<$search> is an |
1418 |
C<$pending> Finds pending orders. Ignores completed and cancelled orders. |
1500 |
order number, C<&ordersearch> returns orders with that order number |
|
|
1501 |
and biblionumber C<$biblionumber>. Otherwise, C<$search> is considered |
1502 |
to be a space-separated list of search terms; in this case, all of the |
1503 |
terms must appear in the title (matching the beginning of title |
1504 |
words). |
1505 |
|
1506 |
If C<$complete> is C<yes>, the results will include only completed |
1507 |
orders. In any case, C<&ordersearch> ignores cancelled orders. |
1508 |
|
1509 |
C<&ordersearch> returns an array. |
1510 |
C<@results> is an array of references-to-hash with the following keys: |
1511 |
|
1512 |
=over 4 |
1513 |
|
1514 |
=item C<author> |
1515 |
|
1419 |
|
1516 |
=item C<seriestitle> |
|
|
1517 |
|
1420 |
|
1518 |
=item C<branchcode> |
1421 |
C<@results> is an array of references-to-hash with the keys are fields |
1519 |
|
1422 |
from aqorders, biblio, biblioitems and aqbasket tables. |
1520 |
=item C<budget_id> |
|
|
1521 |
|
1522 |
=back |
1523 |
|
1423 |
|
1524 |
=cut |
1424 |
=cut |
1525 |
|
1425 |
|
1526 |
sub SearchOrder { |
1426 |
sub SearchOrders { |
1527 |
#### -------- SearchOrder------------------------------- |
1427 |
my ( $params ) = @_; |
1528 |
my ( $ordernumber, $search, $ean, $supplierid, $basket ) = @_; |
1428 |
my $ordernumber = $params->{ordernumber}; |
|
|
1429 |
my $search = $params->{search}; |
1430 |
my $ean = $params->{ean}; |
1431 |
my $booksellerid = $params->{booksellerid}; |
1432 |
my $basketno = $params->{basketno}; |
1433 |
my $basketname = $params->{basketname}; |
1434 |
my $basketgroupname = $params->{basketgroupname}; |
1435 |
my $owner = $params->{owner}; |
1436 |
my $pending = $params->{pending}; |
1529 |
|
1437 |
|
1530 |
my $dbh = C4::Context->dbh; |
1438 |
my $dbh = C4::Context->dbh; |
1531 |
my @args = (); |
1439 |
my @args = (); |
1532 |
my $query = |
1440 |
my $query = q{ |
1533 |
"SELECT * |
1441 |
SELECT aqbasket.basketno, |
1534 |
FROM aqorders |
1442 |
borrowers.surname, |
|
|
1443 |
borrowers.firstname, |
1444 |
biblio.*, |
1445 |
biblioitems.isbn, |
1446 |
biblioitems.biblioitemnumber, |
1447 |
aqbasket.closedate, |
1448 |
aqbasket.creationdate, |
1449 |
aqbasket.basketname, |
1450 |
aqorders.* |
1451 |
FROM aqorders |
1452 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1453 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid = aqbasketgroups.id |
1454 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
1535 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
1455 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
1536 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
1456 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
1537 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1457 |
WHERE (datecancellationprinted is NULL) |
1538 |
WHERE (datecancellationprinted is NULL)"; |
1458 |
}; |
|
|
1459 |
|
1460 |
$query .= q{ |
1461 |
AND (quantity > quantityreceived OR quantityreceived is NULL) |
1462 |
}; |
1463 |
|
1464 |
my $userenv = C4::Context->userenv; |
1465 |
if ( C4::Context->preference("IndependentBranches") ) { |
1466 |
if ( ( $userenv ) and ( $userenv->{flags} != 1 ) ) { |
1467 |
$query .= q{ |
1468 |
AND ( |
1469 |
borrowers.branchcode = ? |
1470 |
OR borrowers.branchcode = '' |
1471 |
) |
1472 |
}; |
1473 |
push @args, $userenv->{branch}; |
1474 |
} |
1475 |
} |
1539 |
|
1476 |
|
1540 |
if($ordernumber){ |
1477 |
if ( $ordernumber ) { |
1541 |
$query .= " AND (aqorders.ordernumber=?)"; |
1478 |
$query .= ' AND (aqorders.ordernumber=?)'; |
1542 |
push @args, $ordernumber; |
1479 |
push @args, $ordernumber; |
1543 |
} |
1480 |
} |
1544 |
if($search){ |
1481 |
if( $search ) { |
1545 |
$query .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; |
1482 |
$query .= ' AND (biblio.title LIKE ? OR biblio.author LIKE ? OR biblioitems.isbn LIKE ?)'; |
1546 |
push @args, ("%$search%","%$search%","%$search%"); |
1483 |
push @args, ("%$search%","%$search%","%$search%"); |
1547 |
} |
1484 |
} |
1548 |
if ($ean) { |
1485 |
if ( $ean ) { |
1549 |
$query .= " AND biblioitems.ean = ?"; |
1486 |
$query .= ' AND biblioitems.ean = ?'; |
1550 |
push @args, $ean; |
1487 |
push @args, $ean; |
1551 |
} |
1488 |
} |
1552 |
if ($supplierid) { |
1489 |
if ( $booksellerid ) { |
1553 |
$query .= "AND aqbasket.booksellerid = ?"; |
1490 |
$query .= 'AND aqbasket.booksellerid = ?'; |
1554 |
push @args, $supplierid; |
1491 |
push @args, $booksellerid; |
1555 |
} |
1492 |
} |
1556 |
if($basket){ |
1493 |
if( $basketno ) { |
1557 |
$query .= "AND aqorders.basketno = ?"; |
1494 |
$query .= 'AND aqbasket.basketno = ?'; |
1558 |
push @args, $basket; |
1495 |
push @args, $basketno; |
1559 |
} |
1496 |
} |
|
|
1497 |
if( $basketname ) { |
1498 |
$query .= 'AND aqbasket.basketname LIKE ?'; |
1499 |
push @args, "%$basketname%"; |
1500 |
} |
1501 |
if( $basketgroupname ) { |
1502 |
$query .= ' AND aqbasketgroups.name LIKE ?'; |
1503 |
push @args, "%$basketgroupname%"; |
1504 |
} |
1505 |
|
1506 |
if ( $owner ) { |
1507 |
$query .= ' AND aqbasket.authorisedby=? '; |
1508 |
push @args, $userenv->{'number'}; |
1509 |
} |
1510 |
|
1511 |
$query .= ' ORDER BY aqbasket.basketno'; |
1560 |
|
1512 |
|
1561 |
my $sth = $dbh->prepare($query); |
1513 |
my $sth = $dbh->prepare($query); |
1562 |
$sth->execute(@args); |
1514 |
$sth->execute(@args); |
1563 |
my $results = $sth->fetchall_arrayref({}); |
1515 |
return $sth->fetchall_arrayref({}); |
1564 |
$sth->finish; |
|
|
1565 |
return $results; |
1566 |
} |
1516 |
} |
1567 |
|
1517 |
|
1568 |
#------------------------------------------------------------# |
1518 |
#------------------------------------------------------------# |
Lines 2365-2372
sub GetInvoiceDetails {
Link Here
|
2365 |
my $invoice = $sth->fetchrow_hashref; |
2315 |
my $invoice = $sth->fetchrow_hashref; |
2366 |
|
2316 |
|
2367 |
$query = qq{ |
2317 |
$query = qq{ |
2368 |
SELECT aqorders.*, biblio.* |
2318 |
SELECT aqorders.*, biblio.*, |
|
|
2319 |
aqbasket.basketname |
2369 |
FROM aqorders |
2320 |
FROM aqorders |
|
|
2321 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
2370 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
2322 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
2371 |
WHERE invoiceid = ? |
2323 |
WHERE invoiceid = ? |
2372 |
}; |
2324 |
}; |