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
This commit is contained in:
tipaul 2004-12-15 10:47:09 +00:00
parent 9cd423cbb4
commit 52a123a1a4
4 changed files with 59 additions and 43 deletions

View file

@ -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.

View file

@ -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;
# 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);
# 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);
}
}

View file

@ -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;

View file

@ -197,6 +197,12 @@
<!-- /TMPL_IF -->
<!-- TMPL_UNLESS name="IMPOSSIBLE" -->
<form method="post">
<!-- TMPL_IF NAME="RESERVED" -->
<p><input type="checkbox" checked name="cancelreserve" value="1">Cancel Reserve</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="RESERVE_WAITING" -->
<p><input type="checkbox" checked name="cancelreserve" value="1">Cancel Reserve</p>
<!-- /TMPL_IF -->
<input type="hidden" name="barcode" value="<!-- TMPL_VAR NAME="barcode" -->">
<input type="hidden" name="borrnumber" value="<!-- TMPL_VAR NAME="borrowernumber">">
<input type="hidden" name="issueconfirmed" value="1">
@ -204,6 +210,7 @@
<input type="hidden" name="month" value="<!-- TMPL_VAR name="month" -->">
<input type="hidden" name="year" value="<!-- TMPL_VAR name="year" -->">
<input type="submit" value="Confirm issue" class="button circulation">
<a href="circulation.pl?borrnumber=<!-- TMPL_VAR NAME="borrowernumber" -->" class="button circulation">Don't issue</a>
</form>
<!-- /TMPL_UNLESS -->
<!-- /TMPL_IF -->