optimize CDR rating after timed rate perf regression, RT#15739
[freeside.git] / httemplate / misc / cust_main_note-import.cgi
index 690ca78..72ac556 100644 (file)
     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 == 5 ) {
+           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';
       }
 
     }
 %  my $fh = $cgi->upload('csvfile');
 %  my $csv = new Text::CSV_XS;
 %  my $skip_fuzzies = $cgi->param('fuzzies') ? 0 : 1;
+%  my $use_agent_custid = $cgi->param('use_agent_custid') ? 1 : 0;
 %
 %  if ( defined($fh) ) {
      <TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
        <TH>First</TH>
        <TH>Note to be added</TH>
      </TR>
-%    my $agentnum   => scalar($cgi->param('agentnum')),
+%    my $agentnum = scalar($cgi->param('agentnum'));
 %    my $line;
 %    my $row = 0;
 %    while ( defined($line=<$fh>) ) {
-%      chomp $line;
+%      $line =~ s/(\S*)\s*$/$1/;
 %      $line =~ s/^(.*)(#!).*/$1/;
 %
 %      $csv->parse($line) or die "can't parse line: " . $csv->error_input();
 %      next unless ( $last || $first || $note );
 %      my @cust_main = ();
 %      warn "searching for: $last, $first" if ($first || $last);
-%      if ($custnum) {
+%      if ($agentnum && $custnum && $use_agent_custid) {
+%        @cust_main = qsearch('cust_main', { 'agent'        => $agentnum,
+%                                             'agent_custid' => $custnum   } );
+%      } elsif ($custnum) { # && !use_agent_custid
 %        @cust_main = qsearch('cust_main', { 'custnum' => $custnum });
 %      } else {
 %        @cust_main = FS::cust_main::smart_search(