bug ya bug resulting from agent-virtualized packages
[freeside.git] / httemplate / search / cust_pkg.cgi
index 84b083a..5c209eb 100755 (executable)
@@ -12,6 +12,7 @@
                                      'Setup',
                                      'Last bill',
                                      'Next bill',
+                                     'Adjourn',
                                      'Susp.',
                                      'Expire',
                                      'Cancel',
@@ -43,7 +44,7 @@
                     #sub { time2str('%b %d %Y', shift->expire); },
                     #sub { time2str('%b %d %Y', shift->get('cancel')); },
                     ( map { time_or_blank($_) }
-                          qw( setup last_bill bill susp expire cancel ) ),
+                          qw( setup last_bill bill adjourn susp expire cancel ) ),
 
                     \&FS::UI::Web::cust_fields,
                     #sub { '<table border=0 cellspacing=0 cellpadding=0 STYLE="border:none">'.
@@ -126,7 +127,7 @@ my @where = ();
 
 if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) {
   push @where,
-    "agentnum = $1";
+    "cust_main.agentnum = $1";
 }
 
 ##
@@ -210,14 +211,14 @@ my $orderby = '';
 #false laziness w/report_cust_pkg.html
 my %disable = (
   'all'             => {},
-  'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
+  'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
   'active'          => { 'susp'=>1, 'cancel'=>1 },
   'suspended'       => { 'cancel' => 1 },
   'cancelled'       => {},
   ''                => {},
 );
 
-foreach my $field (qw( setup last_bill bill susp expire cancel )) {
+foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
 
   my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
 
@@ -225,11 +226,11 @@ foreach my $field (qw( setup last_bill bill susp expire cancel )) {
        or $disable{$cgi->param('status')}->{$field};
 
   push @where,
-    "$field IS NOT NULL",
-    "$field >= $beginning",
-    "$field <= $ending";
+    "cust_pkg.$field IS NOT NULL",
+    "cust_pkg.$field >= $beginning",
+    "cust_pkg.$field <= $ending";
 
-  $orderby ||= "ORDER BY $field";
+  $orderby ||= "ORDER BY cust_pkg.$field";
 
 }
 
@@ -273,7 +274,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) : '';