From cbc652bb880ce6eb3ded7273d31e2b61a3278dd0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 14 Nov 2016 12:41:56 +0000 Subject: [PATCH] Bug 17622: Export biblios without items In some situations, we need to export bibliographic records without items. Test plan: Confirm that you get bibliographic records without items when you expect to get record without items. Basically it should happen when you do not specify filters on items --- misc/export_records.pl | 10 +++++++++- tools/export.pl | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/misc/export_records.pl b/misc/export_records.pl index 34b4da3..950db06 100755 --- a/misc/export_records.pl +++ b/misc/export_records.pl @@ -149,7 +149,15 @@ if ( $record_type eq 'bibs' ) { ), }; - my $biblioitems = Koha::Biblioitems->search( $conditions, { join => 'items' } ); + + my $join_on_items = + $starting_callnumber + || $ending_callnumber + || $start_accession + || $end_accession + || ( $itemtype && C4::Context->preference('item-level_itypes') ); + + my $biblioitems = Koha::Biblioitems->search( $conditions, { ( $join_on_items ? ( join => 'items' ) : () ), columns => 'biblionumber' } ); while ( my $biblioitem = $biblioitems->next ) { push @record_ids, $biblioitem->biblionumber; } diff --git a/tools/export.pl b/tools/export.pl index c585d90..9acbc65 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -144,7 +144,16 @@ if ( $op eq "export" ) { ), }; - my $biblioitems = Koha::Biblioitems->search( $conditions, { join => 'items', columns => 'biblionumber' } ); + + my $join_on_items = + @branchcodes + || $start_callnumber + || $end_callnumber + || $start_accession + || $end_accession + || ( $itemtype && C4::Context->preference('item-level_itypes') ); + + my $biblioitems = Koha::Biblioitems->search( $conditions, { ( $join_on_items ? ( join => 'items' ) : () ), columns => 'biblionumber' } ); while ( my $biblioitem = $biblioitems->next ) { push @record_ids, $biblioitem->biblionumber; } -- 2.1.4