1 <& /elements/xmlhttp.html,
2 'url' => $p.'misc/xmlhttp-pay_batch-note.html',
3 'subs' => [ 'get_note' ]
5 <script type="text/javascript">
6 function format_changed() {
7 var form = document.forms['download'];
8 get_note( <% $batchnum %>, form.elements['format'].value,
11 document.getElementById('download_note').textContent = text;
15 <&| /elements/onload.js &>format_changed()</&>
19 % or ( $status eq 'I' and $curuser->access_right('Reprocess batches') )
20 % or ( $status eq 'R' and $curuser->access_right('Redownload resolved batches') )
22 <FORM ACTION="<%$p%>misc/download-batch.cgi" NAME="download" METHOD="POST">
23 <INPUT TYPE="hidden" NAME="batchnum" VALUE="<%$batchnum%>">
25 <INPUT TYPE="hidden" NAME="format" VALUE="<%$fixed%>">
28 Download batch in format <SELECT NAME="format" onchange="format_changed()">
29 % foreach ( keys %download_formats ) {
30 <OPTION VALUE="<%$_%>"><% $download_formats{$_} %></OPTION>
36 <DIV STYLE="color:#ff0000" ID="download_note"></DIV>
37 <INPUT TYPE="submit" VALUE="Download">
43 % if ( $pay_batch->status eq 'I'
44 % or ( $pay_batch->status eq 'R'
45 % and $curuser->access_right('Reprocess batches')
46 % and $conf->exists('batch-manual_approval')
49 <& /elements/form-file_upload.html,
50 'name' => 'FileUpload',
51 'action' => "${p}misc/upload-batch.cgi",
53 'fields' => [ 'batchnum', 'format', 'gatewaynum' ],
54 'url' => $cgi->self_url,
55 'message' => 'Batch results uploaded.',
58 <& /elements/file-upload.html,
60 'label' => 'Filename',
63 <INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>">
66 % if ( $fixed eq 'td_eft1464' ) { # special case
67 Upload in format <SELECT NAME="format">
68 <OPTION VALUE="td_eftack264">TD EFT Acknowledgement</OPTION>
69 <OPTION VALUE="td_eftret80">TD EFT Returned Items</OPTION>
73 <INPUT TYPE="hidden" NAME="format" VALUE="<% $fixed %>">
77 Upload in format <SELECT NAME="format">
78 % foreach ( keys(%upload_formats) ) {
79 <OPTION VALUE="<%$_%>"><% $upload_formats{$_} %></OPTION>
84 <INPUT TYPE="submit" VALUE="Upload">
89 % if ( $fixed eq 'td_eft1464'
91 % and $payby eq 'CHEK'
92 % and $conf->exists('batch-manual_approval')
94 <INPUT TYPE="button" VALUE="Manually approve" onclick="
95 if ( confirm('Approve all remaining payments in this batch?') )
96 window.location.href='<%$p%>misc/process/pay_batch-approve.cgi?batchnum=<%$batchnum%>';
99 % } # end manual approval
102 Batch is <% $statustext{$status} %><BR>
103 <%$count%> payments batched<BR>
104 <%$money_char%><%$total%> total in batch<BR>
106 <%def .select_gateway>
107 % if ( $show_gateways ) {
109 <& /elements/select-table.html,
111 field => 'gatewaynum',
112 table => 'payment_gateway',
114 value_col => 'gatewaynum',
115 order_by => 'ORDER BY gatewaynum',
117 'gateway_namespace' => 'Business::BatchPayment',
124 my $show_gateways = FS::payment_gateway->count("gateway_namespace = 'Business::BatchPayment' AND disabled IS NULL");
128 my $pay_batch = $opt{'pay_batch'} or return;
129 my $conf = new FS::Conf;
130 my $money_char = $conf->config('money_char') || '$';
131 my $payby = $pay_batch->payby;
132 my $status = $pay_batch->status;
133 my $curuser = $FS::CurrentUser::CurrentUser;
134 my $batchnum = $pay_batch->batchnum;
136 my $fixed = $conf->config("batch-fixed_format-$payby");
138 tie my %download_formats, 'Tie::IxHash', (
139 '' => 'Default batch mode',
140 'NACHA' => '94 byte NACHA',
141 'csv-td_canada_trust-merchant_pc_batch' =>
142 'CSV file for TD Canada Trust Merchant PC Batch',
143 'csv-chase_canada-E-xactBatch' =>
144 'CSV file for Chase Canada E-xactBatch',
145 'PAP' => '80 byte file for TD Canada Trust PAP Batch',
146 'BoM' => 'Bank of Montreal ECA batch',
147 'ach-spiritone' => 'Spiritone ACH batch',
148 'paymentech' => 'XML file for Chase Paymentech',
149 'RBC' => 'Royal Bank of Canada PDS batch',
150 'td_eft1464' => '1464 byte file for TD Commercial Banking EFT',
151 'eft_canada' => 'EFT Canada CSV batch',
152 # insert new batch formats here
155 tie my %upload_formats, 'Tie::IxHash', (
158 'td_eftack' => 'TD EFT Acknowledgement',
159 'td_eftret' => 'TD EFT Returned Items',
161 delete $upload_formats{'td_eft1464'};
162 $upload_formats{'PAP'} = '264 byte results for TD Canada Trust PAP Batch',
164 my %statustext = ( 'O' => 'open', 'I' => 'in transit', 'R' => 'resolved' );
166 my $count_query = "SELECT COUNT(*) FROM cust_pay_batch WHERE batchnum=$batchnum";
167 my $count = FS::Record->scalar_sql($count_query);
168 my $sum_query = "SELECT SUM(amount) FROM cust_pay_batch WHERE batchnum=$batchnum";
169 my $total = sprintf("%.2f", FS::Record->scalar_sql($sum_query));