tolerate custnum errors in quick payment entry, #22369
[freeside.git] / httemplate / misc / xmlhttp-cust_bill-search.html
index 46f15d1..459c5db 100644 (file)
@@ -6,13 +6,15 @@ die 'access denied' unless $curuser->access_right('View invoices');
 my @return;
 if ( $cgi->param('sub') eq 'custnum_search_open' ) { 
   my $custnum = $cgi->param('arg');
-  #warn "searching invoices for $custnum\n";
-  my $cust_main = FS::cust_main->by_key($custnum);
-  @return = map { 
-    +{ $_->hash, 
-      'owed' => $_->owed }
-  } $cust_main->open_cust_bill
-    if $curuser->agentnums_href->{ $cust_main->agentnum };
+  if ( $custnum =~ /^(\d+)$/ ) {
+#warn "searching invoices for $custnum\n";
+    my $cust_main = FS::cust_main->by_key($custnum);
+    @return = map { 
+      +{ $_->hash, 
+        'owed' => $_->owed }
+    } $cust_main->open_cust_bill
+      if $curuser->agentnums_href->{ $cust_main->agentnum };
+  }
 }
 
 </%init>