(bug #4518) enhance 2.2 to 3.0 scripts

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Nahuel ANGELINETTI 2010-05-17 15:43:37 +02:00 committed by Paul Poulain
parent 5d5a047984
commit e0b029a4f5
3 changed files with 25 additions and 4 deletions

View file

@ -21,7 +21,7 @@ use MARC::File::USMARC;
$|=1;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select m.biblionumber,b.biblioitemnumber from biblio m left join biblioitems b on b.biblionumber=m.biblionumber");
my $sth=$dbh->prepare("SELECT biblionumber, biblioitemnumber FROM biblioitems");
$sth->execute();
my $i=1;
@ -35,6 +35,8 @@ while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){
sub MARCmodbiblionumber{
my ($biblionumber,$biblioitemnumber,$record)=@_;
return unless $record;
my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
my ($tagfield2,$biblioitemtagsubfield) = &GetMarcFromKohaField("biblio.biblioitemnumber","");

View file

@ -43,7 +43,7 @@ while ( my ( $authid,$authtypecode ) = $sth->fetchrow ) {
$string=~s/\-//g;
$string = sprintf("%-*s",26, $string);
substr($string,9,6,"frey50");
unless ($record->subfield(100,"a")){
unless ($record->subfield(100,"a") and length($record->subfield(100,"a")) == 26 ){
$record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>$string));
}
if ($record->field(152)){

View file

@ -13,6 +13,8 @@ if (C4::Context->preference("marcflavour") ne "UNIMARC") {
exit;
}
my $rqbiblios=$dbh->prepare("SELECT biblionumber from biblioitems");
my $rqitemnumber=$dbh->prepare("SELECT itemnumber, biblionumber from items where itemnumber = ? and biblionumber = ?");
$rqbiblios->execute;
$|=1;
while (my ($biblionumber)= $rqbiblios->fetchrow_array){
@ -21,10 +23,27 @@ while (my ($biblionumber)= $rqbiblios->fetchrow_array){
my $marcitem=MARC::Record->new();
$marcitem->encoding('UTF-8');
$marcitem->append_fields($itemfield);
eval{ModItemFromMarc($marcitem,$biblionumber,$itemfield->subfield('9'));};
my $itemnum;
my @itemnumbers = $itemfield->subfield('9');
foreach my $itemnumber ( @itemnumbers ){
$rqitemnumber->execute($itemnumber, $biblionumber);
if( my $row = $rqitemnumber->fetchrow_hashref ){
$itemnum = $row->{itemnumber};
}
}
eval{
if($itemnum){
ModItemFromMarc($marcitem,$biblionumber,$itemnum)
}else{
die("$biblionumber");
}
};
print "\r$biblionumber";
if ($@){
warn "$biblionumber : $@";
warn "Problem with : $biblionumber : $@";
warn $record->as_formatted;
}
}