X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fagent.pm;h=0cd07ef15b4984aebc1cb903ca6992351c668242;hb=b5d22578f60ba105934c92c031799671bf6c0f29;hp=57093e3294e08ecae6b7b72a0822d8afc66b088f;hpb=3d0a1bb06b895c5be6e3f0517d355442a6b1e125;p=freeside.git diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm index 57093e329..0cd07ef15 100644 --- a/FS/FS/agent.pm +++ b/FS/FS/agent.pm @@ -626,6 +626,21 @@ sub num_prepay_credit { $sth->fetchrow_arrayref->[0]; } +=item num_sales + +Returns the number of non-disabled sales people for this agent. + +=cut + +sub num_sales { + my $self = shift; + my $sth = dbh->prepare( + "SELECT COUNT(*) FROM sales WHERE agentnum = ? + AND ( disabled = '' OR disabled IS NULL )" + ) or die dbh->errstr; + $sth->execute($self->agentnum) or die $sth->errstr; + $sth->fetchrow_arrayref->[0]; +} =back