package FS::part_svc;
+use base qw(FS::o2m_Common FS::Record);
use strict;
use vars qw( @ISA $DEBUG );
use Tie::IxHash;
use FS::export_svc;
use FS::cust_svc;
use FS::part_svc_class;
-
-@ISA = qw(FS::Record);
+use FS::part_svc_msgcat;
$DEBUG = 0;
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).
sub num_cust_svc {
my $self = shift;
+ return $self->{Hash}{num_cust_svc}
+ if !@_ && exists($self->{Hash}{num_cust_svc});
+
my @param = ( $self->svcpart );
my( $join, $and ) = ( '', '' );
$sth->fetchrow_arrayref->[0];
}
+=item num_cust_svc_cancelled
+
+Returns the number of associated customer services that are
+attached to cancelled packages.
+
+=cut
+
+sub num_cust_svc_cancelled {
+ my $self = shift;
+ my $sth = dbh->prepare(
+ "SELECT COUNT(*) FROM cust_svc
+ LEFT JOIN cust_pkg USING ( pkgnum )
+ WHERE svcpart = ?
+ AND cust_pkg.cancel IS NOT NULL"
+ ) or die dbh->errstr;
+ $sth->execute($self->svcpart)
+ or die $sth->errstr;
+ $sth->fetchrow_arrayref->[0];
+}
+
=item svc_x
Returns a list of associated FS::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;
+}
+
+# 3.x stub
+sub part_svc_msgcat {
+ my $self = shift;
+ qsearch('part_svc_msgcat', { 'svcpart' => $self->svcpart });
+}
+
=back
=head1 CLASS METHODS
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 } });
}
$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