From 7479f93b5ddced5113ad4c0a6975d9bbb76107a2 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 24 Aug 2009 23:47:16 +0200 Subject: [PATCH] Delete All items in one click Signed-off-by: Galen Charlton --- cataloguing/additem.pl | 35 +++++++++---------- .../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 e25bb44dcb..44ec8abf14 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 8adb30b576..bed545390f 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 = ; + 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&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=" }, { text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=&frameworkcode=&op=duplicate" }, { text: _("Delete Record"), onclick: {fn: confirm_deletion },id:'disabled' } + { text: _("Delete all Items"), onclick: {fn: confirm_items_deletion } } ]; var savemenu = [ -- 2.39.5