[freeside-commits] freeside/httemplate/misc xmlhttp-cust_main-search.cgi, 1.8.2.1, 1.8.2.2 cust_main_note-import.cgi, 1.4, 1.4.2.1

Erik Levinson levinse at wavetail.420.am
Mon Feb 21 16:18:53 PST 2011


Update of /home/cvs/cvsroot/freeside/httemplate/misc
In directory wavetail.420.am:/tmp/cvs-serv19913/httemplate/misc

Modified Files:
      Tag: FREESIDE_2_1_BRANCH
	xmlhttp-cust_main-search.cgi cust_main_note-import.cgi 
Log Message:
quick payment tool improvements, RT10698

Index: cust_main_note-import.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/cust_main_note-import.cgi,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -w -d -r1.4 -r1.4.2.1
--- cust_main_note-import.cgi	23 Aug 2010 20:05:39 -0000	1.4
+++ cust_main_note-import.cgi	22 Feb 2011 00:18:51 -0000	1.4.2.1
@@ -39,24 +39,22 @@
     custnum_obj.style.backgroundColor = '#dddddd';
 
 
-    //alert('search for custnum ' + custnum + ', row#' + searchrow );
-
-    function search_custnum_update(name) {
+    function search_custnum_update(customers) {
 
-      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';
       }
 
     }

Index: xmlhttp-cust_main-search.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/xmlhttp-cust_main-search.cgi,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -w -d -r1.8.2.1 -r1.8.2.2
--- xmlhttp-cust_main-search.cgi	15 Feb 2011 04:20:20 -0000	1.8.2.1
+++ xmlhttp-cust_main-search.cgi	22 Feb 2011 00:18:50 -0000	1.8.2.2
@@ -1,24 +1,11 @@
 % 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 $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>



More information about the freeside-commits mailing list