+
+ function <% $opt{prefix} %>search_invnum() {
+
+ this.style.color = '#000000'
+
+ var invnum_obj = this;
+ var searchrow = this.getAttribute('rownum');
+ var invnum = this.value;
+
+ if ( invnum == 'searching...' || invnum == 'Not found' || invnum == '' )
+ return;
+
+ if ( this.getAttribute('magic') == 'nosearch' ) {
+ this.setAttribute('magic', '');
+ return;
+ }
+
+ if ( ( <% $opt{prefix} %>rownum - searchrow ) == 1 ) {
+ <% $opt{prefix} %>addRow();
+ }
+ var customer = document.getElementById('customer'+searchrow);
+ customer.value = 'searching...';
+ customer.disabled = true;
+ customer.style.color = '#000000';
+ customer.style.backgroundColor = '#dddddd';
+
+ var customer_select = document.getElementById('cust_select'+searchrow);
+
+ customer.style.display = '';
+ customer_select.style.display = 'none';
+
+ var custnum_obj = document.getElementById('custnum'+searchrow);
+ var balance = document.getElementById('balance'+searchrow);
+ var status = document.getElementById('status'+searchrow);
+ balance.innerHTML = '';
+ status.innerHTML = '';
+
+ function search_invnum_update(customers) {
+
+ var customerArray = eval('(' + customers + ')');
+
+ custnum_obj.disabled = false;
+ custnum_obj.style.backgroundColor = '#ffffff';
+ customer.disabled = false;
+ customer.style.backgroundColor = '#ffffff';
+
+ if ( customerArray.length == 0 ) {
+
+ custnum_obj.value = 'Not found';
+ customer.value = 'Not found';
+ custnum_obj.style.color = '#ff0000';
+ customer.style.color = '#ff0000';
+
+ customer.style.display = '';
+ customer_select.style.display = 'none';
+
+ } else if ( customerArray.length == 5 ) {
+
+ custnum_obj.value = customerArray[0];
+ custnum_obj.style.color = '#000000';
+ customer.value = customerArray[1];
+ balance.innerHTML = customerArray[2] + ' ';
+ status.innerHTML = customerArray[3];
+ status.style.color = '#'+customerArray[4];
+
+ customer.style.display = '';
+ customer_select.style.display = 'none';
+
+% if ( $opt{invnum_update_callback} ) {
+ <% $opt{invnum_update_callback} %>(searchrow, '<% $opt{prefix} %>')
+% }
+
+ }
+
+ }
+
+ invnum_search( invnum, search_invnum_update );
+
+ }
+