From 19c9f748a7ff549f0802808b6b914cc9433a8c09 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 14 May 2020 11:56:23 +0200 Subject: [PATCH] Bug 25503: Add option to export items bundle contents in checkouts table Test plan: 1. Enable system preference ExportCircHistory 2. Create an item bundle (see bug 28854 comment 458) 3. Check out the item bundle 4. In the checkouts table, check the box in column "Export", choose export format 'MARC with items', check "Export items bundle contents" and click on "Export" button The exported file should contain the biblio and item created at step 2, but also the biblio and items that are part of the bundle Signed-off-by: Marie-Luce Signed-off-by: Katrin Fischer Signed-off-by: Marie-Luce --- .../prog/en/includes/checkouts-table.inc | 1 + tools/export.pl | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index 93df6e4730..8e61310f29 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -78,6 +78,7 @@ [% END %] [% END %] + diff --git a/tools/export.pl b/tools/export.pl index 345158eedd..3fc79d7a5c 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -196,6 +196,22 @@ if ( $op eq "export" ) { @record_ids = grep $record_ids{$_}, @filter_record_ids; } + my $export_items_bundle_contents = $query->param('export_items_bundle_contents'); + if ($export_items_bundle_contents and $record_type eq 'bibs') { + my $schema = Koha::Database->new->schema; + my $items_bundle_rs = $schema->resultset('ItemBundle'); + foreach my $itemnumber (@itemnumbers) { + my @item_bundle_items = $items_bundle_rs->search({ host => $itemnumber }); + foreach my $item_bundle_item (@item_bundle_items) { + my $biblionumber = $item_bundle_item->item->get_column('biblionumber'); + my $itemnumber = $item_bundle_item->get_column('item'); + push @record_ids, $biblionumber; + push @itemnumbers, $itemnumber; + } + } + @record_ids = uniq @record_ids; + } + print CGI->new->header( -type => 'application/octet-stream', -charset => 'utf-8', -- 2.30.2