&GetISBDView
+ &GetMarcControlnumber
&GetMarcNotes
+ &GetMarcISBN
&GetMarcSubjects
&GetMarcBiblio
&GetMarcAuthors
&GetMarcStructure
&GetMarcFromKohaField
&GetFrameworkCode
- &GetPublisherNameFromIsbn
&TransformKohaToMarc
&CountItemsIssued
$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
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;
#<!-- TMPL_VAR NAME="ocoins_format" -->&rft.au=<!-- TMPL_VAR NAME="author" -->&rft.btitle=<!-- TMPL_VAR NAME="title" -->&rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&rft.pages=<!-- TMPL_VAR NAME="pages" -->&rft.isbn=<!-- TMPL_VAR NAME=amazonisbn -->&rft.aucorp=&rft.place=<!-- TMPL_VAR NAME="place" -->&rft.pub=<!-- TMPL_VAR NAME="publishercode" -->&rft.edition=<!-- TMPL_VAR NAME="edition" -->&rft.series=<!-- TMPL_VAR NAME="series" -->&rft.genre="
}
}
+=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 );
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 )
}
$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;
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 {
$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") ) {
=head1 AUTHOR
-Koha Development Team <info@koha.org>
+Koha Development Team <http://koha-community.org/>
Paul POULAIN paul.poulain@free.fr