X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=tools%2Fexport.pl;h=588f1b9c9379a2ab4d1a52379111a55b9beceb0f;hb=5faddae26f7dd2c877161652f396414f56337421;hp=0165cf1ea4bd1b8d95a5b9674115c3740d548d08;hpb=8d5b4306e07a594cd102fcce85f912ab3a5661e9;p=srvgit diff --git a/tools/export.pl b/tools/export.pl index 0165cf1ea4..588f1b9c93 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -32,14 +32,19 @@ use Koha::Exporter::Record; use Koha::ItemTypes; use Koha::Libraries; -my $query = new CGI; +my $query = CGI->new; my $dont_export_items = $query->param("dont_export_item") || 0; my $record_type = $query->param("record_type"); my $op = $query->param("op") || ''; my $output_format = $query->param("format") || $query->param("output_format") || 'iso2709'; my $backupdir = C4::Context->config('backupdir'); -my $filename = $query->param("filename") || ( $output_format eq 'csv' ? 'koha.csv' : 'koha.mrc' ); +my $filename; +if ( $record_type eq 'auths' ) { + $filename = $query->param("filename_auth") || ( $output_format eq 'xml' ? 'koha.xml' : 'koha.mrc' ); +} else { + $filename = $query->param("filename") || ( $output_format eq 'csv' ? 'koha.csv' : 'koha.mrc' ); +} $filename =~ s/(\r|\n)//; my $dbh = C4::Context->dbh; @@ -61,9 +66,7 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( template_name => "tools/export.tt", query => $query, type => "intranet", - authnotrequired => 0, flagsrequired => { tools => 'export_catalog' }, - debug => 1, } ); @@ -74,8 +77,8 @@ if ( $op eq 'export' ) { 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 ); - unless ( grep { /^$mimetype$/ } @valid_mimetypes ) { + my @valid_mimetypes = qw( application/octet-stream text/csv text/plain application/vnd.ms-excel ); + unless ( grep { $_ eq $mimetype } @valid_mimetypes ) { push @messages, { type => 'alert', code => 'invalid_mimetype' }; $op = ''; } @@ -87,13 +90,10 @@ if ( $op eq "export" ) { 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 @sql_params; - my $sql_query; + my $strip_items_not_from_libraries = $query->param('strip_items_not_from_libraries'); - 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 ) { @@ -209,6 +209,7 @@ if ( $op eq "export" ) { 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, } ); } @@ -300,7 +301,7 @@ else { 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, );