Fix for bug 1319, can no longer delete an item with a waiting reserve on it
authorChris Cormack <crc@liblime.com>
Sun, 30 Dec 2007 22:42:40 +0000 (16:42 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Sun, 30 Dec 2007 22:59:05 +0000 (16:59 -0600)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl

index a82b621..88b9f49 100755 (executable)
@@ -135,13 +135,23 @@ if ($op eq "additem") {
     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") {
index 786429c..c436308 100644 (file)
@@ -159,6 +159,7 @@ function CreateKey(){
 
 <!-- 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" -->