X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=ferlib2koha.pl;h=f95f52fc60f6a7d875d624db38aa4ba9050afb00;hb=b41b2ce39d87d31118b2e33bd841ae7d00771289;hp=cafff9a5ca400de258e0f6acc9ec44f80e16a5a3;hpb=037febe03a9f09da6caa6c2cdfdad6c1e4f3127f;p=ferlib2koha.git diff --git a/ferlib2koha.pl b/ferlib2koha.pl index cafff9a..f95f52f 100755 --- a/ferlib2koha.pl +++ b/ferlib2koha.pl @@ -3,12 +3,13 @@ use strict; use DBI; use Data::Dump qw/dump/; +use Algorithm::CheckDigits; $|++; my $import = { - borrowers => 1, - issues => 1, + borrowers => 0, + issues => 0, }; my $f = DBI->connect("dbi:SQLite:dbname=knjiznica.sqlite","","", { RaiseError => 1, AutoCommit => 0 }) || die $DBI::errstr; @@ -231,4 +232,17 @@ set onloan = date_due, datelastborrowed = issuedate }; # import->{issues} + +my $sth = $k->prepare(qq{ select itemnumber,barcode from items }); +my $sth_update = $k->prepare(qq{ update items set barcode=? where itemnumber=? }); + +$sth->execute; +warn "update ", $sth->rows, " barcodes"; + +my $ean = CheckDigits('ean'); + +while( my $row = $sth->fetchrow_hashref ) { + $sth_update->execute( $ean->complete( sprintf('%012d', $row->{barcode}) ), $row->{itemnumber} ); +} + $k->commit;