(BUG #4521) aqbudgets.pl - Transform undefined budget spent value to 0.00 value
[koha.git] / misc / maintenance / UNIMARC_sync_date_created_with_marc_biblio.pl
blob43b5550a1010fdbb1b121ab562a0169b612f58c6
1 #!/usr/bin/perl
3 # This script should be used only with UNIMARC flavour
4 # It is designed to report some missing information from biblio
5 # table into marc data
7 use strict;
8 use warnings;
10 BEGIN {
11 use FindBin;
12 eval { require "$FindBin::Bin/../kohalib.pl" };
15 use C4::Biblio;
17 sub updateMarc {
18 my $id = shift;
19 my $dbh = C4::Context->dbh;
20 my $field;
21 my $biblio = GetMarcBiblio($id);
23 return unless $biblio;
25 if(!$biblio->field('099'))
27 $field = new MARC::Field('099','','',
28 'c' => '',
29 'd'=>'');
30 $biblio->add_fields($field);
33 $field = $biblio->field('099');
35 my $sth = $dbh->prepare("SELECT DATE_FORMAT(datecreated,'%Y-%m-%d') as datecreated,
36 DATE_FORMAT(timestamp,'%Y-%m-%d') as timestamp,
37 frameworkcode
38 FROM biblio
39 WHERE biblionumber = ?");
40 $sth->execute($id);
41 (my $bibliorow = $sth->fetchrow_hashref);
42 my $frameworkcode = $bibliorow->{'frameworkcode'};
44 $field->update( 'c' => $bibliorow->{'datecreated'},
45 'd' => $bibliorow->{'timestamp'}
48 if(&ModBiblio($biblio, $id, $frameworkcode))
50 print "\r$id";
55 sub process {
57 my $dbh = C4::Context->dbh;
59 my $sth = $dbh->prepare("SELECT biblionumber FROM biblio");
60 $sth->execute();
62 while(my $biblios = $sth->fetchrow_hashref)
64 updateMarc($biblios->{'biblionumber'});
65 print ".";
70 if (lc(C4::Context->preference('marcflavour')) eq "unimarc"){
71 process();
73 else {
74 print "this script is UNIMARC only and should be used only on unimarc databases\n";