Fixing reserve handling.
authorrangi <rangi>
Sun, 25 Nov 2001 20:17:53 +0000 (20:17 +0000)
committerrangi <rangi>
Sun, 25 Nov 2001 20:17:53 +0000 (20:17 +0000)
Mulitple copy reserves now handled correctly, and correct charges are being
applied

C4/Circulation/Circ2.pm
C4/Reserves2.pm

index c221fd0..59a27a1 100755 (executable)
@@ -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 &currentissues &getiteminformation &findborrower &issuebook &returnbook);
+@EXPORT = qw(&getbranches &getprinters &getpatroninformation &currentissues &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 
index a59c191..8f0e7db 100755 (executable)
@@ -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;                                                           
       }   
     }