my $biblionumber = $params->{biblionumber};
my $itemnumbers = $params->{itemnumbers};
my $export_items = $params->{export_items} // 1;
- my $only_export_items_for_branch = $params->{only_export_items_for_branch};
+ my $only_export_items_for_branches = $params->{only_export_items_for_branches};
my $record = eval { C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); };
if ($export_items) {
C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, $itemnumbers );
- if ($only_export_items_for_branch) {
+ if ($only_export_items_for_branches && @$only_export_items_for_branches) {
+ my %export_items_for_branches = map { $_ => 1 } @$only_export_items_for_branches;
my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField( 'items.homebranch', '' ); # Should be GetFrameworkCode( $biblionumber )?
for my $itemfield ( $record->field($homebranchfield) ) {
my $homebranch = $itemfield->subfield($homebranchsubfield);
- if ( $only_export_items_for_branch ne $homebranch ) {
+ unless ( $export_items_for_branches{$homebranch} ) {
$record->delete_field($itemfield);
}
}
</li>
<li>
- <label>Library: </label>
+ <label>With items owned by the following libraries: </label>
[% INCLUDE 'branch-selector.inc' branches = libraries %]
</li>
</ol>
<input id="dont_export_item" type="checkbox" name="dont_export_item" />
</li>
<li>
- <label for="strip_nonlocal_items">Remove non-local items:</label>
- <input id="strip_nonlocal_items" type="checkbox" name="strip_nonlocal_items" />
+ <label for="strip_items_not_from_libraries">Remove items not owned by selected libraries:</label>
+ <input id="strip_items_not_from_libraries" type="checkbox" name="strip_items_not_from_libraries" />
</li>
<li>
<label for="export_remove_fields">Don't export fields:</label>
my $export_remove_fields = $query->param("export_remove_fields") || q||;
my @biblionumbers = $query->multi_param("biblionumbers");
my @itemnumbers = $query->multi_param("itemnumbers");
- my $strip_nonlocal_items = $query->param('strip_nonlocal_items');
+ my $strip_items_not_from_libraries = $query->param('strip_items_not_from_libraries');
my @sql_params;
my $sql_query;
- my $libraries = $strip_nonlocal_items
- ? [ Koha::Libraries->find(C4::Context->userenv->{branch})->unblessed ]
- : Koha::Libraries->search_filtered->unblessed;
+ my $libraries = Koha::Libraries->search_filtered->unblessed;
+ my $only_export_items_for_branches = $strip_items_not_from_libraries ? \@branch : undef;
my @branchcodes;
for my $branchcode ( @branch ) {
if ( grep { $_->{branchcode} eq $branchcode } @$libraries ) {
dont_export_fields => $export_remove_fields,
csv_profile_id => $csv_profile_id,
export_items => (not $dont_export_items),
+ only_export_items_for_branches => $only_export_items_for_branches,
}
);
}