DSL status pulling, RT#13656
[freeside.git] / FS / FS / svc_Common.pm
index 5c6e16b..7a93bc4 100644 (file)
@@ -159,6 +159,16 @@ sub label_long {
   $self->label(@_);
 }
 
+sub cust_main {
+  my $self = shift;
+  (($self->cust_svc || return)->cust_pkg || return)->cust_main || return
+}
+
+sub cust_linked {
+  my $self = shift;
+  defined($self->cust_main);
+}
+
 =item check
 
 Checks the validity of fields in this record.
@@ -985,6 +995,26 @@ sub export_getsettings {
   ( \%settings, \%defaults );
 }
 
+=item export_getstatus
+
+Runs export_getstatus callbacks and returns a two item list consisting of an
+HTML status and a status hashref.
+
+=cut
+
+sub export_getstatus {
+  my $self = shift;
+  my $html = '';
+  my %hash = ();
+  my $error = $self->export('getstatus', \$html, \%hash);
+  if ( $error ) {
+    #XXX bubble this up better
+    warn "error running export_getstatus: $error";
+    return ( '', {} );
+  }
+  ( $html, \%hash );
+}
+
 =item export HOOK [ EXPORT_ARGS ]
 
 Runs the provided export hook (i.e. "suspend", "unsuspend") for this service.
@@ -1118,8 +1148,27 @@ sub find_duplicates {
   return grep { $conflict_svcparts{$_->cust_svc->svcpart} } @dup;
 }
 
+=item getstatus_html
+
+=cut
+
+sub getstatus_html {
+  my $self = shift;
+
+  my $part_svc = $self->cust_svc->part_svc;
+
+  my $html = '';
 
+  foreach my $export ( grep $_->can('export_getstatus'), $part_svc->part_export ) {
+    my $export_html = '';
+    my %hash = ();
+    $export->export_getstatus( $self, \$export_html, \%hash );
+    $html .= $export_html;
+  }
+
+  $html;
 
+}
 
 =back