Fix for bug 1456
authorChris Cormack <crc@liblime.com>
Tue, 23 Oct 2007 00:57:01 +0000 (19:57 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 23 Oct 2007 00:58:14 +0000 (19:58 -0500)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Reserves.pm
circ/waitingreserves.pl

index bc97074..0a65152 100644 (file)
@@ -555,15 +555,22 @@ sub GetReservesToBranch {
 sub GetReservesForBranch {
     my ($frombranch) = @_;
     my $dbh          = C4::Context->dbh;
-    my $sth          = $dbh->prepare( "
-        SELECT borrowernumber,reservedate,itemnumber,waitingdate
+       my $query        = "SELECT borrowernumber,reservedate,itemnumber,waitingdate
         FROM   reserves 
         WHERE   priority='0'
             AND cancellationdate IS NULL 
-            AND found='W' 
-            AND branchcode=?
-        ORDER BY waitingdate" );
-    $sth->execute($frombranch);
+            AND found='W' ";
+    if ($frombranch){
+        $query .= " AND branchcode=? ";
+       }
+    $query .= "ORDER BY waitingdate" ;
+    my $sth = $dbh->prepare($query);
+    if ($frombranch){
+               $sth->execute($frombranch);
+       }
+    else {
+               $sth->execute();
+       }
     my @transreserv;
     my $i = 0;
     while ( my $data = $sth->fetchrow_hashref ) {
index f6b101a..a802e95 100755 (executable)
@@ -110,11 +110,12 @@ my @reservloop;
 
 my @getreserves;
 if (C4::Context->preference('IndependantBranches')){
+       # get reserves for the branch we are logged into
        @getreserves = GetReservesForBranch($default);
 }
 else {
-       @getreserves = GetReservesForBranch($default);
-       # need to have a routine to get all waiting reserves
+       # get all reserves waiting
+       @getreserves = GetReservesForBranch();
 }      
        
 foreach my $num (@getreserves) {
@@ -124,7 +125,7 @@ foreach my $num (@getreserves) {
     my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
     $getreserv{'waitingdate'} = format_date( $num->{'waitingdate'} );
 
-    next unless $num->{'waitingdate'} ne '0000-00-00';
+    next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
     my ( $waiting_year, $waiting_month, $waiting_day ) = split /-/,
       $num->{'waitingdate'};
     ( $waiting_year, $waiting_month, $waiting_day ) =