From a4cc394508182f292b4767504dfbac882744c3df Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Thu, 3 Feb 2011 19:45:57 -0500 Subject: [PATCH] Bug 5691 - Delete all items respects independentbranches system preferences Squashed commit of the following: commit 66cdb8804136803a3f626d183c8f192f61f3c7b1 Author: Chris Cormack Date: Fri Feb 4 12:55:10 2011 +1300 Bug 5691: Updating copyright statement commit 79ef6c269afc9c644c51709a7657542a0fc6d7d6 Author: Chris Cormack Date: Fri Feb 4 12:52:13 2011 +1300 Bug 5691 - Fixing a syntax error and tidying up some formatting commit a66485dba113c05ed51a3b4ff19f788e335aa1f6 Author: Henri-Damien LAURENT Date: Tue Oct 5 17:23:55 2010 +0200 (MT #1365) Delete all items Using DelItemCheck in cataloguing/additem.pl when deleting all items commit fe845fd48ab22ff82ad6d8971c468c327b49f3c4 Author: Christophe Croullebois Date: Wed Sep 22 11:39:28 2010 +0200 (MT #1365) Delete all items 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. Signed-off-by: Chris Nighswonger Followup: (MT #1365) Fixing up the English idiom Signed-off-by: Chris Cormack --- C4/Items.pm | 41 ++++++++++++------- cataloguing/additem.pl | 30 ++++++++++---- .../prog/en/modules/cataloguing/additem.tmpl | 1 + 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index c0d8701020..0ea8b8668c 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1,6 +1,7 @@ package C4::Items; # Copyright 2007 LibLime, Inc. +# Parts Copyright Biblibre 2010 # # This file is part of Koha. # @@ -2043,21 +2044,31 @@ sub DelItemCheck { my $sth=$dbh->prepare("select * from issues i where i.itemnumber=?"); $sth->execute($itemnumber); - my $onloan=$sth->fetchrow; - - if ($onloan){ - $error = "book_on_loan" - }else{ - # check it doesnt have a waiting reserve - $sth=$dbh->prepare("SELECT * FROM reserves WHERE (found = 'W' or found = 'T') AND itemnumber = ?"); - $sth->execute($itemnumber); - my $reserve=$sth->fetchrow; - if ($reserve){ - $error = "book_reserved"; - }else{ - DelItem($dbh, $biblionumber, $itemnumber); - return 1; - } + 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" + } + else { + # check it doesnt have a waiting reserve + $sth=$dbh->prepare("SELECT * FROM reserves WHERE (found = 'W' or found = 'T') AND itemnumber = ?"); + $sth->execute($itemnumber); + my $reserve=$sth->fetchrow; + if ($reserve) { + $error = "book_reserved"; + } + else { + DelItem($dbh, $biblionumber, $itemnumber); + return 1; + } + } } return $error; } diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index b79e7f5af0..73176982bd 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -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 =&DelItemCheck( $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; } } #------------------------------------------------------------------------------- diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl index d0be87580c..6a32740c17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl @@ -191,6 +191,7 @@ function set_to_today(id, force) {
Error saving items: Unable to automatically determine values for barcodes. No item has been inserted.
Cannot Delete: item is checked out.
Cannot Delete: item has a waiting hold.
+
Cannot Delete: The items do not belong to your branch.
-- 2.39.5