1 <% include("/elements/header.html", 'Quick payment entry',
3 'Main Menu' => $p, #popurl(1),
5 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
8 % if ( $cgi->param('error') ) {
10 <FONT SIZE="+1" COLOR="#ff0000"><% $cgi->param('error') %></FONT><BR><BR>
15 <FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;">
17 <!-- <B>Batch</B> <INPUT TYPE="text" NAME="paybatch"><BR><BR> -->
19 <SCRIPT TYPE="text/javascript">
21 function clearhint_custnum() {
23 //this.style.color = '#000000';
25 if ( this.value == 'Not found' || this.value == 'Multiple' ) {
27 this.style.color = '#000000';
32 function clearhint_customer() {
34 this.style.color = '#000000';
36 if ( this.value == '(last name or company)' || this.value == 'Not found' )
41 function search_custnum() {
43 this.style.color = '#000000'
45 var custnum_obj = this;
46 var searchrow = this.getAttribute('rownum');
47 var custnum = this.value;
49 if ( custnum == 'searching...' || custnum == 'Not found' || custnum == '' )
52 if ( this.getAttribute('magic') == 'nosearch' ) {
53 this.setAttribute('magic', '');
57 if ( ( rownum - searchrow ) == 1 ) {
60 var customer = document.getElementById('customer'+searchrow);
61 customer.value = 'searching...';
62 customer.disabled = true;
63 customer.style.color = '#000000';
64 customer.style.backgroundColor = '#dddddd';
66 var customer_select = document.getElementById('cust_select'+searchrow);
68 //alert('search for custnum ' + custnum + ', row#' + searchrow );
70 customer.style.display = '';
71 customer_select.style.display = 'none';
73 function search_custnum_update(name) {
75 var name = eval('(' + name + ')' );
77 customer.disabled = false;
78 customer.style.backgroundColor = '#ffffff';
80 if ( name.length > 0 ) {
81 //alert('custnum found: ' + name);
82 customer.value = name;
83 customer.setAttribute('magic', 'nosearch');
85 customer.value = 'Not found';
86 customer.style.color = '#ff0000';
87 custnum_obj.style.color = '#ff0000';
93 custnum_search( custnum, search_custnum_update );
97 function search_customer() {
99 var customer_obj = this;
100 var searchrow = this.getAttribute('rownum');
101 var customer = this.value;
103 if ( customer == 'searching...' || customer == 'Not found' || customer == '' )
106 if ( this.getAttribute('magic') == 'nosearch' ) {
107 this.setAttribute('magic', '');
111 if ( ( rownum - searchrow ) == 1 ) {
115 var custnum_obj = document.getElementById('custnum'+searchrow);
116 custnum_obj.value = 'searching...';
117 custnum_obj.disabled = true;
118 custnum_obj.style.color = '#000000';
119 custnum_obj.style.backgroundColor = '#dddddd';
121 var customer_select = document.getElementById('cust_select'+searchrow);
123 //alert('search for customer ' + customer + ', row#' + searchrow );
125 function search_customer_update(customers) {
127 //alert('customers returned: ' + customers);
129 var customerArray = eval('(' + customers + ')');
131 custnum_obj.disabled = false;
132 custnum_obj.style.backgroundColor = '#ffffff';
134 if ( customerArray.length == 0 ) {
136 custnum_obj.value = 'Not found';
137 custnum_obj.style.color = '#ff0000';
138 customer_obj.style.color = '#ff0000';
140 customer_obj.style.display = '';
141 customer_select.style.display = 'none';
144 } else if ( customerArray.length == 1 ) {
146 //alert('one customer found: ' + customerArray[0]);
148 custnum_obj.value = customerArray[0][0];
149 customer_obj.value = customerArray[0][1];
151 customer_obj.style.display = '';
152 customer_select.style.display = 'none';
157 custnum_obj.value = 'Multiple'; // or something
158 custnum_obj.style.color = '#ff0000';
160 //alert('multiple customers found, have to create select dropdown');
162 //blank the current list
163 for ( var i = customer_select.length; i >= 0; i-- )
164 customer_select.options[i] = null;
166 opt(customer_select, '', 'Multiple customers match "' + customer + '" - select one', '#ff0000');
168 //add the multiple customers
169 for ( var s = 0; s < customerArray.length; s++ )
170 opt(customer_select, customerArray[s][0], customerArray[s][1], '#000000');
172 opt(customer_select, 'cancel', '(Edit search string)', '#000000');
174 customer_obj.style.display = 'none';
176 customer_select.style.display = '';
182 smart_search( customer, search_customer_update );
186 function select_customer() {
188 var custnum = this.options[this.selectedIndex].value;
189 var customer = this.options[this.selectedIndex].text;
191 var searchrow = this.getAttribute('rownum');
192 var custnum_obj = document.getElementById('custnum'+searchrow);
193 var customer_obj = document.getElementById('customer'+searchrow);
195 if ( custnum == '' ) {
196 //this.style.color = '#ff0000';
198 } else if ( custnum == 'cancel' ) {
200 custnum_obj.value = '';
201 custnum_obj.style.color = '#000000';
203 this.style.display = 'none';
204 customer_obj.style.display = '';
205 customer_obj.focus();
210 custnum_obj.value = custnum;
211 custnum_obj.style.color = '#000000';
213 customer_obj.value = customer;
214 customer_obj.style.color = '#000000';
216 this.style.display = 'none';
217 customer_obj.style.display = '';
223 function opt(what,value,text,color) {
224 var optionName = new Option(text, value, false, false);
225 optionName.style.color = color;
226 var length = what.length;
227 what.options[length] = optionName;
232 <TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
239 <TH BGCOLOR="#e8e8e8"></TH>
242 % if ( $cgi->param('error') ) {
243 % my $param = $cgi->Vars;
245 % for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) {
251 <INPUT TYPE="text" NAME="custnum<% $row %>" ID="custnum<% $row %>" SIZE=8 MAXLENGTH=12 VALUE="<% $param->{"custnum$row"} %>" rownum="<% $row %>">
252 <SCRIPT TYPE="text/javascript">
253 var custnum_input<% $row %> = document.getElementById("custnum<% $row %>");
254 custnum_input<% $row %>.onfocus = clearhint_custnum;
255 custnum_input<% $row %>.onchange = search_custnum;
260 <INPUT TYPE="text" NAME="customer<% $row %>" ID="customer<% $row %>" SIZE=64 VALUE="<% $param->{"customer$row"} %>" rownum="<% $row %>">
261 <SCRIPT TYPE="text/javascript">
262 var customer_input<% $row %> = document.getElementById("customer<% $row %>");
263 customer_input<% $row %>.onfocus = clearhint_customer;
264 customer_input<% $row %>.onclick = clearhint_customer;
265 customer_input<% $row %>.onchange = search_customer;
267 <SELECT NAME="cust_select<% $row %>" ID="cust_select<% $row %>" rownum="<% $row %>" STYLE="color:#ff0000; display:none">
269 <SCRIPT TYPE="text/javascript">
270 var customer_select<% $row %> = document.getElementById("cust_select<% $row %>");
271 customer_select<% $row %>.onchange = select_customer;
276 $<INPUT TYPE="text" NAME="paid<% $row %>" SIZE=8 MAXLENGTH=8 VALUE="<% $param->{"paid$row"} %>" >
280 <INPUT TYPE="text" NAME="payinfo<% $row %>" SIZE=10 VALUE="<% $param->{"payinfo$row"} %>" >
283 <TD BGCOLOR="#e8e8e8">
284 % if ( $param->{"error$row"} ) {
286 <FONT SIZE="-1" COLOR="#ff0000">Error: <% $param->{"error$row"} %></FONT>
299 <INPUT TYPE="button" VALUE="TEST addrow" onclick="addRow()"> -->
302 <INPUT TYPE="submit" NAME="submit" VALUE="Post payment batch">
307 <% include('/elements/xmlhttp.html',
308 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi',
309 'subs' => [qw( custnum_search smart_search )],
313 <SCRIPT TYPE="text/javascript">
315 var rownum = <% $row %>;
319 var table = document.getElementById('OneTrueTable');
320 var tablebody = table.getElementsByTagName('tbody').item(0);
322 var row = document.createElement('TR');
324 var custnum_cell = document.createElement('TD');
326 var custnum_input = document.createElement('INPUT');
327 custnum_input.setAttribute('name', 'custnum'+rownum);
328 custnum_input.setAttribute('id', 'custnum'+rownum);
329 custnum_input.setAttribute('size', 8);
330 custnum_input.setAttribute('maxlength', 12);
331 custnum_input.setAttribute('rownum', rownum);
332 custnum_input.onfocus = clearhint_custnum;
333 custnum_input.onchange = search_custnum;
334 custnum_cell.appendChild(custnum_input);
336 row.appendChild(custnum_cell);
338 var customer_cell = document.createElement('TD');
340 var customer_input = document.createElement('INPUT');
341 customer_input.setAttribute('name', 'customer'+rownum);
342 customer_input.setAttribute('id', 'customer'+rownum);
343 customer_input.setAttribute('size', 64);
344 customer_input.setAttribute('value', '(last name or company)' );
345 customer_input.setAttribute('rownum', rownum);
346 customer_input.onfocus = clearhint_customer;
347 customer_input.onclick = clearhint_customer;
348 customer_input.onchange = search_customer;
349 customer_cell.appendChild(customer_input);
351 var customer_select = document.createElement('SELECT');
352 customer_select.setAttribute('name', 'cust_select'+rownum);
353 customer_select.setAttribute('id', 'cust_select'+rownum);
354 customer_select.setAttribute('rownum', rownum);
355 customer_select.style.color = '#ff0000';
356 customer_select.style.display = 'none';
357 customer_select.onchange = select_customer;
358 customer_cell.appendChild(customer_select);
360 row.appendChild(customer_cell);
362 var paid_cell = document.createElement('TD');
364 var paid_text = document.createTextNode('$');
365 paid_cell.appendChild(paid_text);
367 var paid_input = document.createElement('INPUT');
368 paid_input.setAttribute('name', 'paid'+rownum);
369 paid_input.setAttribute('size', 8);
370 paid_input.setAttribute('maxlength', 8);
371 paid_cell.appendChild(paid_input);
373 row.appendChild(paid_cell);
375 var payinfo_cell = document.createElement('TD');
376 var payinfo_input = document.createElement('INPUT');
377 payinfo_input.setAttribute('name', 'payinfo'+rownum);
378 payinfo_input.setAttribute('size', 10);
379 payinfo_cell.appendChild(payinfo_input);
380 row.appendChild(payinfo_cell);
382 var error_cell = document.createElement('TD');
383 error_cell.style.backgroundColor = '#e8e8e8';
384 row.appendChild(error_cell);
386 tablebody.appendChild(row);