@@ -, +, @@
delete
---
Koha/BackgroundJob/BatchDeleteBiblio.pm | 8 ++++++++
.../prog/en/modules/tools/batch_delete_records.tt | 6 ++++++
tools/batch_delete_records.pl | 15 ++++++++++++---
3 files changed, 26 insertions(+), 3 deletions(-)
--- a/Koha/BackgroundJob/BatchDeleteBiblio.pm
+++ a/Koha/BackgroundJob/BatchDeleteBiblio.pm
@@ -7,6 +7,7 @@ use C4::Biblio;
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
use Koha::SearchEngine;
use Koha::SearchEngine::Indexer;
+use Koha::Acquisition::Orders;
use base 'Koha::BackgroundJob';
@@ -123,6 +124,13 @@ sub process {
}
}
+ # Cancel acq order lines
+ my @result = Koha::Acquisition::Orders->search( { biblionumber => $biblionumber } )->cancel;
+ my $warns = @{ $result[1] };
+ if ( $result[0] && $warns ) { # warnings about order lines not removed
+ warn sprintf( "%d order lines were deleted, but %d lines gave a warning\n", $result[0], $warns );
+ }
+
# Finally, delete the biblio
my $error = eval {
C4::Biblio::DelBiblio( $biblionumber, { skip_record_index => 1, skip_holds_queue => 1 } );
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt
@@ -88,6 +88,10 @@
+ -
+
+
+
@@ -257,8 +261,10 @@
$("input[type='radio']").click(function() {
if ($(this).attr('id') == 'authority_type') {
$("a[href='#shelves_tab_panel']").parent().hide();
+ $("li.skip_open_orders").hide();
} else if ($(this).attr('id') == 'biblio_type') {
$("a[href='#shelves_tab_panel']").parent().show();
+ $("li.skip_open_orders").show();
}
});
--- a/tools/batch_delete_records.pl
+++ a/tools/batch_delete_records.pl
@@ -29,6 +29,7 @@ use C4::Output qw( output_html_with_http_headers );
use C4::Auth qw( get_template_and_user );
use C4::Biblio;
use C4::AuthoritiesMarc;
+use Koha::Acquisition::Orders;
use Koha::Virtualshelves;
use Koha::Authorities;
@@ -37,9 +38,10 @@ use Koha::Items;
use Koha::BackgroundJob::BatchDeleteBiblio;
use Koha::BackgroundJob::BatchDeleteAuthority;
-my $input = CGI->new;
-my $op = $input->param('op') // q|form|;
-my $recordtype = $input->param('recordtype') // 'biblio';
+my $input = CGI->new;
+my $op = $input->param('op') // q|form|;
+my $recordtype = $input->param('recordtype') // 'biblio';
+my $skip_open_orders = $input->param('skip_open_orders') // 0;
my ($template, $loggedinuser, $cookie) = get_template_and_user({
template_name => 'tools/batch_delete_records.tt',
@@ -106,6 +108,13 @@ if ( $op eq 'form' ) {
$biblio->{holds_count} = $biblio_object->holds->count;
$biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id );
$biblio->{subscriptions_count} = $biblio_object->subscriptions->count;
+
+ # Respect skip_open_orders
+ next
+ if $skip_open_orders
+ && Koha::Acquisition::Orders->search(
+ { biblionumber => $record_id, orderstatus => [ 'new', 'ordered', 'partial' ] } )->count;
+
push @records, $biblio;
} else {
# Retrieve authority information
--