use MARC::File::XML;
use List::MoreUtils qw(uniq);
use C4::Auth;
-use C4::Koha; # GetItemTypes
use C4::Output;
use Koha::Authority::Types;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Exporter::Record;
+use Koha::ItemTypes;
use Koha::Libraries;
my $query = new CGI;
my $filename = $query->param('id_list_file');
if ( $filename ) {
my $mimetype = $query->uploadInfo($filename)->{'Content-Type'};
- my @valid_mimetypes = qw( application/octet-stream text/csv text/plain );
+ my @valid_mimetypes = qw( application/octet-stream text/csv text/plain application/vnd.ms-excel );
unless ( grep { /^$mimetype$/ } @valid_mimetypes ) {
push @messages, { type => 'alert', code => 'invalid_mimetype' };
$op = '';
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 ) {
);
my $csv_profile_id = $query->param('csv_profile_id');
- unless ( $csv_profile_id ) {
- # FIXME export_format.profile should be a unique key
- my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
- $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef;
- }
-
Koha::Exporter::Record::export(
{ record_type => $record_type,
record_ids => \@record_ids,
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,
}
);
}
else {
- my $itemtypes = GetItemTypes;
- my @itemtypesloop;
- foreach my $thisitemtype ( sort keys %$itemtypes ) {
- my %row = (
- value => $thisitemtype,
- description => $itemtypes->{$thisitemtype}->{translated_description},
- );
- push @itemtypesloop, \%row;
- }
+ my $itemtypes = Koha::ItemTypes->search_with_localization;
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
$template->param(
libraries => $libraries,
- itemtypeloop => \@itemtypesloop,
+ itemtypes => $itemtypes,
authority_types => $authority_types,
export_remove_fields => C4::Context->preference("ExportRemoveFields"),
- csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
+ csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
messages => \@messages,
);