Koha/misc/migration_tools/22_to_30/missing090field.pl
tipaul a481fad4b7 Code cleaning :
== Biblio.pm cleaning (useless) ==
* some sub declaration dropped
* removed modbiblio sub
* removed moditem sub
* removed newitems. It was used only in finishrecieve. Replaced by a Koha2Marc+AddItem, that is better.
* removed MARCkoha2marcItem
* removed MARCdelsubfield declaration
* removed MARCkoha2marcBiblio

== Biblio.pm cleaning (naming conventions) ==
* MARCgettagslib renamed to GetMarcStructure
* MARCgetitems renamed to GetMarcItem
* MARCfind_frameworkcode renamed to GetFrameworkCode
* MARCmarc2koha renamed to TransformMarcToKoha
* MARChtml2marc renamed to TransformHtmlToMarc
* MARChtml2xml renamed to TranformeHtmlToXml
* zebraop renamed to ModZebra

== MARC=OFF ==
* removing MARC=OFF related scripts (in cataloguing directory)
* removed checkitems (function related to MARC=off feature, that is completly broken in head. If someone want to reintroduce it, hard work coming...)
* removed getitemsbybiblioitem (used only by MARC=OFF scripts, that is removed as well)
2007-03-29 13:30:31 +00:00

50 lines
1.4 KiB
Perl
Executable file

#!/usr/bin/perl
# This script finds and fixes missing 090 fields in Koha for MARC21
# Written by TG on 01/10/2005
# Revised by Joshua Ferraro on 03/31/2006
use strict;
# Koha modules used
use C4::Context;
use C4::Biblio;
use MARC::Record;
use MARC::File::USMARC;
$|=1;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select m.biblionumber,b.biblioitemnumber from marc_biblio m left join biblioitems b on b.biblionumber=m.biblionumber");
$sth->execute();
my $i=1;
while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){
my $record = GetMarcBiblio($biblionumber);
print ".";
print "\r$i" unless $i %100;
MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record);
}
sub MARCmodbiblionumber{
my ($biblionumber,$biblioitemnumber,$record)=@_;
my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblionumber","");
my ($tagfield2,$biblioitemtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblioitemnumber","");
my $update=0;
my @tags = $record->field($tagfield);
if (!@tags){
my $newrec = MARC::Field->new( $tagfield,'','', $biblionumtagsubfield => $biblionumber,$biblioitemtagsubfield=>$biblioitemnumber);
$record->append_fields($newrec);
$update=1;
}
if ($update){
&MARCmodbiblio($dbh,$biblionumber,$record,'',0);
print "\n modified : $biblionumber \n";
}
}
END;