|
Lines 1014-1027
sub GetBasketgroups {
Link Here
|
| 1014 |
|
1014 |
|
| 1015 |
@orders = &GetOrders($basketnumber, $orderby); |
1015 |
@orders = &GetOrders($basketnumber, $orderby); |
| 1016 |
|
1016 |
|
| 1017 |
Looks up the pending (non-cancelled) orders with the given basket |
1017 |
Looks up the non-cancelled (pending and received) orders with the given basketnumber. |
| 1018 |
number. If C<$booksellerID> is non-empty, only orders from that seller |
1018 |
Parameters: |
| 1019 |
are returned. |
1019 |
- C<$basketnumber> : mandatory parameter, the basket number |
| 1020 |
|
1020 |
- C<$orderby> : optional parameter, used to sort the results (must be a valid expression |
| 1021 |
return : |
1021 |
using some fields of aqorders, aqbugdets, biblio, deletedbiblio, |
| 1022 |
C<&basket> returns a two-element array. C<@orders> is an array of |
1022 |
biblioitems, deletedbiblioitems, aqorders_transfers tables) |
| 1023 |
references-to-hash, whose keys are the fields from the aqorders, |
1023 |
If C<$orderby> is not provided, results are sorted according to publishercode and title |
| 1024 |
biblio, and biblioitems tables in the Koha database. |
1024 |
|
|
|
1025 |
Return : |
| 1026 |
The returned C<@orders> is an array of references-to-hash, whose keys are: |
| 1027 |
- the fields from the aqorders table |
| 1028 |
- the fields from the aqbudgets table |
| 1029 |
- 2 fields from aqorders_transfers table : ordernumber_from, return as transferred_from |
| 1030 |
and timestamp, return as transferred_from_timestamp |
| 1031 |
- 5 fields of biblio or deletedbiblio tables : title, author, seriestitle, serial, copyrightdate |
| 1032 |
- 9 fields of biblioitems or deletedbiblioitems tables : publicationyear, publishercode, |
| 1033 |
editionstatement, issn, isbn, ean, itemtype, volume, number |
| 1034 |
If the record still exists, the biblionumber key contains the biblionumber |
| 1035 |
If the record have been deleted, the biblionumber key is blank, |
| 1036 |
and the deletedbiblionumber key contains the biblionumber of the deleted record. |
| 1025 |
|
1037 |
|
| 1026 |
=cut |
1038 |
=cut |
| 1027 |
|
1039 |
|
|
Lines 1030-1051
sub GetOrders {
Link Here
|
| 1030 |
return () unless $basketno; |
1042 |
return () unless $basketno; |
| 1031 |
my $dbh = C4::Context->dbh; |
1043 |
my $dbh = C4::Context->dbh; |
| 1032 |
my $query =" |
1044 |
my $query =" |
| 1033 |
SELECT biblio.*,biblioitems.*, |
1045 |
SELECT |
|
|
1046 |
COALESCE(biblio.title, deletedbiblio.title) AS title, |
| 1047 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
| 1048 |
COALESCE(biblio.seriestitle, deletedbiblio.seriestitle) AS seriestitle, |
| 1049 |
COALESCE(biblio.serial, deletedbiblio.serial) AS serial, |
| 1050 |
COALESCE(biblio.copyrightdate, deletedbiblio.copyrightdate) AS copyrightdate, |
| 1051 |
COALESCE(biblioitems.publicationyear, deletedbiblioitems.publicationyear) AS publicationyear, |
| 1052 |
COALESCE(biblioitems.publishercode, deletedbiblioitems.publishercode) AS publishercode, |
| 1053 |
COALESCE(biblioitems.editionstatement, deletedbiblioitems.editionstatement) AS editionstatement, |
| 1054 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
| 1055 |
COALESCE(biblioitems.issn, deletedbiblioitems.issn) AS issn, |
| 1056 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
| 1057 |
COALESCE(biblioitems.itemtype, deletedbiblioitems.itemtype) AS itemtype, |
| 1058 |
COALESCE(biblioitems.volume, deletedbiblioitems.volume) AS volume, |
| 1059 |
COALESCE(biblioitems.number, deletedbiblioitems.number) AS number, |
| 1034 |
aqorders.*, |
1060 |
aqorders.*, |
| 1035 |
aqbudgets.*, |
1061 |
aqbudgets.*, |
| 1036 |
biblio.title, |
|
|
| 1037 |
aqorders_transfers.ordernumber_from AS transferred_from, |
1062 |
aqorders_transfers.ordernumber_from AS transferred_from, |
| 1038 |
aqorders_transfers.timestamp AS transferred_from_timestamp |
1063 |
aqorders_transfers.timestamp AS transferred_from_timestamp |
| 1039 |
FROM aqorders |
1064 |
FROM aqorders |
| 1040 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1065 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
| 1041 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1066 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
| 1042 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
1067 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
|
|
1068 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.deletedbiblionumber |
| 1069 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=deletedbiblio.biblionumber |
| 1043 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_to = aqorders.ordernumber |
1070 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_to = aqorders.ordernumber |
| 1044 |
WHERE basketno=? |
1071 |
WHERE basketno=? |
| 1045 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
1072 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
| 1046 |
"; |
1073 |
"; |
| 1047 |
|
1074 |
|
| 1048 |
$orderby = "biblioitems.publishercode,biblio.title" unless $orderby; |
1075 |
$orderby = "COALESCE(biblioitems.publishercode,deletedbiblioitems.publishercode), COALESCE(biblio.title,deletedbiblio.title)" unless $orderby; |
| 1049 |
$query .= " ORDER BY $orderby"; |
1076 |
$query .= " ORDER BY $orderby"; |
| 1050 |
my $result_set = |
1077 |
my $result_set = |
| 1051 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
1078 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
|
Lines 1072-1080
sub GetOrdersByBiblionumber {
Link Here
|
| 1072 |
return unless $biblionumber; |
1099 |
return unless $biblionumber; |
| 1073 |
my $dbh = C4::Context->dbh; |
1100 |
my $dbh = C4::Context->dbh; |
| 1074 |
my $query =" |
1101 |
my $query =" |
| 1075 |
SELECT biblio.*,biblioitems.*, |
1102 |
SELECT |
| 1076 |
aqorders.*, |
1103 |
biblio.*, biblioitems.*, |
| 1077 |
aqbudgets.* |
1104 |
aqorders.*, |
|
|
1105 |
aqbudgets.* |
| 1078 |
FROM aqorders |
1106 |
FROM aqorders |
| 1079 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1107 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
| 1080 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1108 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
|
Lines 1095-1102
sub GetOrdersByBiblionumber {
Link Here
|
| 1095 |
|
1123 |
|
| 1096 |
Looks up an order by order number. |
1124 |
Looks up an order by order number. |
| 1097 |
|
1125 |
|
| 1098 |
Returns a reference-to-hash describing the order. The keys of |
1126 |
Returns a reference-to-hash describing the order. |
| 1099 |
C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha database. |
1127 |
The keys of C<$order> are |
|
|
1128 |
- all fields from the aqorders table |
| 1129 |
- 2 fields from aqorders table returned with alternate names : rrp as unitpricesupplier, ecost as unitpricelib |
| 1130 |
- 1 field from aqbasket table : basketname |
| 1131 |
- 1 field from borrowers table : branchcode |
| 1132 |
- 1 field from aqbudgets table : budget_name returned as budget |
| 1133 |
- 2 fields from aqbooksellers : name returned as supplier, id returned as supplierid |
| 1134 |
- estimateddeliverydate : ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) |
| 1135 |
- quantity_to_receive : aqorders.quantity - COALESCE(aqorders.quantityreceived,0) |
| 1136 |
- subtotal : (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp |
| 1137 |
- orderdate : DATE (aqbasket.closedate) |
| 1138 |
- latesince : DATEDIFF(CURDATE( ),closedate) |
| 1139 |
- 5 fields of biblio or deletedbiblio tables : title, author, seriestitle, serial, copyrightdate |
| 1140 |
- 9 fields of biblioitems or deletedbiblioitems tables : publicationyear, publishercode, |
| 1141 |
editionstatement, issn, isbn, ean, itemtype, volume, number |
| 1142 |
If the record still exists, the biblionumber key contains the biblionumber |
| 1143 |
If the record have been deleted, the biblionumber key is blank, |
| 1144 |
and the deletedbiblionumber key contains the biblionumber of the deleted record. |
| 1145 |
|
| 1100 |
|
1146 |
|
| 1101 |
=cut |
1147 |
=cut |
| 1102 |
|
1148 |
|
|
Lines 1105-1123
sub GetOrder {
Link Here
|
| 1105 |
return unless $ordernumber; |
1151 |
return unless $ordernumber; |
| 1106 |
|
1152 |
|
| 1107 |
my $dbh = C4::Context->dbh; |
1153 |
my $dbh = C4::Context->dbh; |
|
|
1154 |
# FIXME publishercode column should probably be returned only as publisher or publishercode, but we must first investigate templates to check the use of this value |
| 1108 |
my $query = qq{SELECT |
1155 |
my $query = qq{SELECT |
|
|
1156 |
COALESCE(biblio.title, deletedbiblio.title) AS title, |
| 1157 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
| 1158 |
COALESCE(biblio.seriestitle, deletedbiblio.seriestitle) AS seriestitle, |
| 1159 |
COALESCE(biblio.serial, deletedbiblio.serial) AS serial, |
| 1160 |
COALESCE(biblio.copyrightdate, deletedbiblio.copyrightdate) AS copyrightdate, |
| 1161 |
COALESCE(biblioitems.publicationyear, deletedbiblioitems.publicationyear) AS publicationyear, |
| 1162 |
COALESCE(biblioitems.publishercode, deletedbiblioitems.publishercode) AS publishercode, |
| 1163 |
COALESCE(biblioitems.publishercode, deletedbiblioitems.publishercode) AS publisher, |
| 1164 |
COALESCE(biblioitems.editionstatement, deletedbiblioitems.editionstatement) AS editionstatement, |
| 1165 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
| 1166 |
COALESCE(biblioitems.issn, deletedbiblioitems.issn) AS issn, |
| 1167 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
| 1168 |
COALESCE(biblioitems.itemtype, deletedbiblioitems.itemtype) AS itemtype, |
| 1169 |
COALESCE(biblioitems.volume, deletedbiblioitems.volume) AS volume, |
| 1170 |
COALESCE(biblioitems.number, deletedbiblioitems.number) AS number, |
| 1109 |
aqorders.*, |
1171 |
aqorders.*, |
| 1110 |
biblio.title, |
|
|
| 1111 |
biblio.author, |
| 1112 |
aqbasket.basketname, |
1172 |
aqbasket.basketname, |
| 1113 |
borrowers.branchcode, |
1173 |
borrowers.branchcode, |
| 1114 |
biblioitems.publicationyear, |
|
|
| 1115 |
biblio.copyrightdate, |
| 1116 |
biblioitems.editionstatement, |
| 1117 |
biblioitems.isbn, |
| 1118 |
biblioitems.ean, |
| 1119 |
biblio.seriestitle, |
| 1120 |
biblioitems.publishercode, |
| 1121 |
aqorders.rrp AS unitpricesupplier, |
1174 |
aqorders.rrp AS unitpricesupplier, |
| 1122 |
aqorders.ecost AS unitpricelib, |
1175 |
aqorders.ecost AS unitpricelib, |
| 1123 |
aqorders.claims_count AS claims_count, |
1176 |
aqorders.claims_count AS claims_count, |
|
Lines 1125-1131
sub GetOrder {
Link Here
|
| 1125 |
aqbudgets.budget_name AS budget, |
1178 |
aqbudgets.budget_name AS budget, |
| 1126 |
aqbooksellers.name AS supplier, |
1179 |
aqbooksellers.name AS supplier, |
| 1127 |
aqbooksellers.id AS supplierid, |
1180 |
aqbooksellers.id AS supplierid, |
| 1128 |
biblioitems.publishercode AS publisher, |
|
|
| 1129 |
ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate, |
1181 |
ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate, |
| 1130 |
DATE(aqbasket.closedate) AS orderdate, |
1182 |
DATE(aqbasket.closedate) AS orderdate, |
| 1131 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity_to_receive, |
1183 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity_to_receive, |
|
Lines 1133-1138
sub GetOrder {
Link Here
|
| 1133 |
DATEDIFF(CURDATE( ),closedate) AS latesince |
1185 |
DATEDIFF(CURDATE( ),closedate) AS latesince |
| 1134 |
FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1186 |
FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
| 1135 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
1187 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
|
|
1188 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.deletedbiblionumber |
| 1189 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=deletedbiblio.biblionumber |
| 1136 |
LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id, |
1190 |
LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id, |
| 1137 |
aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber |
1191 |
aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber |
| 1138 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
1192 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
|
Lines 1375-1383
sub ModItemOrder {
Link Here
|
| 1375 |
|
1429 |
|
| 1376 |
=head3 GetCancelledOrders |
1430 |
=head3 GetCancelledOrders |
| 1377 |
|
1431 |
|
| 1378 |
my @orders = GetCancelledOrders($basketno, $orderby); |
1432 |
my @orders = GetCancelledOrders($basketnumber, $orderby); |
| 1379 |
|
1433 |
|
| 1380 |
Returns cancelled orders for a basket |
1434 |
Looks up the cancelled orders with the given basketnumber. |
|
|
1435 |
Parameters: |
| 1436 |
- C<$basketnumber> : mandatory parameter, the basket number |
| 1437 |
- C<$orderby> : optional parameter, used to sort the results (must be a valid expression |
| 1438 |
using some fields of aqorders, aqbugdets, biblio, deletedbiblio, |
| 1439 |
biblioitems, deletedbiblioitems, aqorders_transfers tables) |
| 1440 |
If C<$orderby> is not provided, results are sorted according to publishercode and title |
| 1441 |
|
| 1442 |
Return : |
| 1443 |
The returned C<@orders> is an array of references-to-hash, whose keys are: |
| 1444 |
- the fields from the aqorders table |
| 1445 |
- the fields from the aqbudgets table |
| 1446 |
- 2 fields from aqorders_transfers table : ordernumber_from, return as transferred_from |
| 1447 |
and timestamp, return as transferred_from_timestamp |
| 1448 |
- 5 fields of biblio or deletedbiblio tables : title, author, seriestitle, serial, copyrightdate |
| 1449 |
- 9 fields of biblioitems or deletedbiblioitems tables : publicationyear, publishercode, |
| 1450 |
editionstatement, issn, isbn, ean, itemtype, volume, number |
| 1451 |
If the record still exists, the biblionumber key contains the biblionumber |
| 1452 |
If the record have been deleted, the biblionumber key is blank, |
| 1453 |
and the deletedbiblionumber key contains the biblionumber of the deleted record. |
| 1381 |
|
1454 |
|
| 1382 |
=cut |
1455 |
=cut |
| 1383 |
|
1456 |
|
|
Lines 1389-1396
sub GetCancelledOrders {
Link Here
|
| 1389 |
my $dbh = C4::Context->dbh; |
1462 |
my $dbh = C4::Context->dbh; |
| 1390 |
my $query = " |
1463 |
my $query = " |
| 1391 |
SELECT |
1464 |
SELECT |
| 1392 |
biblio.*, |
1465 |
COALESCE(biblio.title, deletedbiblio.title) AS title, |
| 1393 |
biblioitems.*, |
1466 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
|
|
1467 |
COALESCE(biblio.seriestitle, deletedbiblio.seriestitle) AS seriestitle, |
| 1468 |
COALESCE(biblio.serial, deletedbiblio.serial) AS serial, |
| 1469 |
COALESCE(biblio.copyrightdate, deletedbiblio.copyrightdate) AS copyrightdate, |
| 1470 |
COALESCE(biblioitems.publicationyear, deletedbiblioitems.publicationyear) AS publicationyear, |
| 1471 |
COALESCE(biblioitems.publishercode, deletedbiblioitems.publishercode) AS publishercode, |
| 1472 |
COALESCE(biblioitems.editionstatement, deletedbiblioitems.editionstatement) AS editionstatement, |
| 1473 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
| 1474 |
COALESCE(biblioitems.issn, deletedbiblioitems.issn) AS issn, |
| 1475 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
| 1476 |
COALESCE(biblioitems.itemtype, deletedbiblioitems.itemtype) AS itemtype, |
| 1477 |
COALESCE(biblioitems.volume, deletedbiblioitems.volume) AS volume, |
| 1478 |
COALESCE(biblioitems.number, deletedbiblioitems.number) AS number, |
| 1394 |
aqorders.*, |
1479 |
aqorders.*, |
| 1395 |
aqbudgets.*, |
1480 |
aqbudgets.*, |
| 1396 |
aqorders_transfers.ordernumber_to AS transferred_to, |
1481 |
aqorders_transfers.ordernumber_to AS transferred_to, |
|
Lines 1399-1404
sub GetCancelledOrders {
Link Here
|
| 1399 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1484 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
| 1400 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1485 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
| 1401 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
1486 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
|
|
1487 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.deletedbiblionumber |
| 1488 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=deletedbiblio.biblionumber |
| 1402 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_from = aqorders.ordernumber |
1489 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_from = aqorders.ordernumber |
| 1403 |
WHERE basketno = ? |
1490 |
WHERE basketno = ? |
| 1404 |
AND (datecancellationprinted IS NOT NULL |
1491 |
AND (datecancellationprinted IS NOT NULL |
|
Lines 1688-1694
C<$ordered> Finds orders to receive only (status 'ordered' or 'partial').
Link Here
|
| 1688 |
|
1775 |
|
| 1689 |
|
1776 |
|
| 1690 |
C<@results> is an array of references-to-hash with the keys are fields |
1777 |
C<@results> is an array of references-to-hash with the keys are fields |
| 1691 |
from aqorders, biblio, biblioitems and aqbasket tables. |
1778 |
from aqorders, biblio, deletedbiblio, biblioitems, deletedbiblioitems, |
|
|
1779 |
aqbasket and aqbasketgroups tables. |
| 1780 |
If the record still exists, the biblionumber key contains the biblionumber |
| 1781 |
If the record have been deleted, the biblionumber key is blank, |
| 1782 |
and the deletedbiblionumber key contains the biblionumber of the deleted record. |
| 1692 |
|
1783 |
|
| 1693 |
=cut |
1784 |
=cut |
| 1694 |
|
1785 |
|
|
Lines 1711-1719
sub SearchOrders {
Link Here
|
| 1711 |
SELECT aqbasket.basketno, |
1802 |
SELECT aqbasket.basketno, |
| 1712 |
borrowers.surname, |
1803 |
borrowers.surname, |
| 1713 |
borrowers.firstname, |
1804 |
borrowers.firstname, |
| 1714 |
biblio.*, |
1805 |
COALESCE(biblio.title, deletedbiblio.title) AS title, |
| 1715 |
biblioitems.isbn, |
1806 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
| 1716 |
biblioitems.biblioitemnumber, |
1807 |
COALESCE(biblio.seriestitle, deletedbiblio.seriestitle) AS seriestitle, |
|
|
1808 |
COALESCE(biblio.serial, deletedbiblio.serial) AS serial, |
| 1809 |
COALESCE(biblio.copyrightdate, deletedbiblio.copyrightdate) AS copyrightdate, |
| 1810 |
COALESCE(biblioitems.publicationyear, deletedbiblioitems.publicationyear) AS publicationyear, |
| 1811 |
COALESCE(biblioitems.publishercode, deletedbiblioitems.publishercode) AS publishercode, |
| 1812 |
COALESCE(biblioitems.editionstatement, deletedbiblioitems.editionstatement) AS editionstatement, |
| 1813 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
| 1814 |
COALESCE(biblioitems.issn, deletedbiblioitems.issn) AS issn, |
| 1815 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
| 1816 |
COALESCE(biblioitems.itemtype, deletedbiblioitems.itemtype) AS itemtype, |
| 1817 |
COALESCE(biblioitems.volume, deletedbiblioitems.volume) AS volume, |
| 1818 |
COALESCE(biblioitems.number, deletedbiblioitems.number) AS number, |
| 1717 |
aqbasket.authorisedby, |
1819 |
aqbasket.authorisedby, |
| 1718 |
aqbasket.booksellerid, |
1820 |
aqbasket.booksellerid, |
| 1719 |
aqbasket.closedate, |
1821 |
aqbasket.closedate, |
|
Lines 1728-1733
sub SearchOrders {
Link Here
|
| 1728 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
1830 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
| 1729 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
1831 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
| 1730 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
1832 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
|
|
1833 |
LEFT JOIN deletedbiblio ON aqorders.deletedbiblionumber=deletedbiblio.biblionumber |
| 1834 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=deletedbiblio.biblionumber |
| 1731 |
WHERE (datecancellationprinted is NULL) |
1835 |
WHERE (datecancellationprinted is NULL) |
| 1732 |
}; |
1836 |
}; |
| 1733 |
|
1837 |
|
|
Lines 1756-1766
sub SearchOrders {
Link Here
|
| 1756 |
push @args, $ordernumber; |
1860 |
push @args, $ordernumber; |
| 1757 |
} |
1861 |
} |
| 1758 |
if( $search ) { |
1862 |
if( $search ) { |
| 1759 |
$query .= ' AND (biblio.title LIKE ? OR biblio.author LIKE ? OR biblioitems.isbn LIKE ?)'; |
1863 |
$query .= ' AND (COALESCE (biblio.title, deletedbiblio.title) LIKE ? OR COALESCE (biblio.author, deletedbiblio.author) LIKE ? OR COALESCE (biblioitems.isbn, deletedbiblioitems.isbn) LIKE ?)'; |
| 1760 |
push @args, ("%$search%","%$search%","%$search%"); |
1864 |
push @args, ("%$search%","%$search%","%$search%"); |
| 1761 |
} |
1865 |
} |
| 1762 |
if ( $ean ) { |
1866 |
if ( $ean ) { |
| 1763 |
$query .= ' AND biblioitems.ean = ?'; |
1867 |
$query .= ' AND (COALESCE biblioitems.ean,deletedbiblioitems.ean) = ?'; |
| 1764 |
push @args, $ean; |
1868 |
push @args, $ean; |
| 1765 |
} |
1869 |
} |
| 1766 |
if ( $booksellerid ) { |
1870 |
if ( $booksellerid ) { |
|
Lines 1894-1900
Looks up all of the received items from the supplier with the given
Link Here
|
| 1894 |
bookseller ID at the given date, for the given code (bookseller Invoice number). Ignores cancelled and completed orders. |
1998 |
bookseller ID at the given date, for the given code (bookseller Invoice number). Ignores cancelled and completed orders. |
| 1895 |
|
1999 |
|
| 1896 |
C<@results> is an array of references-to-hash. The keys of each element are fields from |
2000 |
C<@results> is an array of references-to-hash. The keys of each element are fields from |
| 1897 |
the aqorders, biblio, and biblioitems tables of the Koha database. |
2001 |
the aqorders, aqbasket, aqinvoices, borrowers, biblio, and deletedbiblio tables of the Koha database. |
| 1898 |
|
2002 |
|
| 1899 |
C<@results> is sorted alphabetically by book title. |
2003 |
C<@results> is sorted alphabetically by book title. |
| 1900 |
|
2004 |
|
|
Lines 1923-1933
sub GetParcel {
Link Here
|
| 1923 |
aqorders.rrp, |
2027 |
aqorders.rrp, |
| 1924 |
aqorders.ecost, |
2028 |
aqorders.ecost, |
| 1925 |
aqorders.gstrate, |
2029 |
aqorders.gstrate, |
| 1926 |
biblio.title |
2030 |
COALESCE (biblio.title, deletedbiblio.title) AS title |
| 1927 |
FROM aqorders |
2031 |
FROM aqorders |
| 1928 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
2032 |
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno |
| 1929 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
2033 |
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber |
| 1930 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
2034 |
LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber |
|
|
2035 |
LEFT JOIN deletedbiblio ON aqorders.deletedbiblionumber=deletedbiblio.biblionumber |
| 1931 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid |
2036 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid |
| 1932 |
WHERE |
2037 |
WHERE |
| 1933 |
aqbasket.booksellerid = ? |
2038 |
aqbasket.booksellerid = ? |
|
Lines 2043-2055
sub GetParcels {
Link Here
|
| 2043 |
|
2148 |
|
| 2044 |
=head3 GetLateOrders |
2149 |
=head3 GetLateOrders |
| 2045 |
|
2150 |
|
| 2046 |
@results = &GetLateOrders; |
2151 |
@results = &GetLateOrders ($delay, $supplierid, $branch, $estimateddeliverydatefrom, $estimateddeliverydateto) ; |
| 2047 |
|
2152 |
|
| 2048 |
Searches for bookseller with late orders. |
2153 |
Looks up the orders to receive (non cancelled and non completely received) from a given supplier. |
| 2049 |
|
2154 |
|
| 2050 |
return: |
2155 |
return: |
| 2051 |
the table of supplier with late issues. This table is full of hashref. |
2156 |
the table of supplier with late issues. This table is full of hashref. |
| 2052 |
|
2157 |
|
|
|
2158 |
Looks up the cancelled orders with the given basketnumber. |
| 2159 |
Optional parameters are used to limit the results : |
| 2160 |
- C<$delay> : the number of days after the closing of the basket after which an order is late |
| 2161 |
- C<$supplierid> : the id of the vendor this function has to get orders |
| 2162 |
- C<$branch> : the branchcode of the branch this function has to get orders |
| 2163 |
- C<$estimateddeliverydatefrom> : the oldest expected date of delivery (based on aqbooksellers.deliverytime) |
| 2164 |
- C<$estimateddeliverydateto> : the most recent expected date of delivery (based on aqbooksellers.deliverytime). If only |
| 2165 |
C<$estimateddeliverydatefrom> is provided and not C<$estimateddeliverydatefrom>, the current day is used as most recent |
| 2166 |
expected date of delivery. |
| 2167 |
|
| 2168 |
Return : |
| 2169 |
The returned C<@results> is an array of references-to-hash, whose keys are: |
| 2170 |
- 9 fields from the aqorders table : ordernumber, biblionumber, deletedbiblionumber, claims_count, claims_date, |
| 2171 |
closedate as orderdate, rrp as unitpricesupplier, ecost in unitpricelib, budget_name as budget |
| 2172 |
- 1 field from the aqbasket table : basketno |
| 2173 |
- 1 field from the borrowers table : branchcode as branch |
| 2174 |
- 2 fields from aqbooksellers : name as supplier, id as supplierid |
| 2175 |
- 2 fields of biblio or deletedbiblio tables : title, author |
| 2176 |
- 2 fields of biblioitems or deletedbiblioitems tables : publishercode as publisher, publicationyear |
| 2177 |
- estimateddeliverydate : ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) |
| 2178 |
- quantity ; aqorders.quantity - COALESCE(aqorders.quantityreceived,0) |
| 2179 |
- subtotal : (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal |
| 2180 |
- latesince : DATEDIFF(CAST(now() AS date),closedate) AS latesince |
| 2181 |
If the record still exists, the biblionumber key contains the biblionumber |
| 2182 |
If the record have been deleted, the biblionumber key is blank, |
| 2183 |
and the deletedbiblionumber key contains the biblionumber of the deleted record. |
| 2184 |
|
| 2185 |
|
| 2053 |
=cut |
2186 |
=cut |
| 2054 |
|
2187 |
|
| 2055 |
sub GetLateOrders { |
2188 |
sub GetLateOrders { |
|
Lines 2068-2073
sub GetLateOrders {
Link Here
|
| 2068 |
my $select = " |
2201 |
my $select = " |
| 2069 |
SELECT aqbasket.basketno, |
2202 |
SELECT aqbasket.basketno, |
| 2070 |
aqorders.ordernumber, |
2203 |
aqorders.ordernumber, |
|
|
2204 |
aqorders.biblionumber, |
| 2205 |
aqorders.deletedbiblionumber, |
| 2071 |
DATE(aqbasket.closedate) AS orderdate, |
2206 |
DATE(aqbasket.closedate) AS orderdate, |
| 2072 |
aqorders.rrp AS unitpricesupplier, |
2207 |
aqorders.rrp AS unitpricesupplier, |
| 2073 |
aqorders.ecost AS unitpricelib, |
2208 |
aqorders.ecost AS unitpricelib, |
|
Lines 2077-2091
sub GetLateOrders {
Link Here
|
| 2077 |
borrowers.branchcode AS branch, |
2212 |
borrowers.branchcode AS branch, |
| 2078 |
aqbooksellers.name AS supplier, |
2213 |
aqbooksellers.name AS supplier, |
| 2079 |
aqbooksellers.id AS supplierid, |
2214 |
aqbooksellers.id AS supplierid, |
| 2080 |
biblio.author, biblio.title, |
2215 |
COALESCE (biblio.author, deletedbiblio.author) AS author, |
| 2081 |
biblioitems.publishercode AS publisher, |
2216 |
COALESCE (biblio.title, deletedbiblio.title) AS title, |
| 2082 |
biblioitems.publicationyear, |
2217 |
COALESCE (biblioitems.publishercode, deletedbiblioitems.publishercode) AS publisher, |
|
|
2218 |
COALESCE (biblioitems.publicationyear, deletedbiblioitems.publicationyear) AS publicationyear, |
| 2083 |
ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate, |
2219 |
ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate, |
| 2084 |
"; |
2220 |
"; |
| 2085 |
my $from = " |
2221 |
my $from = " |
| 2086 |
FROM |
2222 |
FROM |
| 2087 |
aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
2223 |
aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
| 2088 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
2224 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
|
|
2225 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber = aqorders.deletedbiblionumber |
| 2226 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber = deletedbiblio.biblionumber |
| 2089 |
LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id, |
2227 |
LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id, |
| 2090 |
aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber |
2228 |
aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber |
| 2091 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
2229 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
|
Lines 2214-2219
returns:
Link Here
|
| 2214 |
$total_qty is the sum of all of the quantities in $order_loop |
2352 |
$total_qty is the sum of all of the quantities in $order_loop |
| 2215 |
$total_price is the cost of each in $order_loop times the quantity |
2353 |
$total_price is the cost of each in $order_loop times the quantity |
| 2216 |
$total_qtyreceived is the sum of all of the quantityreceived entries in $order_loop |
2354 |
$total_qtyreceived is the sum of all of the quantityreceived entries in $order_loop |
|
|
2355 |
If the record still exists, the biblionumber key contains the biblionumber |
| 2356 |
If the record have been deleted, the biblionumber key is blank, |
| 2357 |
and the deletedbiblionumber key contains the biblionumber of the deleted record. |
| 2217 |
|
2358 |
|
| 2218 |
=cut |
2359 |
=cut |
| 2219 |
|
2360 |
|
|
Lines 2248-2253
sub GetHistory {
Link Here
|
| 2248 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
2389 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
| 2249 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
2390 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
| 2250 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
2391 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
|
|
2392 |
aqorders.deletedbiblionumber, |
| 2251 |
aqorders.basketno, |
2393 |
aqorders.basketno, |
| 2252 |
aqbasket.basketname, |
2394 |
aqbasket.basketname, |
| 2253 |
aqbasket.basketgroupid, |
2395 |
aqbasket.basketgroupid, |
|
Lines 2277-2284
sub GetHistory {
Link Here
|
| 2277 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
2419 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
| 2278 |
LEFT JOIN aqbudgets ON aqorders.budget_id=aqbudgets.budget_id |
2420 |
LEFT JOIN aqbudgets ON aqorders.budget_id=aqbudgets.budget_id |
| 2279 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid |
2421 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid |
| 2280 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber |
2422 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.deletedbiblionumber |
| 2281 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber |
2423 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=deletedbiblio.biblionumber |
| 2282 |
"; |
2424 |
"; |
| 2283 |
|
2425 |
|
| 2284 |
if ( C4::Context->preference("IndependentBranches") ) { |
2426 |
if ( C4::Context->preference("IndependentBranches") ) { |
|
Lines 2299-2320
sub GetHistory {
Link Here
|
| 2299 |
} |
2441 |
} |
| 2300 |
|
2442 |
|
| 2301 |
if ( $title ) { |
2443 |
if ( $title ) { |
| 2302 |
$query .= " AND biblio.title LIKE ? "; |
2444 |
$query .= " AND COALESCE (biblio.title,deletedbiblio.title) LIKE ? "; |
| 2303 |
$title =~ s/\s+/%/g; |
2445 |
$title =~ s/\s+/%/g; |
| 2304 |
push @query_params, "%$title%"; |
2446 |
push @query_params, "%$title%"; |
| 2305 |
} |
2447 |
} |
| 2306 |
|
2448 |
|
| 2307 |
if ( $author ) { |
2449 |
if ( $author ) { |
| 2308 |
$query .= " AND biblio.author LIKE ? "; |
2450 |
$query .= " AND COALESCE (biblio.author,deletedbiblio.author) LIKE ? "; |
| 2309 |
push @query_params, "%$author%"; |
2451 |
push @query_params, "%$author%"; |
| 2310 |
} |
2452 |
} |
| 2311 |
|
2453 |
|
| 2312 |
if ( $isbn ) { |
2454 |
if ( $isbn ) { |
| 2313 |
$query .= " AND biblioitems.isbn LIKE ? "; |
2455 |
$query .= " AND COALESCE (biblioitems.isbn,deletedbiblioitems.isbn) LIKE ? "; |
| 2314 |
push @query_params, "%$isbn%"; |
2456 |
push @query_params, "%$isbn%"; |
| 2315 |
} |
2457 |
} |
| 2316 |
if ( $ean ) { |
2458 |
if ( $ean ) { |
| 2317 |
$query .= " AND biblioitems.ean = ? "; |
2459 |
$query .= " AND OALESCE (biblioitems.ean,deletedbiblioitems.ean) = ? "; |
| 2318 |
push @query_params, "$ean"; |
2460 |
push @query_params, "$ean"; |
| 2319 |
} |
2461 |
} |
| 2320 |
if ( $name ) { |
2462 |
if ( $name ) { |