Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Fri, 10 Jun 2016 21:21:38 +0000 (14:21 -0700)
committerIvan Kohler <ivan@freeside.biz>
Fri, 10 Jun 2016 21:21:38 +0000 (14:21 -0700)
20 files changed:
FS/FS/ClientAPI/MyAccount.pm
FS/FS/cust_event.pm
FS/FS/cust_main.pm
FS/FS/cust_main/Billing.pm
fs_selfservice/FS-SelfService/cgi/view_usage.html
httemplate/elements/menu.html
httemplate/search/cust_svc.html
httemplate/search/elements/cust_pay_or_refund.html
httemplate/search/report_cust_event.html
httemplate/search/svc_acct.cgi
httemplate/search/svc_broadband.cgi
httemplate/search/svc_circuit.cgi
httemplate/search/svc_dish.cgi
httemplate/search/svc_domain.cgi
httemplate/search/svc_external.cgi
httemplate/search/svc_fiber.html
httemplate/search/svc_forward.cgi
httemplate/search/svc_hardware.cgi
httemplate/search/svc_phone.cgi
httemplate/search/svc_www.cgi

index 9863065..531b2e2 100644 (file)
@@ -1835,6 +1835,7 @@ sub list_svcs {
   #              @svc_x;
 
   my @svcs; # stuff to return to the client
+  my %bytes_used_total; # for _used columns only
   foreach my $cust_svc (@cust_svc) {
     my $svc_x = $cust_svc->svc_x;
     my($label, $value) = $cust_svc->label;
@@ -1868,6 +1869,10 @@ sub list_svcs {
         'downbytes_used'  => display_bytecount($down_used),
         'totalbytes_used' => display_bytecount($up_used + $down_used)
       );
+      $bytes_used_total{'seconds_used'} += $hash{'seconds_used'};
+      $bytes_used_total{'upbytes_used'} += $up_used;
+      $bytes_used_total{'downbytes_used'} += $down_used;
+      $bytes_used_total{'totalbytes_used'} += $up_used + $down_used;
     }
 
     if ( $svcdb eq 'svc_acct' ) {
@@ -1942,12 +1947,19 @@ sub list_svcs {
     push @svcs, \%hash;
   } # foreach $cust_svc
 
+  foreach my $field (keys %bytes_used_total) {
+    if ($field =~ /bytes/) {
+      $bytes_used_total{$field} = display_bytecount($bytes_used_total{$field});
+    }
+  }
+
   return { 
     'svcnum'   => $session->{'svcnum'},
     'custnum'  => $custnum,
     'date_format' => $conf->config('date_format') || '%m/%d/%Y',
     'view_usage_nodomain' => $conf->exists('selfservice-view_usage_nodomain'),
     'svcs'     => \@svcs,
+    'bytes_used_total' => \%bytes_used_total,
     'usage_pools' => [
       map { $usage_pools{$_} }
       sort { $a cmp $b }
index 93743c4..094c4fa 100644 (file)
@@ -245,7 +245,13 @@ sub do_event {
     $statustext = "Error running ". $part_event->action. " action: $@";
   } elsif ( $error ) {
     $status = 'done';
-    $statustext = $error;
+    if ( $error eq 'N/A' ) {
+      # archaic way to indicate no-op completion of spool_csv (and maybe
+      # other events)?
+      $self->no_action('Y');
+    } else {
+      $statustext = $error;
+    }
   } else {
     $status = 'done';
   }
@@ -393,17 +399,22 @@ sub search_sql_where {
   if ( @event_status ) {
     my @status;
 
-    my ($done_Y, $done_N);
+    my ($done_Y, $done_N, $done_S);
+    # done_Y: action was taken
+    # done_N: action was not taken
+    # done_S: status message returned
     foreach (@event_status) {
       if ($_ eq 'done_Y') {
         $done_Y = 1;
       } elsif ( $_ eq 'done_N' ) {
         $done_N = 1;
+      } elsif ( $_ eq 'done_S' ) {
+        $done_S = 1;
       } else {
         push @status, $_;
       }
     }
-    if ( $done_Y or $done_N ) {
+    if ( $done_Y or $done_N or $done_S ) {
       push @status, 'done';
     }
     if ( @status ) {
@@ -412,12 +423,23 @@ sub search_sql_where {
                     ')';
     }
 
-    if ( $done_Y and not $done_N ) {
-      push @search, "cust_event.no_action IS NULL";
-    } elsif ( $done_N and not $done_Y ) {
-      push @search, "cust_event.no_action = 'Y'";
-    } # else they're both true, so don't add a constraint, or both false,
-      # and it doesn't matter.
+    # done_S status should include only those where statustext is not null,
+    # and done_Y should include only those where it is.
+    if ( $done_Y and $done_N and $done_S ) {
+      # then not necessary
+    } else {
+      my @done_status;
+      if ( $done_Y ) {
+        push @done_status, "(cust_event.no_action IS NULL AND cust_event.statustext IS NULL)";
+      }
+      if ( $done_N ) {
+        push @done_status, "(cust_event.no_action = 'Y')";
+      }
+      if ( $done_S ) {
+        push @done_status, "(cust_event.no_action IS NULL AND cust_event.statustext IS NOT NULL)";
+      }
+      push @search, join(' OR ', @done_status) if @done_status;
+    }
 
   } # event_status
 
index 5af1b31..ecd3070 100644 (file)
@@ -2126,36 +2126,59 @@ sub suspend_unless_pkgpart {
 =item cancel [ OPTION => VALUE ... ]
 
 Cancels all uncancelled packages (see L<FS::cust_pkg>) for this customer.
+The cancellation time will be now.
 
-Available options are:
+=back
+
+Always returns a list: an empty list on success or a list of errors.
+
+=cut
+
+sub cancel {
+  my $self = shift;
+  my %opt = @_;
+  warn "$me cancel called on customer ". $self->custnum. " with options ".
+       join(', ', map { "$_: $opt{$_}" } keys %opt ). "\n"
+    if $DEBUG;
+  my @pkgs = $self->ncancelled_pkgs;
+
+  $self->cancel_pkgs( %opt, 'cust_pkg' => \@pkgs );
+}
+
+=item cancel_pkgs OPTIONS
+
+Cancels a specified list of packages. OPTIONS can include:
 
 =over 4
 
+=item cust_pkg - an arrayref of the packages. Required.
+
+=item time - the cancellation time, used to calculate final bills and
+unused-time credits if any. Will be passed through to the bill() and
+FS::cust_pkg::cancel() methods.
+
 =item quiet - can be set true to supress email cancellation notices.
 
 =item reason - can be set to a cancellation reason (see L<FS:reason>), either a reasonnum of an existing reason, or passing a hashref will create a new reason.  The hashref should have the following keys: typenum - Reason type (see L<FS::reason_type>, reason - Text of the new reason.
 
+=item cust_pkg_reason - can be an arrayref of L<FS::cust_pkg_reason> objects
+for the individual packages, parallel to the C<cust_pkg> argument. The
+reason and reason_otaker arguments will be taken from those objects.
+
 =item ban - can be set true to ban this customer's credit card or ACH information, if present.
 
 =item nobill - can be set true to skip billing if it might otherwise be done.
 
-=back
-
-Always returns a list: an empty list on success or a list of errors.
-
 =cut
 
-# nb that dates are not specified as valid options to this method
-
-sub cancel {
+sub cancel_pkgs {
   my( $self, %opt ) = @_;
 
-  my $oldAutoCommit = $FS::UID::AutoCommit;
-  local $FS::UID::AutoCommit = 0;
+  # we're going to cancel services, which is not reversible
+  die "cancel_pkgs cannot be run inside a transaction"
+    if $FS::UID::AutoCommit == 0;
 
-  warn "$me cancel called on customer ". $self->custnum. " with options ".
-       join(', ', map { "$_: $opt{$_}" } keys %opt ). "\n"
-    if $DEBUG;
+  local $FS::UID::AutoCommit = 0;
 
   return ( 'access denied' )
     unless $FS::CurrentUser::CurrentUser->access_right('Cancel customer');
@@ -2173,7 +2196,7 @@ sub cancel {
       my $ban = new FS::banned_pay $cust_payby->_new_banned_pay_hashref;
       my $error = $ban->insert;
       if ($error) {
-        dbh->rollback if $oldAutoCommit;
+        dbh->rollback;
         return ( $error );
       }
 
@@ -2181,29 +2204,33 @@ sub cancel {
 
   }
 
-  my @pkgs = $self->ncancelled_pkgs;
+  my @pkgs = @{ delete $opt{'cust_pkg'} };
+  my $cancel_time = $opt{'time'} || time;
 
   # bill all packages first, so we don't lose usage, service counts for
   # bulk billing, etc.
   if ( !$opt{nobill} && $conf->exists('bill_usage_on_cancel') ) {
     $opt{nobill} = 1;
-    my $error = $self->bill( pkg_list => [ @pkgs ], cancel => 1 );
+    my $error = $self->bill( 'pkg_list' => [ @pkgs ],
+                             'cancel'   => 1,
+                             'time'     => $cancel_time );
     if ($error) {
-      # we should return an error and exit in this case, yes?
       warn "Error billing during cancel, custnum ". $self->custnum. ": $error";
-      dbh->rollback if $oldAutoCommit;
+      dbh->rollback;
       return ( "Error billing during cancellation: $error" );
     }
   }
+  dbh->commit;
 
+  $FS::UID::AutoCommit = 1;
   my @errors;
-  # now cancel all services, the same way we would for individual packages
+  # now cancel all services, the same way we would for individual packages.
+  # if any of them fail, cancel the rest anyway.
   my @cust_svc = map { $_->cust_svc } @pkgs;
   my @sorted_cust_svc =
     map  { $_->[0] }
     sort { $a->[1] <=> $b->[1] }
-    map  { [ $_, $_->svc_x ? $_->svc_x->table_info->{'cancel_weight'} : -1 ]; }
-    @cust_svc
+    map  { [ $_, $_->svc_x ? $_->svc_x->table_info->{'cancel_weight'} : -1 ]; } @cust_svc
   ;
   warn "$me removing ".scalar(@sorted_cust_svc)." service(s) for customer ".
     $self->custnum."\n"
@@ -2215,8 +2242,6 @@ sub cancel {
     push @errors, $error if $error;
   }
   if (@errors) {
-    # then we won't get to the point of canceling packages
-    dbh->rollback if $oldAutoCommit;
     return @errors;
   }
 
@@ -2224,13 +2249,22 @@ sub cancel {
     $self->custnum. "\n"
     if $DEBUG;
 
-  @errors = grep { $_ } map { $_->cancel(%opt) } @pkgs;
-  if (@errors) {
-    dbh->rollback if $oldAutoCommit;
-    return @errors;
+  my @cprs;
+  if ($opt{'cust_pkg_reason'}) {
+    @cprs = @{ delete $opt{'cust_pkg_reason'} };
+  }
+  foreach (@pkgs) {
+    my %lopt = %opt;
+    if (@cprs) {
+      my $cpr = shift @cprs;
+      $lopt{'reason'}        = $cpr->reasonnum;
+      $lopt{'reason_otaker'} = $cpr->otaker;
+    }
+    my $error = $_->cancel(%lopt);
+    push @errors, 'pkgnum '.$_->pkgnum.': '.$error if $error;
   }
 
-  return;
+  return @errors;
 }
 
 sub _banned_pay_hashref {
index d953767..4821ce5 100644 (file)
@@ -216,6 +216,9 @@ sub cancel_expired_pkgs {
 
   my @errors = ();
 
+  my @really_cancel_pkgs;
+  my @cancel_reasons;
+
   CUST_PKG: foreach my $cust_pkg ( @cancel_pkgs ) {
     my $cpr = $cust_pkg->last_cust_pkg_reason('expire');
     my $error;
@@ -233,14 +236,22 @@ sub cancel_expired_pkgs {
       $error = '' if ref $error eq 'FS::cust_pkg';
 
     } else { # just cancel it
-       $error = $cust_pkg->cancel($cpr ? ( 'reason'        => $cpr->reasonnum,
-                                           'reason_otaker' => $cpr->otaker,
-                                           'time'          => $time,
-                                         )
-                                       : ()
-                                 );
+
+      push @really_cancel_pkgs, $cust_pkg;
+      push @cancel_reasons, $cpr;
+
     }
-    push @errors, 'pkgnum '.$cust_pkg->pkgnum.": $error" if $error;
+  }
+
+  if (@really_cancel_pkgs) {
+
+    my %cancel_opt = ( 'cust_pkg' => \@really_cancel_pkgs,
+                       'cust_pkg_reason' => \@cancel_reasons,
+                       'time' => $time,
+                     );
+
+    push @errors, $self->cancel_pkgs(%cancel_opt);
+
   }
 
   join(' / ', @errors);
index 07ccfed..2b9eb8b 100644 (file)
       $OUT .= '</TR>';
     }
   }
+  if ((@bytes_svcs > 1) and (grep { $bytes_show{$_.'_used'} } qw(seconds upbytes downbytes totalbytes) )) {
+    $OUT .= '<TR>';
+    $OUT .= '<TH align="left">Total Used</TH>';
+    foreach my $field (@bytes_cols) {
+      if ($bytes_show{$field}) {
+        $OUT .= '<TD ALIGN="right">';
+        $OUT .= $bytes_used_total{$field} || '0' if $field =~ /_used$/;
+        $OUT .= '</TD>';
+      }
+    }
+    $OUT .= '</TR>';
+  }    
 %>
 
 <%= scalar(@bytes_svcs) ? '</TABLE><BR><BR>' : '' %>
index c385cb4..93bebb1 100644 (file)
@@ -320,7 +320,6 @@ tie my %report_ticketing, 'Tie::IxHash',
 ;
 
 tie my %report_bill_event, 'Tie::IxHash',
-  'All billing events' => [ $fsurl.'search/report_cust_event.html', 'All billing events for a date range' ],
   'Billing event errors' => [ $fsurl.'search/report_cust_event.html?failed=1', 'Failed credit cards, processor or printer problems, etc.' ],
 ;
 
@@ -404,7 +403,7 @@ tie my %report_payable, 'Tie::IxHash',
 ;
 
 tie my %report_logs, 'Tie::IxHash';
-$report_logs{'Billing events'} =  [ \%report_bill_event, 'Billing events' ]
+$report_logs{'Billing events'} =  [ $fsurl.'search/report_cust_event.html', 'Search billing events by date and status' ]
   if $curuser->access_right('Billing event reports');
 $report_logs{'Credit limit incidents'} = [ $fsurl.'search/report_cust_main_credit_limit.html', '' ]
   if $curuser->access_right('List rating data');
index 7000e30..b282630 100644 (file)
@@ -21,6 +21,7 @@
                              },
                              sub {
                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_pkg;
+                               return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                              },
                              # package?
@@ -39,6 +40,8 @@
                              '',
                              '',
                              sub {
+                               $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_pkg;
+                               return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                my $c = FS::cust_pkg::statuscolors;
                                $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                              }, # pkg status
index 9f725bb..c6617b1 100755 (executable)
@@ -327,7 +327,9 @@ if ( $cgi->param('magic') ) {
 
             #avoid posix regexes for portability
             $search =
+              # Visa
               " ( (     substring($table.payinfo from 1 for 1) = '4'     ".
+              #   is not Switch
               "     AND substring($table.payinfo from 1 for 4) != '4936' ".
               "     AND substring($table.payinfo from 1 for 6)           ".
               "         NOT $similar_to '49030[2-9]'                        ".
@@ -340,13 +342,18 @@ if ( $cgi->param('magic') ) {
               "     AND substring($table.payinfo from 1 for 6)           ".
               "         NOT $similar_to '49118[1-2]'                        ".
               "   )".
+              # MasterCard
               "   OR substring($table.payinfo from 1 for 2) = '51' ".
               "   OR substring($table.payinfo from 1 for 2) = '52' ".
               "   OR substring($table.payinfo from 1 for 2) = '53' ".
               "   OR substring($table.payinfo from 1 for 2) = '54' ".
               "   OR substring($table.payinfo from 1 for 2) = '54' ".
               "   OR substring($table.payinfo from 1 for 2) = '55' ".
-#              "   OR substring($table.payinfo from 1 for 2) = '36' ". #Diner's int'l was processed as Visa/MC inside US, now Discover
+              "   OR substring($table.payinfo from 1 for 4) $similar_to '222[1-9]' ".
+              "   OR substring($table.payinfo from 1 for 3) $similar_to '22[3-9]' ".
+              "   OR substring($table.payinfo from 1 for 2) $similar_to '2[3-6]' ".
+              "   OR substring($table.payinfo from 1 for 3) $similar_to '27[0-1]' ".
+              "   OR substring($table.payinfo from 1 for 4) = '2720' ".
               " ) ";
 
           } elsif ( $cardtype eq 'Amex' ) {
@@ -363,14 +370,14 @@ if ( $cgi->param('magic') ) {
             $search =
               " (    substring($table.payinfo from 1 for 4 ) = '6011'  ".
               "   OR substring($table.payinfo from 1 for 2 ) = '65'    ".
-              "   OR substring($table.payinfo from 1 for 3 ) = '300'   ".
+              "   OR substring($table.payinfo from 1 for 3 ) = '300'   ". # diner's 300-305
               "   OR substring($table.payinfo from 1 for 3 ) = '301'   ".
               "   OR substring($table.payinfo from 1 for 3 ) = '302'   ".
               "   OR substring($table.payinfo from 1 for 3 ) = '303'   ".
               "   OR substring($table.payinfo from 1 for 3 ) = '304'   ".
               "   OR substring($table.payinfo from 1 for 3 ) = '305'   ".
-              "   OR substring($table.payinfo from 1 for 4 ) = '3095'  ".
-              "   OR substring($table.payinfo from 1 for 2 ) = '36'    ".
+              "   OR substring($table.payinfo from 1 for 4 ) = '3095'  ". # diner's 3095
+              "   OR substring($table.payinfo from 1 for 2 ) = '36'    ". # diner's 36, 38, 39
               "   OR substring($table.payinfo from 1 for 2 ) = '38'    ".
               "   OR substring($table.payinfo from 1 for 2 ) = '39'    ".
               "   OR substring($table.payinfo from 1 for 3 ) = '644'   ".
@@ -379,8 +386,8 @@ if ( $cgi->param('magic') ) {
               "   OR substring($table.payinfo from 1 for 3 ) = '647'   ".
               "   OR substring($table.payinfo from 1 for 3 ) = '648'   ".
               "   OR substring($table.payinfo from 1 for 3 ) = '649'   ".
-              ( $country =~ /^(US|CA)$/
-               ?" OR substring($table.payinfo from 1 for 4 ) = '3528'  ". # JCB cards in the 3528-3589 range identified as Discover inside US/CA
+              ( $country =~ /^(US|PR|VI|MP|PW|GU)$/
+               ?" OR substring($table.payinfo from 1 for 4 ) = '3528'  ". # JCB cards in the 3528-3589 range identified as Discover inside US & territories (NOT Canada)
                 " OR substring($table.payinfo from 1 for 4 ) = '3529'  ".
                 " OR substring($table.payinfo from 1 for 3 ) = '353'   ".
                 " OR substring($table.payinfo from 1 for 3 ) = '354'   ".
@@ -390,7 +397,10 @@ if ( $cgi->param('magic') ) {
                 " OR substring($table.payinfo from 1 for 3 ) = '358'   "
                :""
               ).
-              "   OR substring($table.payinfo from 1 for 3 ) = '622'   ". #China Union Pay processed as Discover outside CN
+              ( $country =~ /^(US|MX|AI|AG|AW|BS|BB|BM|BQ|VG|KY|CW|DM|DO|GD|GP|JM|MQ|MS|BL|KN|LC|VC|MF|SX|TT|TC)$/
+               ?" OR substring($table.payinfo from 1 for 3 ) $similar_to '62[24-68]'   " #China Union Pay processed as Discover outside CN
+               :""
+              ).
               " ) ";
 
           } elsif ( $cardtype eq 'Maestro' ) {
index 6453500..7aa4ff9 100644 (file)
 %     } else {
 
 % # 'initial' is not on here, since nobody needs to see it. also,
-% # 'done_Y' and 'done_N' are shorthand for "done, and no_action
-% # is null" and "done, and no_action = 'Y'".
+% # 'done_Y' = "done, and no_action is null, and statustext is null"
+% # 'done_S' = "done, and no_action is null, and statustext is not null"
+% # 'done_N' = "done, and no_action = 'Y'".
       <& /elements/tr-select.html,
         'label'         => 'Event status',
         'field'         => 'event_status',
         'multiple'      => 1,
         'all_selected'  => 1,
         'size'          => 5,
-        'options'       => [ qw( done_Y done_N failed new locked ) ],
-        'option_labels' => { done_Y => 'Completed',
+        'options'       => [ qw( done_Y done_S done_N failed new locked ) ],
+        'option_labels' => { done_Y => 'Completed normally',
+                             done_S => 'Completed, with an error',
                              done_N => 'Completed, no action taken',
                              failed => 'Failed',
                              new    => 'Not yet processed',
index ef89f01..ecf37b4 100755 (executable)
@@ -356,11 +356,14 @@ foreach my $pkg_field ( @pkg_fields ) {
 push @header, emt('Pkg. Status');
 push @fields, sub {
   $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+  return '' unless $cust_pkg_cache{$_[0]->svcnum};
   $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status;
 };
 push @links, '';
 $align .= 'r';
 push @color, sub {
+  $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+  return '' unless $cust_pkg_cache{$_[0]->svcnum};
   my $c = FS::cust_pkg::statuscolors;
   $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
 };
index ff2538c..8cdf29d 100755 (executable)
@@ -23,6 +23,7 @@
                                  'ip_addr',
                                  sub {
                                    $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                   return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                    $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                  },
                                  \&FS::UI::Web::cust_fields,
@@ -46,6 +47,8 @@
                                  (map '', @tower_fields),
                                  '',
                                  sub {
+                                   $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                   return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                    my $c = FS::cust_pkg::statuscolors;
                                    $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                                  }, # pkg status
index 2174734..3a85375 100644 (file)
@@ -21,6 +21,7 @@
                      'ip_addr',
                      sub {
                        $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                       return '' unless $cust_pkg_cache{$_[0]->svcnum};
                        $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                      },
                      \&FS::UI::Web::cust_fields,
@@ -38,6 +39,8 @@
   'color'       => [ 
                      ('') x 6,
                      sub {
+                       $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                       return '' unless $cust_pkg_cache{$_[0]->svcnum};
                        my $c = FS::cust_pkg::statuscolors;
                        $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                      }, # pkg status
index 1e73308..5c47608 100755 (executable)
@@ -15,6 +15,7 @@
                                     'acctnum',
                                     sub {
                                       $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                      return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                       $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                     },
                                     \&FS::UI::Web::cust_fields,
@@ -33,6 +34,8 @@
                               '',
                               '',
                               sub {
+                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                 my $c = FS::cust_pkg::statuscolors;
                                 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                               }, # pkg status
index c8fca9f..23eeba6 100755 (executable)
@@ -15,6 +15,7 @@
                                           'domain',
                                           sub {
                                             $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                            return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                             $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                           },
                                           \&FS::UI::Web::cust_fields,
@@ -33,6 +34,8 @@
                               '',
                               '',
                               sub {
+                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                 my $c = FS::cust_pkg::statuscolors;
                                 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                               }, # pkg status
index 5f90561..426ac16 100755 (executable)
@@ -17,6 +17,7 @@
                                           'title',
                                           sub {
                                             $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                            return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                             $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                           },
                                           \&FS::UI::Web::cust_fields,
@@ -38,6 +39,8 @@
                               '',
                               '',
                               sub {
+                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                 my $c = FS::cust_pkg::statuscolors;
                                 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                               }, # pkg status
index 3960a16..a07c5f5 100644 (file)
@@ -23,6 +23,7 @@
                      'ont_serial',
                      sub {
                        $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                       return '' unless $cust_pkg_cache{$_[0]->svcnum};
                        $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                      },
                      \&FS::UI::Web::cust_fields,
@@ -40,6 +41,8 @@
   'color'       => [ 
                      ('') x 6,
                      sub {
+                       $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                       return '' unless $cust_pkg_cache{$_[0]->svcnum};
                        my $c = FS::cust_pkg::statuscolors;
                        $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                      }, # pkg status
index ca2c288..c9b6012 100755 (executable)
@@ -17,6 +17,7 @@
                                           $format_dst,
                                           sub {
                                             $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                            return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                             $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                           },
                                           \&FS::UI::Web::cust_fields,
@@ -37,6 +38,8 @@
                               '',
                               '',
                               sub {
+                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                 my $c = FS::cust_pkg::statuscolors;
                                 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                               }, # pkg status
index 78f413e..c41cc5a 100644 (file)
@@ -25,6 +25,7 @@
                                      'smartcard',
                                      sub {
                                        $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                       return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                        $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                      },
                                      \&FS::UI::Web::cust_fields,
@@ -38,6 +39,8 @@
             'align'             => 'rlllllllr' . FS::UI::Web::cust_aligns(),
             'color'             => [ ('') x 8,
                                      sub {
+                                       $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                       return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                        my $c = FS::cust_pkg::statuscolors;
                                        $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                                      }, # pkg status
index 29e7456..4c0b654 100644 (file)
@@ -19,6 +19,7 @@
                                           @fields,
                                           sub {
                                             $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                            return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                             $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                           },
                                           \&FS::UI::Web::cust_fields,
@@ -44,6 +45,8 @@
                               '',
                               ( map '', @header ),
                               sub {
+                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                 my $c = FS::cust_pkg::statuscolors;
                                 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                               }, # pkg status
index 4f6611f..6e9ba92 100755 (executable)
@@ -23,6 +23,7 @@
                                         },
                                     sub {
                                       $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                      return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                       $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
                                     },
                                     \&FS::UI::Web::cust_fields,
@@ -43,6 +44,8 @@
                               '',
                               '',
                               sub {
+                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                return '' unless $cust_pkg_cache{$_[0]->svcnum};
                                 my $c = FS::cust_pkg::statuscolors;
                                 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
                               }, # pkg status