Changed the status of a Juvinile patron to Adult on his/her 18th birthday
[koha.git] / misc / cronjobs / j2a.pl
1
2 #!/usr/bin/perl -w
3 #run nightly -- changes J to A on someone's 18th birthday
4 use lib '/usr/local/koha/intranet/modules/';
5 use strict;
6 use C4::Context;
7 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
8                                             = localtime(time);
9 $year +=1900;
10 $mon +=1; if ($mon < 10) {$mon = "0".$mon;}
11 if ($mday < 10) {$mday = "0".$mday;}
12
13 $year -=18; #18 year olds here: if your J turns to A before this change here
14 my $dbh=C4::Context->dbh;
15
16 #get today's date, format it and subtract 18 yrs.
17 my $itsyourbirthday = "$year-$mon-$mday";
18
19 my $fixit="UPDATE borrowers SET categorycode='A' WHERE dateofbirth<=? AND dateofbirth!='0000-00-00' AND categorycode='J'";
20
21 my $sth=$dbh->prepare($fixit);
22 my $res = $sth->execute($itsyourbirthday) or die "can't execute";
23 print "$res\n"; #did it work?
24 $dbh->disconnect();