1 <%= include("/elements/header.html", 'Quick payment entry',
3 'Main Menu' => $p, #popurl(1),
5 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
9 <% if ( $cgi->param('error') ) { %>
10 <FONT SIZE="+1" COLOR="#ff0000"><%= $cgi->param('error') %></FONT><BR><BR>
14 <FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;">
16 <!-- <B>Batch</B> <INPUT TYPE="text" NAME="paybatch"><BR><BR> -->
18 <SCRIPT TYPE="text/javascript">
20 function clearhint_custnum() {
22 //this.style.color = '#000000';
24 if ( this.value == 'Not found' || this.value == 'Multiple' ) {
26 this.style.color = '#000000';
31 function clearhint_customer() {
33 this.style.color = '#000000';
35 if ( this.value == '(last name or company)' || this.value == 'Not found' )
40 function search_custnum() {
42 this.style.color = '#000000'
44 var custnum_obj = this;
45 var searchrow = this.getAttribute('rownum');
46 var custnum = this.value;
48 if ( custnum == 'searching...' || custnum == 'Not found' || custnum == '' )
51 if ( this.getAttribute('magic') == 'nosearch' ) {
52 this.setAttribute('magic', '');
56 if ( ( rownum - searchrow ) == 1 ) {
59 var customer = document.getElementById('customer'+searchrow);
60 customer.value = 'searching...';
61 customer.disabled = true;
62 customer.style.color = '#000000';
63 customer.style.backgroundColor = '#dddddd';
65 var customer_select = document.getElementById('cust_select'+searchrow);
67 //alert('search for custnum ' + custnum + ', row#' + searchrow );
69 customer.style.display = '';
70 customer_select.style.display = 'none';
72 function search_custnum_update(name) {
74 var name = eval('(' + name + ')' );
76 customer.disabled = false;
77 customer.style.backgroundColor = '#ffffff';
79 if ( name.length > 0 ) {
80 //alert('custnum found: ' + name);
81 customer.value = name;
82 customer.setAttribute('magic', 'nosearch');
84 customer.value = 'Not found';
85 customer.style.color = '#ff0000';
86 custnum_obj.style.color = '#ff0000';
92 custnum_search( custnum, search_custnum_update );
96 function search_customer() {
98 var customer_obj = this;
99 var searchrow = this.getAttribute('rownum');
100 var customer = this.value;
102 if ( customer == 'searching...' || customer == 'Not found' || customer == '' )
105 if ( this.getAttribute('magic') == 'nosearch' ) {
106 this.setAttribute('magic', '');
110 if ( ( rownum - searchrow ) == 1 ) {
114 var custnum_obj = document.getElementById('custnum'+searchrow);
115 custnum_obj.value = 'searching...';
116 custnum_obj.disabled = true;
117 custnum_obj.style.color = '#000000';
118 custnum_obj.style.backgroundColor = '#dddddd';
120 var customer_select = document.getElementById('cust_select'+searchrow);
122 //alert('search for customer ' + customer + ', row#' + searchrow );
124 function search_customer_update(customers) {
126 //alert('customers returned: ' + customers);
128 var customerArray = eval('(' + customers + ')');
130 custnum_obj.disabled = false;
131 custnum_obj.style.backgroundColor = '#ffffff';
133 if ( customerArray.length == 0 ) {
135 custnum_obj.value = 'Not found';
136 custnum_obj.style.color = '#ff0000';
137 customer_obj.style.color = '#ff0000';
139 customer_obj.style.display = '';
140 customer_select.style.display = 'none';
143 } else if ( customerArray.length == 1 ) {
145 //alert('one customer found: ' + customerArray[0]);
147 custnum_obj.value = customerArray[0][0];
148 customer_obj.value = customerArray[0][1];
150 customer_obj.style.display = '';
151 customer_select.style.display = 'none';
156 custnum_obj.value = 'Multiple'; // or something
157 custnum_obj.style.color = '#ff0000';
159 //alert('multiple customers found, have to create select dropdown');
161 //blank the current list
162 for ( var i = customer_select.length; i >= 0; i-- )
163 customer_select.options[i] = null;
165 opt(customer_select, '', 'Multiple customers match "' + customer + '" - select one', '#ff0000');
167 //add the multiple customers
168 for ( var s = 0; s < customerArray.length; s++ )
169 opt(customer_select, customerArray[s][0], customerArray[s][1], '#000000');
171 opt(customer_select, 'cancel', '(Edit search string)', '#000000');
173 customer_obj.style.display = 'none';
175 customer_select.style.display = '';
181 smart_search( customer, search_customer_update );
185 function select_customer() {
187 var custnum = this.options[this.selectedIndex].value;
188 var customer = this.options[this.selectedIndex].text;
190 var searchrow = this.getAttribute('rownum');
191 var custnum_obj = document.getElementById('custnum'+searchrow);
192 var customer_obj = document.getElementById('customer'+searchrow);
194 if ( custnum == '' ) {
195 //this.style.color = '#ff0000';
197 } else if ( custnum == 'cancel' ) {
199 custnum_obj.value = '';
200 custnum_obj.style.color = '#000000';
202 this.style.display = 'none';
203 customer_obj.style.display = '';
204 customer_obj.focus();
209 custnum_obj.value = custnum;
210 custnum_obj.style.color = '#000000';
212 customer_obj.value = customer;
213 customer_obj.style.color = '#000000';
215 this.style.display = 'none';
216 customer_obj.style.display = '';
222 function opt(what,value,text,color) {
223 var optionName = new Option(text, value, false, false);
224 optionName.style.color = color;
225 var length = what.length;
226 what.options[length] = optionName;
231 <TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
238 <TH BGCOLOR="#e8e8e8"></TH>
242 if ( $cgi->param('error') ) {
243 my $param = $cgi->Vars;
246 <% 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"} ) { %>
285 <FONT SIZE="-1" COLOR="#ff0000">Error: <%= $param->{"error$row"} %></FONT>
298 <INPUT TYPE="button" VALUE="TEST addrow" onclick="addRow()"> -->
301 <INPUT TYPE="submit" NAME="submit" VALUE="Post payment batch">
306 <%= include('/elements/xmlhttp.html',
307 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi',
308 'subs' => [qw( custnum_search smart_search )],
312 <SCRIPT TYPE="text/javascript">
314 var rownum = <%= $row %>;
318 var table = document.getElementById('OneTrueTable');
319 var tablebody = table.getElementsByTagName('tbody').item(0);
321 var row = document.createElement('TR');
323 var custnum_cell = document.createElement('TD');
325 var custnum_input = document.createElement('INPUT');
326 custnum_input.setAttribute('name', 'custnum'+rownum);
327 custnum_input.setAttribute('id', 'custnum'+rownum);
328 custnum_input.setAttribute('size', 8);
329 custnum_input.setAttribute('maxlength', 12);
330 custnum_input.setAttribute('rownum', rownum);
331 custnum_input.onfocus = clearhint_custnum;
332 custnum_input.onchange = search_custnum;
333 custnum_cell.appendChild(custnum_input);
335 row.appendChild(custnum_cell);
337 var customer_cell = document.createElement('TD');
339 var customer_input = document.createElement('INPUT');
340 customer_input.setAttribute('name', 'customer'+rownum);
341 customer_input.setAttribute('id', 'customer'+rownum);
342 customer_input.setAttribute('size', 64);
343 customer_input.setAttribute('value', '(last name or company)' );
344 customer_input.setAttribute('rownum', rownum);
345 customer_input.onfocus = clearhint_customer;
346 customer_input.onclick = clearhint_customer;
347 customer_input.onchange = search_customer;
348 customer_cell.appendChild(customer_input);
350 var customer_select = document.createElement('SELECT');
351 customer_select.setAttribute('name', 'cust_select'+rownum);
352 customer_select.setAttribute('id', 'cust_select'+rownum);
353 customer_select.setAttribute('rownum', rownum);
354 customer_select.style.color = '#ff0000';
355 customer_select.style.display = 'none';
356 customer_select.onchange = select_customer;
357 customer_cell.appendChild(customer_select);
359 row.appendChild(customer_cell);
361 var paid_cell = document.createElement('TD');
363 var paid_text = document.createTextNode('$');
364 paid_cell.appendChild(paid_text);
366 var paid_input = document.createElement('INPUT');
367 paid_input.setAttribute('name', 'paid'+rownum);
368 paid_input.setAttribute('size', 8);
369 paid_input.setAttribute('maxlength', 8);
370 paid_cell.appendChild(paid_input);
372 row.appendChild(paid_cell);
374 var payinfo_cell = document.createElement('TD');
375 var payinfo_input = document.createElement('INPUT');
376 payinfo_input.setAttribute('name', 'payinfo'+rownum);
377 payinfo_input.setAttribute('size', 10);
378 payinfo_cell.appendChild(payinfo_input);
379 row.appendChild(payinfo_cell);
381 var error_cell = document.createElement('TD');
382 error_cell.style.backgroundColor = '#e8e8e8';
383 row.appendChild(error_cell);
385 tablebody.appendChild(row);