fix batch browsing w/ the new agent-specific batches, RT#15310
[freeside.git] / httemplate / search / cust_pay_batch.cgi
index 8022d46..f382644 100755 (executable)
@@ -3,10 +3,8 @@
               'name'        => 'batch details',
              'query'       => $sql_query,
              'count_query' => $count_query,
-              'html_init'   => $pay_batch ? 
-                                  include('elements/cust_pay_batch_top.html',
-                                          'pay_batch' => $pay_batch
-                                  ) : '',
+              'html_init'   => $pay_batch ? $html_init : '',
+              'disable_download' => 1,
              'header'      => [ '#',
                                 'Inv #',
                                 'Customer',
 
 my $conf = new FS::Conf;
 
+my $curuser = $FS::CurrentUser::CurrentUser;
+
 die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Financial reports')
-      || $FS::CurrentUser::CurrentUser->access_right('Process batches')
+  unless $curuser->access_right('Financial reports')
+      || $curuser->access_right('Process batches')
+      || $curuser->access_right('Process global batches')
       || ( $cgi->param('custnum') 
            && (    $conf->exists('batch-enable')
                 || $conf->config('batch-enable_payby')
@@ -110,7 +111,8 @@ unless ($pay_batch){
   $orderby = "pay_batch.download,paybatchnum";
 }
 
-push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
+push @search, $curuser->agentnums_sql({ table=>'cust_main' });
+
 my $search = ' WHERE ' . join(' AND ', @search);
 
 $count_query = 'SELECT COUNT(*) FROM cust_pay_batch AS cpb ' .