X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fprospect_main.pm;h=a6b593d56b42fa3856078a020c1f3dbdbd93104d;hb=0a91d21fcf8ebeb12cd71230d79153c1fa0d82a3;hp=2e3c0b93016621105d3e3f310439e2a720f8e434;hpb=ae732741cb031ddb6c99156a8804cac3e7500f76;p=freeside.git diff --git a/FS/FS/prospect_main.pm b/FS/FS/prospect_main.pm index 2e3c0b930..a6b593d56 100644 --- a/FS/FS/prospect_main.pm +++ b/FS/FS/prospect_main.pm @@ -4,12 +4,14 @@ use strict; use base qw( FS::Quotable_Mixin FS::o2m_Common FS::Record ); use vars qw( $DEBUG @location_fields ); use Scalar::Util qw( blessed ); +use FS::Conf; use FS::Record qw( dbh qsearch qsearchs ); use FS::agent; use FS::cust_location; use FS::cust_main; use FS::contact; use FS::qual; +use FS::part_referral; $DEBUG = 0; @@ -322,6 +324,17 @@ sub agent { qsearchs( 'agent', { 'agentnum' => $self->agentnum } ); } +=item part_referral + +Returns the advertising source (see L) for this customer. + +=cut + +sub part_referral { + my $self = shift; + qsearchs( 'part_referral', { 'refnum' => $self->refnum } ); +} + =item convert_cust_main Converts this prospect to a customer. @@ -351,6 +364,9 @@ sub convert_cust_main { ( map { $_ => $self->$_ } qw( agentnum refnum company ) ), }; + $cust_main->refnum( FS::Conf->new->config('referraldefault') || 1 ) + unless $cust_main->refnum; + #XXX again, arbitrary, if one contact was "billing", that would be better if ( $contact[0] ) { $cust_main->set($_, $contact[0]->get($_)) foreach qw( first last ); @@ -359,6 +375,10 @@ sub convert_cust_main { $cust_main->set('last', 'Unknown'); } + #v3 payby + $cust_main->payby('BILL'); + $cust_main->paydate('12/2037'); + $cust_main->insert( {}, \@invoicing_list, 'prospectnum' => $self->prospectnum, ) @@ -386,15 +406,18 @@ sub search { my @where = (); my $orderby; - ## - # parse agent - ## - + #agent if ( $params->{'agentnum'} =~ /^(\d+)$/ and $1 ) { push @where, "prospect_main.agentnum = $1"; } + #refnum + if ( $params->{'refnum'} =~ /^(\d+)$/ and $1 ) { + push @where, + "prospect_main.refnum = $1"; + } + ## # setup queries, subs, etc. for the search ##