summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevinse <levinse>2011-02-22 00:19:20 +0000
committerlevinse <levinse>2011-02-22 00:19:20 +0000
commit0d75dc389fccdb680237aa1e244e13d254d12f02 (patch)
tree60becbf1a445b2d68807ba4cd1a03c4367ac920e
parent0db6399859f7206855f2e58231c6381511687870 (diff)
quick payment tool improvements, RT10698
-rw-r--r--httemplate/elements/customer-table.html45
-rw-r--r--httemplate/misc/cust_main_note-import.cgi16
-rw-r--r--httemplate/misc/xmlhttp-cust_main-search.cgi49
3 files changed, 57 insertions, 53 deletions
diff --git a/httemplate/elements/customer-table.html b/httemplate/elements/customer-table.html
index c3a5df937..89e54d703 100644
--- a/httemplate/elements/customer-table.html
+++ b/httemplate/elements/customer-table.html
@@ -180,29 +180,36 @@ Example:
var balance = document.getElementById('balance'+searchrow);
balance.value = '';
- function search_custnum_update(name) {
+ function search_custnum_update(customers) {
- var name = eval('(' + name + ')' );
+ var customerArray = eval('(' + customers + ')');
customer.disabled = false;
customer.style.backgroundColor = '#ffffff';
+
+ if ( customerArray.length == 0 ) {
- if ( name.length > 0 ) {
- customer.value = name;
- customer.setAttribute('magic', 'nosearch');
-% if ( $opt{custnum_update_callback} ) {
- <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>')
-% }
- } else {
- customer.value = 'Not found';
+ customer.value = 'Not found';
customer.style.color = '#ff0000';
custnum_obj.style.color = '#ff0000';
- }
+ } else if ( customerArray.length == 3 ) {
+
+ custnum_obj.value = customerArray[0];
+ custnum_obj.style.color = '#000000';
+ customer.value = customerArray[1];
+ balance.value = customerArray[2];
+
+ customer.style.display = '';
+ customer_select.style.display = 'none';
+% if ( $opt{custnum_update_callback} ) {
+ <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>')
+% }
+ }
}
- custnum_search( custnum, search_custnum_update );
+ custnum_search(custnum, search_custnum_update );
}
@@ -280,7 +287,7 @@ Example:
//add the multiple customers
for ( var s = 0; s < customerArray.length; s++ )
- opt(customer_select, customerArray[s][0], customerArray[s][1], '#000000');
+ opt(customer_select, customerArray[s][0] + '_' + customerArray[s][2], customerArray[s][1], '#000000');
opt(customer_select, 'cancel', '(Edit search string)', '#000000');
@@ -298,16 +305,17 @@ Example:
function select_customer() {
- var custnum = this.options[this.selectedIndex].value;
+ var custnum_balance = this.options[this.selectedIndex].value;
var customer = this.options[this.selectedIndex].text;
var searchrow = this.getAttribute('rownum');
var custnum_obj = document.getElementById('custnum'+searchrow);
var customer_obj = document.getElementById('customer'+searchrow);
+ var balance_obj = document.getElementById('balance'+searchrow);
- if ( custnum == '' ) {
+ if ( custnum_balance == '' ) {
- } else if ( custnum == 'cancel' ) {
+ } else if ( custnum_balance == 'cancel' ) {
custnum_obj.value = '';
custnum_obj.style.color = '#000000';
@@ -317,6 +325,9 @@ Example:
customer_obj.focus();
} else {
+
+ var custnum = custnum_balance.substring(0,custnum_balance.indexOf('_'));
+ var balance = custnum_balance.substring(custnum_balance.indexOf('_')+1);
custnum_obj.value = custnum;
custnum_obj.style.color = '#000000';
@@ -324,6 +335,8 @@ Example:
customer_obj.value = customer;
customer_obj.style.color = '#000000';
+ balance_obj.value = balance;
+
this.style.display = 'none';
customer_obj.style.display = '';
diff --git a/httemplate/misc/cust_main_note-import.cgi b/httemplate/misc/cust_main_note-import.cgi
index 8a94ae4d4..79fdd09ff 100644
--- a/httemplate/misc/cust_main_note-import.cgi
+++ b/httemplate/misc/cust_main_note-import.cgi
@@ -39,24 +39,22 @@
custnum_obj.style.backgroundColor = '#dddddd';
- //alert('search for custnum ' + custnum + ', row#' + searchrow );
+ function search_custnum_update(customers) {
- function search_custnum_update(name) {
-
- var name = eval('(' + name + ')' );
+ var customerArray = eval('(' + customers + ')');
custnum_obj.disabled = false;
custnum_obj.style.backgroundColor = '#ffffff';
- if ( name.length > 0 ) {
- //alert('custnum found: ' + name);
+ if ( customerArray.length == 0 ) {
+ custnum_obj.value = 'Not found';
+ custnum_obj.style.color = '#ff0000';
+ } else if ( customerArray.length == 3 ) {
+ var name = customerArray[1];
opt(customer_select,custnum,name,'#000000');
customer_select.selectedIndex = customer_select.length - 1;
custnum_obj.value = custnum;
name_obj.value = name;
- } else {
- custnum_obj.value = 'Not found';
- custnum_obj.style.color = '#ff0000';
}
}
diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi
index c71953ba9..7140b20b8 100644
--- a/httemplate/misc/xmlhttp-cust_main-search.cgi
+++ b/httemplate/misc/xmlhttp-cust_main-search.cgi
@@ -1,24 +1,11 @@
-% if ( $sub eq 'custnum_search' ) {
-%
+% if ( $sub eq 'custnum_search' ) {
% my $custnum = $cgi->param('arg');
-% my $cust_main = '';
-% if ( $custnum =~ /^(\d+)$/ and $1 <= 2147483647 ) {
-% $cust_main = qsearchs({
-% 'table' => 'cust_main',
-% 'hashref' => { 'custnum' => $1 },
-% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
-% });
-% }
-% if ( ! $cust_main ) {
-% $cust_main = qsearchs({
-% 'table' => 'cust_main',
-% 'hashref' => { 'agent_custid' => $custnum },
-% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
-% });
+% my $return = [];
+% if ( $custnum =~ /^(\d+)$/ ) {
+% $return = findbycustnum($1,0);
+% $return = findbycustnum($1,1) if(!scalar(@$return));
% }
-%
-"<% $cust_main ? $cust_main->name : '' %>"
-%
+<% objToJson($return) %>
% } elsif ( $sub eq 'smart_search' ) {
%
% my $string = $cgi->param('arg');
@@ -32,15 +19,7 @@
%
% my $string = $cgi->param('arg');
% my $inv = qsearchs('cust_bill', { 'invnum' => $string });
-% my $return = [];
-% if ( $inv ) {
-% my $cust_main = qsearchs({
-% 'table' => 'cust_main',
-% 'hashref' => { 'custnum' => $inv->custnum },
-% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
-% });
-% $return = [ $cust_main->custnum, $cust_main->name, $cust_main->balance ];
-% }
+% my $return = $inv ? findbycustnum($inv->custnum,0) : [];
<% objToJson($return) %>
% }
<%init>
@@ -49,4 +28,18 @@ my $conf = new FS::Conf;
my $sub = $cgi->param('sub');
+sub findbycustnum{
+ my $custnum = shift;
+ my $agent = shift;
+ my $hashref = { 'custnum' => $custnum };
+ $hashref = { 'agent_custid' => $custnum } if $agent;
+ my $cust_main = qsearchs({
+ 'table' => 'cust_main',
+ 'hashref' => $hashref,
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+ });
+ return [ $cust_main->custnum, $cust_main->name, $cust_main->balance ]
+ if $cust_main;
+ [];
+}
</%init>