X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Faccess_user.pm;h=250e432dd98aec6346a90b691ed1b09f013274bc;hb=3a7497433b36b3aa882d30d2d0b6b519a7e1a675;hp=8e4ad46bd2b96401740fc4f3c5e804187cd0e3f1;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1;p=freeside.git diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm index 8e4ad46bd..250e432dd 100644 --- a/FS/FS/access_user.pm +++ b/FS/FS/access_user.pm @@ -319,9 +319,19 @@ Options are passed as a hashref or a list. Available options are: =over 4 -=item null - The frament will also allow the selection of null agentnums. +=item null -=item null_right - The fragment will also allow the selection of null agentnums if the current user has the provided access right +The frament will also allow the selection of null agentnums. + +=item null_right + +The fragment will also allow the selection of null agentnums if the current +user has the provided access right + +=item table + +Optional table name in which agentnum is being checked. Sometimes required to +resolve 'column reference "agentnum" is ambiguous' errors. =back @@ -331,9 +341,11 @@ sub agentnums_sql { my( $self ) = shift; my %opt = ref($_[0]) ? %{$_[0]} : @_; - my @agentnums = map { "agentnum = $_" } $self->agentnums; + my $agentnum = $opt{'table'} ? $opt{'table'}.'.agentnum' : 'agentnum'; + + my @agentnums = map { "$agentnum = $_" } $self->agentnums; - push @agentnums, 'agentnum IS NULL' + push @agentnums, "$agentnum IS NULL" if $opt{'null'} || ( $opt{'null_right'} && $self->access_right($opt{'null_right'}) );