5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch qsearchs dbh);
11 &untaint_argv; #what it sounds like (eww)
14 my $user = shift or die &usage;
15 my $dbh = adminsuidsetup $user;
17 my $sql = "select cp.* from cust_pkg cp, part_pkg pp
18 where cp.pkgpart = pp.pkgpart and pp.plan = 'flat'
19 and cp.cancel is null and cp.bill is not null and cp.bill > 0";
20 my $sth = $dbh->prepare($sql);
21 $sth->execute or die $sth->errstr;
23 while ( $row = $sth->fetchrow_hashref ) {
24 my $bill = $row->{'bill'}; # interpret in local time zone
26 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
29 my $date = new Date::Manip::Date;
30 my $err = $date->parse($bill);
32 my $datefixed = $date->calc(?,1);
34 if ( $hour != 0 || $min != 0 || $sec != 0 ) {
38 my $newbill = mktime($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
39 $sql = "update cust_pkg set bill = ? where pkgnum = ?";
40 my $sth2 = $dbh->prepare($sql);
41 $sth2->execute($newbill,$row->{'pkgnum'}) or die $sth2->errstr;
52 foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
53 #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
55 $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
61 die "Usage:\n freeside-pkg-date-midnight user \n";
70 freeside-pkg-date-midnight - change the time portion of next bill dates on all active anniversary packages to midnight
74 freeside-pkg-date-midnight user
78 user - name of an internal Freeside user