fixing rebuildnonmarc.pl
authorPaul POULAIN <paul@koha-fr.org>
Fri, 16 Nov 2007 17:48:32 +0000 (18:48 +0100)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 20 Nov 2007 22:17:44 +0000 (16:17 -0600)
the API of TransformMarcToKoha has changed.
+
For a reason I don't understand (& appear a conception bug), the biblioitemnumber is not shipped in the hash
and it's needed by the UPDATE. So it has to be reintroduced manually.
That's how it's done in Biblio.pm/Sub ModItem.

I think 3.2 will see the end of biblioitems (& it's replacement by something else)

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
misc/rebuildnonmarc.pl

index fd28081..21063d2 100755 (executable)
@@ -45,7 +45,7 @@ my $starttime = gettimeofday;
 #1st of all, find item MARC tag.
 my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.itemnumber",'');
 # $dbh->do("lock tables biblio write, biblioitems write, items write, marc_biblio write, marc_subfield_table write, marc_blob_subfield write, marc_word write, marc_subfield_structure write, stopwords write");
-my $sth = $dbh->prepare("select biblionumber from biblio where biblionumber >54500");
+my $sth = $dbh->prepare("SELECT biblionumber FROM biblio");
 $sth->execute;
 # my ($biblionumbermax) =  $sth->fetchrow;
 # warn "$biblionumbermax <<==";
@@ -89,8 +89,7 @@ sub localNEWmodbiblio {
     $frameworkcode="" unless $frameworkcode;
     my $oldbiblio = TransformMarcToKoha($dbh,$record,$frameworkcode);
     C4::Biblio::_koha_modify_biblio( $dbh, $oldbiblio );
-    C4::Biblio::_koha_modify_biblioitem( $dbh, $oldbiblio );
-
+    C4::Biblio::_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
     return 1;
 }
 
@@ -98,6 +97,13 @@ sub localNEWmoditem {
     my ( $dbh, $record, $biblionumber, $itemnumber, $delete ) = @_;
 #     warn "NEWmoditem $biblionumber / $itemnumber / $delete ".$record->as_formatted;
     my $frameworkcode=GetFrameworkCode($biblionumber);
-    my $olditem = TransformMarcToKoha( $dbh, $record,$frameworkcode );
+    my $olditem = TransformMarcToKoha( $dbh, $record, $frameworkcode, 'items' );
+#     warn "OLDITEM : ".Data::Dumper::Dumper( $olditem );
+    my $sth =  $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?");
+    $sth->execute($biblionumber);
+    my ($biblioitemnumber) = $sth->fetchrow;
+    $sth->finish(); 
+    $olditem->{'biblioitemnumber'} = $biblioitemnumber;
     C4::Biblio::_koha_modify_item( $dbh, $olditem );
+#     die;
 }