MT 2116: Addons to the CSV export
[koha.git] / misc / cronjobs / j2a.pl
blobde648ca2901ee6f11776e2ce9fa5ceead754c865
1 #!/usr/bin/perl
2 #run nightly -- changes J to A on someone's 18th birthday
3 use strict;
4 BEGIN {
5 # find Koha's Perl modules
6 # test carefully before changing this
7 use FindBin;
8 eval { require "$FindBin::Bin/../kohalib.pl" };
11 use C4::Context;
12 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
13 = localtime(time);
14 $year +=1900;
15 $mon +=1; if ($mon < 10) {$mon = "0".$mon;}
16 if ($mday < 10) {$mday = "0".$mday;}
18 $year -=18; #18 year olds here: if your J turns to A before this change here
19 my $dbh=C4::Context->dbh;
21 #get today's date, format it and subtract 18 yrs.
22 my $itsyourbirthday = "$year-$mon-$mday";
24 my $query=qq|UPDATE borrowers
25 SET categorycode='A',
26 guarantorid ='0'
27 WHERE dateofbirth<=?
28 AND dateofbirth!='0000-00-00'
29 AND categorycode IN (select categorycode from categories where category_type='C')|;
30 my $sth=$dbh->prepare($query);
31 my $res = $sth->execute($itsyourbirthday) or die "can't execute";
32 print "$res\n"; #did it work?
33 $dbh->disconnect();