adjust EFT Canada processing delay based on time of day, and warn the user, #20384
[freeside.git] / httemplate / search / elements / cust_pay_batch_top.html
1 <& /elements/xmlhttp.html,
2   'url'   => $p.'misc/xmlhttp-pay_batch-note.html',
3   'subs'  => [ 'get_note' ]
4 &>
5 <script type="text/javascript">
6 function format_changed() {
7   var form = document.forms['download'];
8   get_note( <% $batchnum %>, form.elements['format'].value,
9     //callback
10     function(text) {
11       document.getElementById('download_note').textContent = text;
12     }
13   );
14 }
15 </script>
16 % # Download batch
17 % if ( $status eq 'O'
18 %   or ( $status eq 'I' and $curuser->access_right('Reprocess batches') )
19 %   or ( $status eq 'R' and $curuser->access_right('Redownload resolved batches') )
20 %   ) {
21 <FORM ACTION="<%$p%>misc/download-batch.cgi" NAME="download" METHOD="POST">
22     <INPUT TYPE="hidden" NAME="batchnum" VALUE="<%$batchnum%>">
23 %   if ( $fixed ) {
24     <INPUT TYPE="hidden" NAME="format" VALUE="<%$fixed%>">
25 %   }
26 %   else {
27     Download batch in format <SELECT NAME="format" onchange="format_changed()">
28 %     foreach ( keys %download_formats ) {
29       <OPTION VALUE="<%$_%>"><% $download_formats{$_} %></OPTION>
30 %     }
31     </SELECT> 
32     <BR>
33     <DIV STYLE="color:#ff0000" ID="download_note"></DIV>
34     <& .select_gateway &>
35 %   }
36     <INPUT TYPE="submit" VALUE="Download">
37 % } # end of download
38 </FORM>
39 <BR>
40
41 % # Upload batch
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')
46 %   ) 
47 % ) {
48 <& /elements/form-file_upload.html,
49               'name'      => 'FileUpload',
50               'action'    => "${p}misc/upload-batch.cgi",
51               'num_files' => 1,
52               'fields'    => [ 'batchnum', 'format', 'gatewaynum' ],
53               'url'       => $cgi->self_url,
54               'message'   => 'Batch results uploaded.',
55 &>
56   Upload results<BR>
57   <& /elements/file-upload.html,
58               'field'     => 'file',
59               'label'     => 'Filename',
60               'no_table'  => 1,
61   &>
62   <INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>">
63   <BR>
64 %   if ( $fixed ) {
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>
69   </SELECT>
70 %     }
71 %     else {
72   <INPUT TYPE="hidden" NAME="format" VALUE="<% $fixed %>">
73 %     }
74 %   }
75 %   else {
76   Upload in format <SELECT NAME="format">
77 %     foreach ( keys(%upload_formats) ) {
78     <OPTION VALUE="<%$_%>"><% $upload_formats{$_} %></OPTION>
79 %     }
80   </SELECT>
81   <& .select_gateway &>
82 %   } # if $fixed
83   <INPUT TYPE="submit" VALUE="Upload">
84 </FORM><BR>
85 % } # end upload
86
87 % # manual approval
88 % if ( $fixed eq 'td_eft1464'
89 %   and $status eq 'I'
90 %   and $payby eq 'CHEK'
91 %   and $conf->exists('batch-manual_approval')
92 %   ) {
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%>';
96 ">
97 <BR>
98 % } # end manual approval
99
100 % # summary info
101 Batch is <% $statustext{$status} %><BR>
102 <%$count%> payments batched<BR>
103 <%$money_char%><%$total%> total in batch<BR>
104
105 <%def .select_gateway>
106 % if ( $show_gateways ) {
107  or for gateway
108 <& /elements/select-table.html,
109   empty_label => ' ',
110   field     => 'gatewaynum',
111   table     => 'payment_gateway',
112   name_col  => 'label',
113   value_col => 'gatewaynum',
114   order_by  => 'ORDER BY gatewaynum',
115   hashref   => { 
116     'gateway_namespace' => 'Business::BatchPayment',
117     'disabled'          => '',
118   }
119 &>
120 % }
121 </%def>
122 <%shared>
123 my $show_gateways = FS::payment_gateway->count("gateway_namespace = 'Business::BatchPayment' AND disabled IS NULL");
124 </%shared>
125 <%init>
126 my %opt = @_;
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;
134
135 my $fixed = $conf->config("batch-fixed_format-$payby");
136
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
152 );
153
154 tie my %upload_formats, 'Tie::IxHash', (
155   %download_formats,
156 # minor tweaks
157   'td_eftack' => 'TD EFT Acknowledgement',
158   'td_eftret' => 'TD EFT Returned Items',
159 );
160 delete $upload_formats{'td_eft1464'};
161 $upload_formats{'PAP'} = '264 byte results for TD Canada Trust PAP Batch',
162
163 my %statustext = ( 'O' => 'open', 'I' => 'in transit', 'R' => 'resolved' );
164
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));
169
170 </%init>