} );
}
+ #if this becomes agent-virt need to get a list of all prefixes the current
+ #user can see (via their agents)
+ my $prefix = $conf->config('cust_main-custnum-display_prefix');
+ if ( $prefix && $prefix eq substr($num, 0, length($prefix)) ) {
+ push @cust_main, qsearch( {
+ 'table' => 'cust_main',
+ 'hashref' => { 'custnum' => 0 + substr($num, length($prefix)),
+ %options,
+ },
+ 'extra_sql' => " AND $agentnums_sql", #agent virtualization
+ } );
+ }
+
push @cust_main, qsearch( {
'table' => 'cust_main',
'hashref' => { 'agent_custid' => $num, %options },
my @where = ();
my $orderby;
+ # initialize these to prevent warnings
+ $params = {
+ 'custnum' => '',
+ 'agentnum' => '',
+ 'usernum' => '',
+ 'status' => '',
+ 'address' => '',
+ 'paydate_year' => '',
+ 'invoice_terms' => '',
+ 'custbatch' => '',
+ %$params
+ };
+
+ ##
+ # explicit custnum(s)
+ ##
+
+ if ( $params->{'custnum'} ) {
+ my @custnums = ref($params->{'custnum'}) ?
+ @{ $params->{'custnum'} } :
+ $params->{'custnum'};
+ push @where,
+ 'cust_main.custnum IN (' .
+ join(',', map { $_ =~ /^(\d+)$/ ? $1 : () } @custnums ) .
+ ')' if scalar(@custnums) > 0;
+ }
+
##
# parse agent
##