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:13:08 -0500
commit9297bc3d2ea9b585532943fe613ed36d9c494ba5 (patch)
treeeb1e2d3e968e463e8bab551df1f55e1c59c3edb5 /FS
parent46b8fda3ffb17a2aabf7c9cbee68e988400d6273 (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 612c59013..621a55410 100644
--- a/FS/FS/part_svc.pm
+++ b/FS/FS/part_svc.pm
@@ -590,6 +590,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 73658f67a..4fd2d0b63 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -1385,11 +1385,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) = @_;
@@ -1493,6 +1499,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 ) {