batch payment revocation, RT#10545
[freeside.git] / httemplate / search / elements / cust_pay_batch_top.html
1 % # Download batch
2 % if ( $status eq 'O'
3 %   or ( $status eq 'I' and $curuser->access_right('Reprocess batches') )
4 %   or ( $status eq 'R' and $curuser->access_right('Redownload resolved batches') )
5 %   ) {
6 <TABLE>
7 <TR><FORM ACTION="<%$p%>misc/download-batch.cgi" METHOD="POST">
8 <INPUT TYPE="hidden" NAME="batchnum" VALUE="<%$batchnum%>">
9 %   if ( $fixed ) {
10 <INPUT TYPE="hidden" NAME="format" VALUE="<%$fixed%>">
11 %   }
12 %   else {
13 Download batch in format <SELECT NAME="format">
14 %     foreach ( keys %download_formats ) {
15 <OPTION VALUE="<%$_%>"><% $download_formats{$_} %></OPTION>
16 %     }
17 </SELECT>
18 %   }
19 <INPUT TYPE="submit" VALUE="Download"></FORM><BR><BR></TR>
20 % } # end of download
21
22 % # Upload batch
23 % if ( $pay_batch->status eq 'I'
24 %   or ( $pay_batch->status eq 'R'
25 %     and $curuser->access_right('Reprocess batches')
26 %     and $conf->exists('batch-manual_approval')
27 %   ) 
28 % ) {
29 <TR>
30 <% include('/elements/form-file_upload.html',
31               'name'      => 'FileUpload',
32               'action'    => "${p}misc/upload-batch.cgi",
33               'num_files' => 1,
34               'fields'    => [ 'batchnum', 'format' ],
35               'message'   => 'Batch results uploaded.',
36 ) %>
37 Upload results<BR></TR>
38 <TR>
39 <% include('/elements/file-upload.html',
40               'field'     => 'file',
41               'label'     => 'Filename',
42               'no_table'  => 1,
43 ) %>
44 <INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>">
45 <BR></TR>
46 %   if ( $fixed ) {
47 %     if ( $fixed eq 'td_eft1464' ) { # special case
48 <TR>Format <SELECT NAME="format">
49 <OPTION VALUE="td_eftack264">TD EFT Acknowledgement</OPTION>
50 <OPTION VALUE="td_eftret80">TD EFT Returned Items</OPTION>
51 </SELECT></TR>
52 %     }
53 %     else {
54 <INPUT TYPE="hidden" NAME="format" VALUE="<% $fixed %>">
55 %     }
56 %   }
57 %   else {
58 <TR>Format <SELECT NAME="format">
59 %     foreach ( keys(%upload_formats) ) {
60 <OPTION VALUE="<%$_%>"><% $upload_formats{$_} %></OPTION>
61 %     }
62 %   } # if $fixed
63 <TR><INPUT TYPE="submit" VALUE="Upload"></TR>
64 </FORM><BR>
65 % } # end upload
66
67 % # manual approval
68 % if ( $fixed eq 'td_eft1464'
69 %   and $status eq 'I'
70 %   and $payby eq 'CHEK'
71 %   and $conf->exists('batch-manual_approval')
72 %   ) {
73 <TR><INPUT TYPE="button" VALUE="Manually approve" onclick="
74 if ( confirm('Approve all remaining payments in this batch?') ) 
75   window.location.href='<%$p%>misc/process/pay_batch-approve.cgi?batchnum=<%$batchnum%>';
76 "></TR>
77 % } # end manual approval
78 </TABLE>
79
80 % # summary info
81 Batch is <% $statustext{$status} %><BR>
82 <%$count%> payments batched<BR>
83 <%$money_char%><%$total%> total in batch<BR>
84
85 <%init>
86 my %opt = @_;
87 my $pay_batch = $opt{'pay_batch'} or return;
88 my $conf = new FS::Conf;
89 my $money_char = $conf->config('money_char') || '$';
90 my $payby = $pay_batch->payby;
91 my $status = $pay_batch->status;
92 my $curuser = $FS::CurrentUser::CurrentUser;
93 my $batchnum = $pay_batch->batchnum;
94  
95 my $fixed = $conf->config("batch-fixed_format-$payby");
96
97 tie my %download_formats, 'Tie::IxHash', (
98 '' => 'Default batch mode',
99 'csv-td_canada_trust-merchant_pc_batch' => 
100               'CSV file for TD Canada Trust Merchant PC Batch',
101 'csv-chase_canada-E-xactBatch' =>
102               'CSV file for Chase Canada E-xactBatch',
103 'PAP' => '80 byte file for TD Canada Trust PAP Batch',
104 'BoM' => 'Bank of Montreal ECA batch',
105 'ach-spiritone' => 'Spiritone ACH batch',
106 'paymentech' => 'XML file for Chase Paymentech',
107 'RBC' => 'Royal Bank of Canada PDS batch',
108 'td_eft1464' => '1464 byte file for TD Commercial Banking EFT',
109 # insert new batch formats here
110 );
111
112 tie my %upload_formats, 'Tie::IxHash', (
113   %download_formats,
114 # minor tweaks
115   'td_eftack' => 'TD EFT Acknowledgement',
116   'td_eftret' => 'TD EFT Returned Items',
117 );
118 delete $upload_formats{'td_eft1464'};
119 $upload_formats{'PAP'} = '264 byte results for TD Canada Trust PAP Batch',
120
121 my %statustext = ( 'O' => 'open', 'I' => 'in transit', 'R' => 'resolved' );
122
123 my $count_query = "SELECT COUNT(*) FROM cust_pay_batch WHERE batchnum=$batchnum";
124 my $count = FS::Record->scalar_sql($count_query);
125 my $sum_query = "SELECT SUM(amount) FROM cust_pay_batch WHERE batchnum=$batchnum";
126 my $total = sprintf("%.2f", FS::Record->scalar_sql($sum_query));
127 </%init>