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 <marie-luce.laflamme@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Marie-Luce <marie-luce.laflamme@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

https://bugs.koha-community.org/show_bug.cgi?id=25508
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Julian Maurice 2020-05-14 11:56:23 +02:00 committed by Tomas Cohen Arazi
parent 1d553ca4da
commit d6d7d4b876
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 18 additions and 1 deletions

View File

@ -78,7 +78,8 @@
[% END %]
</select>
[% END %]
<label for="export_remove_fields">Don't export fields:</label> <input type="text" id="export_remove_fields" name="export_remove_fields" value="[% Koha.Preference('ExportRemoveFields') | html %]" title="Use for MARC exports" />
<label for="export_items_bundle_contents">Export items bundle contents</label> <input type="checkbox" name="export_items_bundle_contents" id="export_items_bundle_contents">
<label for="export_remove_fields">Don't export fields:</label> <input type="text" id="export_remove_fields" name="export_remove_fields" value="[% Koha.Preference('ExportRemoveFields') | html %]" title="Use for MARC exports" />
<input type="hidden" name="op" value="export" />
<input type="hidden" id="output_format" name="output_format" value="iso2709" />
<input type="hidden" id="dont_export_item" name="dont_export_item" value="0" />

View File

@ -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',