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

(-)a/C4/Items.pm (-15 / +15 lines)
Lines 235-242 sub AddItemFromMarc { Link Here
235
    my $dbh = C4::Context->dbh;
235
    my $dbh = C4::Context->dbh;
236
236
237
    # parse item hash from MARC
237
    # parse item hash from MARC
238
    my $frameworkcode = GetFrameworkCode( $biblionumber );
238
    my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber );
239
	my ($itemtag,$itemsubfield)=GetMarcFromKohaField("items.itemnumber",$frameworkcode);
239
    my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode);
240
	
240
	
241
	my $localitemmarc=MARC::Record->new;
241
	my $localitemmarc=MARC::Record->new;
242
	$localitemmarc->append_fields($source_item_marc->field($itemtag));
242
	$localitemmarc->append_fields($source_item_marc->field($itemtag));
Lines 271-277 sub AddItem { Link Here
271
    my $biblionumber = shift;
271
    my $biblionumber = shift;
272
272
273
    my $dbh           = @_ ? shift : C4::Context->dbh;
273
    my $dbh           = @_ ? shift : C4::Context->dbh;
274
    my $frameworkcode = @_ ? shift : GetFrameworkCode($biblionumber);
274
    my $frameworkcode = @_ ? shift : C4::Biblio::GetFrameworkCode($biblionumber);
275
    my $unlinked_item_subfields;
275
    my $unlinked_item_subfields;
276
    if (@_) {
276
    if (@_) {
277
        $unlinked_item_subfields = shift;
277
        $unlinked_item_subfields = shift;
Lines 364-370 sub AddItemBatchFromMarc { Link Here
364
    $record = $record->clone();
364
    $record = $record->clone();
365
    # loop through the item tags and start creating items
365
    # loop through the item tags and start creating items
366
    my @bad_item_fields = ();
366
    my @bad_item_fields = ();
367
    my ($itemtag, $itemsubfield) = &GetMarcFromKohaField("items.itemnumber",'');
367
    my ($itemtag, $itemsubfield) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",'');
368
    my $item_sequence_num = 0;
368
    my $item_sequence_num = 0;
369
    ITEMFIELD: foreach my $item_field ($record->field($itemtag)) {
369
    ITEMFIELD: foreach my $item_field ($record->field($itemtag)) {
370
        $item_sequence_num++;
370
        $item_sequence_num++;
Lines 499-506 sub ModItemFromMarc { Link Here
499
    my $itemnumber = shift;
499
    my $itemnumber = shift;
500
500
501
    my $dbh           = C4::Context->dbh;
501
    my $dbh           = C4::Context->dbh;
502
    my $frameworkcode = GetFrameworkCode($biblionumber);
502
    my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber);
503
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
503
    my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
504
504
505
    my $localitemmarc = MARC::Record->new;
505
    my $localitemmarc = MARC::Record->new;
506
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
506
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
Lines 552-558 sub ModItem { Link Here
552
    }
552
    }
553
553
554
    my $dbh           = @_ ? shift : C4::Context->dbh;
554
    my $dbh           = @_ ? shift : C4::Context->dbh;
555
    my $frameworkcode = @_ ? shift : GetFrameworkCode( $biblionumber );
555
    my $frameworkcode = @_ ? shift : C4::Biblio::GetFrameworkCode( $biblionumber );
556
    
556
    
557
    my $unlinked_item_subfields;  
557
    my $unlinked_item_subfields;  
558
    if (@_) {
558
    if (@_) {
Lines 1321-1327 references on array of itemnumbers. Link Here
1321
1321
1322
sub get_hostitemnumbers_of {
1322
sub get_hostitemnumbers_of {
1323
    my ($biblionumber) = @_;
1323
    my ($biblionumber) = @_;
1324
    my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
1324
    my $marcrecord = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
1325
1325
1326
    return unless $marcrecord;
1326
    return unless $marcrecord;
1327
1327
Lines 1479-1485 sub GetMarcItem { Link Here
1479
1479
1480
    my $itemrecord = GetItem($itemnumber);
1480
    my $itemrecord = GetItem($itemnumber);
1481
1481
1482
    # Tack on 'items.' prefix to column names so that TransformKohaToMarc will work.
1482
    # Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work.
1483
    # Also, don't emit a subfield if the underlying field is blank.
1483
    # Also, don't emit a subfield if the underlying field is blank.
1484
1484
1485
    
1485
    
Lines 1493-1500 sub Item2Marc { Link Here
1493
            defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : ()  
1493
            defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : ()  
1494
        } keys %{ $itemrecord } 
1494
        } keys %{ $itemrecord } 
1495
    };
1495
    };
1496
    my $itemmarc = TransformKohaToMarc($mungeditem);
1496
    my $itemmarc = C4::Biblio::TransformKohaToMarc($mungeditem);
1497
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",GetFrameworkCode($biblionumber)||'');
1497
    my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",C4::Biblio::GetFrameworkCode($biblionumber)||'');
1498
1498
1499
    my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'});
1499
    my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'});
1500
    if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) {
1500
    if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) {
Lines 2120-2126 sub _marc_from_item_hash { Link Here
2120
2120
2121
    my $item_marc = MARC::Record->new();
2121
    my $item_marc = MARC::Record->new();
2122
    foreach my $item_field ( keys %{$mungeditem} ) {
2122
    foreach my $item_field ( keys %{$mungeditem} ) {
2123
        my ( $tag, $subfield ) = GetMarcFromKohaField( $item_field, $frameworkcode );
2123
        my ( $tag, $subfield ) = C4::Biblio::GetMarcFromKohaField( $item_field, $frameworkcode );
2124
        next unless defined $tag and defined $subfield;    # skip if not mapped to MARC field
2124
        next unless defined $tag and defined $subfield;    # skip if not mapped to MARC field
2125
        my @values = split(/\s?\|\s?/, $mungeditem->{$item_field}, -1);
2125
        my @values = split(/\s?\|\s?/, $mungeditem->{$item_field}, -1);
2126
        foreach my $value (@values){
2126
        foreach my $value (@values){
Lines 2334-2340 sub _SearchItems_build_where_fragment { Link Here
2334
                    # items.more_subfields_xml, depending on the MARC field.
2334
                    # items.more_subfields_xml, depending on the MARC field.
2335
                    my $xpath;
2335
                    my $xpath;
2336
                    my $sqlfield;
2336
                    my $sqlfield;
2337
                    my ($itemfield) = GetMarcFromKohaField('items.itemnumber');
2337
                    my ($itemfield) = C4::Biblio::GetMarcFromKohaField('items.itemnumber');
2338
                    if ($marcfield eq $itemfield) {
2338
                    if ($marcfield eq $itemfield) {
2339
                        $sqlfield = 'more_subfields_xml';
2339
                        $sqlfield = 'more_subfields_xml';
2340
                        $xpath = '//record/datafield/subfield[@code="' . $marcsubfield . '"]';
2340
                        $xpath = '//record/datafield/subfield[@code="' . $marcsubfield . '"]';
Lines 2541-2548 sub PrepareItemrecordDisplay { Link Here
2541
    my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_;
2541
    my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_;
2542
2542
2543
    my $dbh = C4::Context->dbh;
2543
    my $dbh = C4::Context->dbh;
2544
    $frameworkcode = &GetFrameworkCode($bibnum) if $bibnum;
2544
    $frameworkcode = C4::Biblio::GetFrameworkCode($bibnum) if $bibnum;
2545
    my ( $itemtagfield, $itemtagsubfield ) = &GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
2545
    my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
2546
2546
2547
    # Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is
2547
    # Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is
2548
    # a shared data structure. No plugin (including custom ones) should change
2548
    # a shared data structure. No plugin (including custom ones) should change
(-)a/misc/migration_tools/rebuild_zebra.pl (-5 / +4 lines)
Lines 172-179 my $kohadir = C4::Context->config('intranetdir'); Link Here
172
my $bib_index_mode  = C4::Context->config('zebra_bib_index_mode')  // 'dom';
172
my $bib_index_mode  = C4::Context->config('zebra_bib_index_mode')  // 'dom';
173
my $auth_index_mode = C4::Context->config('zebra_auth_index_mode') // 'dom';
173
my $auth_index_mode = C4::Context->config('zebra_auth_index_mode') // 'dom';
174
174
175
my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
175
my ($biblionumbertagfield,$biblionumbertagsubfield) = C4::Biblio::GetMarcFromKohaField("biblio.biblionumber","");
176
my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
176
my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = C4::Biblio::GetMarcFromKohaField("biblioitems.biblioitemnumber","");
177
177
178
my $marcxml_open = q{<?xml version="1.0" encoding="UTF-8"?>
178
my $marcxml_open = q{<?xml version="1.0" encoding="UTF-8"?>
179
<collection xmlns="http://www.loc.gov/MARC21/slim">
179
<collection xmlns="http://www.loc.gov/MARC21/slim">
Lines 497-503 sub export_marc_records_from_sth { Link Here
497
    print {$fh} $marcxml_open;
497
    print {$fh} $marcxml_open;
498
498
499
    my $i = 0;
499
    my $i = 0;
500
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",'');
500
    my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",'');
501
    while (my ($record_number) = $sth->fetchrow_array) {
501
    while (my ($record_number) = $sth->fetchrow_array) {
502
        print "." if ( $verbose_logging );
502
        print "." if ( $verbose_logging );
503
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
503
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
Lines 675-681 sub get_raw_marc_record { Link Here
675
675
676
    my $marc;
676
    my $marc;
677
    if ($record_type eq 'biblio') {
677
    if ($record_type eq 'biblio') {
678
        eval { $marc = GetMarcBiblio({ biblionumber => $record_number, embed_items => 1 }); };
678
        eval { $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $record_number, embed_items => 1 }); };
679
        if ($@ || !$marc) {
679
        if ($@ || !$marc) {
680
            # here we do warn since catching an exception
680
            # here we do warn since catching an exception
681
            # means that the bib was found but failed
681
            # means that the bib was found but failed
682
- 

Return to bug 18927