add options for balance over/under to advanced customer report
[freeside.git] / httemplate / search / cust_pkg.cgi
index 941a2e7..b354bc1 100755 (executable)
@@ -16,6 +16,7 @@
                                      'Susp.',
                                      'Expire',
                                      'Cancel',
+                                     'Reason',
                                      FS::UI::Web::cust_header(
                                        $cgi->param('cust_fields')
                                      ),
                     ( map { time_or_blank($_) }
                           qw( setup last_bill bill adjourn susp expire cancel ) ),
 
+                    sub { my $self = shift;
+                          my $return = '';
+                          if ($self->getfield('cancel') ||
+                            $self->getfield('suspend')) {
+                              my $reason = $self->last_reason;# too inefficient?
+                              $return = $reason->reason if $reason;
+
+                          }
+                          $return;
+                        },
+
                     \&FS::UI::Web::cust_fields,
                     #sub { '<table border=0 cellspacing=0 cellpadding=0 STYLE="border:none">'.
                     #      join('', map { '<tr><td align="right" style="border:none">'. $_->[0].
@@ -127,7 +139,7 @@ my @where = ();
 
 if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) {
   push @where,
-    "agentnum = $1";
+    "cust_main.agentnum = $1";
 }
 
 ##
@@ -274,7 +286,7 @@ if ( $cgi->param('magic') &&
 ##
 
 # here is the agent virtualization
-push @where, $FS::CurrentUser::CurrentUser->agentnums_sql;
+push @where, $FS::CurrentUser::CurrentUser->agentnums_sql('table'=>'cust_main');
 
 my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : '';