foreach my $field (fields($svcdb), @fields) {
next if $field eq 'svcnum';
my $prefix = $svcdb.'__';
- if ( defined( $self->getfield($prefix.$_.'_flag'))
- or defined($self->getfield($prefix.$_.'_required'))
- or length($self->getfield($prefix.$_.'_label'))
+ if ( defined( $self->getfield($prefix.$field.'_flag'))
+ or defined($self->getfield($prefix.$field.'_required'))
+ or length($self->getfield($prefix.$field.'_label'))
) {
my $part_svc_column = $self->part_svc_column($field);
my $previous = qsearchs('part_svc_column', {
foreach my $field (fields($svcdb),@fields) {
next if $field eq 'svcnum';
my $prefix = $svcdb.'__';
- if ( defined( $new->getfield($prefix.$_.'_flag'))
- or defined($new->getfield($prefix.$_.'_required'))
- or length($new->getfield($prefix.$_.'_label'))
+ if ( defined( $new->getfield($prefix.$field.'_flag'))
+ or defined($new->getfield($prefix.$field.'_required'))
+ or length($new->getfield($prefix.$field.'_label'))
) {
my $part_svc_column = $new->part_svc_column($field);
my $previous = qsearchs('part_svc_column', {
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.