From 5306178eae6b78d6be993ddaa58fb766bcb8201a Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Tue, 22 Jul 2014 12:48:38 +0300 Subject: [PATCH] Bug 12625 - (KD-153) Batch delete component parts when deleting the parent from detailed-view See Bug 11175 for explanation of component parts. This feature automatically deletes all linked component parts when the component parent is deleted using "catalogue/detail.pl -> Edit -> Delete record" Generalizing this to C4::Biblio::DelBiblio() is not a good idea because we don't wan't to delete all component parts when we are for example, merging records :) --- cataloguing/addbiblio.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 387522c..41827f8 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -966,6 +966,20 @@ elsif ( $op eq "delete" ) { exit; } + #Check if there are component part records to delete + my @removalErrors; + foreach my $componentPartBiblionumber ( @{C4::Biblio::getComponentBiblionumbers( $record )} ) { + my $error = &DelBiblio($componentPartBiblionumber); + my $html = "$componentPartBiblionumber"; + push(@removalErrors, $html.' : '.$error) if $error; + } + if (@removalErrors) { + warn "ERROR when DELETING COMPONENT PART BIBLIOS: \n" . join("\n",@removalErrors); + print "Content-Type: text/html\n\n

ERROR when DELETING COMPONENT PART BIBLIOS:

" . join("
",@removalErrors).""; + exit; + } + #I think we got them all! + print $input->redirect('/cgi-bin/koha/catalogue/search.pl'); exit; -- 1.8.1.2