(bug #2914) delete all items of a notice
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Wed, 14 Jan 2009 15:07:34 +0000 (16:07 +0100)
committerHenri-Damien LAURENT <henridamien@koha-fr.org>
Tue, 27 Jan 2009 11:19:47 +0000 (12:19 +0100)
This patch allow the librarian to delete all items attached to a notice in one click.

Signed-off-by: Henri-Damien LAURENT <henridamien@koha-fr.org>
cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc

index 9592bc7..376687c 100755 (executable)
@@ -157,6 +157,18 @@ 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){
+            &DelItem($dbh,$biblionumber,$item->{itemnumber});
+        }
+    }
+    print $input->redirect("/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=$biblionumber");
+#-------------------------------------------------------------------------------
 } elsif ($op eq "saveitem") {
 #-------------------------------------------------------------------------------
     # rebuild
index dbc2fc6..0b3fcbb 100644 (file)
@@ -27,6 +27,15 @@ function confirm_deletion() {
        }
 }
 
+function confirm_items_deletion() {
+        var count = <!-- TMPL_VAR NAME="count" -->;
+        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() {
@@ -55,7 +64,8 @@ function confirm_deletion() {
                { text: _("Edit Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=" },
                { 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 Record"), onclick: {fn: confirm_deletion }<!-- TMPL_IF NAME="count" -->,id:'disabled'<!-- /TMPL_IF --> },
+            { text: _("Delete all Items"), onclick: {fn: confirm_items_deletion } }
            ];
                
                var savemenu = [