This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / httemplate / misc / batch-cust_pay.html
1 <%= header( 'Quick payment entry',
2             menubar(
3                      'Main Menu' => $p, #popurl(1),
4                      'Old-style quick payment entry' =>
5                        $p. 'search/cust_main-quickpay.html',
6                    ),
7             ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
8           )
9 %>
10
11 <% if ( $cgi->param('error') ) { %>
12   <FONT SIZE="+1" COLOR="#ff0000"><%= $cgi->param('error') %></FONT><BR><BR>
13 <% } %>
14
15
16 <FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;">
17
18 <!-- <B>Batch</B> <INPUT TYPE="text" NAME="paybatch"><BR><BR> -->
19
20 <SCRIPT TYPE="text/javascript">
21
22   function clearhint_custnum() {
23
24     //this.style.color = '#000000';
25
26     if ( this.value == 'Not found' || this.value == 'Multiple' ) {
27       this.value = '';
28       this.style.color = '#000000';
29     }
30
31   }
32
33   function clearhint_customer() {
34
35     this.style.color = '#000000';
36
37     if ( this.value == '(last name or company)' || this.value == 'Not found' )
38       this.value = '';
39
40   }
41
42   function search_custnum() {
43
44     this.style.color = '#000000'
45
46     var custnum_obj = this;
47     var searchrow = this.getAttribute('rownum');
48     var custnum = this.value;
49
50     if ( custnum == 'searching...' || custnum == 'Not found' || custnum == '' )
51       return;
52
53     if ( this.getAttribute('magic') == 'nosearch' ) {
54       this.setAttribute('magic', '');
55       return;
56     }
57
58     if ( ( rownum - searchrow ) == 1 ) {
59       addRow();
60     }
61     var customer = document.getElementById('customer'+searchrow);
62     customer.value = 'searching...';
63     customer.disabled = true;
64     customer.style.color = '#000000';
65     customer.style.backgroundColor = '#dddddd';
66
67     var customer_select = document.getElementById('cust_select'+searchrow);
68
69     //alert('search for custnum ' + custnum + ', row#' + searchrow );
70
71     customer.style.display = '';
72     customer_select.style.display = 'none';
73
74     function search_custnum_update(name) {
75
76       var name = eval('(' + name + ')' );
77
78       customer.disabled = false;
79       customer.style.backgroundColor = '#ffffff';
80
81       if ( name.length > 0 ) {
82         //alert('custnum found: ' + name);
83         customer.value = name;
84         customer.setAttribute('magic', 'nosearch');
85       } else {
86         customer.value = 'Not found';
87         customer.style.color = '#ff0000';
88         custnum_obj.style.color = '#ff0000';
89
90       }
91
92     }
93
94     custnum_search( custnum, search_custnum_update );
95
96   }
97
98   function search_customer() {
99
100     var customer_obj = this;
101     var searchrow = this.getAttribute('rownum');
102     var customer = this.value;
103
104     if ( customer == 'searching...' || customer == 'Not found' || customer == '' )
105       return;
106
107     if ( this.getAttribute('magic') == 'nosearch' ) {
108       this.setAttribute('magic', '');
109       return;
110     }
111
112     if ( ( rownum - searchrow ) == 1 ) {
113       addRow();
114     }
115
116     var custnum_obj = document.getElementById('custnum'+searchrow);
117     custnum_obj.value = 'searching...';
118     custnum_obj.disabled = true;
119     custnum_obj.style.color = '#000000';
120     custnum_obj.style.backgroundColor = '#dddddd';
121
122     var customer_select = document.getElementById('cust_select'+searchrow);
123
124     //alert('search for customer ' + customer + ', row#' + searchrow );
125
126     function search_customer_update(customers) {
127
128       //alert('customers returned: ' + customers);
129
130       var customerArray = eval('(' + customers + ')');
131
132       custnum_obj.disabled = false;
133       custnum_obj.style.backgroundColor = '#ffffff';
134
135       if ( customerArray.length == 0 ) {
136
137         custnum_obj.value = 'Not found';
138         custnum_obj.style.color = '#ff0000';
139         customer_obj.style.color = '#ff0000';
140
141         customer_obj.style.display = '';
142         customer_select.style.display = 'none';
143
144
145       } else if ( customerArray.length == 1 ) {
146
147         //alert('one customer found: ' + customerArray[0]);
148
149         custnum_obj.value = customerArray[0][0];
150         customer_obj.value = customerArray[0][1];
151
152         customer_obj.style.display = '';
153         customer_select.style.display = 'none';
154
155
156       } else {
157
158         custnum_obj.value = 'Multiple'; // or something
159         custnum_obj.style.color = '#ff0000';
160
161         //alert('multiple customers found, have to create select dropdown');
162
163         //blank the current list
164         for ( var i = customer_select.length; i >= 0; i-- )
165           customer_select.options[i] = null;
166
167         opt(customer_select, '', 'Multiple customers match "' + customer + '" - select one', '#ff0000');
168
169         //add the multiple customers
170         for ( var s = 0; s < customerArray.length; s++ )
171           opt(customer_select, customerArray[s][0], customerArray[s][1], '#000000');
172
173         opt(customer_select, 'cancel', '(Edit search string)', '#000000');
174
175         customer_obj.style.display = 'none';
176
177         customer_select.style.display = '';
178
179       }
180
181     }
182
183     smart_search( customer, search_customer_update );
184
185   }
186
187   function select_customer() {
188
189     var custnum = this.options[this.selectedIndex].value;
190     var customer = this.options[this.selectedIndex].text;
191
192     var searchrow = this.getAttribute('rownum');
193     var custnum_obj = document.getElementById('custnum'+searchrow);
194     var customer_obj = document.getElementById('customer'+searchrow);
195
196     if ( custnum == '' ) {
197       //this.style.color = '#ff0000';
198
199     } else if ( custnum == 'cancel' ) {
200
201       custnum_obj.value = '';
202       custnum_obj.style.color = '#000000';
203
204       this.style.display = 'none';
205       customer_obj.style.display = '';
206       customer_obj.focus();
207
208     } else {
209
210
211       custnum_obj.value = custnum;
212       custnum_obj.style.color = '#000000';
213
214       customer_obj.value = customer;
215       customer_obj.style.color = '#000000';
216
217       this.style.display = 'none';
218       customer_obj.style.display = '';
219
220     }
221
222   }
223
224   function opt(what,value,text,color) {
225     var optionName = new Option(text, value, false, false);
226     optionName.style.color = color;
227     var length = what.length;
228     what.options[length] = optionName;
229   }
230
231 </SCRIPT>
232
233 <TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
234
235 <TR>
236   <TH>Cust #</TH>
237   <TH>Customer</TH>
238   <TH>Amount</TH>
239   <TH>Check #</TH>
240   <TH BGCOLOR="#e8e8e8"></TH>
241 </TR>
242
243 <% my $row = 0;
244    if ( $cgi->param('error') ) {
245      my $param = $cgi->Vars;
246 %>
247
248   <% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { %>
249
250     <TR>
251
252       <TD>
253         <INPUT TYPE="text" NAME="custnum<%= $row %>" ID="custnum<%= $row %>" SIZE=8 MAXLENGTH=12 VALUE="<%= $param->{"custnum$row"} %>" rownum="<%= $row %>">
254           <SCRIPT TYPE="text/javascript">
255             var custnum_input<%= $row %> = document.getElementById("custnum<%= $row %>");
256             custnum_input<%= $row %>.onfocus = clearhint_custnum;
257             custnum_input<%= $row %>.onchange = search_custnum;
258           </SCRIPT>
259       </TD>
260
261       <TD>
262         <INPUT TYPE="text" NAME="customer<%= $row %>" ID="customer<%= $row %>" SIZE=64 VALUE="<%= $param->{"customer$row"} %>" rownum="<%= $row %>">
263           <SCRIPT TYPE="text/javascript">
264             var customer_input<%= $row %> = document.getElementById("customer<%= $row %>");
265             customer_input<%= $row %>.onfocus = clearhint_customer;
266             customer_input<%= $row %>.onclick = clearhint_customer;
267             customer_input<%= $row %>.onchange = search_customer;
268           </SCRIPT>
269         <SELECT NAME="cust_select<%= $row %>" ID="cust_select<%= $row %>" rownum="<%= $row %>" STYLE="color:#ff0000; display:none"">
270         </SELECT>
271           <SCRIPT TYPE="text/javascript">
272             var customer_select<%= $row %> = document.getElementById("cust_select<%= $row %>");
273             customer_select<%= $row %>.onchange = select_customer;
274           </SCRIPT>
275       </TD>
276
277       <TD>
278         $<INPUT TYPE="text" NAME="paid<%= $row %>" SIZE=8 MAXLENGTH=8 VALUE="<%= $param->{"paid$row"} %>" >
279       </TD>
280
281       <TD>
282         <INPUT TYPE="text" NAME="payinfo<%= $row %>" SIZE=10 VALUE="<%= $param->{"payinfo$row"} %>" >
283       </TD>
284
285       <TD BGCOLOR="#e8e8e8">
286       <% if ( $param->{"error$row"} ) { %>
287         <FONT SIZE="-1" COLOR="#ff0000">Error: <%= $param->{"error$row"} %></FONT>
288       <% } %>
289       </TD>
290
291     </TR>
292
293   <% } %>
294
295 <% } %>
296
297 </TABLE>
298
299 <!-- <BR>
300 <INPUT TYPE="button" VALUE="TEST addrow" onclick="addRow()"> -->
301
302 <BR>
303 <INPUT TYPE="submit" NAME="submit" VALUE="Post payment batch">
304
305 </FORM>
306
307
308 <%= include('/elements/xmlhttp.html',
309               'url'  => $p. 'misc/xmlhttp-cust_main-search.cgi',
310               'subs' => [qw( custnum_search smart_search )],
311            )
312 %>
313
314 <SCRIPT TYPE="text/javascript">
315
316   var rownum = <%= $row %>;
317
318   function addRow() {
319
320     var table = document.getElementById('OneTrueTable');
321     var tablebody = table.getElementsByTagName('tbody').item(0);
322
323     var row = document.createElement('TR');
324
325     var custnum_cell = document.createElement('TD');
326
327       var custnum_input = document.createElement('INPUT');
328       custnum_input.setAttribute('name', 'custnum'+rownum);
329       custnum_input.setAttribute('id',   'custnum'+rownum);
330       custnum_input.setAttribute('size', 8);
331       custnum_input.setAttribute('maxlength', 12);
332       custnum_input.setAttribute('rownum', rownum);
333       custnum_input.onfocus = clearhint_custnum;
334       custnum_input.onchange = search_custnum;
335       custnum_cell.appendChild(custnum_input);
336
337     row.appendChild(custnum_cell);
338
339     var customer_cell = document.createElement('TD');
340
341       var customer_input = document.createElement('INPUT');
342       customer_input.setAttribute('name', 'customer'+rownum);
343       customer_input.setAttribute('id',   'customer'+rownum);
344       customer_input.setAttribute('size', 64);
345       customer_input.setAttribute('value', '(last name or company)' );
346       customer_input.setAttribute('rownum', rownum);
347       customer_input.onfocus = clearhint_customer;
348       customer_input.onclick = clearhint_customer;
349       customer_input.onchange = search_customer;
350       customer_cell.appendChild(customer_input);
351
352       var customer_select = document.createElement('SELECT');
353       customer_select.setAttribute('name', 'cust_select'+rownum);
354       customer_select.setAttribute('id',   'cust_select'+rownum);
355       customer_select.setAttribute('rownum', rownum);
356       customer_select.style.color = '#ff0000';
357       customer_select.style.display = 'none';
358       customer_select.onchange = select_customer;
359       customer_cell.appendChild(customer_select);
360
361     row.appendChild(customer_cell);
362
363     var paid_cell = document.createElement('TD');
364
365       var paid_text = document.createTextNode('$');
366       paid_cell.appendChild(paid_text);
367
368       var paid_input = document.createElement('INPUT');
369       paid_input.setAttribute('name', 'paid'+rownum);
370       paid_input.setAttribute('size', 8);
371       paid_input.setAttribute('maxlength', 8);
372       paid_cell.appendChild(paid_input);
373
374     row.appendChild(paid_cell);
375
376     var payinfo_cell = document.createElement('TD');
377       var payinfo_input = document.createElement('INPUT');
378       payinfo_input.setAttribute('name', 'payinfo'+rownum);
379       payinfo_input.setAttribute('size', 10);
380       payinfo_cell.appendChild(payinfo_input);
381     row.appendChild(payinfo_cell);
382
383     var error_cell = document.createElement('TD');
384     error_cell.style.backgroundColor = '#e8e8e8';
385     row.appendChild(error_cell);
386
387     tablebody.appendChild(row);
388
389     rownum++;
390
391   }
392
393 </SCRIPT>
394
395 </BODY>
396 </HTML>