X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_svc.pm;h=65a76e40026c23a1a961bdaed9cd20748ced70f9;hp=db39ea9ae715ab0977ca5bc26b2630ada2f612c5;hb=626f5cd83480c923e7657e34fabfe1256a07e27d;hpb=57f5975a062022e280680feed1f692f3e937414b diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index db39ea9ae..65a76e400 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -53,6 +53,8 @@ L, and L, among others. =item disabled - Disabled flag, empty or `Y' +=item preserve - Preserve after cancellation, empty or 'Y' + =back =head1 METHODS @@ -190,6 +192,8 @@ sub insert { } } + # XXX shouldn't this update fixed values? + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; @@ -381,6 +385,8 @@ sub check { || $self->ut_text('svc') || $self->ut_alpha('svcdb') || $self->ut_enum('disabled', [ '', 'Y' ] ) + || $self->ut_enum('preserve', [ '', 'Y' ] ) + || $self->ut_enum('selfservice_access', [ '', 'hidden', 'readonly' ] ) ; return $error if $error; @@ -431,6 +437,7 @@ sub part_export { my $self = shift; my %search; $search{'exporttype'} = shift if @_; + sort { $a->weight <=> $b->weight } map { qsearchs('part_export', { 'exportnum' => $_->exportnum, %search } ) } qsearch('export_svc', { 'svcpart' => $self->svcpart } ); } @@ -459,6 +466,17 @@ sub part_export_did { grep $_->can('get_dids'), $self->part_export; } +=item part_export_dsl_pull + +Returns a list of any exports (see L) for this service that +are capable of pulling/pushing DSL orders. + +=cut + +sub part_export_dsl_pull { + my $self = shift; + grep $_->can('dsl_pull'), $self->part_export; +} =item cust_svc [ PKGPART ] @@ -658,7 +676,8 @@ the following keys: =item def_label - Optional description of the field in the context of service definitions -=item type - Currently "text", "select", "disabled", or "radius_usergroup_selector" +=item type - Currently "text", "select", "checkbox", "textarea", "disabled", +some components specified by "select-.*.html", and a bunch more... =item disable_default - This field should not allow a default value in service definitions @@ -720,11 +739,17 @@ sub process { my $old = qsearchs('part_svc', { 'svcpart' => $param->{'svcpart'} }) if $param->{'svcpart'}; - $param->{'svc_acct__usergroup'} = - ref($param->{'svc_acct__usergroup'}) - ? join(',', @{$param->{'svc_acct__usergroup'}} ) - : $param->{'svc_acct__usergroup'}; + #unmunge cgp_accessmodes (falze laziness-ish w/edit/process/svc_acct.cgi) + $param->{'svc_acct__cgp_accessmodes'} ||= + join(' ', sort + grep { $_ !~ /^(flag|label)$/ } + map { /^svc_acct__cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; } + grep $param->{$_}, + grep /^svc_acct__cgp_accessmodes_([\w\/]+)$/, + keys %$param + ); + my $new = new FS::part_svc ( { map { $_ => $param->{$_}; @@ -732,14 +757,17 @@ sub process { } ( fields('part_svc'), map { my $svcdb = $_; my @fields = fields($svcdb); - push @fields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge + push @fields, 'usergroup' if $svcdb eq 'svc_acct' + or $svcdb eq 'svc_broadband'; #kludge map { my $f = $svcdb.'__'.$_; - if ( $param->{ $f.'_flag' } =~ /^[MA]$/ ) { + my $flag = $param->{ $f.'_flag' } || ''; #silence warnings + if ( $flag =~ /^[MAH]$/ ) { $param->{ $f } = delete( $param->{ $f.'_classnum' } ); } - if ( $param->{ $f.'_flag' } =~ /^S$/ ) { + if ( $flag =~ /^S$/ + or $_ eq 'usergroup' ) { $param->{ $f } = ref($param->{ $f }) ? join(',', @{$param->{ $f }} ) : $param->{ $f }; @@ -790,6 +818,9 @@ sub process_bulk_cust_svc { my $param = thaw(decode_base64(shift)); warn Dumper($param) if $DEBUG; + local($FS::svc_Common::noexport_hack) = 1 + if $param->{'noexport'}; + my $old_part_svc = qsearchs('part_svc', { 'svcpart' => $param->{'old_svcpart'} } ); @@ -838,6 +869,49 @@ sub process_bulk_cust_svc { } +sub _upgrade_data { #class method + my ($class, %opts) = @_; + + my @part_svc_column = qsearch('part_svc_column', { 'columnname' => 'usergroup' }); + foreach my $col ( @part_svc_column ) { + next if $col->columnvalue =~ /^[\d,]+$/ || !$col->columnvalue; + my @groupnames = split(',',$col->columnvalue); + my @groupnums; + my $error = ''; + foreach my $groupname ( @groupnames ) { + my $g = qsearchs('radius_group', { 'groupname' => $groupname } ); + unless ( $g ) { + $g = new FS::radius_group { + 'groupname' => $groupname, + 'description' => $groupname, + }; + $error = $g->insert; + die $error if $error; + } + push @groupnums, $g->groupnum; + } + $col->columnvalue(join(',',@groupnums)); + $error = $col->replace; + die $error if $error; + } + + my @badlabels = qsearch({ + 'table' => 'part_svc_column', + 'hashref' => {}, + 'extra_sql' => 'WHERE columnlabel IN ('. + "'Descriptive label for this particular device.',". + "'IP address. Leave blank for automatic assignment.',". + "'Maximum upload speed for this service in Kbps. 0 denotes unlimited.',". + "'Maximum download speed for this service in Kbps. 0 denotes unlimited.')" + }); + foreach my $col ( @badlabels ) { + $col->columnlabel(''); + my $error = $col->replace; + die $error if $error; + } + +} + =head1 BUGS Delete is unimplemented.