Revert "2 FixPriority calls were broken. FixPriority itself may be broken too,"
authorJoshua Ferraro <jmf@liblime.com>
Wed, 23 Apr 2008 00:16:30 +0000 (19:16 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 23 Apr 2008 00:16:30 +0000 (19:16 -0500)
This reverts commit ea9e0804cd05ee0b0ff386afe28561a2d3cf23e0.

C4/Reserves.pm

index 4097f4f..6fedf23 100644 (file)
@@ -81,7 +81,7 @@ C4::Reserves - Koha functions for dealing with reservation.
 
 BEGIN {
     # set the version for version checking
-    $VERSION = 3.02;
+    $VERSION = 3.01;
        require Exporter;
     @ISA = qw(Exporter);
     @EXPORT = qw(
@@ -430,7 +430,7 @@ sub GetReserveFee {
     my $data = $sth->fetchrow_hashref;
     $sth->finish();
     my $fee      = $data->{'reservefee'};
-    my $cntitems = @- > $bibitems;     # FIXME: @- is a regexp match var.  Unclear and probably INCORRECT usage here.
+    my $cntitems = @- > $bibitems;
 
     if ( $fee > 0 ) {
 
@@ -457,9 +457,15 @@ sub GetReserveFee {
                     }
                     $x++;
                 }
-                if ( $found == 0 or
-                    ($found == 1 and $const eq 'o')) {
-                                       push @biblioitems, $data1;
+                if ( $const eq 'o' ) {
+                    if ( $found == 1 ) {
+                        push @biblioitems, $data1;
+                    }
+                }
+                else {
+                    if ( $found == 0 ) {
+                        push @biblioitems, $data1;
+                    }
                 }
             }
         }
@@ -470,21 +476,32 @@ sub GetReserveFee {
         my $allissued     = 1;
         while ( $x < $cntitemsfound ) {
             my $bitdata = $biblioitems[$x];
-            my $sth2    = $dbh->prepare("SELECT * FROM items WHERE biblioitemnumber = ?");
+            my $sth2    = $dbh->prepare(
+                "SELECT * FROM items
+                     WHERE biblioitemnumber = ?"
+            );
             $sth2->execute( $bitdata->{'biblioitemnumber'} );
             while ( my $itdata = $sth2->fetchrow_hashref ) {
-                my $sth3 = $dbh->prepare("SELECT * FROM issues WHERE itemnumber = ?");
+                my $sth3 = $dbh->prepare(
+                    "SELECT * FROM issues
+                       WHERE itemnumber = ?"
+                );
                 $sth3->execute( $itdata->{'itemnumber'} );
-                unless ($sth3->rows()) {
+                if ( my $isdata = $sth3->fetchrow_hashref ) {
+                }
+                else {
                     $allissued = 0;
                 }
             }
             $x++;
         }
         if ( $allissued == 0 ) {
-            my $rsth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ?");
+            my $rsth =
+              $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ?");
             $rsth->execute($biblionumber);
-            unless ($rsth->rows()) {
+            if ( my $rdata = $rsth->fetchrow_hashref ) {
+            }
+            else {
                 $fee = 0;
             }
         }
@@ -760,7 +777,7 @@ sub CancelReserve {
         $sth->execute( $biblio, $borr );
 
         # now fix the priority on the others....
-        _FixPriority($biblio,$borr,$priority);
+        _FixPriority( $priority, $biblio );
     }
 }
 
@@ -881,7 +898,7 @@ sub ModReserveFill {
     # now fix the priority on the others (if the priority wasn't
     # already sorted!)....
     unless ( $priority == 0 ) {
-        _FixPriority($biblionumber, $borrowernumber, $priority);
+        _FixPriority( $priority, $biblionumber );
     }
 }
 
@@ -1193,7 +1210,12 @@ sub _Findgroupreserve {
     /;
     my $sth = $dbh->prepare($query);
     $sth->execute( $biblio, $bibitem );
-       return $sth->fetchall_arrayref({});
+    my @results;
+    while ( my $data = $sth->fetchrow_hashref ) {
+        push( @results, $data );
+    }
+    $sth->finish;
+    return @results;
 }
 
 =back