From bdade9bc9d2aff6a59ccabfb07d54117169ef19c Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Thu, 20 Dec 2007 15:23:14 +0100 Subject: [PATCH] Adding rebuild field 100$a for Unimarc Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- .../22_to_30/move_marc_to_biblioitems.pl | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/misc/migration_tools/22_to_30/move_marc_to_biblioitems.pl b/misc/migration_tools/22_to_30/move_marc_to_biblioitems.pl index 2cca920631..d55d48b02e 100755 --- a/misc/migration_tools/22_to_30/move_marc_to_biblioitems.pl +++ b/misc/migration_tools/22_to_30/move_marc_to_biblioitems.pl @@ -37,7 +37,13 @@ while (my ($bibid,$biblionumber) = $sth->fetchrow) { my $record = LocalMARCgetbiblio($dbh,$bibid); #Force UTF-8 in record leader $record->encoding('UTF-8'); - $sth_update->execute($record->as_usmarc(),$record->as_xml_record(),$biblionumber); + my $marcflavour; + if (C4::Context->preference("marcflavour")=~/unimarc/i){ + $marcflavour="UNIMARC"; + } else { + $marcflavour="USMARC"; + } + $sth_update->execute($record->as_usmarc(),$record->as_xml_record($marcflavour),$biblionumber); $totaldone++; print "."; print "\r$totaldone / $totaltodo" unless ($totaldone % 100); @@ -141,5 +147,24 @@ sub LocalMARCgetbiblio { $record->add_fields($field); } } + if (C4::Context->preference('marcflavour')=~/unimarc/i){ + $record->leader(' nac 22 1u 4500'); + $update=1; + my $string; + if ($record->field(100)) { + $string = substr($record->subfield(100,"a")." ",0,35); + my $f100 = $record->field(100); + $record->delete_field($f100); + } else { + $string = POSIX::strftime("%Y%m%d", localtime); + $string=~s/\-//g; + $string = sprintf("%-*s",35, $string); + } + substr($string,22,6,"frey50"); + unless ($record->subfield(100,"a")){ + $record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>"$string")); + } + } + return $record; } -- 2.39.5