include agent and restore cust-level status in small_custview
[freeside.git] / FS / FS / access_user.pm
index 68d2dea..a3f55bc 100644 (file)
@@ -283,6 +283,22 @@ sub report_sales {
 Returns links to the the groups this user is a part of, as FS::access_usergroup
 objects (see L<FS::access_usergroup>).
 
+=item num_agents
+
+Returns the number of agents this user can view (via group membership).
+
+=cut
+
+sub num_agents {
+  my $self = shift;
+  $self->scalar_sql(
+    'SELECT COUNT(DISTINCT agentnum) FROM access_usergroup
+                                     JOIN access_groupagent USING ( groupnum )
+       WHERE usernum = ?',
+    $self->usernum,
+  );
+}
+
 =item agentnums 
 
 Returns a list of agentnums this user can view (via group membership).