View | Details | Raw Unified | Return to bug 20447
Collapse All | Expand All

(-)a/C4/Holdings.pm (+47 lines)
Lines 379-384 sub GetXmlHolding { Link Here
379
    return $marcxml;
379
    return $marcxml;
380
}
380
}
381
381
382
=head2 GetMarcHoldingsByBiblionumber
383
384
  my $records = GetMarcHoldingsByBiblionumber(biblionumber);
385
386
Returns MARC::Record array representing holding records
387
388
=over 4
389
390
=item C<$biblionumber>
391
392
biblionumber
393
394
=back
395
396
=cut
397
398
sub GetMarcHoldingsByBiblionumber {
399
    my $biblionumber = shift;
400
401
    my $marcflavour = C4::Context->preference('marcflavour');
402
    my $sth = C4::Context->dbh->prepare(
403
        q|
404
        SELECT metadata
405
        FROM holdings_metadata
406
        WHERE holding_id IN (SELECT holding_id FROM holdings WHERE biblionumber=?)
407
            AND format='marcxml'
408
            AND marcflavour=?
409
        |
410
    );
411
412
    $sth->execute( $biblionumber, $marcflavour );
413
414
    my @records;
415
    while (my ($marcxml) = $sth->fetchrow()) {
416
        $marcxml = StripNonXmlChars( $marcxml );
417
        my $record = eval {
418
            MARC::Record::new_from_xml( $marcxml, "utf8", $marcflavour );
419
        };
420
        if ($@) {
421
            warn " problem with holding for biblio $biblionumber : $@ \n$marcxml";
422
        }
423
        push @records, $record if $record;
424
    }
425
    $sth->finish();
426
    return \@records;
427
}
428
382
=head2 GetHoldingFrameworkCode
429
=head2 GetHoldingFrameworkCode
383
430
384
  $frameworkcode = GetFrameworkCode( $holding_id )
431
  $frameworkcode = GetFrameworkCode( $holding_id )
(-)a/Koha/Exporter/Record.pm (-16 / +62 lines)
Lines 82-108 sub _get_record_for_export { Link Here
82
        }
82
        }
83
    }
83
    }
84
84
85
    if ($dont_export_fields) {
85
    _strip_unwanted_fields($record, $dont_export_fields) if $dont_export_fields;
86
        for my $f ( split / /, $dont_export_fields ) {
86
    C4::Biblio::RemoveAllNsb($record) if $clean;
87
            if ( $f =~ m/^(\d{3})(.)?$/ ) {
87
    return $record;
88
                my ( $field, $subfield ) = ( $1, $2 );
88
}
89
89
90
                # skip if this record doesn't have this field
90
sub _strip_unwanted_fields {
91
                if ( defined $record->field($field) ) {
91
    my ($record, $dont_export_fields) = @_;
92
                    if ( defined $subfield ) {
92
93
                        my @tags = $record->field($field);
93
    for my $f ( split / /, $dont_export_fields ) {
94
                        foreach my $t (@tags) {
94
        if ( $f =~ m/^(\d{3})(.)?$/ ) {
95
                            $t->delete_subfields($subfield);
95
            my ( $field, $subfield ) = ( $1, $2 );
96
                        }
96
97
                    } else {
97
            # skip if this record doesn't have this field
98
                        $record->delete_fields( $record->field($field) );
98
            if ( defined $record->field($field) ) {
99
                if ( defined $subfield ) {
100
                    my @tags = $record->field($field);
101
                    foreach my $t (@tags) {
102
                        $t->delete_subfields($subfield);
99
                    }
103
                    }
104
                } else {
105
                    $record->delete_fields( $record->field($field) );
100
                }
106
                }
101
            }
107
            }
102
        }
108
        }
103
    }
109
    }
104
    C4::Biblio::RemoveAllNsb($record) if $clean;
105
    return $record;
106
}
110
}
107
111
108
sub _get_authority_for_export {
112
sub _get_authority_for_export {
Lines 144-149 sub _get_biblio_for_export { Link Here
144
    return $record;
148
    return $record;
145
}
149
}
146
150
151
sub _get_holdings_for_export {
152
    my ($params)           = @_;
153
    my $dont_export_fields = $params->{dont_export_fields};
154
    my $clean              = $params->{clean};
155
    my $biblionumber       = $params->{biblionumber};
156
157
    my $records = C4::Holdings::GetMarcHoldingsByBiblionumber($biblionumber);
158
    foreach my $record (@$records) {
159
        _strip_unwanted_fields($record, $dont_export_fields) if $dont_export_fields;
160
        C4::Biblio::RemoveAllNsb($record) if $clean;
161
        C4::Biblio::UpsertMarcControlField($record, '004', $biblionumber);
162
        my $leader = $record->leader();
163
        if ($leader !~ /^.{6}[uvxy]/) {
164
            $leader =~ s/^(.{6})./$1u/;
165
            $record->leader($leader);
166
        }
167
    }
168
    return $records;
169
}
170
147
sub export {
171
sub export {
148
    my ($params) = @_;
172
    my ($params) = @_;
149
173
Lines 155-160 sub export { Link Here
155
    my $dont_export_fields = $params->{dont_export_fields};
179
    my $dont_export_fields = $params->{dont_export_fields};
156
    my $csv_profile_id     = $params->{csv_profile_id};
180
    my $csv_profile_id     = $params->{csv_profile_id};
157
    my $output_filepath    = $params->{output_filepath};
181
    my $output_filepath    = $params->{output_filepath};
182
    my $export_holdings    = $params->{export_holdings} // 0;
158
183
159
    if( !$record_type ) {
184
    if( !$record_type ) {
160
        Koha::Logger->get->warn( "No record_type given." );
185
        Koha::Logger->get->warn( "No record_type given." );
Lines 184-189 sub export { Link Here
184
                next;
209
                next;
185
            }
210
            }
186
            print $record->as_usmarc();
211
            print $record->as_usmarc();
212
            if ($export_holdings && $record_type eq 'bibs') {
213
                my $holdings = _get_holdings_for_export( { %$params, biblionumber => $record_id } );
214
                foreach my $holding (@$holdings) {
215
                    my $errorcount_on_decode = eval { scalar( MARC::File::USMARC->decode( $holding->as_usmarc )->warnings() ) };
216
                    if ( $errorcount_on_decode or $@ ) {
217
                        my $msg = "Holdings record for biblio $record_id could not be exported. " .
218
                            ( $@ // '' );
219
                        chomp $msg;
220
                        Koha::Logger->get->info( $msg );
221
                        next;
222
                    }
223
                    print $holding->as_usmarc();
224
                }
225
            }
187
        }
226
        }
188
    } elsif ( $format eq 'xml' ) {
227
    } elsif ( $format eq 'xml' ) {
189
        my $marcflavour = C4::Context->preference("marcflavour");
228
        my $marcflavour = C4::Context->preference("marcflavour");
Lines 196-201 sub export { Link Here
196
            next unless $record;
235
            next unless $record;
197
            print MARC::File::XML::record($record);
236
            print MARC::File::XML::record($record);
198
            print "\n";
237
            print "\n";
238
            if ($export_holdings && $record_type eq 'bibs') {
239
                my $holdings = _get_holdings_for_export( { %$params, biblionumber => $record_id } );
240
                foreach my $holding (@$holdings) {
241
                    print MARC::File::XML::record($holding);
242
                    print "\n";
243
                }
244
            }
199
        }
245
        }
200
        print MARC::File::XML::footer();
246
        print MARC::File::XML::footer();
201
        print "\n";
247
        print "\n";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt (-1 / +8 lines)
Lines 117-123 Link Here
117
    </fieldset>
117
    </fieldset>
118
    <fieldset class="rows">
118
    <fieldset class="rows">
119
    <legend> Options</legend>
119
    <legend> Options</legend>
120
<ol>        <li>
120
<ol>
121
        [% IF ( show_summary_holdings ) %]
122
        <li>
123
        <label for="export_holdings">Export holdings records (MARC 21 biblios only):</label>
124
        <input id="export_holdings" type="checkbox" name="export_holdings" />
125
        </li>
126
        [% END %]
127
        <li>
121
        <label for="dont_export_item">Don't export items:</label>
128
        <label for="dont_export_item">Don't export items:</label>
122
        <input id="dont_export_item" type="checkbox" name="dont_export_item" />
129
        <input id="dont_export_item" type="checkbox" name="dont_export_item" />
123
        </li>
130
        </li>
(-)a/misc/export_records.pl (-1 / +14 lines)
Lines 53-58 my ( Link Here
53
    $start_accession,
53
    $start_accession,
54
    $end_accession,
54
    $end_accession,
55
    $marc_conditions,
55
    $marc_conditions,
56
    $export_holdings,
56
    $help
57
    $help
57
);
58
);
58
59
Lines 77-82 GetOptions( Link Here
77
    'start_accession=s'       => \$start_accession,
78
    'start_accession=s'       => \$start_accession,
78
    'end_accession=s'         => \$end_accession,
79
    'end_accession=s'         => \$end_accession,
79
    'marc_conditions=s'       => \$marc_conditions,
80
    'marc_conditions=s'       => \$marc_conditions,
81
    'holdings'                => \$export_holdings,
80
    'h|help|?'                => \$help
82
    'h|help|?'                => \$help
81
) || pod2usage(1);
83
) || pod2usage(1);
82
84
Lines 111-116 if ( $deleted_barcodes and $record_type ne 'bibs' ) { Link Here
111
    pod2usage(q|--deleted_barcodes can only be used with biblios|);
113
    pod2usage(q|--deleted_barcodes can only be used with biblios|);
112
}
114
}
113
115
116
my $marcFlavour = C4::Context->preference('marcflavour') || 'MARC21';
117
if ( $export_holdings and ( $record_type ne 'bibs' or $marcFlavour ne 'MARC21' ) ) {
118
    pod2usage(q|--holdings can only be used with MARC 21 biblios|);
119
}
120
114
$start_accession = dt_from_string( $start_accession ) if $start_accession;
121
$start_accession = dt_from_string( $start_accession ) if $start_accession;
115
$end_accession   = dt_from_string( $end_accession )   if $end_accession;
122
$end_accession   = dt_from_string( $end_accession )   if $end_accession;
116
123
Lines 243-248 else { Link Here
243
            format             => $output_format,
250
            format             => $output_format,
244
            csv_profile_id     => $csv_profile_id,
251
            csv_profile_id     => $csv_profile_id,
245
            export_items       => (not $dont_export_items),
252
            export_items       => (not $dont_export_items),
253
            export_holdings    => $export_holdings,
246
            clean              => $clean || 0,
254
            clean              => $clean || 0,
247
        }
255
        }
248
    );
256
    );
Lines 256-262 export records - This script exports record (biblios or authorities) Link Here
256
264
257
=head1 SYNOPSIS
265
=head1 SYNOPSIS
258
266
259
export_records.pl [-h|--help] [--format=format] [--date=datetime] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile
267
export_records.pl [-h|--help] [--format=format] [--date=datetime] [--record-type=TYPE] [--holdings] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile
260
268
261
=head1 OPTIONS
269
=head1 OPTIONS
262
270
Lines 281-286 Print a brief help message. Link Here
281
289
282
 --record-type=TYPE     TYPE is 'bibs' or 'auths'.
290
 --record-type=TYPE     TYPE is 'bibs' or 'auths'.
283
291
292
=item B<--holdings>
293
294
 --holdings             Export MARC 21 holding records interleaved with bibs. Used only if TYPE
295
                        is 'bibs' and FORMAT is 'xml' or 'marc'.
296
284
=item B<--dont_export_items>
297
=item B<--dont_export_items>
285
298
286
 --dont_export_items    If enabled, the item infos won't be exported.
299
 --dont_export_items    If enabled, the item infos won't be exported.
(-)a/misc/migration_tools/bulkmarcimport.pl (-11 / +50 lines)
Lines 24-29 use C4::Debug; Link Here
24
use C4::Charset;
24
use C4::Charset;
25
use C4::Items;
25
use C4::Items;
26
use C4::MarcModificationTemplates;
26
use C4::MarcModificationTemplates;
27
use C4::Holdings;
27
28
28
use YAML;
29
use YAML;
29
use Unicode::Normalize;
30
use Unicode::Normalize;
Lines 40-46 use open qw( :std :encoding(UTF-8) ); Link Here
40
binmode( STDOUT, ":encoding(UTF-8)" );
41
binmode( STDOUT, ":encoding(UTF-8)" );
41
my ( $input_marc_file, $number, $offset) = ('',0,0);
42
my ( $input_marc_file, $number, $offset) = ('',0,0);
42
my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile);
43
my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile);
43
my ( $insert, $filters, $update, $all, $yamlfile, $authtypes, $append );
44
my ( $insert, $filters, $update, $all, $yamlfile, $authtypes, $append, $import_holdings );
44
my $cleanisbn = 1;
45
my $cleanisbn = 1;
45
my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode);
46
my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode);
46
my $framework = '';
47
my $framework = '';
Lines 84-96 GetOptions( Link Here
84
    'framework=s' => \$framework,
85
    'framework=s' => \$framework,
85
    'custom:s'    => \$localcust,
86
    'custom:s'    => \$localcust,
86
    'marcmodtemplate:s' => \$marc_mod_template,
87
    'marcmodtemplate:s' => \$marc_mod_template,
88
    'holdings' => \$import_holdings,
87
);
89
);
88
$biblios ||= !$authorities;
90
$biblios ||= !$authorities;
89
$insert  ||= !$update;
91
$insert  ||= !$update;
90
my $writemode = ($append) ? "a" : "w";
92
my $writemode = ($append) ? "a" : "w";
93
my $marcFlavour = C4::Context->preference('marcflavour') || 'MARC21';
91
94
92
pod2usage( -msg => "\nYou must specify either --biblios or --authorities, not both.\n", -exitval ) if $biblios && $authorities;
95
pod2usage( -msg => "\nYou must specify either --biblios or --authorities, not both.\n", -exitval ) if $biblios && $authorities;
93
96
97
pod2usage( -msg => "\nHoldings only supported for MARC 21 biblios.\n", -exitval ) if $import_holdings && (!$biblios || $marcFlavour ne 'MARC21');
98
94
if ($all) {
99
if ($all) {
95
    $insert = 1;
100
    $insert = 1;
96
    $update = 1;
101
    $update = 1;
Lines 174-184 if ($fk_off) { Link Here
174
179
175
180
176
if ($delete) {
181
if ($delete) {
177
	if ($biblios){
182
    if ($biblios) {
178
    	print "deleting biblios\n";
183
        print "deleting biblios\n";
179
    	$dbh->do("truncate biblio");
184
        $dbh->do("truncate holdings");
180
    	$dbh->do("truncate biblioitems");
185
        $dbh->do("truncate biblio");
181
    	$dbh->do("truncate items");
186
        $dbh->do("truncate biblioitems");
187
        $dbh->do("truncate items");
182
	}
188
	}
183
	else {
189
	else {
184
    	print "deleting authorities\n";
190
    	print "deleting authorities\n";
Lines 193-200 if ($test_parameter) { Link Here
193
    print "TESTING MODE ONLY\n    DOING NOTHING\n===============\n";
199
    print "TESTING MODE ONLY\n    DOING NOTHING\n===============\n";
194
}
200
}
195
201
196
my $marcFlavour = C4::Context->preference('marcflavour') || 'MARC21';
197
198
print "Characteristic MARC flavour: $marcFlavour\n" if $verbose;
202
print "Characteristic MARC flavour: $marcFlavour\n" if $verbose;
199
my $starttime = gettimeofday;
203
my $starttime = gettimeofday;
200
my $batch;
204
my $batch;
Lines 260-265 my $searcher = Koha::SearchEngine::Search->new( Link Here
260
    }
264
    }
261
);
265
);
262
266
267
my $biblionumber;
263
RECORD: while (  ) {
268
RECORD: while (  ) {
264
    my $record;
269
    my $record;
265
    # get records
270
    # get records
Lines 308-318 RECORD: while ( ) { Link Here
308
            $field->update('a' => $isbn);
313
            $field->update('a' => $isbn);
309
        }
314
        }
310
    }
315
    }
316
317
    # check for holdings records
318
    my $holdings_record = 0;
319
    if ($biblios && $marcFlavour eq 'MARC21') {
320
        my $leader = $record->leader();
321
        $holdings_record = $leader =~ /^.{6}[uvxy]/;
322
    }
323
311
    my $id;
324
    my $id;
312
    # search for duplicates (based on Local-number)
325
    # search for duplicates (based on Local-number)
313
    my $originalid;
326
    my $originalid;
314
    $originalid = GetRecordId( $record, $tagid, $subfieldid );
327
    $originalid = GetRecordId( $record, $tagid, $subfieldid );
315
    if ($match) {
328
    if ($match && !$holdings_record) {
316
        require C4::Search;
329
        require C4::Search;
317
        my $query = build_query( $match, $record );
330
        my $query = build_query( $match, $record );
318
        my $server = ( $authorities ? 'authorityserver' : 'biblioserver' );
331
        my $server = ( $authorities ? 'authorityserver' : 'biblioserver' );
Lines 428-435 RECORD: while ( ) { Link Here
428
            $yamlhash->{$originalid}->{'subfields'} = \@subfields;
441
            $yamlhash->{$originalid}->{'subfields'} = \@subfields;
429
            }
442
            }
430
        }
443
        }
444
        elsif ($holdings_record) {
445
            if ($import_holdings) {
446
                if (!defined $biblionumber) {
447
                    warn "ERROR: Encountered holdings record without preceding biblio record\n";
448
                } else {
449
                    if ($insert) {
450
                        my $holdings_id = 0;
451
                        eval { ( $holdings_id ) = AddHolding( $record, '', $biblionumber ) };
452
                        if ($@) {
453
                            warn "ERROR: Adding holdings record $holdings_id for biblio $biblionumber failed: $@\n";
454
                            printlog( { $holdings_id, op => "insert", status => "ERROR" } ) if ($logfile);
455
                            next RECORD;
456
                        } else {
457
                            printlog( { $holdings_id, op => "insert", status => "ok" } ) if ($logfile);
458
                        }
459
                    } else {
460
                        printlog( { 0, op => "update", status => "warning : not in database" } ) if ($logfile);
461
                    }
462
                }
463
            }
464
        }
431
        else {
465
        else {
432
            my ( $biblionumber, $biblioitemnumber, $itemnumbers_ref, $errors_ref );
466
            my ( $biblioitemnumber, $itemnumbers_ref, $errors_ref );
433
            $biblionumber = $id;
467
            $biblionumber = $id;
434
            # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter
468
            # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter
435
            if (!$biblionumber && $isbn_check && $isbn) {
469
            if (!$biblionumber && $isbn_check && $isbn) {
Lines 701-706 Type of import: authority records Link Here
701
735
702
The I<FILE> to import
736
The I<FILE> to import
703
737
738
=item B<-holdings>
739
740
Import MARC 21 holdings records when interleaved with bibliographic records
741
(insert only, update not supported). Used only with -biblios.
742
704
=item  B<-v>
743
=item  B<-v>
705
744
706
Verbose mode. 1 means "some infos", 2 means "MARC dumping"
745
Verbose mode. 1 means "some infos", 2 means "MARC dumping"
Lines 746-752 I<UNIMARC> are supported. MARC21 by default. Link Here
746
=item B<-d>
785
=item B<-d>
747
786
748
Delete EVERYTHING related to biblio in koha-DB before import. Tables: biblio,
787
Delete EVERYTHING related to biblio in koha-DB before import. Tables: biblio,
749
biblioitems, items
788
biblioitems, items, holdings
750
789
751
=item B<-m>=I<FORMAT>
790
=item B<-m>=I<FORMAT>
752
791
(-)a/t/db_dependent/Exporter/Record.t (-1 / +68 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 6;
20
use Test::More tests => 8;
21
use Test::Warn;
21
use Test::Warn;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
23
Lines 35-40 use Koha::Biblio; Link Here
35
use Koha::Biblioitem;
35
use Koha::Biblioitem;
36
use Koha::Exporter::Record;
36
use Koha::Exporter::Record;
37
use Koha::Biblio::Metadata;
37
use Koha::Biblio::Metadata;
38
use Koha::Holdings;
38
39
39
my $schema  = Koha::Database->new->schema;
40
my $schema  = Koha::Database->new->schema;
40
$schema->storage->txn_begin;
41
$schema->storage->txn_begin;
Lines 63-68 Koha::Biblio::Metadata->new( { biblionumber => $bad_biblio->id, format => 'marcx Link Here
63
my $bad_biblionumber = $bad_biblio->id;
64
my $bad_biblionumber = $bad_biblio->id;
64
65
65
my $builder = t::lib::TestBuilder->new;
66
my $builder = t::lib::TestBuilder->new;
67
my $holdingbranch = $builder->build({ source => 'Branch' });
68
69
my $holding_1 = MARC::Record->new();
70
$holding_1->leader('00202cx  a22000973  4500');
71
$holding_1->append_fields(
72
    MARC::Field->new('852', '8', ' ', b => $holdingbranch->{branchcode}, c => 'Location', k => '1973', h => 'Tb', t => 'Copy 1')
73
);
74
C4::Holdings::AddHolding($holding_1, '', $biblionumber_1);
75
66
my $item_1_1 = $builder->build({
76
my $item_1_1 = $builder->build({
67
    source => 'Item',
77
    source => 'Item',
68
    value => {
78
    value => {
Lines 199-204 subtest 'export iso2709' => sub { Link Here
199
    is( $title, $biblio_2_title, 'Export ISO2709: The title is correctly encoded' );
209
    is( $title, $biblio_2_title, 'Export ISO2709: The title is correctly encoded' );
200
};
210
};
201
211
212
subtest 'export xml with holdings' => sub {
213
    plan tests => 3;
214
    my $generated_xml_file = '/tmp/test_export.xml';
215
    Koha::Exporter::Record::export(
216
        {   record_type     => 'bibs',
217
            record_ids      => [ $biblionumber_1, $biblionumber_2 ],
218
            format          => 'xml',
219
            output_filepath => $generated_xml_file,
220
            export_holdings => 1,
221
        }
222
    );
223
224
    my $generated_xml_content = read_file( $generated_xml_file );
225
    $MARC::File::XML::_load_args{BinaryEncoding} = 'utf-8';
226
    open my $fh, '<', $generated_xml_file;
227
    my $records = MARC::Batch->new( 'XML', $fh );
228
    my @records;
229
    # The following statement produces
230
    # Use of uninitialized value in concatenation (.) or string at /usr/share/perl5/MARC/File/XML.pm line 398, <$fh> chunk 5.
231
    # Why?
232
    while ( my $record = $records->next ) {
233
        push @records, $record;
234
    }
235
    is( scalar( @records ), 3, 'Export XML with holdings: 3 records should have been exported' );
236
    my $holding_record = $records[1];
237
    my $branch = $holding_record->subfield('852', 'b');
238
    is( $branch, $holdingbranch->{branchcode}, 'Export XML with holdings: The holding record contains correct branch code' );
239
    my $location = $holding_record->subfield('852', 'c');
240
    is( $location, 'Location', 'Export XML with holdings: The holding record contains correct location' );
241
};
242
243
subtest 'export iso2709 with holdings' => sub {
244
    plan tests => 3;
245
    my $generated_mrc_file = '/tmp/test_export.mrc';
246
    # Get all item infos
247
    Koha::Exporter::Record::export(
248
        {   record_type     => 'bibs',
249
            record_ids      => [ $biblionumber_1, $biblionumber_2 ],
250
            format          => 'iso2709',
251
            output_filepath => $generated_mrc_file,
252
            export_holdings => 1,
253
        }
254
    );
255
256
    my $records = MARC::File::USMARC->in( $generated_mrc_file );
257
    my @records;
258
    while ( my $record = $records->next ) {
259
        push @records, $record;
260
    }
261
    is( scalar( @records ), 3, 'Export ISO2709 with holdings: 3 records should have been exported' );
262
    my $holding_record = $records[1];
263
    my $branch = $holding_record->subfield('852', 'b');
264
    is( $branch, $holdingbranch->{branchcode}, 'Export ISO2709 with holdings: The holding record contains correct branch code' );
265
    my $location = $holding_record->subfield('852', 'c');
266
    is( $location, 'Location', 'Export ISO2709 with holdings: The holding record contains correct location' );
267
};
268
202
subtest 'export without record_type' => sub {
269
subtest 'export without record_type' => sub {
203
    plan tests => 1;
270
    plan tests => 1;
204
271
(-)a/tools/export.pl (-1 / +3 lines)
Lines 35-40 use Koha::Libraries; Link Here
35
my $query = new CGI;
35
my $query = new CGI;
36
36
37
my $dont_export_items = $query->param("dont_export_item") || 0;
37
my $dont_export_items = $query->param("dont_export_item") || 0;
38
my $export_holdings   = $query->param("export_holdings") || 0;
38
my $record_type       = $query->param("record_type");
39
my $record_type       = $query->param("record_type");
39
my $op                = $query->param("op") || '';
40
my $op                = $query->param("op") || '';
40
my $output_format     = $query->param("format") || $query->param("output_format") || 'iso2709';
41
my $output_format     = $query->param("format") || $query->param("output_format") || 'iso2709';
Lines 208-213 if ( $op eq "export" ) { Link Here
208
                dont_export_fields => $export_remove_fields,
209
                dont_export_fields => $export_remove_fields,
209
                csv_profile_id     => $csv_profile_id,
210
                csv_profile_id     => $csv_profile_id,
210
                export_items       => (not $dont_export_items),
211
                export_items       => (not $dont_export_items),
212
                export_holdings    => $export_holdings,
211
                only_export_items_for_branches => $only_export_items_for_branches,
213
                only_export_items_for_branches => $only_export_items_for_branches,
212
            }
214
            }
213
        );
215
        );
Lines 302-307 else { Link Here
302
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
304
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
303
        csv_profiles             => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
305
        csv_profiles             => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
304
        messages                 => \@messages,
306
        messages                 => \@messages,
307
        show_summary_holdings    => C4::Context->preference('SummaryHoldings') ? 1 : 0,
305
    );
308
    );
306
309
307
    output_html_with_http_headers $query, $cookie, $template->output;
310
    output_html_with_http_headers $query, $cookie, $template->output;
308
- 

Return to bug 20447