From 7aeb26593b4b253a9a39bfdd7679b3c115d73ac7 Mon Sep 17 00:00:00 2001 From: tonnesen Date: Thu, 24 Oct 2002 18:30:17 +0000 Subject: [PATCH] Merging changes from rel-1-2 into trunk (circulation module only) --- C4/Circulation/Circ2.pm | 72 +++++++++++++++++++++++-------------- circ/branchtransfers.pl | 12 ++++--- circ/circulation.pl | 15 ++++++-- circ/selectbranchprinter.pl | 18 +++++----- 4 files changed, 75 insertions(+), 42 deletions(-) diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index fa4bd3c4ad..ab5c59e4b5 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -5,7 +5,6 @@ package C4::Circulation::Circ2; #package to deal with Returns #written 3/11/99 by olwen@katipo.co.nz -# $Id$ # Copyright 2000-2002 Katipo Communications # @@ -247,10 +246,21 @@ sub getpatroninformation { $sth = $dbh->prepare($query); $sth->execute; my $borrower = $sth->fetchrow_hashref; + my $amount = checkaccount($env, $borrowernumber, $dbh); + $borrower->{'amountoutstanding'} = $amount; my $flags = patronflags($env, $borrower, $dbh); + my $accessflagshash; + + $sth=$dbh->prepare("select bit,flag from userflags"); + $sth->execute; + while (my ($bit, $flag) = $sth->fetchrow) { + if ($borrower->{'flags'} & 2**$bit) { + $accessflagshash->{$flag}=1; + } + } $sth->finish; $borrower->{'flags'}=$flags; - return($borrower, $flags); + return ($borrower, $flags, $accessflagshash); } =item decode @@ -723,7 +733,7 @@ sub issuebook { last SWITCH; } if ($iteminformation->{'notforloan'} == 1) { - $rejected="Reference item: not for loan."; + $rejected="Item not for loan."; last SWITCH; } if ($iteminformation->{'wthdrawn'} == 1) { @@ -734,8 +744,10 @@ sub issuebook { $rejected="Restricted item."; last SWITCH; } - - # See who, if anyone, currently has this book. + if ($iteminformation->{'itemtype'} eq 'REF') { + $rejected="Reference item: Not for loan."; + last SWITCH; + } my ($currentborrower) = currentborrower($iteminformation->{'itemnumber'}); if ($currentborrower eq $patroninformation->{'borrowernumber'}) { # Already issued to current borrower. Ask whether the loan should @@ -1012,6 +1024,7 @@ sub returnbook { # find reserves..... my ($resfound, $resrec) = CheckReserves($iteminformation->{'itemnumber'}); if ($resfound) { + my $tobrcd = ReserveWaiting($resrec->{'itemnumber'}, $resrec->{'borrowernumber'}); $resrec->{'ResFound'} = $resfound; $messages->{'ResFound'} = $resrec; } @@ -1485,21 +1498,28 @@ sub getissues { my ($borrower) = @_; my $dbh = C4::Context->dbh; my $borrowernumber = $borrower->{'borrowernumber'}; - my $brn =$dbh->quote($borrowernumber); my %currentissues; - my $select = "select issues.timestamp, issues.date_due, items.biblionumber, - items.barcode, biblio.title, biblio.author, biblioitems.dewey, - biblioitems.subclass - from issues,items,biblioitems,biblio - where issues.borrowernumber = $brn - and issues.itemnumber = items.itemnumber - and items.biblionumber = biblio.biblionumber - and items.biblioitemnumber = biblioitems.biblioitemnumber - and issues.returndate is null - order by issues.date_due"; -# warn $select; + my $select = "SELECT issues.timestamp AS timestamp, + issues.date_due AS date_due, + items.biblionumber AS biblionumber, + items.itemnumber AS itemnumber, + items.barcode AS barcode, + biblio.title AS title, + biblio.author AS author, + biblioitems.dewey AS dewey, + itemtypes.description AS itemtype, + biblioitems.subclass AS subclass + FROM issues,items,biblioitems,biblio, itemtypes + WHERE issues.borrowernumber = ? + AND issues.itemnumber = items.itemnumber + AND items.biblionumber = biblio.biblionumber + AND items.biblioitemnumber = biblioitems.biblioitemnumber + AND itemtypes.itemtype = biblioitems.itemtype + AND issues.returndate IS NULL + ORDER BY issues.date_due"; +# print $select; my $sth=$dbh->prepare($select); - $sth->execute; + $sth->execute($borrowernumber); my $counter = 0; while (my $data = $sth->fetchrow_hashref) { $data->{'dewey'} =~ s/0*$//; @@ -1558,18 +1578,18 @@ sub checkaccount { #take borrower number #check accounts and list amounts owing my ($env,$bornumber,$dbh,$date)=@_; - my $select="Select sum(amountoutstanding) from accountlines where - borrowernumber=$bornumber and amountoutstanding<>0"; + my $select="SELECT SUM(amountoutstanding) AS total + FROM accountlines + WHERE borrowernumber = $bornumber + AND amountoutstanding<>0"; if ($date ne ''){ - $select.=" and date < '$date'"; + $select.=" AND date < '$date'"; } # print $select; my $sth=$dbh->prepare($select); $sth->execute; - my $total=0; - while (my $data=$sth->fetchrow_hashref){ - $total += $data->{'sum(amountoutstanding)'}; - } + my $data=$sth->fetchrow_hashref; + my $total = $data->{'total'}; $sth->finish; # output(1,2,"borrower owes $total"); #if ($total > 0){ @@ -1701,7 +1721,7 @@ sub calc_charges { } $sth1->finish; # close FILE; - return ($charge); + return ($charge, $itemtype); } # FIXME - A virtually identical function appears in diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl index d2f0e982d8..70990a00e0 100755 --- a/circ/branchtransfers.pl +++ b/circ/branchtransfers.pl @@ -26,6 +26,7 @@ use CGI; use C4::Circulation::Circ2; use C4::Output; use C4::Reserves2; +use C4::Auth; ############################################### # constants @@ -46,6 +47,7 @@ my $printers = getprinters(\%env); # Getting state my $query=new CGI; +my ($loggedinuser, $sessioncookie, $sessionID) = checkauth($query); my $branch = $query->param("branch"); @@ -55,6 +57,9 @@ my $printer = $query->param("printer"); ($branch) || ($branch=$query->cookie('branch')) ; ($printer) || ($printer=$query->cookie('printer')) ; +($branches->{$branch}) || ($branch=(keys %$branches)[0]); +($printers->{$printer}) || ($printer=(keys %$printers)[0]); + my $request=$query->param('request'); @@ -64,10 +69,7 @@ my $frbranchcd=''; # set up the branchselect options.... my $tobranchoptions; foreach my $br (keys %$branches) { -# FIXME - Dunno what this line was supposed to do, but "CU" never -# appears anywhere else, so this was preventing this code from -# working, by creating an empty