blob: 708e2fa30d40e9d7645e002b277a50a2a957817a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/perl
use strict;
use FS::UID qw(adminsuidsetup);
use FS::Conf;
use FS::Record qw(qsearch qsearchs);
use FS::cust_main;
use FS::svc_acct;
&untaint_argv; #what it sounds like (eww)
my $user = shift or die &usage;
adminsuidsetup $user;
foreach my $cust_main (
grep { ! scalar($_->invoicing_list) }
qsearch( 'cust_main', {} )
) {
my @dest;
my @cust_pkg = $cust_main->ncancelled_pkgs;
foreach my $cust_pkg ( @cust_pkg ) {
foreach my $cust_svc ( $cust_pkg->cust_svc ) {
my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $cust_svc->svcnum } );
push @dest, $svc_acct->svcnum if $svc_acct;
}
}
push @dest, 'POST' unless @dest;
$cust_main->invoicing_list(\@dest);
}
sub untaint_argv {
foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
$ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
$ARGV[$_]=$1;
}
}
sub usage {
die "Usage:\n\n freeside-setinvoice user\n";
}
|