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 75-80
BEGIN {
Link Here
|
75 |
&GetItemnumbersFromOrder |
75 |
&GetItemnumbersFromOrder |
76 |
|
76 |
|
77 |
&AddClaim |
77 |
&AddClaim |
|
|
78 |
&GetBiblioCountByBasketno |
78 |
); |
79 |
); |
79 |
} |
80 |
} |
80 |
|
81 |
|
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 |
} |
228 |
} |
240 |
} |
229 |
|
241 |
|
230 |
#------------------------------------------------------------# |
242 |
#------------------------------------------------------------# |
Lines 464-469
sub ModBasket {
Link Here
|
464 |
my $dbh = C4::Context->dbh; |
476 |
my $dbh = C4::Context->dbh; |
465 |
my $sth = $dbh->prepare($query); |
477 |
my $sth = $dbh->prepare($query); |
466 |
$sth->execute(@params); |
478 |
$sth->execute(@params); |
|
|
479 |
|
480 |
# set orders status = new |
481 |
my @orders = GetOrders($basketinfo->{'basketno'}); |
482 |
foreach my $order (@orders) { |
483 |
$query = qq{ |
484 |
UPDATE aqorders |
485 |
SET orderstatus = 0 |
486 |
WHERE ordernumber = ?; |
487 |
}; |
488 |
$sth = $dbh->prepare($query); |
489 |
$sth->execute($order->{'ordernumber'}); |
490 |
} |
491 |
|
467 |
$sth->finish; |
492 |
$sth->finish; |
468 |
} |
493 |
} |
469 |
|
494 |
|
Lines 1040-1046
The following keys are used: "biblionumber", "title", "basketno", "quantity", "n
Link Here
|
1040 |
|
1065 |
|
1041 |
sub NewOrder { |
1066 |
sub NewOrder { |
1042 |
my $orderinfo = shift; |
1067 |
my $orderinfo = shift; |
1043 |
#### ------------------------------ |
1068 |
my $parent_ordernumber = shift; |
|
|
1069 |
|
1044 |
my $dbh = C4::Context->dbh; |
1070 |
my $dbh = C4::Context->dbh; |
1045 |
my @params; |
1071 |
my @params; |
1046 |
|
1072 |
|
Lines 1313-1318
sub ModReceiveOrder {
Link Here
|
1313 |
$sth=$dbh->prepare(" |
1339 |
$sth=$dbh->prepare(" |
1314 |
UPDATE aqorders |
1340 |
UPDATE aqorders |
1315 |
SET quantity = ? |
1341 |
SET quantity = ? |
|
|
1342 |
ordernumber = 2 |
1316 |
WHERE ordernumber = ? |
1343 |
WHERE ordernumber = ? |
1317 |
"); |
1344 |
"); |
1318 |
|
1345 |
|
Lines 1339-1345
sub ModReceiveOrder {
Link Here
|
1339 |
} else { |
1366 |
} else { |
1340 |
$sth=$dbh->prepare("update aqorders |
1367 |
$sth=$dbh->prepare("update aqorders |
1341 |
set quantityreceived=?,datereceived=?,invoiceid=?, |
1368 |
set quantityreceived=?,datereceived=?,invoiceid=?, |
1342 |
unitprice=?,rrp=?,ecost=? |
1369 |
unitprice=?,rrp=?,ecost=?,orderstatus=3 |
1343 |
where biblionumber=? and ordernumber=?"); |
1370 |
where biblionumber=? and ordernumber=?"); |
1344 |
$sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber); |
1371 |
$sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber); |
1345 |
$sth->finish; |
1372 |
$sth->finish; |
Lines 1556-1562
sub DelOrder {
Link Here
|
1556 |
my $dbh = C4::Context->dbh; |
1583 |
my $dbh = C4::Context->dbh; |
1557 |
my $query = " |
1584 |
my $query = " |
1558 |
UPDATE aqorders |
1585 |
UPDATE aqorders |
1559 |
SET datecancellationprinted=now() |
1586 |
SET datecancellationprinted=now(), orderstatus=4 |
1560 |
WHERE biblionumber=? AND ordernumber=? |
1587 |
WHERE biblionumber=? AND ordernumber=? |
1561 |
"; |
1588 |
"; |
1562 |
my $sth = $dbh->prepare($query); |
1589 |
my $sth = $dbh->prepare($query); |
Lines 1917-1922
sub GetHistory {
Link Here
|
1917 |
my $basket = $params{basket}; |
1944 |
my $basket = $params{basket}; |
1918 |
my $booksellerinvoicenumber = $params{booksellerinvoicenumber}; |
1945 |
my $booksellerinvoicenumber = $params{booksellerinvoicenumber}; |
1919 |
my $basketgroupname = $params{basketgroupname}; |
1946 |
my $basketgroupname = $params{basketgroupname}; |
|
|
1947 |
my $budget = $params{budget}; |
1948 |
my $branchcode = $params{branchcode}; |
1949 |
my $orderstatus = $params{orderstatus}; |
1950 |
|
1920 |
my @order_loop; |
1951 |
my @order_loop; |
1921 |
my $total_qty = 0; |
1952 |
my $total_qty = 0; |
1922 |
my $total_qtyreceived = 0; |
1953 |
my $total_qtyreceived = 0; |
Lines 1925-1934
sub GetHistory {
Link Here
|
1925 |
my $dbh = C4::Context->dbh; |
1956 |
my $dbh = C4::Context->dbh; |
1926 |
my $query =" |
1957 |
my $query =" |
1927 |
SELECT |
1958 |
SELECT |
1928 |
biblio.title, |
1959 |
COALESCE(biblio.title, deletedbiblio.title) AS title, |
1929 |
biblio.author, |
1960 |
COALESCE(biblio.author, deletedbiblio.author) AS author, |
1930 |
biblioitems.isbn, |
1961 |
COALESCE(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, |
1931 |
biblioitems.ean, |
1962 |
COALESCE(biblioitems.ean, deletedbiblioitems.ean) AS ean, |
1932 |
aqorders.basketno, |
1963 |
aqorders.basketno, |
1933 |
aqbasket.basketname, |
1964 |
aqbasket.basketname, |
1934 |
aqbasket.basketgroupid, |
1965 |
aqbasket.basketgroupid, |
Lines 1942-1960
sub GetHistory {
Link Here
|
1942 |
aqorders.ordernumber, |
1973 |
aqorders.ordernumber, |
1943 |
aqinvoices.invoicenumber, |
1974 |
aqinvoices.invoicenumber, |
1944 |
aqbooksellers.id as id, |
1975 |
aqbooksellers.id as id, |
1945 |
aqorders.biblionumber |
1976 |
aqorders.biblionumber, |
|
|
1977 |
aqorders.orderstatus, |
1978 |
aqorders.parent_ordernumber"; |
1979 |
$query .= ", aqbudgets.budget_id AS budget" if defined $budget; |
1980 |
$query .= ", aqorders.branchcode " if ( not C4::Context->preference("IndependantBranches") and defined $branchcode and $branchcode ); |
1981 |
$query .= " |
1946 |
FROM aqorders |
1982 |
FROM aqorders |
1947 |
LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno |
1983 |
LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno |
1948 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id |
1984 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id |
1949 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id |
1985 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id |
1950 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber |
1986 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber |
1951 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
1987 |
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber |
1952 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid"; |
1988 |
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid |
|
|
1989 |
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber |
1990 |
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber |
1991 |
"; |
1992 |
|
1993 |
$query .= " LEFT JOIN aqbudgets ON aqorders.budget_id=aqbudgets.budget_id" |
1994 |
if defined $budget; |
1995 |
|
1996 |
if ( C4::Context->preference("IndependantBranches") ) { |
1997 |
$query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"; |
1998 |
} elsif ( defined $branchcode and $branchcode) { |
1999 |
$query .= " LEFT JOIN borrowers ON aqorders.branchcode=borrowers.branchcode" |
2000 |
} |
1953 |
|
2001 |
|
1954 |
$query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber" |
2002 |
$query .= " WHERE 1 "; |
1955 |
if ( C4::Context->preference("IndependantBranches") ); |
|
|
1956 |
|
2003 |
|
1957 |
$query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') "; |
2004 |
$query .= " AND (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') " if $orderstatus ne '4'; |
1958 |
|
2005 |
|
1959 |
my @query_params = (); |
2006 |
my @query_params = (); |
1960 |
|
2007 |
|
Lines 1973-1979
sub GetHistory {
Link Here
|
1973 |
$query .= " AND biblioitems.isbn LIKE ? "; |
2020 |
$query .= " AND biblioitems.isbn LIKE ? "; |
1974 |
push @query_params, "%$isbn%"; |
2021 |
push @query_params, "%$isbn%"; |
1975 |
} |
2022 |
} |
1976 |
if ( defined $ean and $ean ) { |
2023 |
if ( $ean ) { |
1977 |
$query .= " AND biblioitems.ean = ? "; |
2024 |
$query .= " AND biblioitems.ean = ? "; |
1978 |
push @query_params, "$ean"; |
2025 |
push @query_params, "$ean"; |
1979 |
} |
2026 |
} |
Lines 1982-1987
sub GetHistory {
Link Here
|
1982 |
push @query_params, "%$name%"; |
2029 |
push @query_params, "%$name%"; |
1983 |
} |
2030 |
} |
1984 |
|
2031 |
|
|
|
2032 |
if ( $budget ) { |
2033 |
$query .= " AND aqbudgets.budget_id = ? "; |
2034 |
push @query_params, "$budget"; |
2035 |
} |
2036 |
|
1985 |
if ( $from_placed_on ) { |
2037 |
if ( $from_placed_on ) { |
1986 |
$query .= " AND creationdate >= ? "; |
2038 |
$query .= " AND creationdate >= ? "; |
1987 |
push @query_params, $from_placed_on; |
2039 |
push @query_params, $from_placed_on; |
Lines 1992-1997
sub GetHistory {
Link Here
|
1992 |
push @query_params, $to_placed_on; |
2044 |
push @query_params, $to_placed_on; |
1993 |
} |
2045 |
} |
1994 |
|
2046 |
|
|
|
2047 |
if ( defined $orderstatus and $orderstatus ne '') { |
2048 |
$query .= " AND aqorders.orderstatus = ? "; |
2049 |
push @query_params, "$orderstatus"; |
2050 |
} |
2051 |
|
1995 |
if ($basket) { |
2052 |
if ($basket) { |
1996 |
if ($basket =~ m/^\d+$/) { |
2053 |
if ($basket =~ m/^\d+$/) { |
1997 |
$query .= " AND aqorders.basketno = ? "; |
2054 |
$query .= " AND aqorders.basketno = ? "; |
Lines 2018-2023
sub GetHistory {
Link Here
|
2018 |
$query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) "; |
2075 |
$query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) "; |
2019 |
push @query_params, $userenv->{branch}; |
2076 |
push @query_params, $userenv->{branch}; |
2020 |
} |
2077 |
} |
|
|
2078 |
} elsif ( defined $branchcode and $branchcode ) { |
2079 |
$query .= " AND aqorders.branchcode = ? "; |
2080 |
push @query_params, $branchcode; |
2021 |
} |
2081 |
} |
2022 |
$query .= " ORDER BY id"; |
2082 |
$query .= " ORDER BY id"; |
2023 |
my $sth = $dbh->prepare($query); |
2083 |
my $sth = $dbh->prepare($query); |
Lines 2027-2035
sub GetHistory {
Link Here
|
2027 |
$line->{count} = $cnt++; |
2087 |
$line->{count} = $cnt++; |
2028 |
$line->{toggle} = 1 if $cnt % 2; |
2088 |
$line->{toggle} = 1 if $cnt % 2; |
2029 |
push @order_loop, $line; |
2089 |
push @order_loop, $line; |
2030 |
$total_qty += $line->{'quantity'}; |
2090 |
$total_qty += ( $line->{quantity} ) ? $line->{quantity} : 0; |
2031 |
$total_qtyreceived += $line->{'quantityreceived'}; |
2091 |
$total_qtyreceived += ( $line->{quantityreceived} ) ? $line->{quantityreceived} : 0; |
2032 |
$total_price += $line->{'quantity'} * $line->{'ecost'}; |
2092 |
$total_price += ( $line->{quantity} and $line->{ecost} ) ? $line->{quantity} * $line->{ecost} : 0; |
2033 |
} |
2093 |
} |
2034 |
return \@order_loop, $total_qty, $total_price, $total_qtyreceived; |
2094 |
return \@order_loop, $total_qty, $total_price, $total_qtyreceived; |
2035 |
} |
2095 |
} |
Lines 2491-2496
sub ReopenInvoice {
Link Here
|
2491 |
$sth->execute($invoiceid); |
2551 |
$sth->execute($invoiceid); |
2492 |
} |
2552 |
} |
2493 |
|
2553 |
|
|
|
2554 |
=head3 GetBiblioCountByBasketno |
2555 |
|
2556 |
$biblio_count = &GetBiblioCountByBasketno($basketno); |
2557 |
|
2558 |
Looks up the biblio's count that has basketno value $basketno |
2559 |
|
2560 |
Returns a quantity |
2561 |
|
2562 |
=cut |
2563 |
|
2564 |
sub GetBiblioCountByBasketno { |
2565 |
my ($basketno) = @_; |
2566 |
my $dbh = C4::Context->dbh; |
2567 |
my $query = " |
2568 |
SELECT COUNT( DISTINCT( biblionumber ) ) |
2569 |
FROM aqorders |
2570 |
WHERE basketno = ? |
2571 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
2572 |
"; |
2573 |
|
2574 |
my $sth = $dbh->prepare($query); |
2575 |
$sth->execute($basketno); |
2576 |
return $sth->fetchrow; |
2577 |
} |
2578 |
|
2494 |
1; |
2579 |
1; |
2495 |
__END__ |
2580 |
__END__ |
2496 |
|
2581 |
|