[Koha-patches] [PATCH] Delete All items in one click

Henri-Damien LAURENT henridamien.laurent at biblibre.com
Mon Aug 24 23:47:16 CEST 2009


---
 cataloguing/additem.pl                             |   35 +++++++++----------
 .../intranet-tmpl/prog/en/includes/cat-toolbar.inc |   12 ++++++-
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index e25bb44..44ec8ab 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -239,26 +239,25 @@ if ($op eq "additem") {
 } elsif ($op eq "delitem") {
 #-------------------------------------------------------------------------------
     # check that there is no issue on this item before deletion.
-    my $sth=$dbh->prepare("select * from issues i where i.itemnumber=?");
-    $sth->execute($itemnumber);
-    my $onloan=$sth->fetchrow;
-	$sth->finish();
-    $nextop="additem";
-    if ($onloan){
-        push @errors,"book_on_loan";
-    } else {
-		# check it doesnt have a waiting reserve
-		$sth=$dbh->prepare("SELECT * FROM reserves WHERE found = 'W' AND itemnumber = ?");
-		$sth->execute($itemnumber);
-		my $reserve=$sth->fetchrow;
-		unless ($reserve){
-			&DelItem($dbh,$biblionumber,$itemnumber);
-			print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
-            exit;
-		}
-        push @errors,"book_reserved";
+    $error = &DelItemCheck($dbh,$biblionumber,$itemnumber);
+    if($error == 1){
+        print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
+    }else{
+        push @errors,$error;
+        $nextop="additem";
     }
 #-------------------------------------------------------------------------------
+} elsif ($op eq "delallitems") {
+#-------------------------------------------------------------------------------
+    my @biblioitems = &GetBiblioItemByBiblioNumber($biblionumber);
+    foreach my $biblioitem (@biblioitems){
+        my $items = &GetItemsByBiblioitemnumber($biblioitem->{biblioitemnumber});
+
+        foreach my $item (@$items){
+            &DelItem($dbh,$biblionumber,$item->{itemnumber});
+        }
+	}
+#-------------------------------------------------------------------------------
 } elsif ($op eq "saveitem") {
 #-------------------------------------------------------------------------------
     # rebuild
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 8adb30b..bed5453 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
@@ -43,7 +43,16 @@ function confirm_deletion() {
 		return false;
 	}
 }
-
+function confirm_items_deletion() {
+        var count = <!-- TMPL_VAR NAME="count" -->;
+        if(count > 0){
+            if(confirm(_('Are you sure you want to delete the ' + count + ' attached items? '))){
+                window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->";
+            }else{
+                return false;
+            }
+		}
+}
 	// prepare DOM for YUI Toolbar
 
 	 $(document).ready(function() {
@@ -76,6 +85,7 @@ function confirm_deletion() {
 	        { text: _("Edit Items"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
 	        { text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=duplicate" },
 			{ text: _("Delete Record"), onclick: {fn: confirm_deletion }<!-- TMPL_IF NAME="count" -->,id:'disabled'<!-- /TMPL_IF --> }
+            { text: _("Delete all Items"), onclick: {fn: confirm_items_deletion } }
 	    ];
 		
 		var savemenu = [
-- 
1.6.0.4




More information about the Koha-patches mailing list