Bugzilla – Attachment 3064 Details for
Bug 5691
If someone deletes all items, with independent branches on, it deletes all
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Patch
0001-Bug-5691-Delete-all-items-respects-independentbranch.patch (text/plain), 5.81 KB, created by
Chris Cormack
on 2011-02-04 00:01:40 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-02-04 00:01:40 UTC
Size:
5.81 KB
patch
obsolete
>From 97238df74d5bf3e71f31f83b66d4c3b4efda32bf Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Fri, 4 Feb 2011 12:57:19 +1300 >Subject: [PATCH] Bug 5691 - Delete all items respects independentbranches system preferences > >Squashed commit of the following: > >commit 66cdb8804136803a3f626d183c8f192f61f3c7b1 >Author: Chris Cormack <chrisc@catalyst.net.nz> >Date: Fri Feb 4 12:55:10 2011 +1300 > > Bug 5691: Updating copyright statement > >commit 79ef6c269afc9c644c51709a7657542a0fc6d7d6 >Author: Chris Cormack <chrisc@catalyst.net.nz> >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 <henridamien.laurent@biblibre.com> >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 <christophe.croullebois@biblibre.com> >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. >--- > 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 4ab385c..ecc52c2 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. > # >@@ -2040,21 +2041,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 b79e7f5..7317698 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 d0be875..6929787 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) { > <!-- 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" --> >-- >1.7.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5691
: 3064