Reverted menu-left-example.png back to original and cleaned up menu-top-example to...
[freeside.git] / FS / bin / freeside-pull-dsl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Getopt::Std;
5 use FS::UID qw(adminsuidsetup);
6 use FS::Conf;
7 use FS::Record qw(qsearch qsearchs dbh);
8 use FS::svc_dsl;
9 use FS::part_export;
10 use Data::Dumper;
11
12 &untaint_argv;  #what it sounds like  (eww)
13 use vars qw(%opt);
14
15 my $user = shift or die &usage;
16 adminsuidsetup $user;
17
18 my @monitored = qsearch('svc_dsl', { 'monitored' => 'Y' } );
19 foreach my $svc_dsl ( @monitored ) {
20     my @exports = $svc_dsl->part_svc->part_export_dsl_pull;
21     my $svcnum = $svc_dsl->svcnum;
22     warn "either zero or more than one DSL-pulling export attached to svcnum "
23         . "$svcnum, skipping" if ( scalar(@exports) != 1 );
24     my $export = $exports[0];
25     my $error = $export->dsl_pull($svc_dsl); # this will commit to db by default
26     warn "Error pulling DSL svcnum $svcnum: $error" unless $error eq '';
27 }
28
29 ###
30 # subroutines
31 ###
32
33 sub untaint_argv {
34   foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
35     #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
36     # Date::Parse
37     $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
38     $ARGV[$_]=$1;
39   }
40 }
41
42 sub usage {
43   die "Usage:\n  freeside-pull-dsl user \n";
44 }
45
46 ###
47 # documentation
48 ###
49
50 =head1 NAME
51
52 freeside-pull-dsl - Pull DSL order data from telcos/vendors for all monitored DSL orders to update
53
54 =head1 SYNOPSIS
55
56   freeside-pull-dsl user
57
58 =head1 DESCRIPTION
59
60 user - name of an internal Freeside user
61
62 This is still a work in progress - in future may add limiting by exportnum or svcpart or other such stuff.
63
64 =head1 BUGS
65
66 =head1 SEE ALSO
67
68 L<FS::cust_main>, config.html from the base documentation
69
70 =cut
71