1 <% include('/elements/header.html', 'Quick payment entry', ''
2 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
6 <% include('/elements/error.html') %>
8 <FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;">
10 <!-- <B>Batch</B> <INPUT TYPE="text" NAME="paybatch"><BR><BR> -->
12 <SCRIPT TYPE="text/javascript">
14 function clearhint_custnum() {
16 //this.style.color = '#000000';
18 if ( this.value == 'Not found' || this.value == 'Multiple' ) {
20 this.style.color = '#000000';
25 function clearhint_customer() {
27 this.style.color = '#000000';
29 if ( this.value == '(last name or company)' || this.value == 'Not found' )
34 function search_custnum() {
36 this.style.color = '#000000'
38 var custnum_obj = this;
39 var searchrow = this.getAttribute('rownum');
40 var custnum = this.value;
42 if ( custnum == 'searching...' || custnum == 'Not found' || custnum == '' )
45 if ( this.getAttribute('magic') == 'nosearch' ) {
46 this.setAttribute('magic', '');
50 if ( ( rownum - searchrow ) == 1 ) {
53 var customer = document.getElementById('customer'+searchrow);
54 customer.value = 'searching...';
55 customer.disabled = true;
56 customer.style.color = '#000000';
57 customer.style.backgroundColor = '#dddddd';
59 var customer_select = document.getElementById('cust_select'+searchrow);
61 //alert('search for custnum ' + custnum + ', row#' + searchrow );
63 customer.style.display = '';
64 customer_select.style.display = 'none';
66 function search_custnum_update(name) {
68 var name = eval('(' + name + ')' );
70 customer.disabled = false;
71 customer.style.backgroundColor = '#ffffff';
73 if ( name.length > 0 ) {
74 //alert('custnum found: ' + name);
75 customer.value = name;
76 customer.setAttribute('magic', 'nosearch');
78 customer.value = 'Not found';
79 customer.style.color = '#ff0000';
80 custnum_obj.style.color = '#ff0000';
86 custnum_search( custnum, search_custnum_update );
90 function search_customer() {
92 var customer_obj = this;
93 var searchrow = this.getAttribute('rownum');
94 var customer = this.value;
96 if ( customer == 'searching...' || customer == 'Not found' || customer == '' )
99 if ( this.getAttribute('magic') == 'nosearch' ) {
100 this.setAttribute('magic', '');
104 if ( ( rownum - searchrow ) == 1 ) {
108 var custnum_obj = document.getElementById('custnum'+searchrow);
109 custnum_obj.value = 'searching...';
110 custnum_obj.disabled = true;
111 custnum_obj.style.color = '#000000';
112 custnum_obj.style.backgroundColor = '#dddddd';
114 var customer_select = document.getElementById('cust_select'+searchrow);
116 //alert('search for customer ' + customer + ', row#' + searchrow );
118 function search_customer_update(customers) {
120 //alert('customers returned: ' + customers);
122 var customerArray = eval('(' + customers + ')');
124 custnum_obj.disabled = false;
125 custnum_obj.style.backgroundColor = '#ffffff';
127 if ( customerArray.length == 0 ) {
129 custnum_obj.value = 'Not found';
130 custnum_obj.style.color = '#ff0000';
131 customer_obj.style.color = '#ff0000';
133 customer_obj.style.display = '';
134 customer_select.style.display = 'none';
137 } else if ( customerArray.length == 1 ) {
139 //alert('one customer found: ' + customerArray[0]);
141 custnum_obj.value = customerArray[0][0];
142 customer_obj.value = customerArray[0][1];
144 customer_obj.style.display = '';
145 customer_select.style.display = 'none';
150 custnum_obj.value = 'Multiple'; // or something
151 custnum_obj.style.color = '#ff0000';
153 //alert('multiple customers found, have to create select dropdown');
155 //blank the current list
156 for ( var i = customer_select.length; i >= 0; i-- )
157 customer_select.options[i] = null;
159 opt(customer_select, '', 'Multiple customers match "' + customer + '" - select one', '#ff0000');
161 //add the multiple customers
162 for ( var s = 0; s < customerArray.length; s++ )
163 opt(customer_select, customerArray[s][0], customerArray[s][1], '#000000');
165 opt(customer_select, 'cancel', '(Edit search string)', '#000000');
167 customer_obj.style.display = 'none';
169 customer_select.style.display = '';
175 smart_search( customer, search_customer_update );
179 function select_customer() {
181 var custnum = this.options[this.selectedIndex].value;
182 var customer = this.options[this.selectedIndex].text;
184 var searchrow = this.getAttribute('rownum');
185 var custnum_obj = document.getElementById('custnum'+searchrow);
186 var customer_obj = document.getElementById('customer'+searchrow);
188 if ( custnum == '' ) {
189 //this.style.color = '#ff0000';
191 } else if ( custnum == 'cancel' ) {
193 custnum_obj.value = '';
194 custnum_obj.style.color = '#000000';
196 this.style.display = 'none';
197 customer_obj.style.display = '';
198 customer_obj.focus();
203 custnum_obj.value = custnum;
204 custnum_obj.style.color = '#000000';
206 customer_obj.value = customer;
207 customer_obj.style.color = '#000000';
209 this.style.display = 'none';
210 customer_obj.style.display = '';
216 function opt(what,value,text,color) {
217 var optionName = new Option(text, value, false, false);
218 optionName.style.color = color;
219 var length = what.length;
220 what.options[length] = optionName;
225 <TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
232 <TH BGCOLOR="#e8e8e8"></TH>
235 % if ( $cgi->param('error') ) {
236 % my $param = $cgi->Vars;
238 % for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) {
244 <INPUT TYPE="text" NAME="custnum<% $row %>" ID="custnum<% $row %>" SIZE=8 MAXLENGTH=12 VALUE="<% $param->{"custnum$row"} %>" rownum="<% $row %>">
245 <SCRIPT TYPE="text/javascript">
246 var custnum_input<% $row %> = document.getElementById("custnum<% $row %>");
247 custnum_input<% $row %>.onfocus = clearhint_custnum;
248 custnum_input<% $row %>.onchange = search_custnum;
253 <INPUT TYPE="text" NAME="customer<% $row %>" ID="customer<% $row %>" SIZE=64 VALUE="<% $param->{"customer$row"} %>" rownum="<% $row %>">
254 <SCRIPT TYPE="text/javascript">
255 var customer_input<% $row %> = document.getElementById("customer<% $row %>");
256 customer_input<% $row %>.onfocus = clearhint_customer;
257 customer_input<% $row %>.onclick = clearhint_customer;
258 customer_input<% $row %>.onchange = search_customer;
260 <SELECT NAME="cust_select<% $row %>" ID="cust_select<% $row %>" rownum="<% $row %>" STYLE="color:#ff0000; display:none">
262 <SCRIPT TYPE="text/javascript">
263 var customer_select<% $row %> = document.getElementById("cust_select<% $row %>");
264 customer_select<% $row %>.onchange = select_customer;
269 $<INPUT TYPE="text" NAME="paid<% $row %>" SIZE=8 MAXLENGTH=8 VALUE="<% $param->{"paid$row"} %>" >
273 <INPUT TYPE="text" NAME="payinfo<% $row %>" SIZE=10 VALUE="<% $param->{"payinfo$row"} %>" >
276 <TD BGCOLOR="#e8e8e8">
277 % if ( $param->{"error$row"} ) {
279 <FONT SIZE="-1" COLOR="#ff0000">Error: <% $param->{"error$row"} %></FONT>
292 <INPUT TYPE="button" VALUE="TEST addrow" onclick="addRow()"> -->
295 <INPUT TYPE="submit" NAME="submit" VALUE="Post payment batch">
300 <% include('/elements/xmlhttp.html',
301 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi',
302 'subs' => [qw( custnum_search smart_search )],
306 <SCRIPT TYPE="text/javascript">
308 var rownum = <% $row %>;
312 var table = document.getElementById('OneTrueTable');
313 var tablebody = table.getElementsByTagName('tbody').item(0);
315 var row = document.createElement('TR');
317 var custnum_cell = document.createElement('TD');
319 var custnum_input = document.createElement('INPUT');
320 custnum_input.setAttribute('name', 'custnum'+rownum);
321 custnum_input.setAttribute('id', 'custnum'+rownum);
322 custnum_input.setAttribute('size', 8);
323 custnum_input.setAttribute('maxlength', 12);
324 custnum_input.setAttribute('rownum', rownum);
325 custnum_input.onfocus = clearhint_custnum;
326 custnum_input.onchange = search_custnum;
327 custnum_cell.appendChild(custnum_input);
329 row.appendChild(custnum_cell);
331 var customer_cell = document.createElement('TD');
333 var customer_input = document.createElement('INPUT');
334 customer_input.setAttribute('name', 'customer'+rownum);
335 customer_input.setAttribute('id', 'customer'+rownum);
336 customer_input.setAttribute('size', 64);
337 customer_input.setAttribute('value', '(last name or company)' );
338 customer_input.setAttribute('rownum', rownum);
339 customer_input.onfocus = clearhint_customer;
340 customer_input.onclick = clearhint_customer;
341 customer_input.onchange = search_customer;
342 customer_cell.appendChild(customer_input);
344 var customer_select = document.createElement('SELECT');
345 customer_select.setAttribute('name', 'cust_select'+rownum);
346 customer_select.setAttribute('id', 'cust_select'+rownum);
347 customer_select.setAttribute('rownum', rownum);
348 customer_select.style.color = '#ff0000';
349 customer_select.style.display = 'none';
350 customer_select.onchange = select_customer;
351 customer_cell.appendChild(customer_select);
353 row.appendChild(customer_cell);
355 var paid_cell = document.createElement('TD');
357 var paid_text = document.createTextNode('$');
358 paid_cell.appendChild(paid_text);
360 var paid_input = document.createElement('INPUT');
361 paid_input.setAttribute('name', 'paid'+rownum);
362 paid_input.setAttribute('size', 8);
363 paid_input.setAttribute('maxlength', 8);
364 paid_cell.appendChild(paid_input);
366 row.appendChild(paid_cell);
368 var payinfo_cell = document.createElement('TD');
369 var payinfo_input = document.createElement('INPUT');
370 payinfo_input.setAttribute('name', 'payinfo'+rownum);
371 payinfo_input.setAttribute('size', 10);
372 payinfo_cell.appendChild(payinfo_input);
373 row.appendChild(payinfo_cell);
375 var error_cell = document.createElement('TD');
376 error_cell.style.backgroundColor = '#e8e8e8';
377 row.appendChild(error_cell);
379 tablebody.appendChild(row);
387 <% include('/elements/footer.html') %>
392 unless $FS::CurrentUser::CurrentUser->access_right('Post payment batch');