my $sth=$dbh->prepare("select * from issues i where i.returndate is null and i.itemnumber=?");
$sth->execute($itemnumber);
my $onloan=$sth->fetchrow;
+ $sth->finish();
push @errors,"book_on_loan" if ($onloan); ##error book_on_loan added to template as well
if ($onloan){
- $nextop="additem";
+ $nextop="additem";
} else {
- &DelItem($dbh,$biblionumber,$itemnumber);
- print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
- #$nextop="additem";
+ # check it doesnt have a waiting reserve
+ $sth=$dbh->prepare("SELECT * FROM reserves WHERE found = 'w' AND cancellationdate IS NULL AND itemnumber = ?");
+ $sth->execute($itemnumber);
+ my $reserve=$sth->fetchrow;
+ if ($reserve){
+ push @errors,"book_reserved";
+ $nextop="additem";
+ }
+ else {
+ &DelItem($dbh,$biblionumber,$itemnumber);
+ print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
+ }
}
#-------------------------------------------------------------------------------
} elsif ($op eq "saveitem") {
<!-- TMPL_IF NAME="barcode_not_unique" --><div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="book_on_loan" --><div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div><!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="book_reserved" --><div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div><!-- /TMPL_IF -->
<div id="cataloguing_additem_itemlist">
<!-- TMPL_IF name="item_loop" -->