[Koha-patches] [PATCH] [ReplacePrevious] (bug #2914) delete only items from the user homebranch

Nahuel ANGELINETTI nahuel.angelinetti at biblibre.com
Mon Apr 27 15:30:26 CEST 2009


This patch is a fix for the previous one.
This one, alert the user will delete only "all" items from his branch, and not from others.
So if the holdingbranch equal the user branch, and the item is not issued, the item will be deleted.
---
 catalogue/detail.pl                                |    5 +++++
 cataloguing/additem.pl                             |    5 ++++-
 .../intranet-tmpl/prog/en/includes/cat-toolbar.inc |    5 +++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/catalogue/detail.pl b/catalogue/detail.pl
index d21b8a7..b143e61 100755
--- a/catalogue/detail.pl
+++ b/catalogue/detail.pl
@@ -97,6 +97,7 @@ if ( defined $dat->{'itemtype'} ) {
     $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} );
 }
 $dat->{'count'} = scalar @items;
+$dat->{'homecount'} = 0;
 my $shelflocations = GetKohaAuthorisedValues('items.location', $fw);
 my $collections    = GetKohaAuthorisedValues('items.ccode'   , $fw);
 my (@itemloop, %itemfields);
@@ -108,6 +109,10 @@ foreach my $item (@items) {
     # can place holds defaults to yes
     $norequests = 0 unless ( ( $item->{'notforloan'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) );
 
+    if($item->{holdingbranch} eq C4::Context->userenv->{branch}){
+        $dat->{'homecount'}++;
+    }
+
     # format some item fields for display
     if ( defined $item->{'publictype'} ) {
         $item->{ $item->{'publictype'} } = 1;
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index ee551c9..b8d5b3b 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -149,7 +149,10 @@ if ($op eq "additem") {
         my $items = &GetItemsByBiblioitemnumber($biblioitem->{biblioitemnumber});
 
         foreach my $item (@$items){
-            &DelItem($dbh,$biblionumber,$item->{itemnumber});
+            my $issue = C4::Circulation::GetItemIssue($item->{itemnumber});
+            if(($item->{holdingbranch} eq C4::Context->userenv->{branch}) and not $issue->{borrowernumber}){
+                &DelItem($dbh,$biblionumber,$item->{itemnumber});
+            }
         }
     }
     print $input->redirect("/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=$biblionumber");
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
index 3449e94..acda0c3 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
@@ -28,9 +28,10 @@ function confirm_deletion() {
 }
 
 function confirm_items_deletion() {
-        var count = <!-- TMPL_VAR NAME="count" -->;
+        var count = <!-- TMPL_VAR NAME="homecount" -->;
         if(count > 0)
-            if(confirm(_('Are you sure you want to delete the ' + count + ' attached items? '))){
+            if(confirm(_("Are you sure you want to delete all (" + count + " item(s)) the items attached to your branch?\n" + 
+    					"This will delete only items attached to your branch which are not issued."))){
                 window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
             }else{
                 return false;
-- 
1.6.0.4




More information about the Koha-patches mailing list