2 use base qw(FS::Record);
7 use FS::Record qw( qsearch qsearchs fields dbh );
8 use FS::Schema qw( dbdef );
9 use FS::part_svc_column;
13 use FS::part_svc_class;
15 FS::UID->install_callback(sub {
16 # preload the cache and make sure all modules load
17 my $svc_defs = FS::part_svc->_svc_defs;
24 FS::part_svc - Object methods for part_svc objects
30 $record = new FS::part_svc \%hash
31 $record = new FS::part_svc { 'column' => 'value' };
33 $error = $record->insert;
34 $error = $record->insert( [ 'pseudofield' ] );
35 $error = $record->insert( [ 'pseudofield' ], \%exportnums );
37 $error = $new_record->replace($old_record);
38 $error = $new_record->replace($old_record, '1.3-COMPAT', [ 'pseudofield' ] );
39 $error = $new_record->replace($old_record, '1.3-COMPAT', [ 'pseudofield' ], \%exportnums );
41 $error = $record->delete;
43 $error = $record->check;
47 An FS::part_svc represents a service definition. FS::part_svc inherits from
48 FS::Record. The following fields are currently supported:
52 =item svcpart - primary key (assigned automatically for new service definitions)
54 =item svc - text name of this service definition
56 =item svcdb - table used for this service. See L<FS::svc_acct>,
57 L<FS::svc_domain>, and L<FS::svc_forward>, among others.
59 =item classnum - Optional service class (see L<FS::svc_class>)
61 =item disabled - Disabled flag, empty or `Y'
63 =item preserve - Preserve after cancellation, empty or 'Y'
65 =item selfservice_access - Access allowed to the service via self-service:
66 empty for full access, "readonly" for read-only, "hidden" to hide it entirely
68 =item restrict_edit_password - Require the "Provision customer service" access
69 right to change the password field, rather than just "Edit password". Only
70 relevant to svc_acct for now.
72 =item has_router - Allow the service to have an L<FS::router> connected
73 through it. Probably only relevant to svc_broadband, svc_acct, and svc_dsl
84 Creates a new service definition. To add the service definition to the
85 database, see L<"insert">.
89 sub table { 'part_svc'; }
91 =item insert [ EXTRA_FIELDS_ARRAYREF [ , EXPORTNUMS_HASHREF [ , JOB ] ] ]
93 Adds this service definition to the database. If there is an error, returns
94 the error, otherwise returns false.
96 The following pseudo-fields may be defined, and will be maintained in
97 the part_svc_column table appropriately (see L<FS::part_svc_column>).
101 =item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
103 =item I<svcdb>__I<field>_label
105 =item I<svcdb>__I<field>_flag - defines I<svcdb>__I<field> action: null or empty (no default), `D' for default, `F' for fixed (unchangeable), , `S' for selectable choice, `M' for manual selection from inventory, or `A' for automatic selection from inventory. For virtual fields, can also be 'X' for excluded.
107 =item I<svcdb>__I<field>_required - I<field> should always have a true value
111 If you want to add part_svc_column records for fields that do not exist as
112 fields in the I<svcdb> table, make sure to list then in
113 EXTRA_FIELDS_ARRAYREF also.
115 If EXPORTNUMS_HASHREF is specified (keys are exportnums and values are
116 boolean), the appopriate export_svc records will be inserted.
125 @fields = @{shift(@_)} if @_;
126 my $exportnums = shift || {};
130 local $SIG{HUP} = 'IGNORE';
131 local $SIG{INT} = 'IGNORE';
132 local $SIG{QUIT} = 'IGNORE';
133 local $SIG{TERM} = 'IGNORE';
134 local $SIG{TSTP} = 'IGNORE';
135 local $SIG{PIPE} = 'IGNORE';
137 my $oldAutoCommit = $FS::UID::AutoCommit;
138 local $FS::UID::AutoCommit = 0;
141 my $error = $self->SUPER::insert;
143 $dbh->rollback if $oldAutoCommit;
147 # add part_svc_column records
149 my $svcdb = $self->svcdb;
150 foreach my $field (fields($svcdb), @fields) {
151 next if $field eq 'svcnum';
152 my $prefix = $svcdb.'__';
153 if ( defined( $self->getfield($prefix.$field.'_flag'))
154 or defined($self->getfield($prefix.$field.'_required'))
155 or length($self->getfield($prefix.$field.'_label'))
157 my $part_svc_column = $self->part_svc_column($field);
158 my $previous = qsearchs('part_svc_column', {
159 'svcpart' => $self->svcpart,
160 'columnname' => $field,
163 my $flag = $self->getfield($prefix.$field.'_flag');
164 my $label = $self->getfield($prefix.$field.'_label');
165 my $required = $self->getfield($prefix.$field.'_required') ? 'Y' : '';
166 if ( uc($flag) =~ /^([A-Z])$/ || $label !~ /^\s*$/ ) {
168 if ( uc($flag) =~ /^([A-Z])$/ ) {
169 my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse}
171 $part_svc_column->setfield('columnflag', $1);
172 $part_svc_column->setfield('columnvalue',
173 &$parser($self->getfield($prefix.$field))
177 $part_svc_column->setfield('columnlabel', $label)
178 if $label !~ /^\s*$/;
180 $part_svc_column->setfield('required', $required);
183 $error = $part_svc_column->replace($previous);
185 $error = $part_svc_column->insert;
189 $error = $previous ? $previous->delete : '';
192 $dbh->rollback if $oldAutoCommit;
199 # add export_svc records
200 my @exportnums = grep $exportnums->{$_}, keys %$exportnums;
201 my $slice = 100/scalar(@exportnums) if @exportnums;
203 foreach my $exportnum ( @exportnums ) {
204 my $export_svc = new FS::export_svc ( {
205 'exportnum' => $exportnum,
206 'svcpart' => $self->svcpart,
207 'role' => $exportnums->{$exportnum},
209 $error = $export_svc->insert($job, $slice*$done++, $slice);
211 $dbh->rollback if $oldAutoCommit;
216 # XXX shouldn't this update fixed values?
218 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
225 Currently unimplemented. Set the "disabled" field instead.
230 return "Can't (yet?) delete service definitions.";
231 # check & make sure the svcpart isn't in cust_svc or pkg_svc (in any packages)?
234 =item replace OLD_RECORD [ '1.3-COMPAT' [ , EXTRA_FIELDS_ARRAYREF [ , EXPORTNUMS_HASHREF [ , JOB ] ] ] ]
236 Replaces OLD_RECORD with this one in the database. If there is an error,
237 returns the error, otherwise returns false.
241 TODOC: EXTRA_FIELDS_ARRAYREF (same as insert method)
248 my ( $new, $old ) = ( shift, shift );
253 if ( @_ && $_[0] eq '1.3-COMPAT' ) {
256 @fields = @{shift(@_)} if @_;
257 $exportnums = @_ ? shift : '';
260 return 'non-1.3-COMPAT interface not yet written';
264 return "Can't change svcdb for an existing service definition!"
265 unless $old->svcdb eq $new->svcdb;
267 local $SIG{HUP} = 'IGNORE';
268 local $SIG{INT} = 'IGNORE';
269 local $SIG{QUIT} = 'IGNORE';
270 local $SIG{TERM} = 'IGNORE';
271 local $SIG{TSTP} = 'IGNORE';
272 local $SIG{PIPE} = 'IGNORE';
274 my $oldAutoCommit = $FS::UID::AutoCommit;
275 local $FS::UID::AutoCommit = 0;
278 my $error = $new->SUPER::replace( $old );
280 $dbh->rollback if $oldAutoCommit;
284 if ( $compat eq '1.3' ) {
286 # maintain part_svc_column records
288 my $svcdb = $new->svcdb;
289 foreach my $field (fields($svcdb),@fields) {
290 next if $field eq 'svcnum';
291 my $prefix = $svcdb.'__';
292 if ( defined( $new->getfield($prefix.$field.'_flag'))
293 or defined($new->getfield($prefix.$field.'_required'))
294 or length($new->getfield($prefix.$field.'_label'))
296 my $part_svc_column = $new->part_svc_column($field);
297 my $previous = qsearchs('part_svc_column', {
298 'svcpart' => $new->svcpart,
299 'columnname' => $field,
302 my $flag = $new->getfield($svcdb.'__'.$field.'_flag');
303 my $label = $new->getfield($svcdb.'__'.$field.'_label');
304 my $required = $new->getfield($svcdb.'__'.$field.'_required') ? 'Y' : '';
306 if ( uc($flag) =~ /^([A-Z])$/ || $label !~ /^\s*$/ ) {
308 if ( uc($flag) =~ /^([A-Z])$/ ) {
309 $part_svc_column->setfield('columnflag', $1);
310 my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse}
312 $part_svc_column->setfield('columnvalue',
313 &$parser($new->getfield($svcdb.'__'.$field))
316 $part_svc_column->setfield('columnflag', '');
317 $part_svc_column->setfield('columnvalue', '');
320 $part_svc_column->setfield('columnlabel', $label)
321 if $label !~ /^\s*$/;
323 $part_svc_column->setfield('required', $required);
326 $error = $part_svc_column->replace($previous);
328 $error = $part_svc_column->insert;
331 $error = $previous ? $previous->delete : '';
334 $dbh->rollback if $oldAutoCommit;
340 # maintain export_svc records
342 if ( $exportnums ) { # hash of exportnum => role
344 #false laziness w/ edit/process/agent_type.cgi
345 #and, more importantly, with m2m_Common
346 my @new_export_svc = ();
347 foreach my $part_export ( qsearch('part_export', {}) ) {
348 my $exportnum = $part_export->exportnum;
350 'exportnum' => $exportnum,
351 'svcpart' => $new->svcpart,
353 my $export_svc = qsearchs('export_svc', $hashref);
356 my $old_role = $export_svc->role || 1; # 1 = null in the db
357 if ( ! $exportnums->{$exportnum}
358 or $old_role ne $exportnums->{$exportnum} ) {
360 $error = $export_svc->delete;
362 $dbh->rollback if $oldAutoCommit;
365 undef $export_svc; # on a role change, force it to be reinserted
369 if ( ! $export_svc && $exportnums->{$exportnum} ) {
370 # also applies if it's been undef'd because of role change
371 $hashref->{role} = $exportnums->{$exportnum};
372 push @new_export_svc, new FS::export_svc ( $hashref );
377 my $slice = 100/scalar(@new_export_svc) if @new_export_svc;
379 foreach my $export_svc (@new_export_svc) {
380 $error = $export_svc->insert($job, $slice*$done++, $slice);
382 $dbh->rollback if $oldAutoCommit;
386 $error = $job->update_statustext( int( $slice * $done ) );
388 $dbh->rollback if $oldAutoCommit;
397 $dbh->rollback if $oldAutoCommit;
398 return 'non-1.3-COMPAT interface not yet written';
402 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
409 Checks all fields to make sure this is a valid service definition. If there is
410 an error, returns the error, otherwise returns false. Called by the insert
420 $self->ut_numbern('svcpart')
421 || $self->ut_text('svc')
422 || $self->ut_alpha('svcdb')
423 || $self->ut_flag('disabled')
424 || $self->ut_flag('preserve')
425 || $self->ut_enum('selfservice_access', [ '', 'hidden', 'readonly' ] )
426 || $self->ut_foreign_keyn('classnum', 'part_svc_class', 'classnum' )
427 || $self->ut_flag('restrict_edit_password')
428 || $self->ut_flag('has_router')
430 return $error if $error;
432 my @fields = eval { fields( $self->svcdb ) }; #might die
433 return "Unknown svcdb: ". $self->svcdb. " (Error: $@)"
439 =item part_svc_column COLUMNNAME
441 Returns the part_svc_column object (see L<FS::part_svc_column>) for the given
442 COLUMNNAME, or a new part_svc_column object if none exists.
446 sub part_svc_column {
447 my( $self, $columnname) = @_;
449 qsearchs('part_svc_column', {
450 'svcpart' => $self->svcpart,
451 'columnname' => $columnname,
453 ) or new FS::part_svc_column {
454 'svcpart' => $self->svcpart,
455 'columnname' => $columnname,
459 =item all_part_svc_column
463 sub all_part_svc_column {
465 qsearch('part_svc_column', { 'svcpart' => $self->svcpart } );
468 =item part_export [ EXPORTTYPE ]
470 Returns a list of all exports (see L<FS::part_export>) for this service, or,
471 if an export type is specified, only returns exports of the given type.
478 $search{'exporttype'} = shift if @_;
479 map { $_ } #behavior of sort undefined in scalar context
480 sort { $a->weight <=> $b->weight }
481 map { qsearchs('part_export', { 'exportnum'=>$_->exportnum, %search } ) }
482 qsearch('export_svc', { 'svcpart'=>$self->svcpart } );
485 =item part_export_usage
487 Returns a list of any exports (see L<FS::part_export>) for this service that
488 are capable of reporting usage information.
492 sub part_export_usage {
494 grep $_->can('usage_sessions'), $self->part_export;
497 =item part_export_did
499 Returns a list of any exports (see L<FS::part_export>) for this service that
500 are capable of returing available DID (phone number) information.
504 sub part_export_did {
506 grep $_->can_get_dids, $self->part_export;
509 =item part_export_dsl_pull
511 Returns a list of any exports (see L<FS::part_export>) for this service that
512 are capable of pulling/pushing DSL orders.
516 sub part_export_dsl_pull {
518 grep $_->can('dsl_pull'), $self->part_export;
521 =item cust_svc [ PKGPART ]
523 Returns a list of associated customer services (FS::cust_svc records).
525 If a PKGPART is specified, returns the customer services which are contained
526 within packages of that type (see L<FS::part_pkg>). If PKGPARTis specified as
527 B<0>, returns unlinked customer services.
534 my $hashref = { 'svcpart' => $self->svcpart };
536 my( $addl_from, $extra_sql ) = ( '', '' );
539 if ( $pkgpart =~ /^(\d+)$/ ) {
540 $addl_from = 'LEFT JOIN cust_pkg USING ( pkgnum )';
541 $extra_sql = "AND pkgpart = $1";
542 } elsif ( $pkgpart eq '0' ) {
543 $hashref->{'pkgnum'} = '';
548 'table' => 'cust_svc',
549 'addl_from' => $addl_from,
550 'hashref' => $hashref,
551 'extra_sql' => $extra_sql,
555 =item num_cust_svc [ PKGPART ]
557 Returns the number of associated customer services (FS::cust_svc records).
559 If a PKGPART is specified, returns the number of customer services which are
560 contained within packages of that type (see L<FS::part_pkg>). If PKGPART
561 is specified as B<0>, returns the number of unlinked customer services.
568 return $self->{Hash}{num_cust_svc}
569 if !@_ && exists($self->{Hash}{num_cust_svc});
571 my @param = ( $self->svcpart );
573 my( $join, $and ) = ( '', '' );
577 $join = 'LEFT JOIN cust_pkg USING ( pkgnum )';
578 $and = 'AND pkgpart = ?';
579 push @param, $pkgpart;
580 } elsif ( $pkgpart eq '0' ) {
581 $and = 'AND pkgnum IS NULL';
585 my $sth = dbh->prepare(
586 "SELECT COUNT(*) FROM cust_svc $join WHERE svcpart = ? $and"
587 ) or die dbh->errstr;
588 $sth->execute(@param)
590 $sth->fetchrow_arrayref->[0];
593 =item num_cust_svc_cancelled
595 Returns the number of associated customer services that are
596 attached to cancelled packages.
600 sub num_cust_svc_cancelled {
602 my $sth = dbh->prepare(
603 "SELECT COUNT(*) FROM cust_svc
604 LEFT JOIN cust_pkg USING ( pkgnum )
606 AND cust_pkg.cancel IS NOT NULL"
607 ) or die dbh->errstr;
608 $sth->execute($self->svcpart)
610 $sth->fetchrow_arrayref->[0];
615 Returns a list of associated FS::svc_* records.
621 map { $_->svc_x } $self->cust_svc;
636 return $svc_defs if $svc_defs; #cache
638 my $conf = new FS::Conf;
640 #false laziness w/part_pkg.pm::plan_info
643 foreach my $INC ( @INC ) {
644 warn "globbing $INC/FS/svc_*.pm\n" if $DEBUG;
645 foreach my $file ( glob("$INC/FS/svc_*.pm") ) {
647 warn "attempting to load service table info from $file\n" if $DEBUG;
648 $file =~ /\/(\w+)\.pm$/ or do {
649 warn "unrecognized file in $INC/FS/: $file\n";
654 if ( $mod =~ /^svc_[A-Z]/ or $mod =~ /^(svc_acct_pop|svc_export_machine)$/ ) {
655 warn "skipping FS::$mod" if $DEBUG;
659 eval "use FS::$mod;";
661 die "error using FS::$mod (skipping): $@\n" if $@;
664 unless ( UNIVERSAL::can("FS::$mod", 'table_info') ) {
665 warn "FS::$mod has no table_info method; skipping";
669 my $info = "FS::$mod"->table_info;
670 unless ( keys %$info ) {
671 warn "FS::$mod->table_info doesn't return info, skipping\n";
674 warn "got info from FS::$mod: $info\n" if $DEBUG;
675 if ( exists($info->{'disabled'}) && $info->{'disabled'} ) {
676 warn "skipping disabled service FS::$mod" if $DEBUG;
681 # all svc_* modules are required to have h_svc_* modules for invoice
682 # display. check for them as early as possible.
683 eval "use FS::h_$mod;";
685 die "couldn't load history record module h_$mod: $@\n";
691 tie my %svc_defs, 'Tie::IxHash',
692 map { $_ => $info{$_}->{'fields'} }
693 sort { $info{$a}->{'display_weight'} <=> $info{$b}->{'display_weight'} }
697 tie my %svc_info, 'Tie::IxHash',
698 map { $_ => $info{$_} }
699 sort { $info{$a}->{'display_weight'} <=> $info{$b}->{'display_weight'} }
703 $svc_info = \%svc_info; #access via svc_table_info
704 $svc_defs = \%svc_defs; #cache
710 Returns a list of all svc_ tables.
716 my $svc_defs = $class->_svc_defs;
717 grep { defined( dbdef->table($_) ) } keys %$svc_defs;
720 =item svc_table_fields TABLE
722 Given a table name, returns a hashref of field names. The field names
723 returned are those with additional (service-definition related) information,
724 not necessarily all database fields of the table. Pseudo-fields may also
725 be returned (i.e. svc_acct.usergroup).
727 Each value of the hashref is another hashref, which can have one or more of
732 =item label - Description of the field
734 =item def_label - Optional description of the field in the context of service definitions
736 =item type - Currently "text", "select", "checkbox", "textarea", "disabled",
737 some components specified by "select-.*.html", and a bunch more...
739 =item disable_default - This field should not allow a default value in service definitions
741 =item disable_fixed - This field should not allow a fixed value in service definitions
743 =item disable_inventory - This field should not allow inventory values in service definitions
745 =item select_list - If type is "text", this can be a listref of possible values.
747 =item select_table - An alternative to select_list, this defines a database table with the possible choices.
749 =item select_key - Used with select_table, this is the field name of keys
751 =item select_label - Used with select_table, this is the field name of labels
753 =item select_allow_empty - Used with select_table, adds an empty option
755 =item required - This field should always have a true value (do not use with type checkbox or disabled)
761 #maybe this should move and be a class method in svc_Common.pm
762 sub svc_table_fields {
763 my($class, $table) = @_;
764 my $svc_defs = $class->_svc_defs;
765 my $def = $svc_defs->{$table};
767 foreach ( grep !ref($def->{$_}), keys %$def ) {
769 #normalize the shortcut in %info hash
770 $def->{$_} = { 'label' => $def->{$_} };
772 $def->{$_}{'type'} ||= 'text';
779 =item svc_table_info TABLE
781 Returns table_info for TABLE from cache, or empty
782 hashref if none is found.
784 Caution: caches table_info for ALL services when run;
785 access a service's table_info directly unless you know
786 you're loading them all.
788 Caution: does not standardize fields into hashrefs;
789 use L</svc_table_fields> to access fields.
796 $class->_svc_defs; #creates cache if needed
797 return $svc_info->{$table} || {};
808 Job-queue processor for web interface adds/edits
816 warn Dumper($param) if $DEBUG;
818 my $old = qsearchs('part_svc', { 'svcpart' => $param->{'svcpart'} })
819 if $param->{'svcpart'};
821 #unmunge cgp_accessmodes (falze laziness-ish w/edit/process/svc_acct.cgi)
822 $param->{'svc_acct__cgp_accessmodes'} ||=
824 grep { $_ !~ /^(flag|label)$/ }
825 map { /^svc_acct__cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
827 grep /^svc_acct__cgp_accessmodes_([\w\/]+)$/,
832 my $new = new FS::part_svc ( {
835 # } qw(svcpart svc svcdb)
836 } ( fields('part_svc'),
837 map { my $svcdb = $_;
838 my @fields = fields($svcdb);
839 push @fields, 'usergroup' if $svcdb eq 'svc_acct'
840 or $svcdb eq 'svc_broadband'; #kludge
843 my $f = $svcdb.'__'.$_;
844 my $flag = $param->{ $f.'_flag' } || ''; #silence warnings
845 if ( $flag =~ /^[MAH]$/ ) {
846 $param->{ $f } = delete( $param->{ $f.'_classnum' } );
848 if ( ( $flag =~ /^[MAHS]$/ or $_ eq 'usergroup' )
849 and ref($param->{ $f }) ) {
850 $param->{ $f } = join(',', @{ $param->{ $f } });
852 ( $f, $f.'_flag', $f.'_label', $f.'_required' );
856 } FS::part_svc->svc_tables()
861 map { $_->exportnum => ( $param->{'exportnum'.$_->exportnum} || '') }
862 qsearch('part_export', {} );
863 foreach my $exportnum (%exportnums) {
864 my $role = $param->{'exportnum'.$exportnum.'_role'};
865 # role is undef if the export has no role selector
866 if ( $exportnums{$exportnum} && $role ) {
867 $exportnums{$exportnum} = $role;
871 if ( $param->{'svcpart'} ) {
872 $error = $new->replace( $old,
873 '1.3-COMPAT', #totally bunk, as jeff noted
879 $error = $new->insert( [ 'usergroup' ],
883 $param->{'svcpart'} = $new->getfield('svcpart');
886 die "$error\n" if $error;
889 =item process_bulk_cust_svc
891 Job-queue processor for web interface bulk customer service changes
896 sub process_bulk_cust_svc {
899 warn Dumper($param) if $DEBUG;
901 local($FS::svc_Common::noexport_hack) = 1
902 if $param->{'noexport'};
905 qsearchs('part_svc', { 'svcpart' => $param->{'old_svcpart'} } );
907 die "Must select a new service definition\n" unless $param->{'new_svcpart'};
909 #the rest should be abstracted out to to its own subroutine?
911 local $SIG{HUP} = 'IGNORE';
912 local $SIG{INT} = 'IGNORE';
913 local $SIG{QUIT} = 'IGNORE';
914 local $SIG{TERM} = 'IGNORE';
915 local $SIG{TSTP} = 'IGNORE';
916 local $SIG{PIPE} = 'IGNORE';
918 my $oldAutoCommit = $FS::UID::AutoCommit;
919 local $FS::UID::AutoCommit = 0;
922 local( $FS::cust_svc::ignore_quantity ) = 1;
924 my $total = $old_part_svc->num_cust_svc( $param->{'pkgpart'} );
927 foreach my $old_cust_svc ( $old_part_svc->cust_svc( $param->{'pkgpart'} ) ) {
929 my $new_cust_svc = new FS::cust_svc { $old_cust_svc->hash };
931 $new_cust_svc->svcpart( $param->{'new_svcpart'} );
932 my $error = $new_cust_svc->replace($old_cust_svc);
934 $dbh->rollback if $oldAutoCommit;
935 die "$error\n" if $error;
938 $error = $job->update_statustext( int( 100 * ++$n / $total ) );
940 $dbh->rollback if $oldAutoCommit;
941 die $error if $error;
946 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
952 sub _upgrade_data { #class method
953 my ($class, %opts) = @_;
955 my @part_svc_column = qsearch('part_svc_column', { 'columnname' => 'usergroup' });
956 foreach my $col ( @part_svc_column ) {
957 next if $col->columnvalue =~ /^[\d,]+$/ || !$col->columnvalue;
958 my @groupnames = split(',',$col->columnvalue);
961 foreach my $groupname ( @groupnames ) {
962 my $g = qsearchs('radius_group', { 'groupname' => $groupname } );
964 $g = new FS::radius_group {
965 'groupname' => $groupname,
966 'description' => $groupname,
969 die "Error inserting new radius_group for service definition group \"$groupname\": $error"
972 push @groupnums, $g->groupnum;
974 $col->columnvalue(join(',',@groupnums));
975 $error = $col->replace;
976 die $error if $error;
979 my @badlabels = qsearch({
980 'table' => 'part_svc_column',
982 'extra_sql' => 'WHERE columnlabel IN ('.
983 "'Descriptive label for this particular device.',".
984 "'IP address. Leave blank for automatic assignment.',".
985 "'Maximum upload speed for this service in Kbps. 0 denotes unlimited.',".
986 "'Maximum download speed for this service in Kbps. 0 denotes unlimited.')"
988 foreach my $col ( @badlabels ) {
989 $col->columnlabel('');
990 my $error = $col->replace;
991 die $error if $error;
998 Delete is unimplemented.
1000 The list of svc_* tables is no longer hardcoded, but svc_acct_pop is skipped
1001 as a special case until it is renamed.
1003 all_part_svc_column methods should be documented
1007 L<FS::Record>, L<FS::part_svc_column>, L<FS::part_pkg>, L<FS::pkg_svc>,
1008 L<FS::cust_svc>, L<FS::svc_acct>, L<FS::svc_forward>, L<FS::svc_domain>,
1009 schema.html from the base documentation.