summaryrefslogtreecommitdiff
path: root/FS/FS/cust_location.pm
diff options
context:
space:
mode:
authorivan <ivan>2009-12-28 19:20:25 +0000
committerivan <ivan>2009-12-28 19:20:25 +0000
commit03ceab71dad1e5eb366865d304e5e459cc905ce4 (patch)
tree18b4532289a0237ae694b1ad5c033b25f448bd7c /FS/FS/cust_location.pm
parent5950a980cef4968ac59ca8041d2204e6d98e7a3d (diff)
beginning of prospect/CRM/contact work
Diffstat (limited to 'FS/FS/cust_location.pm')
-rw-r--r--FS/FS/cust_location.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm
index 87c6c3e..da586f0 100644
--- a/FS/FS/cust_location.pm
+++ b/FS/FS/cust_location.pm
@@ -4,6 +4,7 @@ use strict;
use base qw( FS::Record );
use Locale::Country;
use FS::Record qw( qsearch ); #qsearchs );
+use FS::prospect_main;
use FS::cust_main;
use FS::cust_main_county;
@@ -119,7 +120,8 @@ sub check {
my $error =
$self->ut_numbern('locationnum')
- || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
+ || $self->ut_foreign_keyn('prospectnum', 'prospect_main', 'prospectnum')
+ || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
|| $self->ut_text('address1')
|| $self->ut_textn('address2')
|| $self->ut_text('city')
@@ -131,6 +133,9 @@ sub check {
;
return $error if $error;
+ return "No prospect or customer!" unless $self->prospectnum || $self->custnum;
+ return "Prospect and customer!" if $self->prospectnum && $self->custnum;
+
unless ( qsearch('cust_main_county', {
'country' => $self->country,
'state' => '',
@@ -187,8 +192,10 @@ sub location_label {
my $separator = $opt{join_string} || ', ';
my $escape = $opt{escape_function} || sub{ shift };
+ my $ds = $opt{double_space} || ' ';
my $line = '';
- my $cydefault = FS::conf->new->config('countrydefault') || 'US';
+ my $cydefault =
+ $opt{'countrydefault'} || FS::Conf->new->config('countrydefault') || 'US';
my $prefix = '';
my $notfirst = 0;
@@ -202,11 +209,13 @@ sub location_label {
foreach (qw ( city county state zip ) ) {
my $method = "$prefix$_";
if ( $self->$method ) {
- $line .= ' (' if $method eq 'county';
- $line .= ($notfirst ? ' ' : $separator). &$escape($self->$method);
- $line .= ' )' if $method eq 'county';
+ $line .= ($notfirst ? ($method eq 'zip' ? $ds : ' ') : $separator);
+ $line .= '(' if $method eq 'county';
+ $line .= &$escape($self->$method);
+ $line .= ')' if $method eq 'county';
$notfirst++;
}
+ $line .= ',' if $method eq 'county';
}
$line .= $separator. &$escape(code2country($self->country))
if $self->country ne $cydefault;