From 79ebd030d615a2fa62b7215a1bf7a6b4578ff381 Mon Sep 17 00:00:00 2001 From: rangi Date: Sun, 25 Nov 2001 20:17:53 +0000 Subject: [PATCH] Fixing reserve handling. Mulitple copy reserves now handled correctly, and correct charges are being applied --- C4/Circulation/Circ2.pm | 39 +++++++++++++++++++++------------------ C4/Reserves2.pm | 25 ++++++++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index c221fd091a..59a27a113c 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -23,7 +23,8 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&getbranches &getprinters &getpatroninformation ¤tissues &getiteminformation &findborrower &issuebook &returnbook); +@EXPORT = qw(&getbranches &getprinters &getpatroninformation ¤tissues &getiteminformation &findborrower &issuebook &returnbook +&find_reserves); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -476,7 +477,7 @@ sub returnbook { $usth = $dbh->prepare($uquery); $usth->execute; $usth->finish; - $uquery="update items set itemnotes='' where itemnumber=$iteminformation->{'itemnumber'}"; + $uquery="update items set paidfor='' where itemnumber=$iteminformation->{'itemnumber'}"; $usth = $dbh->prepare($uquery); $usth->execute; $usth->finish; @@ -887,30 +888,32 @@ sub find_reserves { my $resfound = "n"; my $resrec; my $lastrec; +# print $query; while (($resrec=$sth->fetchrow_hashref) && ($resfound eq "n")) { $lastrec=$resrec; if ($resrec->{'found'} eq "W") { if ($resrec->{'itemnumber'} eq $itemno) { $resfound = "y"; - } - } - if ($resrec->{'constrainttype'} eq "a") { - $resfound = "y"; + } } else { - my $conquery = "select * from reserveconstraints where borrowernumber -= $resrec->{'borrowernumber'} and reservedate = '$resrec->{'reservedate'}' and biblionumber = $resrec->{'biblionumber'} and biblioitemnumber = $itemdata->{'biblioitemnumber'}"; - my $consth = $dbh->prepare($conquery); - $consth->execute; - if (my $conrec=$consth->fetchrow_hashref) { - if ($resrec->{'constrainttype'} eq "o") { - $resfound = "y"; - } + if ($resrec->{'constrainttype'} eq "a") { + $resfound = "y"; } else { - if ($resrec->{'constrainttype'} eq "e") { - $resfound = "y"; - } + my $conquery = "select * from reserveconstraints where borrowernumber += $resrec->{'borrowernumber'} and reservedate = '$resrec->{'reservedate'}' and biblionumber = $resrec->{'biblionumber'} and biblioitemnumber = $itemdata->{'biblioitemnumber'}"; + my $consth = $dbh->prepare($conquery); + $consth->execute; + if (my $conrec=$consth->fetchrow_hashref) { + if ($resrec->{'constrainttype'} eq "o") { + $resfound = "y"; + } + } else { + if ($resrec->{'constrainttype'} eq "e") { + $resfound = "y"; + } + } + $consth->finish; } - $consth->finish; } if ($resfound eq "y") { my $updquery = "update reserves diff --git a/C4/Reserves2.pm b/C4/Reserves2.pm index a59c1916c6..8f0e7dbd62 100755 --- a/C4/Reserves2.pm +++ b/C4/Reserves2.pm @@ -54,7 +54,7 @@ my $priv_func = sub { sub FindReserves { my ($bib,$bor)=@_; my $dbh=C4Connect; - my $query="Select *,reserves.branchcode + my $query="Select *,reserves.branchcode,biblio.title as btitle from reserves,borrowers,biblio "; if ($bib ne ''){ if ($bor ne ''){ @@ -175,8 +175,15 @@ sub CalcReserveFee { } $x++; } - if ($const eq 'o') {if ($found == 1) {push @biblioitems,$data;} - } else {if ($found == 0) {push @biblioitems,$data;} } + if ($const eq 'o') { + if ( $found == 1) { + push @biblioitems,$data1; + } + } else { + if ($found == 0) { + push @biblioitems,$data1; + } + } } } $sth1->finish; @@ -193,11 +200,14 @@ sub CalcReserveFee { while (my $itdata=$sth2->fetchrow_hashref) { my $query3 = "select * from issues where itemnumber = '$itdata->{'itemnumber'}' and - returndate is null"; + returndate is null"; + my $sth3 = $dbh->prepare($query3); $sth3->execute(); - if (my $isdata=$sth3->fetchrow_hashref) { } else - {$allissued = 0; } + if (my $isdata=$sth3->fetchrow_hashref) { + } else { + $allissued = 0; + } } $x++; } @@ -206,7 +216,8 @@ sub CalcReserveFee { where biblionumber = '$biblionumber'"; my $rsth = $dbh->prepare($rquery); $rsth->execute(); - if (my $rdata = $rsth->fetchrow_hashref) { } else { + if (my $rdata = $rsth->fetchrow_hashref) { + } else { $fee = 0; } } -- 2.39.5