(MT #1365) Delete all items
authorChristophe Croullebois <christophe.croullebois@biblibre.com>
Wed, 22 Sep 2010 09:39:28 +0000 (11:39 +0200)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 3 Feb 2011 22:17:20 +0000 (11:17 +1300)
Now if IndependantBranches is on and a user try to delete all items, only the items of his branch will be deleted.
A message explain this fact.

C4/Items.pm
cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl

index 4ab385c..7b0f2a9 100644 (file)
@@ -2040,7 +2040,14 @@ sub DelItemCheck {
     my $sth=$dbh->prepare("select * from issues i where i.itemnumber=?");
     $sth->execute($itemnumber);
 
-    my $onloan=$sth->fetchrow;
+    my $item = GetItem($itemnumber);
+    my $onloan = $sth->fetchrow;
+    if ($onloan) {
+        $error = "book_on_loan";
+    }
+    elsif (C4::Context->preference("IndependantBranches") and (C4::Context->userenv->{branch} ne $item->{C4::Context->preference("HomeOrHoldingBranch")||'homebranch'})){
+        $error = "not_same_branch";
+    } else {
 
     if ($onloan){
         $error = "book_on_loan" 
index b79e7f5..07c4a05 100755 (executable)
@@ -435,14 +435,28 @@ if ($op eq "additem") {
 } elsif ($op eq "delallitems") {
 #-------------------------------------------------------------------------------
     my @biblioitems = &GetBiblioItemByBiblioNumber($biblionumber);
-    foreach my $biblioitem (@biblioitems){
-        my $items = &GetItemsByBiblioitemnumber($biblioitem->{biblioitemnumber});
-
-        foreach my $item (@$items){
-            # FIXME although it won't delete items that have loans
-            # or waiting holds on them, should explicitly tell operator
-            # about items that are not deleted
-            &DelItemCheck($dbh,$biblionumber,$item->{itemnumber});
+    my $errortest=0;
+    my $itemfail;
+    foreach my $biblioitem (@biblioitems) {
+        my $items = &GetItemsByBiblioitemnumber( $biblioitem->{biblioitemnumber} );
+
+        foreach my $item (@$items) {
+            $error =&DelItem( $dbh, $biblionumber, $item->{itemnumber} );
+            $itemfail =$item;
+        if($error == 1){
+            next
+            }
+        else {
+            push @errors,$error;
+            $errortest++
+            }
+        }
+        if($errortest > 0){
+            $nextop="additem";
+        } 
+        else {
+            print $input->redirect("/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=$biblionumber");
+            exit;
         }
        }
 #-------------------------------------------------------------------------------
index d0be875..6929787 100644 (file)
@@ -191,6 +191,7 @@ function set_to_today(id, force) {
 <!-- TMPL_IF NAME="no_next_barcode" --><div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</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 -->
+<!-- TMPL_IF Name="not_same_branch" --><div class="dialog alert"><strong>Cannot Delete</strong>: branch of item is not yours.</div><!-- /TMPL_IF -->
 
 <div id="cataloguing_additem_itemlist">
     <!-- TMPL_IF name="item_loop" -->