2 # This script finds and fixes missing 090 fields in Koha for MARC21
3 # Written by TG on 01/10/2005
4 # Revised by Joshua Ferraro on 03/31/2006
6 #use warnings; FIXME - Bug 2505
8 # find Koha's Perl modules
9 # test carefully before changing this
11 eval { require "$FindBin::Bin/../../kohalib.pl" };
19 use MARC
::File
::USMARC
;
22 my $dbh = C4
::Context
->dbh;
24 my $sth=$dbh->prepare("select biblionumber,timestamp from biblioitems");
27 $|=1; # flushes output
28 print "Creating/updating field 100 if needed\n";
29 while (my ($biblionumber,$time)=$sth->fetchrow ){
31 # print "record : $biblionumber \n";
32 my $record = GetMarcBiblio
({ biblionumber
=> $biblionumber });
33 # print "=> ".$record->as_formatted;
34 MARCmodrecord
($biblionumber,$record,$time) if ($record);
39 my ($biblionumber,$record,$time)=@_;
40 # warn "AVANT : ".$record->as_formatted;
42 $record->leader(' nac 22 1u 4500');
45 if ($record->field(100)) {
46 $string = substr($record->subfield(100,"a")." ",0,35);
47 my $f100 = $record->field(100);
48 $record->delete_field($f100);
50 $string = POSIX
::strftime
("%Y%m%d", localtime);
52 $string = sprintf("%-*s",35, $string);
54 substr($string,22,6,"frey50");
55 unless ($record->subfield(100,"a")){
56 $record->insert_fields_ordered(MARC
::Field
->new(100,"","","a"=>"$string"));
59 &ModBiblioMarc
($record,$biblionumber,'');
60 print "\r$biblionumber" unless ( $biblionumber % 100 );