From 52a123a1a4e38165b05ebe1b2b38b1a33a45b7da Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 15 Dec 2004 10:47:09 +0000 Subject: [PATCH] fix for : http://bugs.koha.org/cgi-bin/bugzilla/show_bug.cgi?id=858 * added a button to cancel issue * adding checkbox to cancel reserve on the book (checked by default) * the cancelation reserve is done on reserves done for a given item or for any item Nelsonville, pls test & confirm it's OK --- C4/Circulation/Circ2.pm | 21 +++++- C4/Reserves2.pm | 73 +++++++++---------- circ/circulation.pl | 3 +- .../default/en/circ/circulation.tmpl | 7 ++ 4 files changed, 60 insertions(+), 44 deletions(-) diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index 3b17539d83..56c5faf249 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -800,7 +800,7 @@ C<$date> contains the max date of return. calculated if empty. # issuing book. We already have checked it can be issued, so, just issue it ! # sub issuebook { - my ($env,$borrower,$barcode,$date) = @_; + my ($env,$borrower,$barcode,$date,$cancelreserve) = @_; my $dbh = C4::Context->dbh; # my ($borrower, $flags) = &getpatroninformation($env, $borrowernumber, 0); my $iteminformation = getiteminformation($env, 0, $barcode); @@ -833,7 +833,9 @@ sub issuebook { if ($resbor eq $borrower->{'borrowernumber'}) { # The item is on reserve to the current patron FillReserve($res); + warn "FillReserve"; } elsif ($restype eq "Waiting") { + warn "Waiting"; # The item is on reserve and waiting, but has been # reserved by some other patron. my ($resborrower, $flags)=getpatroninformation($env, $resbor,0); @@ -841,12 +843,25 @@ sub issuebook { my $branchname = $branches->{$res->{'branchcode'}}->{'branchname'}; CancelReserve(0, $res->{'itemnumber'}, $res->{'borrowernumber'}); } elsif ($restype eq "Reserved") { + warn "Reserved"; # The item is on reserve for someone else. my ($resborrower, $flags)=getpatroninformation($env, $resbor,0); my $branches = getbranches(); my $branchname = $branches->{$res->{'branchcode'}}->{'branchname'}; - my $tobrcd = ReserveWaiting($res->{'itemnumber'}, $res->{'borrowernumber'}); - transferbook($tobrcd,$barcode, 1); + if ($cancelreserve) { + # cancel reserves on this item + CancelReserve(0, $res->{'itemnumber'}, $res->{'borrowernumber'}); + # also cancel reserve on biblio related to this item + my $st_Fbiblio = $dbh->prepare("select biblionumber from items where itemnumber=?"); + $st_Fbiblio->execute($res->{'itemnumber'}); + my $biblionumber = $st_Fbiblio->fetchrow; + CancelReserve($biblionumber,0,$res->{'borrowernumber'}); + warn "CancelReserve $res->{'itemnumber'}, $res->{'borrowernumber'}"; + } else { + my $tobrcd = ReserveWaiting($res->{'itemnumber'}, $res->{'borrowernumber'}); + transferbook($tobrcd,$barcode, 1); + warn "transferbook"; + } } } # Record in the database the fact that the book was issued. diff --git a/C4/Reserves2.pm b/C4/Reserves2.pm index 75b39d4f60..ed8889c189 100755 --- a/C4/Reserves2.pm +++ b/C4/Reserves2.pm @@ -291,48 +291,41 @@ sub CancelReserve { my $dbh = C4::Context->dbh; #warn "In CancelReserve"; if (($item and $borr) and (not $biblio)) { - # removing a waiting reserve record.... - # update the database... - my $sth = $dbh->prepare("update reserves set cancellationdate = now(), - found = Null, - priority = 0 - where itemnumber = ? - and borrowernumber = ?"); - $sth->execute($item,$borr); - $sth->finish; + # removing a waiting reserve record.... + # update the database... + my $sth = $dbh->prepare("update reserves set cancellationdate = now(), + found = Null, + priority = 0 + where itemnumber = ? + and borrowernumber = ?"); + $sth->execute($item,$borr); + $sth->finish; } if (($biblio and $borr) and (not $item)) { - - # removing a reserve record.... - - # get the prioritiy on this record.... - my $priority; - { - my $sth=$dbh->prepare("SELECT priority FROM reserves - WHERE biblionumber = ? - AND borrowernumber = ? - AND cancellationdate is NULL - AND (found <> 'F' or found is NULL)"); - $sth->execute($biblio,$borr); - ($priority) = $sth->fetchrow_array; - $sth->finish; - } - - # update the database, removing the record... - { - my $sth = $dbh->prepare("update reserves set cancellationdate = now(), - found = Null, - priority = 0 - where biblionumber = ? - and borrowernumber = ? - and cancellationdate is NULL - and (found <> 'F' or found is NULL)"); - $sth->execute($biblio,$borr); - $sth->finish; - } - - # now fix the priority on the others.... - fixpriority($priority, $biblio); + # removing a reserve record.... + # get the prioritiy on this record.... + my $priority; + my $sth=$dbh->prepare("SELECT priority FROM reserves + WHERE biblionumber = ? + AND borrowernumber = ? + AND cancellationdate is NULL + AND (found <> 'F' or found is NULL)"); + $sth->execute($biblio,$borr); + ($priority) = $sth->fetchrow_array; + $sth->finish; + + # update the database, removing the record... + my $sth = $dbh->prepare("update reserves set cancellationdate = now(), + found = Null, + priority = 0 + where biblionumber = ? + and borrowernumber = ? + and cancellationdate is NULL + and (found <> 'F' or found is NULL)"); + $sth->execute($biblio,$borr); + $sth->finish; + # now fix the priority on the others.... + fixpriority($priority, $biblio); } } diff --git a/circ/circulation.pl b/circ/circulation.pl index ac32ccddc5..85267be287 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -65,6 +65,7 @@ my $month=$query->param('month'); my $day=$query->param('day'); my $stickyduedate=$query->param('stickyduedate'); my $issueconfirmed = $query->param('issueconfirmed'); +my $cancelreserve = $query->param('cancelreserve'); #set up cookie..... @@ -138,7 +139,7 @@ if ($barcode) { $barcode = cuecatbarcodedecode($barcode); my ($datedue, $invalidduedate) = fixdate($year, $month, $day); if ($issueconfirmed) { - issuebook(\%env, $borrower, $barcode, $datedue); + issuebook(\%env, $borrower, $barcode, $datedue,$cancelreserve); } else { my ($error, $question) = canbookbeissued(\%env, $borrower, $barcode, $year, $month, $day); my $noerror=1; diff --git a/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl index 65ce942a6a..ec53f8de66 100644 --- a/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl @@ -197,6 +197,12 @@
+ +

Cancel Reserve

+ + +

Cancel Reserve

+ "> "> @@ -204,6 +210,7 @@ "> "> + " class="button circulation">Don't issue
-- 2.39.5