fix multiple-agent virtualization properly for these reports
[freeside.git] / FS / FS / cust_main.pm
index 8956d5b..cbcf6cc 100644 (file)
@@ -944,10 +944,13 @@ sub replace {
     $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
@@ -1302,9 +1305,12 @@ sub check {
 
   } 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');
@@ -3880,7 +3886,7 @@ sub smart_search {
       push @cust_main, qsearch( {
         'table'     => 'cust_main',
         'hashref'   => { 'last'     => { 'op'    => 'ILIKE',
-                                         'value' => "%$q_value%" },
+                                         'value' => "%$value%" },
                          %options,
                        },
         'extra_sql' => " AND $agentnums_sql", #agent virtualizaiton
@@ -3888,7 +3894,7 @@ sub smart_search {
       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
@@ -3898,7 +3904,7 @@ sub smart_search {
       push @cust_main, qsearch( {
         'table'     => 'cust_main',
         'hashref'   => { 'company'  => { 'op'    => 'ILIKE',
-                                         'value' => "%$q_value%" },
+                                         'value' => "%$value%" },
                          %options,
                        },
         'extra_sql' => " AND $agentnums_sql", #agent virtualization
@@ -3906,7 +3912,7 @@ sub smart_search {
       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