This commit was generated by cvs2svn to compensate for changes in r6252,
[freeside.git] / httemplate / search / cust_pay_batch.cgi
index fec3dfd..60dca8c 100755 (executable)
@@ -1,7 +1,6 @@
 <% include('elements/search.html',
               'title'       => 'Batch payment details',
               'name'        => 'batch details',
-             'menubar'     => ['Main Menu'  => $p,],
              'query'       => $sql_query,
              'count_query' => $count_query,
               'html_init'   => $pay_batch ? $html_init : '',
 %>
 <%init>
 
+my $conf = new FS::Conf;
+
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports')
-      || $FS::CurrentUser::CurrentUser->access_right('Process batches');
+      || $FS::CurrentUser::CurrentUser->access_right('Process batches')
+      || ( $cgi->param('custnum') 
+           && $conf->exists('batch-enable')
+           #&& $FS::CurrentUser::CurrentUser->access_right('View customer batched payments')
+         );
 
 my( $count_query, $sql_query );
 my $hashref = {};
@@ -75,6 +80,14 @@ if ( $cgi->param('batchnum') && $cgi->param('batchnum') =~ /^(\d+)$/ ) {
   $batchnum = $pay_batch->batchnum;
 }
 
+if ( $cgi->param('custnum') && $cgi->param('custnum') =~ /^(\d+)$/ ) {
+  push @search, "custnum = $1";
+}
+
+if ( $cgi->param('status') && $cgi->param('status') =~ /^(\w)$/ ) {
+  push @search, "pay_batch.status = '$1'";
+}
+
 if ( $cgi->param('payby') ) {
   $cgi->param('payby') =~ /^(CARD|CHEK)$/
     or die "illegal payby " . $cgi->param('payby');
@@ -111,7 +124,6 @@ $sql_query = "SELECT paybatchnum,invnum,custnum,cpb.last,cpb.first," .
 
 my $html_init = '';
 if ( $pay_batch ) {
-  my $conf = new FS::Conf;
   my $fixed = $conf->config('batch-fixed_format-'. $pay_batch->payby);
   if (
        $pay_batch->status eq 'O' 
@@ -129,6 +141,7 @@ if ( $pay_batch ) {
                     qq!<OPTION VALUE="csv-chase_canada-E-xactBatch">CSV file for Chase Canada E-xactBatch</OPTION>!.
                     qq!<OPTION VALUE="PAP">80 byte file for TD Canada Trust PAP Batch</OPTION>!.
                     qq!<OPTION VALUE="BoM">Bank of Montreal ECA batch</OPTION>!.
+                    qq!<OPTION VALUE="ach-spiritone">Spiritone ACH batch</OPTION>!.
                     qq!</SELECT>!;
     }
     $html_init .= qq!<INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum"><INPUT TYPE="submit" VALUE="Download"></FORM><BR>!;
@@ -152,6 +165,7 @@ if ( $pay_batch ) {
                     qq!<OPTION VALUE="csv-chase_canada-E-xactBatch">CSV file for Chase Canada E-xactBatch</OPTION>!.
                     qq!<OPTION VALUE="PAP">264 byte results for TD Canada Trust PAP Batch</OPTION>!.
                     qq!<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION>!.
+                    qq!<OPTION VALUE="ach-spiritone">Spiritone ACH batch</OPTION>!.
                     qq!</SELECT><BR>!;
     }
     $html_init .= qq!<INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum">!;