Delete All items in one click

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Henri-Damien LAURENT 2009-08-24 23:47:16 +02:00
parent bd5bcfd151
commit 7479f93b5d
2 changed files with 28 additions and 19 deletions

View file

@ -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

View file

@ -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 = [