1 <%= include("/elements/header.html", 'Quick payment entry',
3 'Main Menu' => $p, #popurl(1),
4 'Old-style quick payment entry' =>
5 $p. 'search/cust_main-quickpay.html',
7 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
11 <% if ( $cgi->param('error') ) { %>
12 <FONT SIZE="+1" COLOR="#ff0000"><%= $cgi->param('error') %></FONT><BR><BR>
16 <FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;">
18 <!-- <B>Batch</B> <INPUT TYPE="text" NAME="paybatch"><BR><BR> -->
20 <SCRIPT TYPE="text/javascript">
22 function clearhint_custnum() {
24 //this.style.color = '#000000';
26 if ( this.value == 'Not found' || this.value == 'Multiple' ) {
28 this.style.color = '#000000';
33 function clearhint_customer() {
35 this.style.color = '#000000';
37 if ( this.value == '(last name or company)' || this.value == 'Not found' )
42 function search_custnum() {
44 this.style.color = '#000000'
46 var custnum_obj = this;
47 var searchrow = this.getAttribute('rownum');
48 var custnum = this.value;
50 if ( custnum == 'searching...' || custnum == 'Not found' || custnum == '' )
53 if ( this.getAttribute('magic') == 'nosearch' ) {
54 this.setAttribute('magic', '');
58 if ( ( rownum - searchrow ) == 1 ) {
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';
67 var customer_select = document.getElementById('cust_select'+searchrow);
69 //alert('search for custnum ' + custnum + ', row#' + searchrow );
71 customer.style.display = '';
72 customer_select.style.display = 'none';
74 function search_custnum_update(name) {
76 var name = eval('(' + name + ')' );
78 customer.disabled = false;
79 customer.style.backgroundColor = '#ffffff';
81 if ( name.length > 0 ) {
82 //alert('custnum found: ' + name);
83 customer.value = name;
84 customer.setAttribute('magic', 'nosearch');
86 customer.value = 'Not found';
87 customer.style.color = '#ff0000';
88 custnum_obj.style.color = '#ff0000';
94 custnum_search( custnum, search_custnum_update );
98 function search_customer() {
100 var customer_obj = this;
101 var searchrow = this.getAttribute('rownum');
102 var customer = this.value;
104 if ( customer == 'searching...' || customer == 'Not found' || customer == '' )
107 if ( this.getAttribute('magic') == 'nosearch' ) {
108 this.setAttribute('magic', '');
112 if ( ( rownum - searchrow ) == 1 ) {
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';
122 var customer_select = document.getElementById('cust_select'+searchrow);
124 //alert('search for customer ' + customer + ', row#' + searchrow );
126 function search_customer_update(customers) {
128 //alert('customers returned: ' + customers);
130 var customerArray = eval('(' + customers + ')');
132 custnum_obj.disabled = false;
133 custnum_obj.style.backgroundColor = '#ffffff';
135 if ( customerArray.length == 0 ) {
137 custnum_obj.value = 'Not found';
138 custnum_obj.style.color = '#ff0000';
139 customer_obj.style.color = '#ff0000';
141 customer_obj.style.display = '';
142 customer_select.style.display = 'none';
145 } else if ( customerArray.length == 1 ) {
147 //alert('one customer found: ' + customerArray[0]);
149 custnum_obj.value = customerArray[0][0];
150 customer_obj.value = customerArray[0][1];
152 customer_obj.style.display = '';
153 customer_select.style.display = 'none';
158 custnum_obj.value = 'Multiple'; // or something
159 custnum_obj.style.color = '#ff0000';
161 //alert('multiple customers found, have to create select dropdown');
163 //blank the current list
164 for ( var i = customer_select.length; i >= 0; i-- )
165 customer_select.options[i] = null;
167 opt(customer_select, '', 'Multiple customers match "' + customer + '" - select one', '#ff0000');
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');
173 opt(customer_select, 'cancel', '(Edit search string)', '#000000');
175 customer_obj.style.display = 'none';
177 customer_select.style.display = '';
183 smart_search( customer, search_customer_update );
187 function select_customer() {
189 var custnum = this.options[this.selectedIndex].value;
190 var customer = this.options[this.selectedIndex].text;
192 var searchrow = this.getAttribute('rownum');
193 var custnum_obj = document.getElementById('custnum'+searchrow);
194 var customer_obj = document.getElementById('customer'+searchrow);
196 if ( custnum == '' ) {
197 //this.style.color = '#ff0000';
199 } else if ( custnum == 'cancel' ) {
201 custnum_obj.value = '';
202 custnum_obj.style.color = '#000000';
204 this.style.display = 'none';
205 customer_obj.style.display = '';
206 customer_obj.focus();
211 custnum_obj.value = custnum;
212 custnum_obj.style.color = '#000000';
214 customer_obj.value = customer;
215 customer_obj.style.color = '#000000';
217 this.style.display = 'none';
218 customer_obj.style.display = '';
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;
233 <TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
240 <TH BGCOLOR="#e8e8e8"></TH>
244 if ( $cgi->param('error') ) {
245 my $param = $cgi->Vars;
248 <% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { %>
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;
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;
269 <SELECT NAME="cust_select<%= $row %>" ID="cust_select<%= $row %>" rownum="<%= $row %>" STYLE="color:#ff0000; display:none"">
271 <SCRIPT TYPE="text/javascript">
272 var customer_select<%= $row %> = document.getElementById("cust_select<%= $row %>");
273 customer_select<%= $row %>.onchange = select_customer;
278 $<INPUT TYPE="text" NAME="paid<%= $row %>" SIZE=8 MAXLENGTH=8 VALUE="<%= $param->{"paid$row"} %>" >
282 <INPUT TYPE="text" NAME="payinfo<%= $row %>" SIZE=10 VALUE="<%= $param->{"payinfo$row"} %>" >
285 <TD BGCOLOR="#e8e8e8">
286 <% if ( $param->{"error$row"} ) { %>
287 <FONT SIZE="-1" COLOR="#ff0000">Error: <%= $param->{"error$row"} %></FONT>
300 <INPUT TYPE="button" VALUE="TEST addrow" onclick="addRow()"> -->
303 <INPUT TYPE="submit" NAME="submit" VALUE="Post payment batch">
308 <%= include('/elements/xmlhttp.html',
309 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi',
310 'subs' => [qw( custnum_search smart_search )],
314 <SCRIPT TYPE="text/javascript">
316 var rownum = <%= $row %>;
320 var table = document.getElementById('OneTrueTable');
321 var tablebody = table.getElementsByTagName('tbody').item(0);
323 var row = document.createElement('TR');
325 var custnum_cell = document.createElement('TD');
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);
337 row.appendChild(custnum_cell);
339 var customer_cell = document.createElement('TD');
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);
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);
361 row.appendChild(customer_cell);
363 var paid_cell = document.createElement('TD');
365 var paid_text = document.createTextNode('$');
366 paid_cell.appendChild(paid_text);
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);
374 row.appendChild(paid_cell);
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);
383 var error_cell = document.createElement('TD');
384 error_cell.style.backgroundColor = '#e8e8e8';
385 row.appendChild(error_cell);
387 tablebody.appendChild(row);