summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-04-11 07:08:02 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-04-11 07:21:15 -0500
commit5b77b3d0c9aa2d0fa15ca5284d7e34ed68f4ee12 (patch)
treeb272629cf46aaf2ffe86ac7bb31f726f1d08e330 /FS
parent5cda22da9d0771878b5256895e1655d75f3ea1f6 (diff)
RT#40641: unprovisioning preserved cancelled services
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/part_svc.pm20
-rw-r--r--FS/FS/svc_Common.pm16
2 files changed, 35 insertions, 1 deletions
diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm
index aba3ead40..884e3ad80 100644
--- a/FS/FS/part_svc.pm
+++ b/FS/FS/part_svc.pm
@@ -586,6 +586,26 @@ sub num_cust_svc {
$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.
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index dea31ea85..d11b58375 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -1394,11 +1394,17 @@ Parameters:
=item order_by
+=item cancelled - if true, only returns svcs attached to cancelled pkgs;
+if defined and false, only returns svcs not attached to cancelled packages
+
=back
=cut
-# svc_broadband::search should eventually use this instead
+### Don't call the 'cancelled' option 'Service Status'
+### There is no such thing
+### See cautionary note in httemplate/browse/part_svc.cgi
+
sub search {
my ($class, $params) = @_;
@@ -1502,6 +1508,14 @@ sub search {
push @where, "exportnum = $1";
}
+ if ( defined($params->{'cancelled'}) ) {
+ if ($params->{'cancelled'}) {
+ push @where, "cust_pkg.cancel IS NOT NULL";
+ } else {
+ push @where, "cust_pkg.cancel IS NULL";
+ }
+ }
+
# # sector and tower
# my @where_sector = $class->tower_sector_sql($params);
# if ( @where_sector ) {