&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
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;