X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fprospect_main.pm;h=b5d51d33395b2e8e998e8bb0f357e2818162ee35;hb=a9e018d378fd83aadf4c84a33001e39333c7cd30;hp=369029bab206be67e6952919444f842f82e0a323;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/FS/FS/prospect_main.pm b/FS/FS/prospect_main.pm index 369029bab..b5d51d333 100644 --- a/FS/FS/prospect_main.pm +++ b/FS/FS/prospect_main.pm @@ -1,13 +1,14 @@ package FS::prospect_main; use strict; -use base qw( FS::o2m_Common FS::Record ); +use base qw( FS::Quotable_Mixin FS::o2m_Common FS::Record ); use vars qw( $DEBUG ); use Scalar::Util qw( blessed ); -use FS::Record qw( dbh qsearch ); #qsearchs ); +use FS::Record qw( dbh qsearch qsearchs ); use FS::agent; use FS::cust_location; use FS::contact; +use FS::qual; $DEBUG = 0; @@ -41,14 +42,13 @@ from FS::Record. The following fields are currently supported: primary key -=item company - -company +=item agentnum -=item locationnum +Agent -locationnum +=item company +company =back @@ -204,13 +204,30 @@ sub check { my $error = $self->ut_numbern('prospectnum') || $self->ut_foreign_key('agentnum', 'agent', 'agentnum' ) - || $self->ut_text('company') + || $self->ut_textn('company') ; return $error if $error; $self->SUPER::check; } +=item name + +Returns a name for this prospect, as a string (company name for commercial +prospects, contact name for residential prospects). + +=cut + +sub name { + my $self = shift; + return $self->company if $self->company; + + my $contact = ($self->contact)[0]; #first contact? good enough for now + return $contact->line if $contact; + + 'Prospect #'. $self->prospectnum; +} + =item contact Returns the contacts (see L) associated with this prospect. @@ -222,6 +239,40 @@ sub contact { qsearch( 'contact', { 'prospectnum' => $self->prospectnum } ); } +=item cust_location + +Returns the locations (see L) associated with this prospect. + +=cut + +sub cust_location { + my $self = shift; + qsearch( 'cust_location', { 'prospectnum' => $self->prospectnum, + 'custnum' => '' } ); +} + +=item qual + +Returns the qualifications (see L) associated with this prospect. + +=cut + +sub qual { + my $self = shift; + qsearch( 'qual', { 'prospectnum' => $self->prospectnum } ); +} + +=item agent + +Returns the agent (see L) for this customer. + +=cut + +sub agent { + my $self = shift; + qsearchs( 'agent', { 'agentnum' => $self->agentnum } ); +} + =item search HASHREF (Class method)