From 53a2d72db7b3a155e9b45d6d792cdf14368b4f8b Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 8 Aug 2022 02:23:57 +0000 Subject: [PATCH] Bug 6936: Allow multiple itemtypes for bib record export This patch allows multiple item types to be chosen when exporting bib records from the Tools module. Test plan: 0. Apply patch and koha-plack --restart kohadev 1. Go to http://localhost:8081/cgi-bin/koha/tools/export.pl 2. Select "All" for "Item type" and note 435 bibs are exported 3. Select "Books" and note 360 bibs are exported 4. Select "Books" and "Visual Materials" and note 380 bibs are exported Signed-off-by: Owen Leonard --- .../intranet-tmpl/prog/en/modules/tools/export.tt | 2 +- tools/export.pl | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt index fe01cf2b1f..b55aa7ff30 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt @@ -88,7 +88,7 @@
  • - [% FOREACH itemtype IN itemtypes %] diff --git a/tools/export.pl b/tools/export.pl index b738afc60b..345158eedd 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -105,9 +105,12 @@ if ( $op eq "export" ) { # No need to retrieve the record_ids if we already get them unless ( @record_ids ) { if ( $record_type eq 'bibs' ) { + + my %it_map = map { $_->itemtype => 1 } Koha::ItemTypes->search->as_list; + my @itemtypes = map { $it_map{$_} ? $_ : () } $query->multi_param('itemtype'); #Validate inputs against map + my $starting_biblionumber = $query->param("StartingBiblionumber"); my $ending_biblionumber = $query->param("EndingBiblionumber"); - my $itemtype = $query->param("itemtype"); my $start_callnumber = $query->param("start_callnumber"); my $end_callnumber = $query->param("end_callnumber"); my $start_accession = @@ -148,11 +151,11 @@ if ( $op eq "export" ) { ) : (), ( @branchcodes ? ( 'items.homebranch' => { in => \@branchcodes } ) : () ), - ( $itemtype + ( @itemtypes ? C4::Context->preference('item-level_itypes') - ? ( 'items.itype' => $itemtype ) - : ( 'me.itemtype' => $itemtype ) + ? ( 'items.itype' => { in => \@itemtypes } ) + : ( 'me.itemtype' => { in => \@itemtypes } ) : () ), -- 2.20.1