Lines 28-34
use MARC::Record;
Link Here
|
28 |
use C4::Suggestions; |
28 |
use C4::Suggestions; |
29 |
use C4::Biblio; |
29 |
use C4::Biblio; |
30 |
use C4::Debug; |
30 |
use C4::Debug; |
31 |
use C4::SQLHelper qw(InsertInTable); |
31 |
use C4::SQLHelper qw(InsertInTable UpdateInTable); |
32 |
use C4::Bookseller qw(GetBookSellerFromId); |
32 |
use C4::Bookseller qw(GetBookSellerFromId); |
33 |
use C4::Templates qw(gettemplate); |
33 |
use C4::Templates qw(gettemplate); |
34 |
|
34 |
|
Lines 43-49
BEGIN {
Link Here
|
43 |
require Exporter; |
43 |
require Exporter; |
44 |
@ISA = qw(Exporter); |
44 |
@ISA = qw(Exporter); |
45 |
@EXPORT = qw( |
45 |
@EXPORT = qw( |
46 |
&GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket |
46 |
&GetBasket &NewBasket &CloseBasket &ReopenBasket &DelBasket &ModBasket |
47 |
&GetBasketAsCSV &GetBasketGroupAsCSV |
47 |
&GetBasketAsCSV &GetBasketGroupAsCSV |
48 |
&GetBasketsByBookseller &GetBasketsByBasketgroup |
48 |
&GetBasketsByBookseller &GetBasketsByBasketgroup |
49 |
&GetBasketsInfosByBookseller |
49 |
&GetBasketsInfosByBookseller |
Lines 75-80
BEGIN {
Link Here
|
75 |
&GetItemnumbersFromOrder |
75 |
&GetItemnumbersFromOrder |
76 |
|
76 |
|
77 |
&AddClaim |
77 |
&AddClaim |
|
|
78 |
&GetBiblioCountByBasketno |
78 |
); |
79 |
); |
79 |
} |
80 |
} |
80 |
|
81 |
|
Lines 211-217
sub NewBasket {
Link Here
|
211 |
|
212 |
|
212 |
&CloseBasket($basketno); |
213 |
&CloseBasket($basketno); |
213 |
|
214 |
|
214 |
close a basket (becomes unmodifiable,except for recieves) |
215 |
close a basket (becomes unmodifiable, except for receives) |
215 |
|
216 |
|
216 |
=cut |
217 |
=cut |
217 |
|
218 |
|
Lines 225-230
sub CloseBasket {
Link Here
|
225 |
"; |
226 |
"; |
226 |
my $sth = $dbh->prepare($query); |
227 |
my $sth = $dbh->prepare($query); |
227 |
$sth->execute($basketno); |
228 |
$sth->execute($basketno); |
|
|
229 |
|
230 |
my @orders = GetOrders($basketno); |
231 |
foreach my $order (@orders) { |
232 |
$query = qq{ |
233 |
UPDATE aqorders |
234 |
SET orderstatus = 1 |
235 |
WHERE ordernumber = ?; |
236 |
}; |
237 |
$sth = $dbh->prepare($query); |
238 |
$sth->execute($order->{'ordernumber'}); |
239 |
} |
240 |
} |
241 |
|
242 |
=head3 CloseBasket |
243 |
|
244 |
&ReopenBasket($basketno); |
245 |
|
246 |
reopen a basket |
247 |
|
248 |
=cut |
249 |
|
250 |
sub ReopenBasket { |
251 |
my ($basketno) = @_; |
252 |
my $dbh = C4::Context->dbh; |
253 |
my $query = " |
254 |
UPDATE aqbasket |
255 |
SET closedate=NULL |
256 |
WHERE basketno=? |
257 |
"; |
258 |
my $sth = $dbh->prepare($query); |
259 |
$sth->execute($basketno); |
260 |
|
261 |
my @orders = GetOrders($basketno); |
262 |
foreach my $order (@orders) { |
263 |
$query = qq{ |
264 |
UPDATE aqorders |
265 |
SET orderstatus = 0 |
266 |
WHERE ordernumber = ?; |
267 |
}; |
268 |
$sth = $dbh->prepare($query); |
269 |
$sth->execute($order->{'ordernumber'}); |
270 |
} |
228 |
} |
271 |
} |
229 |
|
272 |
|
230 |
#------------------------------------------------------------# |
273 |
#------------------------------------------------------------# |
Lines 464-469
sub ModBasket {
Link Here
|
464 |
my $dbh = C4::Context->dbh; |
507 |
my $dbh = C4::Context->dbh; |
465 |
my $sth = $dbh->prepare($query); |
508 |
my $sth = $dbh->prepare($query); |
466 |
$sth->execute(@params); |
509 |
$sth->execute(@params); |
|
|
510 |
|
467 |
$sth->finish; |
511 |
$sth->finish; |
468 |
} |
512 |
} |
469 |
|
513 |
|
Lines 1040-1046
The following keys are used: "biblionumber", "title", "basketno", "quantity", "n
Link Here
|
1040 |
|
1084 |
|
1041 |
sub NewOrder { |
1085 |
sub NewOrder { |
1042 |
my $orderinfo = shift; |
1086 |
my $orderinfo = shift; |
1043 |
#### ------------------------------ |
1087 |
my $parent_ordernumber = shift; |
|
|
1088 |
|
1044 |
my $dbh = C4::Context->dbh; |
1089 |
my $dbh = C4::Context->dbh; |
1045 |
my @params; |
1090 |
my @params; |
1046 |
|
1091 |
|
Lines 1313-1318
sub ModReceiveOrder {
Link Here
|
1313 |
$sth=$dbh->prepare(" |
1358 |
$sth=$dbh->prepare(" |
1314 |
UPDATE aqorders |
1359 |
UPDATE aqorders |
1315 |
SET quantity = ? |
1360 |
SET quantity = ? |
|
|
1361 |
ordernumber = 2 |
1316 |
WHERE ordernumber = ? |
1362 |
WHERE ordernumber = ? |
1317 |
"); |
1363 |
"); |
1318 |
|
1364 |
|
Lines 1339-1345
sub ModReceiveOrder {
Link Here
|
1339 |
} else { |
1385 |
} else { |
1340 |
$sth=$dbh->prepare("update aqorders |
1386 |
$sth=$dbh->prepare("update aqorders |
1341 |
set quantityreceived=?,datereceived=?,invoiceid=?, |
1387 |
set quantityreceived=?,datereceived=?,invoiceid=?, |
1342 |
unitprice=?,rrp=?,ecost=? |
1388 |
unitprice=?,rrp=?,ecost=?,orderstatus=3 |
1343 |
where biblionumber=? and ordernumber=?"); |
1389 |
where biblionumber=? and ordernumber=?"); |
1344 |
$sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber); |
1390 |
$sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber); |
1345 |
$sth->finish; |
1391 |
$sth->finish; |
Lines 1556-1562
sub DelOrder {
Link Here
|
1556 |
my $dbh = C4::Context->dbh; |
1602 |
my $dbh = C4::Context->dbh; |
1557 |
my $query = " |
1603 |
my $query = " |
1558 |
UPDATE aqorders |
1604 |
UPDATE aqorders |
1559 |
SET datecancellationprinted=now() |
1605 |
SET datecancellationprinted=now(), orderstatus=4 |
1560 |
WHERE biblionumber=? AND ordernumber=? |
1606 |
WHERE biblionumber=? AND ordernumber=? |
1561 |
"; |
1607 |
"; |
1562 |
my $sth = $dbh->prepare($query); |
1608 |
my $sth = $dbh->prepare($query); |
Lines 1917-1922
sub GetHistory {
Link Here
|
1917 |
my $basket = $params{basket}; |
1963 |
my $basket = $params{basket}; |
1918 |
my $booksellerinvoicenumber = $params{booksellerinvoicenumber}; |
1964 |
my $booksellerinvoicenumber = $params{booksellerinvoicenumber}; |
1919 |
my $basketgroupname = $params{basketgroupname}; |
1965 |
my $basketgroupname = $params{basketgroupname}; |
|
|
1966 |
my $budget = $params{budget}; |
1967 |
my $branchcode = $params{branchcode}; |
1968 |
my $orderstatus = $params{orderstatus}; |
1969 |
|
1920 |
my @order_loop; |
1970 |
my @order_loop; |
1921 |
my $total_qty = 0; |
1971 |
my $total_qty = 0; |
1922 |
my $total_qtyreceived = 0; |
1972 |
my $total_qtyreceived = 0; |
Lines 1925-1934
sub GetHistory {
Link Here
|
1925 |
my $dbh = C4::Context->dbh; |
1975 |
my $dbh = C4::Context->dbh; |
1926 |
my $query =" |
1976 |
my $query =" |
1927 |
SELECT |
1977 |
SELECT |
1928 |
biblio.title, |
1978 |
COALESCE(biblio.title, deletedbiblio.title) AS title, |
1929 |
biblio.author, |
1979 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
1930 |
biblioitems.isbn, |
1980 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
1931 |
biblioitems.ean, |
1981 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
1932 |
aqorders.basketno, |
1982 |
aqorders.basketno, |
1933 |
aqbasket.basketname, |
1983 |
aqbasket.basketname, |
1934 |
aqbasket.basketgroupid, |
1984 |
aqbasket.basketgroupid, |
Lines 1942-1960
sub GetHistory {
Link Here
|
1942 |
aqorders.ordernumber, |
1992 |
aqorders.ordernumber, |
1943 |
aqinvoices.invoicenumber, |
1993 |
aqinvoices.invoicenumber, |
1944 |
aqbooksellers.id as id, |
1994 |
aqbooksellers.id as id, |
1945 |
aqorders.biblionumber |
1995 |
aqorders.biblionumber, |
|
|
1996 |
aqorders.orderstatus, |
1997 |
aqorders.branchcode, |
1998 |
aqorders.parent_ordernumber, |
1999 |
aqbudgets.budget_name, |
2000 |
branches.branchname |
2001 |
"; |
2002 |
$query .= ", aqbudgets.budget_id AS budget" if defined $budget; |
2003 |
$query .= " |
1946 |
FROM aqorders |
2004 |
FROM aqorders |
1947 |
LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno |
2005 |
LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno |
1948 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id |
2006 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id |
1949 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id |
2007 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id |
1950 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber |
2008 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber |
1951 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
2009 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
1952 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid"; |
2010 |
LEFT JOIN branches ON branches.branchcode=aqorders.branchcode |
|
|
2011 |
LEFT JOIN aqbudgets ON aqorders.budget_id=aqbudgets.budget_id |
2012 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid |
2013 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber |
2014 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber |
2015 |
"; |
2016 |
|
2017 |
if ( C4::Context->preference("IndependantBranches") ) { |
2018 |
$query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"; |
2019 |
} |
1953 |
|
2020 |
|
1954 |
$query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber" |
2021 |
$query .= " WHERE 1 "; |
1955 |
if ( C4::Context->preference("IndependantBranches") ); |
|
|
1956 |
|
2022 |
|
1957 |
$query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') "; |
2023 |
$query .= " AND (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') " if $orderstatus ne '4'; |
1958 |
|
2024 |
|
1959 |
my @query_params = (); |
2025 |
my @query_params = (); |
1960 |
|
2026 |
|
Lines 1973-1979
sub GetHistory {
Link Here
|
1973 |
$query .= " AND biblioitems.isbn LIKE ? "; |
2039 |
$query .= " AND biblioitems.isbn LIKE ? "; |
1974 |
push @query_params, "%$isbn%"; |
2040 |
push @query_params, "%$isbn%"; |
1975 |
} |
2041 |
} |
1976 |
if ( defined $ean and $ean ) { |
2042 |
if ( $ean ) { |
1977 |
$query .= " AND biblioitems.ean = ? "; |
2043 |
$query .= " AND biblioitems.ean = ? "; |
1978 |
push @query_params, "$ean"; |
2044 |
push @query_params, "$ean"; |
1979 |
} |
2045 |
} |
Lines 1982-1987
sub GetHistory {
Link Here
|
1982 |
push @query_params, "%$name%"; |
2048 |
push @query_params, "%$name%"; |
1983 |
} |
2049 |
} |
1984 |
|
2050 |
|
|
|
2051 |
if ( $budget ) { |
2052 |
$query .= " AND aqbudgets.budget_id = ? "; |
2053 |
push @query_params, "$budget"; |
2054 |
} |
2055 |
|
1985 |
if ( $from_placed_on ) { |
2056 |
if ( $from_placed_on ) { |
1986 |
$query .= " AND creationdate >= ? "; |
2057 |
$query .= " AND creationdate >= ? "; |
1987 |
push @query_params, $from_placed_on; |
2058 |
push @query_params, $from_placed_on; |
Lines 1992-1997
sub GetHistory {
Link Here
|
1992 |
push @query_params, $to_placed_on; |
2063 |
push @query_params, $to_placed_on; |
1993 |
} |
2064 |
} |
1994 |
|
2065 |
|
|
|
2066 |
if ( defined $orderstatus and $orderstatus ne '') { |
2067 |
$query .= " AND aqorders.orderstatus = ? "; |
2068 |
push @query_params, "$orderstatus"; |
2069 |
} |
2070 |
|
1995 |
if ($basket) { |
2071 |
if ($basket) { |
1996 |
if ($basket =~ m/^\d+$/) { |
2072 |
if ($basket =~ m/^\d+$/) { |
1997 |
$query .= " AND aqorders.basketno = ? "; |
2073 |
$query .= " AND aqorders.basketno = ? "; |
Lines 2018-2023
sub GetHistory {
Link Here
|
2018 |
$query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) "; |
2094 |
$query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) "; |
2019 |
push @query_params, $userenv->{branch}; |
2095 |
push @query_params, $userenv->{branch}; |
2020 |
} |
2096 |
} |
|
|
2097 |
} elsif ( defined $branchcode and $branchcode ) { |
2098 |
$query .= " AND aqorders.branchcode = ? "; |
2099 |
push @query_params, $branchcode; |
2021 |
} |
2100 |
} |
2022 |
$query .= " ORDER BY id"; |
2101 |
$query .= " ORDER BY id"; |
2023 |
my $sth = $dbh->prepare($query); |
2102 |
my $sth = $dbh->prepare($query); |
Lines 2027-2035
sub GetHistory {
Link Here
|
2027 |
$line->{count} = $cnt++; |
2106 |
$line->{count} = $cnt++; |
2028 |
$line->{toggle} = 1 if $cnt % 2; |
2107 |
$line->{toggle} = 1 if $cnt % 2; |
2029 |
push @order_loop, $line; |
2108 |
push @order_loop, $line; |
2030 |
$total_qty += $line->{'quantity'}; |
2109 |
$total_qty += ( $line->{quantity} ) ? $line->{quantity} : 0; |
2031 |
$total_qtyreceived += $line->{'quantityreceived'}; |
2110 |
$total_qtyreceived += ( $line->{quantityreceived} ) ? $line->{quantityreceived} : 0; |
2032 |
$total_price += $line->{'quantity'} * $line->{'ecost'}; |
2111 |
$total_price += ( $line->{quantity} and $line->{ecost} ) ? $line->{quantity} * $line->{ecost} : 0; |
2033 |
} |
2112 |
} |
2034 |
return \@order_loop, $total_qty, $total_price, $total_qtyreceived; |
2113 |
return \@order_loop, $total_qty, $total_price, $total_qtyreceived; |
2035 |
} |
2114 |
} |
Lines 2491-2496
sub ReopenInvoice {
Link Here
|
2491 |
$sth->execute($invoiceid); |
2570 |
$sth->execute($invoiceid); |
2492 |
} |
2571 |
} |
2493 |
|
2572 |
|
|
|
2573 |
=head3 GetBiblioCountByBasketno |
2574 |
|
2575 |
$biblio_count = &GetBiblioCountByBasketno($basketno); |
2576 |
|
2577 |
Looks up the biblio's count that has basketno value $basketno |
2578 |
|
2579 |
Returns a quantity |
2580 |
|
2581 |
=cut |
2582 |
|
2583 |
sub GetBiblioCountByBasketno { |
2584 |
my ($basketno) = @_; |
2585 |
my $dbh = C4::Context->dbh; |
2586 |
my $query = " |
2587 |
SELECT COUNT( DISTINCT( biblionumber ) ) |
2588 |
FROM aqorders |
2589 |
WHERE basketno = ? |
2590 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
2591 |
"; |
2592 |
|
2593 |
my $sth = $dbh->prepare($query); |
2594 |
$sth->execute($basketno); |
2595 |
return $sth->fetchrow; |
2596 |
} |
2597 |
|
2494 |
1; |
2598 |
1; |
2495 |
__END__ |
2599 |
__END__ |
2496 |
|
2600 |
|