5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch qsearchs dbh);
10 &untaint_argv; #what it sounds like (eww)
13 my $user = shift or die &usage;
14 my $dbh = adminsuidsetup $user;
16 my $sql = "select cp.* from cust_pkg cp, part_pkg pp
17 where cp.pkgpart = pp.pkgpart and pp.plan = 'flat'
18 and cp.cancel is null and cp.bill is not null and cp.bill > 0";
19 my $sth = $dbh->prepare($sql);
20 $sth->execute or die $sth->errstr;
22 while ( $row = $sth->fetchrow_hashref ) {
23 my $bill = $row->{'bill'}; # interpret in local time zone
25 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
28 if ( $hour != 0 || $min != 0 || $sec != 0 ) {
32 my $newbill = mktime($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
33 $sql = "update cust_pkg set bill = ? where pkgnum = ?";
34 my $sth2 = $dbh->prepare($sql);
35 $sth2->execute($newbill,$row->{'pkgnum'}) or die $sth2->errstr;
46 foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
47 #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
49 $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
55 die "Usage:\n freeside-pkg-date-midnight user \n";
64 freeside-pkg-date-midnight - change the time portion of next bill dates on all active anniversary packages to midnight
68 freeside-pkg-date-midnight user
72 user - name of an internal Freeside user