X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FBiblio.pm;h=7eb312484d774376f070b193360490d7235f9670;hb=aa398ed055a7226ba02d6559b297cb172b3ce3df;hp=11767a72acb2f77e05b7bf802897b64cbb3c22ec;hpb=8480f56370e2e52995c3de2923985abcd9aad931;p=koha_fer diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 11767a72ac..7eb312484d 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -67,7 +67,9 @@ BEGIN { &GetISBDView + &GetMarcControlnumber &GetMarcNotes + &GetMarcISBN &GetMarcSubjects &GetMarcBiblio &GetMarcAuthors @@ -81,7 +83,6 @@ BEGIN { &GetMarcStructure &GetMarcFromKohaField &GetFrameworkCode - &GetPublisherNameFromIsbn &TransformKohaToMarc &CountItemsIssued @@ -325,6 +326,14 @@ sub ModBiblio { $record->append_fields($field); } + foreach my $field ($record->fields()) { + if (! $field->is_control_field()) { + if (scalar($field->subfields()) == 0) { + $record->delete_fields($field); + } + } + } + # update biblionumber and biblioitemnumber in MARC # FIXME - this is assuming a 1 to 1 relationship between # biblios and biblioitems @@ -1198,6 +1207,7 @@ sub GetCOinSBiblio { my $coins_value = "ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A$mtx$genre$title&rft.isbn=$isbn&rft.issn=$issn&rft.aulast=$aulast&rft.aufirst=$aufirst$oauthors&rft.pub=$publisher&rft.date=$pubyear"; $coins_value =~ s/(\ |&[^a])/\+/g; + $coins_value =~ s/\"/\"\;/g; #&rft.au=&rft.btitle=&rft.date=&rft.pages=&rft.isbn=&rft.aucorp=&rft.place=&rft.pub=&rft.edition=&rft.series=&rft.genre=" @@ -1253,6 +1263,68 @@ sub GetAuthorisedValueDesc { } } +=head2 GetMarcControlnumber + + $marccontrolnumber = GetMarcControlnumber($record,$marcflavour); + +Get the control number / record Identifier from the MARC record and return it. + +=cut + +sub GetMarcControlnumber { + my ( $record, $marcflavour ) = @_; + my $controlnumber = ""; + # Control number or Record identifier are the same field in MARC21 and UNIMARC + # Keep $marcflavour for possible later use + if ($marcflavour eq "MARC21" || $marcflavour eq "UNIMARC") { + my $controlnumberField = $record->field('001'); + if ($controlnumberField) { + $controlnumber = $controlnumberField->data(); + } + } + return $controlnumber; +} + +=head2 GetMarcISBN + + $marcisbnsarray = GetMarcISBN( $record, $marcflavour ); + +Get all ISBNs from the MARC record and returns them in an array. +ISBNs stored in differents places depending on MARC flavour + +=cut + +sub GetMarcISBN { + my ( $record, $marcflavour ) = @_; + my $scope; + if ( $marcflavour eq "MARC21" ) { + $scope = '020'; + } else { # assume unimarc if not marc21 + $scope = '010'; + } + my @marcisbns; + my $isbn = ""; + my $tag = ""; + my $marcisbn; + foreach my $field ( $record->field($scope) ) { + my $value = $field->as_string(); + if ( $isbn ne "" ) { + $marcisbn = { marcisbn => $isbn, }; + push @marcisbns, $marcisbn; + $isbn = $value; + } + if ( $isbn ne $value ) { + $isbn = $isbn . " " . $value; + } + } + + if ($isbn) { + $marcisbn = { marcisbn => $isbn }; + push @marcisbns, $marcisbn; #load last tag into array + } + return \@marcisbns; +} # end GetMarcISBN + =head2 GetMarcNotes $marcnotesarray = GetMarcNotes( $record, $marcflavour ); @@ -1568,36 +1640,6 @@ sub GetFrameworkCode { return $frameworkcode; } -=head2 GetPublisherNameFromIsbn - - $name = GetPublishercodeFromIsbn($isbn); - if(defined $name){ - ... - } - -=cut - -sub GetPublisherNameFromIsbn($) { - my $isbn = shift; - $isbn =~ s/[- _]//g; - $isbn =~ s/^0*//; - my @codes = ( split '-', DisplayISBN($isbn) ); - my $code = $codes[0] . $codes[1] . $codes[2]; - my $dbh = C4::Context->dbh; - my $query = qq{ - SELECT distinct publishercode - FROM biblioitems - WHERE isbn LIKE ? - AND publishercode IS NOT NULL - LIMIT 1 - }; - my $sth = $dbh->prepare($query); - $sth->execute("$code%"); - my $name = $sth->fetchrow; - return $name if length $name; - return undef; -} - =head2 TransformKohaToMarc $record = TransformKohaToMarc( $hash ) @@ -1638,13 +1680,18 @@ sub TransformKohaToMarcOneField { } $sth->execute( $frameworkcode, $kohafieldname ); if ( ( $tagfield, $tagsubfield ) = $sth->fetchrow ) { + my @values = split(/\s?\|\s?/, $value, -1); + + foreach my $itemvalue (@values){ my $tag = $record->field($tagfield); if ($tag) { - $tag->update( $tagsubfield => $value ); + $tag->add_subfields( $tagsubfield => $itemvalue ); $record->delete_field($tag); $record->insert_fields_ordered($tag); - } else { - $record->add_fields( $tagfield, " ", " ", $tagsubfield => $value ); + } + else { + $record->add_fields( $tagfield, " ", " ", $tagsubfield => $itemvalue ); + } } } return $record; @@ -2272,6 +2319,19 @@ sub PrepareItemrecordDisplay { push @authorised_values, $itemtype; $authorised_lib{$itemtype} = $description; } + #---- class_sources + } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) { + push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); + + my $class_sources = GetClassSources(); + my $default_source = C4::Context->preference("DefaultClassificationSource"); + + foreach my $class_source (sort keys %$class_sources) { + next unless $class_sources->{$class_source}->{'used'} or + ($class_source eq $default_source); + push @authorised_values, $class_source; + $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'}; + } #---- "true" authorised value } else { @@ -3204,6 +3264,15 @@ sub ModBiblioMarc { $record->insert_grouped_field( MARC::Field->new( 100, "", "", "a" => $string ) ); } } + + #enhancement 5374: update transaction date (005) for marc21/unimarc + if($encoding =~ /MARC21|UNIMARC/) { + my @a= (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++; + # YY MM DD HH MM SS (update year and month) + my $f005= $record->field('005'); + $f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005; + } + my $oldRecord; if ( C4::Context->preference("NoZebra") ) { @@ -3392,7 +3461,7 @@ __END__ =head1 AUTHOR -Koha Development Team +Koha Development Team Paul POULAIN paul.poulain@free.fr