From 53be8065d1c2d83bba56234026c00c77f5856e1f Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 22 Oct 2007 19:57:01 -0500 Subject: [PATCH] Fix for bug 1456 Signed-off-by: Joshua Ferraro --- C4/Reserves.pm | 19 +++++++++++++------ circ/waitingreserves.pl | 7 ++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index bc9707433b..0a65152294 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -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 ) { diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index f6b101a3bb..a802e957f7 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -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 ) = -- 2.39.5