package FS::part_svc;
-use base qw(FS::Record);
+use base qw(FS::o2m_Common FS::Record);
use strict;
use vars qw( $DEBUG );
use FS::export_svc;
use FS::cust_svc;
use FS::part_svc_class;
+use FS::part_svc_msgcat;
FS::UID->install_callback(sub {
# preload the cache and make sure all modules load
=item svcdb - table used for this service. See L<FS::svc_acct>,
L<FS::svc_domain>, and L<FS::svc_forward>, among others.
-=item classnum - Optional service class (see L<FS::svc_class>)
+=item classnum - Optional service class (see L<FS::part_svc_class>)
=item disabled - Disabled flag, empty or `Y'
grep $_->can('dsl_pull'), $self->part_export;
}
+=item part_export_partsvc
+
+Returns a list of any exports (see L<FS::part_export>) for this service that
+are capable of pushing a change after part svc is changed.
+
+=cut
+
+sub part_export_partsvc {
+ my $self = shift;
+ grep $_->can('export_partsvc'), $self->part_export;
+}
+
=item cust_svc [ PKGPART ]
Returns a list of associated customer services (FS::cust_svc records).
map { $_->svc_x } $self->cust_svc;
}
+=item svc_locale LOCALE
+
+Returns a customer-viewable service definition label in the chosen LOCALE.
+If there is no entry for that locale or if LOCALE is empty, returns
+part_svc.svc.
+
+=cut
+
+sub svc_locale {
+ my( $self, $locale ) = @_;
+ return $self->svc unless $locale;
+ my $part_svc_msgcat = qsearchs('part_svc_msgcat', {
+ svcpart => $self->svcpart,
+ locale => $locale
+ }) or return $self->svc;
+ $part_svc_msgcat->svc;
+}
+
=back
=head1 CLASS METHODS
warn "skipping disabled service FS::$mod" if $DEBUG;
next;
}
+
+ foreach ("FS::$mod"->virtual_fields_hash) {
+ $info->{'fields'}->{$_->{'name'}} = $_->{'label'};
+ }
+
$info{$mod} = $info;
# all svc_* modules are required to have h_svc_* modules for invoice
map {
my $f = $svcdb.'__'.$_;
my $flag = $param->{ $f.'_flag' } || ''; #silence warnings
- if ( $flag =~ /^[MAH]$/ ) {
+ if ( $flag =~ /^[MAHP]$/ ) {
$param->{ $f } = delete( $param->{ $f.'_classnum' } );
}
- if ( ( $flag =~ /^[MAHS]$/ or $_ eq 'usergroup' )
+ if ( ( $flag =~ /^[MAHSP]$/ or $_ eq 'usergroup' )
and ref($param->{ $f }) ) {
$param->{ $f } = join(',', @{ $param->{ $f } });
}
$exportnums{$exportnum} = $role;
}
}
+
+ ## make sure export required fields are marked required.
+ my @required_fields;
+ foreach (keys %exportnums) {
+ my $export = qsearchs('part_export', { 'exportnum' => $_ })
+ if $exportnums{$_};
+ if ($export) {
+ push @required_fields, $export->required_fields if $export->can('required_fields');
+ }
+ }
+ foreach (@required_fields) { $new->set($_, 'Y'); }
+
my $error;
if ( $param->{'svcpart'} ) {
$error = $new->replace( $old,
$param->{'svcpart'} = $new->getfield('svcpart');
}
+ $error ||= $new->process_o2m(
+ 'table' => 'part_svc_msgcat',
+ 'params' => $param,
+ 'fields' => [ 'locale', 'svc' ],
+ );
+
die "$error\n" if $error;
+
+ foreach my $part_svc_export ( $new->part_export_partsvc ) {
+ $error = $part_svc_export->export_partsvc($new);
+ }
+ return $error if $error;
}
=item process_bulk_cust_svc