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;
18 % or ( $status eq 'I' and $curuser->access_right('Reprocess batches') )
19 % or ( $status eq 'R' and $curuser->access_right('Redownload resolved batches') )
21 <FORM ACTION="<%$p%>misc/download-batch.cgi" NAME="download" METHOD="POST">
22 <INPUT TYPE="hidden" NAME="batchnum" VALUE="<%$batchnum%>">
24 <INPUT TYPE="hidden" NAME="format" VALUE="<%$fixed%>">
27 Download batch in format <SELECT NAME="format" onchange="format_changed()">
28 % foreach ( keys %download_formats ) {
29 <OPTION VALUE="<%$_%>"><% $download_formats{$_} %></OPTION>
33 <DIV STYLE="color:#ff0000" ID="download_note"></DIV>
36 <INPUT TYPE="submit" VALUE="Download">
42 % if ( $pay_batch->status eq 'I'
43 % or ( $pay_batch->status eq 'R'
44 % and $curuser->access_right('Reprocess batches')
45 % and $conf->exists('batch-manual_approval')
48 <& /elements/form-file_upload.html,
49 'name' => 'FileUpload',
50 'action' => "${p}misc/upload-batch.cgi",
52 'fields' => [ 'batchnum', 'format', 'gatewaynum' ],
53 'url' => $cgi->self_url,
54 'message' => 'Batch results uploaded.',
57 <& /elements/file-upload.html,
59 'label' => 'Filename',
62 <INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>">
65 % if ( $fixed eq 'td_eft1464' ) { # special case
66 Upload in format <SELECT NAME="format">
67 <OPTION VALUE="td_eftack264">TD EFT Acknowledgement</OPTION>
68 <OPTION VALUE="td_eftret80">TD EFT Returned Items</OPTION>
72 <INPUT TYPE="hidden" NAME="format" VALUE="<% $fixed %>">
76 Upload in format <SELECT NAME="format">
77 % foreach ( keys(%upload_formats) ) {
78 <OPTION VALUE="<%$_%>"><% $upload_formats{$_} %></OPTION>
83 <INPUT TYPE="submit" VALUE="Upload">
88 % if ( $fixed eq 'td_eft1464'
90 % and $payby eq 'CHEK'
91 % and $conf->exists('batch-manual_approval')
93 <INPUT TYPE="button" VALUE="Manually approve" onclick="
94 if ( confirm('Approve all remaining payments in this batch?') )
95 window.location.href='<%$p%>misc/process/pay_batch-approve.cgi?batchnum=<%$batchnum%>';
98 % } # end manual approval
101 Batch is <% $statustext{$status} %><BR>
102 <%$count%> payments batched<BR>
103 <%$money_char%><%$total%> total in batch<BR>
105 <%def .select_gateway>
106 % if ( $show_gateways ) {
108 <& /elements/select-table.html,
110 field => 'gatewaynum',
111 table => 'payment_gateway',
113 value_col => 'gatewaynum',
114 order_by => 'ORDER BY gatewaynum',
116 'gateway_namespace' => 'Business::BatchPayment',
123 my $show_gateways = FS::payment_gateway->count("gateway_namespace = 'Business::BatchPayment' AND disabled IS NULL");
127 my $pay_batch = $opt{'pay_batch'} or return;
128 my $conf = new FS::Conf;
129 my $money_char = $conf->config('money_char') || '$';
130 my $payby = $pay_batch->payby;
131 my $status = $pay_batch->status;
132 my $curuser = $FS::CurrentUser::CurrentUser;
133 my $batchnum = $pay_batch->batchnum;
135 my $fixed = $conf->config("batch-fixed_format-$payby");
137 tie my %download_formats, 'Tie::IxHash', (
138 '' => 'Default batch mode',
139 'NACHA' => '94 byte NACHA',
140 'csv-td_canada_trust-merchant_pc_batch' =>
141 'CSV file for TD Canada Trust Merchant PC Batch',
142 'csv-chase_canada-E-xactBatch' =>
143 'CSV file for Chase Canada E-xactBatch',
144 'PAP' => '80 byte file for TD Canada Trust PAP Batch',
145 'BoM' => 'Bank of Montreal ECA batch',
146 'ach-spiritone' => 'Spiritone ACH batch',
147 'paymentech' => 'XML file for Chase Paymentech',
148 'RBC' => 'Royal Bank of Canada PDS batch',
149 'td_eft1464' => '1464 byte file for TD Commercial Banking EFT',
150 'eft_canada' => 'EFT Canada CSV batch',
151 # insert new batch formats here
154 tie my %upload_formats, 'Tie::IxHash', (
157 'td_eftack' => 'TD EFT Acknowledgement',
158 'td_eftret' => 'TD EFT Returned Items',
160 delete $upload_formats{'td_eft1464'};
161 $upload_formats{'PAP'} = '264 byte results for TD Canada Trust PAP Batch',
163 my %statustext = ( 'O' => 'open', 'I' => 'in transit', 'R' => 'resolved' );
165 my $count_query = "SELECT COUNT(*) FROM cust_pay_batch WHERE batchnum=$batchnum";
166 my $count = FS::Record->scalar_sql($count_query);
167 my $sum_query = "SELECT SUM(amount) FROM cust_pay_batch WHERE batchnum=$batchnum";
168 my $total = sprintf("%.2f", FS::Record->scalar_sql($sum_query));