-# my @agentnums = map { "$agentnum = $_" } $self->agentnums;
- my @agentnums = ();
- push @agentnums, "$agentnum IN (". join(',', $self->agentnums). ')';
+ my @or = ();
+
+ my $viewall_right = $opt{'viewall_right'} || 'View customers of all agents';
+ if ( $self->access_right($viewall_right) ) {
+ push @or, "$agentnum IS NOT NULL";
+ } else {
+ push @or, "$agentnum IN (". join(',', $self->agentnums). ')';
+ }