Fixing delete shelf button javascript problem. Now works well with and without javasc...
[koha.git] / misc / migration_tools / rebuild_zebra_idx.pl
1 #!/usr/bin/perl
2 # small script that import an iso2709 file into koha 2.0
3
4 use strict;
5
6 # Koha modules used
7 use MARC::File::USMARC;
8 use MARC::Record;
9 use MARC::Batch;
10 use C4::Context;
11 use C4::Biblio;
12 use Time::HiRes qw(gettimeofday);
13
14 use Getopt::Long;
15 my ( $input_marc_file, $number) = ('',0);
16 my ($confirm);
17 GetOptions(
18     'c' => \$confirm,
19 );
20
21 unless ($confirm) {
22         print <<EOF
23
24 script to write files for zebra DB reindexing. Once it's done, run zebraidx update biblios
25
26 run the script with -c to confirm the reindexing.
27
28 EOF
29 ;#'
30 die;
31 }
32
33 $|=1; # flushes output
34
35 my $dbh = C4::Context->dbh;
36 my $cgidir = C4::Context->intranetdir."/";
37
38 my $starttime = gettimeofday;
39 my $sth = $dbh->prepare("select biblionumber from biblio");
40 $sth->execute;
41 my $i=0;
42 while ((my $biblionumber) = $sth->fetchrow) {
43         my $record = GetMarcBiblio($biblionumber);
44         my $filename = $cgidir."/tmp/BIBLIO".$biblionumber.".iso2709";
45         open F,"> $filename";
46         print F $record->as_usmarc();
47         close F;
48         $i++;
49         print "\r$i" unless ($i % 100);
50 }
51 my $timeneeded = gettimeofday - $starttime;
52 print "\n$i MARC record done in $timeneeded seconds\n";