X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-sqlradius-reset;h=a77bad64f6542f0ee06bdef19ce7aee4b4696895;hb=65a5489102636c5c1351928eed3fa576fbda95bc;hp=94fa68a0673be6465133bf74e459b9b397e7a689;hpb=7b5ee7aa4b9789b230cef4163a06c0dbaa2136e1;p=freeside.git diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset index 94fa68a06..a77bad64f 100755 --- a/FS/bin/freeside-sqlradius-reset +++ b/FS/bin/freeside-sqlradius-reset @@ -6,7 +6,7 @@ use Getopt::Std; use FS::UID qw(adminsuidsetup); use FS::Record qw(qsearch qsearchs); use FS::part_export; -use FS::svc_acct; +#use FS::svc_acct; use FS::cust_svc; getopts("n"); @@ -19,7 +19,7 @@ adminsuidsetup $user; my @exports = (); if ( @ARGV ) { foreach my $exportnum ( @ARGV ) { - foreach my $exporttype (qw( sqlradius sqlradius_withdomain )) { + foreach my $exporttype (qw( sqlradius sqlradius_withdomain phone_sqlradius )) { push @exports, qsearch('part_export', { exportnum => $exportnum, exporttype => $exporttype, } ); } @@ -42,30 +42,45 @@ unless ( $opt_n ) { } } +use FS::svc_Common; +$FS::svc_Common::overlimit_missing_cust_svc_nonfatal_kludge = 1; +$FS::svc_Common::overlimit_missing_cust_svc_nonfatal_kludge = 1; + foreach my $export ( @exports ) { #my @svcparts = map { $_->svcpart } $export->export_svc; my $overlimit_groups = $export->option('overlimit_groups'); - my @svc_acct = - map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) } - map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } - grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } - $export->export_svc; - - foreach my $svc_acct ( @svc_acct ) { - - $svc_acct->check; #set any fixed usergroup so it'll export even if all - #svc_acct records don't have the group yet - - if ($overlimit_groups && $svc_acct->overlimit) { - $svc_acct->usergroup( &{ $svc_acct->_fieldhandlers->{'usergroup'} } - ($svc_acct, $overlimit_groups) - ); + my @svc_x = + map { $_->svc_x } + #map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } + #grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } + # $export->export_svc; + map { @{ $_->[1] } } + grep { scalar( @{ $_->[1] } ) } + map { [ $_, [ qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) ] ] } + $export->export_svc; + + + foreach my $svc_x ( @svc_x ) { + + #$svc_x->check; #set any fixed usergroup so it'll export even if all + # #svc_acct records don't have the group yet + #more efficient? + my $x = $svc_x->setfixed( $svc_x->_fieldhandlers); + unless ( ref($x) ) { + warn "WARNING: can't set fixed usergroups for svcnum ". $svc_x->svcnum. + "\n"; + } + + if ($overlimit_groups && $svc_x->overlimit) { + $svc_x->usergroup( &{ $svc_x->_fieldhandlers->{'usergroup'} } + ($svc_x, $overlimit_groups) + ); } #false laziness with FS::svc_acct::insert (like it matters) - my $error = $export->export_insert($svc_acct); + my $error = $export->export_insert($svc_x); die $error if $error; } @@ -100,5 +115,4 @@ L, L, L =cut - - +1;