summaryrefslogtreecommitdiff
path: root/FS/FS/cust_location.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/cust_location.pm')
-rw-r--r--FS/FS/cust_location.pm80
1 files changed, 68 insertions, 12 deletions
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm
index ab80941..0c5c023 100644
--- a/FS/FS/cust_location.pm
+++ b/FS/FS/cust_location.pm
@@ -1,7 +1,7 @@
package FS::cust_location;
use strict;
-use base qw( FS::geocode_Mixin FS::Record );
+use base qw( FS::Record );
use Locale::Country;
use FS::Record qw( qsearch ); #qsearchs );
use FS::prospect_main;
@@ -163,35 +163,91 @@ sub country_full {
code2country($self->country);
}
-=item line
+=item location_label [ OPTION => VALUE ... ]
-Synonym for location_label
+Returns the label of the service location for this customer.
+
+Options are
+
+=over 4
+
+=item join_string
+
+used to separate the address elements (defaults to ', ')
+
+=item escape_function
+
+
+a callback used for escaping the text of the address elements
+
+=back
=cut
-sub line {
+# false laziness with FS::cust_main::location_label
+
+sub location_label {
my $self = shift;
- $self->location_label;
+ my %opt = @_;
+
+ my $separator = $opt{join_string} || ', ';
+ my $escape = $opt{escape_function} || sub{ shift };
+ my $ds = $opt{double_space} || ' ';
+ my $line = '';
+ my $cydefault =
+ $opt{'countrydefault'} || FS::Conf->new->config('countrydefault') || 'US';
+ my $prefix = '';
+
+ my $notfirst = 0;
+ foreach (qw ( address1 address2 ) ) {
+ my $method = "$prefix$_";
+ $line .= ($notfirst ? $separator : ''). &$escape($self->$method)
+ if $self->$method;
+ $notfirst++;
+ }
+ $notfirst = 0;
+ foreach (qw ( city county state zip ) ) {
+ my $method = "$prefix$_";
+ if ( $self->$method ) {
+ $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;
+
+ $line;
}
-=item has_ship_address
+=item line
-Returns false since cust_location objects do not have a separate shipping
-address.
+Synonym for location_label
=cut
-sub has_ship_address {
- '';
+sub line {
+ my $self = shift;
+ $self->location_label;
}
=item location_hash
-Returns a list of key/value pairs, with the following keys: address1, address2,
-city, county, state, zip, country, geocode.
+Returns a list of key/value pairs, with the following keys: address1, adddress2,
+city, county, state, zip, country.
=cut
+#geocode? not yet set
+
+sub location_hash {
+ my $self = shift;
+ map { $_ => $self->$_ } qw( address1 address2 city county state zip country );
+}
+
=back
=head1 BUGS