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

(-)a/C4/AuthoritiesMarc.pm (-1 / +1 lines)
Lines 1552-1558 sub merge { Link Here
1552
#         $update=1;
1552
#         $update=1;
1553
#       }#for each tag
1553
#       }#for each tag
1554
#     }#foreach tagfield
1554
#     }#foreach tagfield
1555
#     my $authoritynumber = TransformMarcToKoha($dbh,$marcrecord,"") ;
1555
#     my $authoritynumber = TransformMarcToKoha($marcrecord,"") ;
1556
#     if ($update==1){
1556
#     if ($update==1){
1557
#       &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ;
1557
#       &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ;
1558
#     }
1558
#     }
(-)a/C4/Biblio.pm (-5 / +4 lines)
Lines 257-263 sub AddBiblio { Link Here
257
257
258
    # transform the data into koha-table style data
258
    # transform the data into koha-table style data
259
    SetUTF8Flag($record);
259
    SetUTF8Flag($record);
260
    my $olddata = TransformMarcToKoha( $dbh, $record, $frameworkcode );
260
    my $olddata = TransformMarcToKoha( $record, $frameworkcode );
261
    ( $biblionumber, $error ) = _koha_add_biblio( $dbh, $olddata, $frameworkcode );
261
    ( $biblionumber, $error ) = _koha_add_biblio( $dbh, $olddata, $frameworkcode );
262
    $olddata->{'biblionumber'} = $biblionumber;
262
    $olddata->{'biblionumber'} = $biblionumber;
263
    ( $biblioitemnumber, $error ) = _koha_add_biblioitem( $dbh, $olddata );
263
    ( $biblioitemnumber, $error ) = _koha_add_biblioitem( $dbh, $olddata );
Lines 340-346 sub ModBiblio { Link Here
340
    _koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, $biblioitemnumber );
340
    _koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, $biblioitemnumber );
341
341
342
    # load the koha-table data object
342
    # load the koha-table data object
343
    my $oldbiblio = TransformMarcToKoha( $dbh, $record, $frameworkcode );
343
    my $oldbiblio = TransformMarcToKoha( $record, $frameworkcode );
344
344
345
    # update MARC subfield that stores biblioitems.cn_sort
345
    # update MARC subfield that stores biblioitems.cn_sort
346
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
346
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
Lines 2606-2612 our $inverted_field_map; Link Here
2606
2606
2607
=head2 TransformMarcToKoha
2607
=head2 TransformMarcToKoha
2608
2608
2609
  $result = TransformMarcToKoha( $dbh, $record, $frameworkcode )
2609
  $result = TransformMarcToKoha( $record, $frameworkcode )
2610
2610
2611
Extract data from a MARC bib record into a hashref representing
2611
Extract data from a MARC bib record into a hashref representing
2612
Koha biblio, biblioitems, and items fields. 
2612
Koha biblio, biblioitems, and items fields. 
Lines 2617-2624 hash_ref Link Here
2617
=cut
2617
=cut
2618
2618
2619
sub TransformMarcToKoha {
2619
sub TransformMarcToKoha {
2620
    my ( $dbh, $record, $frameworkcode, $limit_table ) = @_;
2620
    my ( $record, $frameworkcode, $limit_table ) = @_;
2621
    ## FIXME: $dbh parameter is never used inside this subroutine ???
2622
2621
2623
    my $result = {};
2622
    my $result = {};
2624
    if (!defined $record) {
2623
    if (!defined $record) {
(-)a/C4/ImportBatch.pm (-2 / +2 lines)
Lines 759-765 sub BatchCommitItems { Link Here
759
        my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan', GetFrameworkCode($biblionumber) );
759
        my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan', GetFrameworkCode($biblionumber) );
760
        $item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield );
760
        $item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield );
761
761
762
        my $item = TransformMarcToKoha( $dbh, $item_marc );
762
        my $item = TransformMarcToKoha( $item_marc );
763
763
764
        my $duplicate_barcode = exists( $item->{'barcode'} ) && GetItemnumberFromBarcode( $item->{'barcode'} );
764
        my $duplicate_barcode = exists( $item->{'barcode'} ) && GetItemnumberFromBarcode( $item->{'barcode'} );
765
        my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
765
        my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
Lines 1545-1551 sub _parse_biblio_fields { Link Here
1545
    my ($marc_record) = @_;
1545
    my ($marc_record) = @_;
1546
1546
1547
    my $dbh = C4::Context->dbh;
1547
    my $dbh = C4::Context->dbh;
1548
    my $bibliofields = TransformMarcToKoha($dbh, $marc_record, '');
1548
    my $bibliofields = TransformMarcToKoha($marc_record, '');
1549
    return ($bibliofields->{'title'}, $bibliofields->{'author'}, $bibliofields->{'isbn'}, $bibliofields->{'issn'});
1549
    return ($bibliofields->{'title'}, $bibliofields->{'author'}, $bibliofields->{'isbn'}, $bibliofields->{'issn'});
1550
1550
1551
}
1551
}
(-)a/C4/Items.pm (-3 / +3 lines)
Lines 251-257 sub AddItemFromMarc { Link Here
251
	
251
	
252
	my $localitemmarc=MARC::Record->new;
252
	my $localitemmarc=MARC::Record->new;
253
	$localitemmarc->append_fields($source_item_marc->field($itemtag));
253
	$localitemmarc->append_fields($source_item_marc->field($itemtag));
254
    my $item = &TransformMarcToKoha( $dbh, $localitemmarc, $frameworkcode ,'items');
254
    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items');
255
    my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode);
255
    my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode);
256
    return AddItem($item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields);
256
    return AddItem($item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields);
257
}
257
}
Lines 383-389 sub AddItemBatchFromMarc { Link Here
383
        $temp_item_marc->append_fields($item_field);
383
        $temp_item_marc->append_fields($item_field);
384
    
384
    
385
        # add biblionumber and biblioitemnumber
385
        # add biblionumber and biblioitemnumber
386
        my $item = TransformMarcToKoha( $dbh, $temp_item_marc, $frameworkcode, 'items' );
386
        my $item = TransformMarcToKoha( $temp_item_marc, $frameworkcode, 'items' );
387
        my $unlinked_item_subfields = _get_unlinked_item_subfields($temp_item_marc, $frameworkcode);
387
        my $unlinked_item_subfields = _get_unlinked_item_subfields($temp_item_marc, $frameworkcode);
388
        $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields);
388
        $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields);
389
        $item->{'biblionumber'} = $biblionumber;
389
        $item->{'biblionumber'} = $biblionumber;
Lines 507-513 sub ModItemFromMarc { Link Here
507
507
508
    my $localitemmarc = MARC::Record->new;
508
    my $localitemmarc = MARC::Record->new;
509
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
509
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
510
    my $item = &TransformMarcToKoha( $dbh, $localitemmarc, $frameworkcode, 'items' );
510
    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
511
    my $default_values = _build_default_values_for_mod_marc();
511
    my $default_values = _build_default_values_for_mod_marc();
512
    foreach my $item_field ( keys %$default_values ) {
512
    foreach my $item_field ( keys %$default_values ) {
513
        $item->{$item_field} = $default_values->{$item_field}
513
        $item->{$item_field} = $default_values->{$item_field}
(-)a/C4/Matcher.pm (-1 / +1 lines)
Lines 707-713 sub get_matches { Link Here
707
        foreach my $marcblob (keys %matches) {
707
        foreach my $marcblob (keys %matches) {
708
            my $target_record = C4::Search::new_record_from_zebra('biblioserver',$marcblob);
708
            my $target_record = C4::Search::new_record_from_zebra('biblioserver',$marcblob);
709
            my $record_number;
709
            my $record_number;
710
            my $result = C4::Biblio::TransformMarcToKoha(C4::Context->dbh, $target_record, '');
710
            my $result = C4::Biblio::TransformMarcToKoha($target_record, '');
711
            $record_number = $result->{'biblionumber'};
711
            $record_number = $result->{'biblionumber'};
712
            push @results, { 'record_id' => $record_number, 'score' => $matches{$marcblob} };
712
            push @results, { 'record_id' => $record_number, 'score' => $matches{$marcblob} };
713
        }
713
        }
(-)a/C4/Search.pm (-4 / +4 lines)
Lines 83-89 This function attempts to find duplicate records using a hard-coded, fairly simp Link Here
83
sub FindDuplicate {
83
sub FindDuplicate {
84
    my ($record) = @_;
84
    my ($record) = @_;
85
    my $dbh = C4::Context->dbh;
85
    my $dbh = C4::Context->dbh;
86
    my $result = TransformMarcToKoha( $dbh, $record, '' );
86
    my $result = TransformMarcToKoha( $record, '' );
87
    my $sth;
87
    my $sth;
88
    my $query;
88
    my $query;
89
    my $search;
89
    my $search;
Lines 145-151 sub FindDuplicate { Link Here
145
                $possible_duplicate_record
145
                $possible_duplicate_record
146
            );
146
            );
147
147
148
            my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
148
            my $result = TransformMarcToKoha( $marcrecord, '' );
149
149
150
            # FIXME :: why 2 $biblionumber ?
150
            # FIXME :: why 2 $biblionumber ?
151
            if ($result) {
151
            if ($result) {
Lines 201-207 my @results; Link Here
201
201
202
for my $r ( @{$marcresults} ) {
202
for my $r ( @{$marcresults} ) {
203
    my $marcrecord = MARC::File::USMARC::decode($r);
203
    my $marcrecord = MARC::File::USMARC::decode($r);
204
    my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,q{});
204
    my $biblio = TransformMarcToKoha($marcrecord,q{});
205
205
206
    #build the iarray of hashs for the template.
206
    #build the iarray of hashs for the template.
207
    push @results, {
207
    push @results, {
Lines 1889-1895 sub searchResults { Link Here
1889
               : GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf));
1889
               : GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf));
1890
1890
1891
        SetUTF8Flag($marcrecord);
1891
        SetUTF8Flag($marcrecord);
1892
        my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, $fw );
1892
        my $oldbiblio = TransformMarcToKoha( $marcrecord, $fw );
1893
        $oldbiblio->{subtitle} = GetRecordValue('subtitle', $marcrecord, $fw);
1893
        $oldbiblio->{subtitle} = GetRecordValue('subtitle', $marcrecord, $fw);
1894
        $oldbiblio->{result_number} = $i + 1;
1894
        $oldbiblio->{result_number} = $i + 1;
1895
1895
(-)a/acqui/neworderbiblio.pl (-1 / +1 lines)
Lines 122-128 my @results; Link Here
122
122
123
foreach my $result ( @{$marcresults} ) {
123
foreach my $result ( @{$marcresults} ) {
124
    my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $result );
124
    my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $result );
125
    my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
125
    my $biblio = TransformMarcToKoha( $marcrecord, '' );
126
126
127
    $biblio->{booksellerid} = $booksellerid;
127
    $biblio->{booksellerid} = $booksellerid;
128
    push @results, $biblio;
128
    push @results, $biblio;
(-)a/cataloguing/additem.pl (-3 / +3 lines)
Lines 404-410 $restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && Link Here
404
404
405
my $tagslib = &GetMarcStructure(1,$frameworkcode);
405
my $tagslib = &GetMarcStructure(1,$frameworkcode);
406
my $record = GetMarcBiblio($biblionumber);
406
my $record = GetMarcBiblio($biblionumber);
407
my $oldrecord = TransformMarcToKoha($dbh,$record);
407
my $oldrecord = TransformMarcToKoha($record);
408
my $itemrecord;
408
my $itemrecord;
409
my $nextop="additem";
409
my $nextop="additem";
410
my @errors; # store errors found while checking data BEFORE saving item.
410
my @errors; # store errors found while checking data BEFORE saving item.
Lines 457-463 if ($op eq "additem") { Link Here
457
        $record = _increment_barcode($record, $frameworkcode);
457
        $record = _increment_barcode($record, $frameworkcode);
458
    }
458
    }
459
459
460
    my $addedolditem = TransformMarcToKoha( $dbh, $record );
460
    my $addedolditem = TransformMarcToKoha( $record );
461
461
462
    # If we have to add or add & duplicate, we add the item
462
    # If we have to add or add & duplicate, we add the item
463
    if ( $add_submit || $add_duplicate_submit ) {
463
    if ( $add_submit || $add_duplicate_submit ) {
Lines 683-689 if ($op eq "additem") { Link Here
683
    # MARC::Record builded => now, record in DB
683
    # MARC::Record builded => now, record in DB
684
    # warn "R: ".$record->as_formatted;
684
    # warn "R: ".$record->as_formatted;
685
    # check that the barcode don't exist already
685
    # check that the barcode don't exist already
686
    my $addedolditem = TransformMarcToKoha($dbh,$itemtosave);
686
    my $addedolditem = TransformMarcToKoha($itemtosave);
687
    my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
687
    my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
688
    if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
688
    if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
689
        push @errors,"barcode_not_unique";
689
        push @errors,"barcode_not_unique";
(-)a/cataloguing/value_builder/marc21_linking_section.pl (-1 / +1 lines)
Lines 208-214 my $launcher = sub { Link Here
208
        my @field_data = ($search);
208
        my @field_data = ($search);
209
        for ( my $i = 0 ; $i < $resultsperpage ; $i++ ) {
209
        for ( my $i = 0 ; $i < $resultsperpage ; $i++ ) {
210
            my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
210
            my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
211
            my $rechash = TransformMarcToKoha( $dbh, $record );
211
            my $rechash = TransformMarcToKoha( $record );
212
            my $pos;
212
            my $pos;
213
            my $countitems = $rechash->{itembumber} ? 1 : 0;
213
            my $countitems = $rechash->{itembumber} ? 1 : 0;
214
            while ( index( $rechash->{itemnumber}, '|', $pos ) > 0 ) {
214
            while ( index( $rechash->{itemnumber}, '|', $pos ) > 0 ) {
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-1 / +1 lines)
Lines 397-403 sub plugin { Link Here
397
         {
397
         {
398
            my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
398
            my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
399
            next unless $record;
399
            next unless $record;
400
            my $rechash = TransformMarcToKoha( $dbh, $record );
400
            my $rechash = TransformMarcToKoha( $record );
401
            if ( my $f = $record->field('200') ) {
401
            if ( my $f = $record->field('200') ) {
402
                $rechash->{fulltitle} =
402
                $rechash->{fulltitle} =
403
                    join(', ', map { $_->[1] } grep { $_->[0] =~ /[aehi]/ } $f->subfields() );
403
                    join(', ', map { $_->[1] } grep { $_->[0] =~ /[aehi]/ } $f->subfields() );
(-)a/circ/circulation.pl (-2 / +1 lines)
Lines 361-368 if (@$barcodes) { Link Here
361
            my @options = ();
361
            my @options = ();
362
            foreach my $hit ( @{$results} ) {
362
            foreach my $hit ( @{$results} ) {
363
                my $chosen =
363
                my $chosen =
364
                  TransformMarcToKoha( C4::Context->dbh,
364
                  TransformMarcToKoha( C4::Search::new_record_from_zebra('biblioserver',$hit) );
365
                    C4::Search::new_record_from_zebra('biblioserver',$hit) );
366
365
367
                # offer all barcodes individually
366
                # offer all barcodes individually
368
                if ( $chosen->{barcode} ) {
367
                if ( $chosen->{barcode} ) {
(-)a/labels/label-item-search.pl (-1 / +1 lines)
Lines 132-138 if ($show_results) { Link Here
132
        #DEBUG Notes: Decode the MARC record from each resulting MARC record...
132
        #DEBUG Notes: Decode the MARC record from each resulting MARC record...
133
        my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcresults->[$i] );
133
        my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcresults->[$i] );
134
        #DEBUG Notes: Transform it to Koha form...
134
        #DEBUG Notes: Transform it to Koha form...
135
        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
135
        my $biblio = TransformMarcToKoha( $marcrecord, '' );
136
        #DEBUG Notes: Stuff the bib into @biblio_data...
136
        #DEBUG Notes: Stuff the bib into @biblio_data...
137
        push (@results_set, $biblio);
137
        push (@results_set, $biblio);
138
        my $biblionumber = $biblio->{'biblionumber'};
138
        my $biblionumber = $biblio->{'biblionumber'};
(-)a/misc/batchRebuildBiblioTables.pl (-1 / +1 lines)
Lines 96-102 if (scalar(@errors) > 0) { Link Here
96
sub localNEWmodbiblio {
96
sub localNEWmodbiblio {
97
    my ($dbh,$record,$biblionumber,$frameworkcode) =@_;
97
    my ($dbh,$record,$biblionumber,$frameworkcode) =@_;
98
    $frameworkcode="" unless $frameworkcode;
98
    $frameworkcode="" unless $frameworkcode;
99
    my $oldbiblio = TransformMarcToKoha($dbh,$record,$frameworkcode);
99
    my $oldbiblio = TransformMarcToKoha($record,$frameworkcode);
100
    C4::Biblio::_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
100
    C4::Biblio::_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
101
    C4::Biblio::_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
101
    C4::Biblio::_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
102
    return 1;
102
    return 1;
(-)a/opac/opac-ISBDdetail.pl (-1 / +1 lines)
Lines 119-125 $template->param( Link Here
119
#coping with subscriptions
119
#coping with subscriptions
120
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
120
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
121
my $dbh = C4::Context->dbh;
121
my $dbh = C4::Context->dbh;
122
my $dat                 = TransformMarcToKoha( $dbh, $record );
122
my $dat                 = TransformMarcToKoha( $record );
123
123
124
my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
124
my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
125
my @subs;
125
my @subs;
(-)a/opac/opac-MARCdetail.pl (-1 / +1 lines)
Lines 306-312 if(C4::Context->preference("ISBD")) { Link Here
306
306
307
#Search for title in links
307
#Search for title in links
308
my $marcflavour  = C4::Context->preference("marcflavour");
308
my $marcflavour  = C4::Context->preference("marcflavour");
309
my $dat = TransformMarcToKoha( $dbh, $record );
309
my $dat = TransformMarcToKoha( $record );
310
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
310
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
311
my $marccontrolnumber   = GetMarcControlnumber ($record, $marcflavour);
311
my $marccontrolnumber   = GetMarcControlnumber ($record, $marcflavour);
312
my $marcissns = GetMarcISSN( $record, $marcflavour );
312
my $marcissns = GetMarcISSN( $record, $marcflavour );
(-)a/serials/subscription-bib-search.pl (-1 / +1 lines)
Lines 114-120 if ( $op eq "do_search" && $query ) { Link Here
114
    for ( my $i = 0 ; $i < $total ; $i++ ) {
114
    for ( my $i = 0 ; $i < $total ; $i++ ) {
115
        my %resultsloop;
115
        my %resultsloop;
116
        my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcrecords->[$i] );
116
        my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcrecords->[$i] );
117
        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
117
        my $biblio = TransformMarcToKoha( $marcrecord, '' );
118
118
119
        #build the hash for the template.
119
        #build the hash for the template.
120
        $resultsloop{highlight}       = ( $i % 2 ) ? (1) : (0);
120
        $resultsloop{highlight}       = ( $i % 2 ) ? (1) : (0);
(-)a/t/Biblio.t (-2 / +1 lines)
Lines 162-168 ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec'); Link Here
162
162
163
my $hash_ref;
163
my $hash_ref;
164
164
165
warning_is { $hash_ref = TransformMarcToKoha(undef, undef) }
165
warning_is { $hash_ref = TransformMarcToKoha( undef) }
166
           { carped => 'TransformMarcToKoha called with undefined record'},
166
           { carped => 'TransformMarcToKoha called with undefined record'},
167
           "TransformMarcToKoha returns carped warning on undef record";
167
           "TransformMarcToKoha returns carped warning on undef record";
168
168
169
- 

Return to bug 16169