$old = qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
}
- if ( $self->payby eq 'COMP' && $self->payby ne $old->payby
- && $conf->config('users-allow_comp') ) {
- return "You are not permitted to create complimentary accounts."
- unless grep { $_ eq getotaker } $conf->config('users-allow_comp');
+ my $curuser = $FS::CurrentUser::CurrentUser;
+ if ( $self->payby eq 'COMP'
+ && $self->payby ne $old->payby
+ && ! $curuser->access_right('Complimentary customer')
+ )
+ {
+ return "You are not permitted to create complimentary accounts.";
}
local($ignore_expired_card) = 1
} elsif ( $self->payby eq 'COMP' ) {
- if ( !$self->custnum && $conf->config('users-allow_comp') ) {
+ my $curuser = $FS::CurrentUser::CurrentUser;
+ if ( ! $self->custnum
+ && ! $curuser->access_right('Complimentary customer')
+ )
+ {
return "You are not permitted to create complimentary accounts."
- unless grep { $_ eq getotaker } $conf->config('users-allow_comp');
}
$error = $self->ut_textn('payinfo');
=cut
+use vars qw(%statuscolor);
+%statuscolor = (
+ 'prospect' => '7e0079', #'000000', #black? naw, purple
+ 'active' => '00CC00', #green
+ 'inactive' => '0000CC', #blue
+ 'suspended' => 'FF9900', #yellow
+ 'cancelled' => 'FF0000', #red
+);
sub statuscolor {
my $self = shift;
-
- my %statuscolor = (
- 'prospect' => '7e0079', #'000000', #black? naw, purple
- 'active' => '00CC00', #green
- 'inactive' => '0000CC', #blue
- 'suspended' => 'FF9900', #yellow
- 'cancelled' => 'FF0000', #red
- );
-
$statuscolor{$self->status};
}
"SELECT COUNT(*) FROM cust_pkg
WHERE cust_pkg.custnum = cust_main.custnum";
+sub select_count_pkgs_sql {
+ $select_count_pkgs;
+}
+
sub prospect_sql { "
0 = ( $select_count_pkgs )
"; }
} elsif ( $search =~ /^\s*(\S.*\S)\s*$/ ) { #value search
my $value = lc($1);
+
+ # remove "(Last, First)" in "Company (Last, First"), otherwise the
+ # full strings the browser remembers won't work
+ $value =~ s/\([\w \,\.\-\']*\)$//; #false laziness w/Record::ut_name
+
my $q_value = dbh->quote($value);
#exact
push @cust_main, qsearch( {
'table' => 'cust_main',
'hashref' => { 'last' => { 'op' => 'ILIKE',
- 'value' => "%$q_value%" },
+ 'value' => "%$value%" },
%options,
},
'extra_sql' => " AND $agentnums_sql", #agent virtualizaiton
push @cust_main, qsearch( {
'table' => 'cust_main',
'hashref' => { 'ship_last' => { 'op' => 'ILIKE',
- 'value' => "%$q_value%" },
+ 'value' => "%$value%" },
%options,
},
'extra_sql' => " AND $agentnums_sql", #agent virtualization
push @cust_main, qsearch( {
'table' => 'cust_main',
'hashref' => { 'company' => { 'op' => 'ILIKE',
- 'value' => "%$q_value%" },
+ 'value' => "%$value%" },
%options,
},
'extra_sql' => " AND $agentnums_sql", #agent virtualization
push @cust_main, qsearch( {
'table' => 'cust_main',
'hashref' => { 'ship_company' => { 'op' => 'ILIKE',
- 'value' => "%$q_value%" },
+ 'value' => "%$value%" },
%options,
},
'extra_sql' => " AND $agentnums_sql", #agent virtualization
}
+ #eliminate duplicates
+ my %saw = ();
+ @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
+
}
@cust_main;