summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm3
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/Template_Mixin.pm3
-rw-r--r--FS/FS/cust_location.pm62
-rw-r--r--FS/FS/cust_main.pm1
-rw-r--r--FS/FS/cust_main/Location.pm10
6 files changed, 68 insertions, 12 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index e410586e3..9cac9e1e2 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3484,7 +3484,8 @@ and customer address. Include units.',
'description' => 'Optional "site ID" to show in the location label',
'type' => 'select',
'select_hash' => [ '' => '',
- 'CoStAg' => 'CoStAgXXXXX (country, state, agent name, locationnum)',
+ 'CoStAg' => 'CoStAgXXXXX (country, state, agent name, locationnum)',
+ '_location' => 'Manually defined per location',
],
},
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 0b82f91a5..ae34bba57 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1910,6 +1910,7 @@ sub tables_hashref {
'locationnum', 'serial', '', '', '', '',
'prospectnum', 'int', 'NULL', '', '', '',
'custnum', 'int', 'NULL', '', '', '',
+ 'locationname', 'varchar', 'NULL', $char_d, '', '',
'address1', 'varchar', '', $char_d, '', '',
'address2', 'varchar', 'NULL', $char_d, '', '',
'city', 'varchar', '', $char_d, '', '',
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index d652d5349..ce7efcab1 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -2090,8 +2090,9 @@ sub _items_sections {
$section->{'sort_weight'} = sprintf('%012s',$location->zip) .
$locationnum;
$section->{'location'} = {
+ label_prefix => &{ $escape }($location->label_prefix),
map { $_ => &{ $escape }($location->get($_)) }
- $location->fields
+ $location->fields
};
} else {
$section->{'category'} = $sectionname;
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm
index 309ab0631..66fd7a077 100644
--- a/FS/FS/cust_location.pm
+++ b/FS/FS/cust_location.pm
@@ -322,6 +322,7 @@ sub check {
$self->ut_numbern('locationnum')
|| $self->ut_foreign_keyn('prospectnum', 'prospect_main', 'prospectnum')
|| $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
+ || $self->ut_alphan('locationname')
|| $self->ut_text('address1')
|| $self->ut_textn('address2')
|| $self->ut_text('city')
@@ -604,14 +605,61 @@ sub dealternize {
=item location_label
-Returns the label of the location object, with an optional site ID
-string (based on the cust_location-label_prefix config option).
+Returns the label of the location object.
+
+Options:
+
+=over 4
+
+=item cust_main
+
+Customer object (see L<FS::cust_main>)
+
+=item prospect_main
+
+Prospect object (see L<FS::prospect_main>)
+
+=item join_string
+
+String used to join location elements
+
+=back
=cut
sub location_label {
my( $self, %opt ) = @_;
+ my $prefix = $self->label_prefix;
+ $prefix .= ($opt{join_string} || ': ') if $prefix;
+
+ $prefix . $self->SUPER::location_label(%opt);
+}
+
+=item label_prefix
+
+Returns the optional site ID string (based on the cust_location-label_prefix
+config option), "Default service location", or the empty string.
+
+Options:
+
+=over 4
+
+=item cust_main
+
+Customer object (see L<FS::cust_main>)
+
+=item prospect_main
+
+Prospect object (see L<FS::prospect_main>)
+
+=back
+
+=cut
+
+sub label_prefix {
+ my( $self, %opt ) = @_;
+
my $cust_or_prospect = $opt{cust_main} || $opt{prospect_main};
unless ( $cust_or_prospect ) {
if ( $self->custnum ) {
@@ -633,14 +681,16 @@ sub location_label {
($agent =~ /^(..)/),
sprintf('%05d', $self->locationnum)
) );
- }
- elsif ( ( $opt{'cust_main'} || $self->custnum )
+
+ } elsif ( $label_prefix eq '_location' && $self->locationname ) {
+ $prefix = $self->locationname;
+
+ } elsif ( ( $opt{'cust_main'} || $self->custnum )
&& $self->locationnum == $cust_or_prospect->ship_locationnum ) {
$prefix = 'Default service location';
}
- $prefix .= ($opt{join_string} || ': ') if $prefix;
- $prefix . $self->SUPER::location_label(%opt);
+ $prefix;
}
=item county_state_county
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 84426b4ac..f3447cc6d 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2099,6 +2099,7 @@ Returns a list of fields which have ship_ duplicates.
sub addr_fields {
qw( last first company
+ locationname
address1 address2 city county state zip country
latitude longitude
daytime night fax mobile
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index 17a8f3dfa..be375dda9 100644
--- a/FS/FS/cust_main/Location.pm
+++ b/FS/FS/cust_main/Location.pm
@@ -17,10 +17,12 @@ BEGIN {
# set up accessors for location fields
if (!$init) {
no strict 'refs';
- @location_fields =
- qw( address1 address2 city county state zip country district
- latitude longitude coord_auto censustract censusyear geocode
- addr_clean );
+ @location_fields = qw(
+ locationname
+ address1 address2 city county state zip country
+ district latitude longitude coord_auto censustract censusyear geocode
+ addr_clean
+ );
foreach my $f (@location_fields) {
*{"FS::cust_main::Location::$f"} = sub {