} else {
if ( locationnum == 0 ) {
- what.form.address1.value = <% $cust_main->address1 |js_string %>;
- what.form.address2.value = <% $cust_main->address2 |js_string %>;
- what.form.city.value = <% $cust_main->city |js_string %>;
- what.form.zip.value = <% $cust_main->zip |js_string %>;
+ what.form.address1.value = <% $cust_main->get($prefix.'address1') |js_string %>;
+ what.form.address2.value = <% $cust_main->get($prefix.'address2') |js_string %>;
+ what.form.city.value = <% $cust_main->get($prefix.'city') |js_string %>;
+ what.form.zip.value = <% $cust_main->get($prefix.'zip') |js_string %>;
- changeSelect(what.form.country, <% $cust_main->country | js_string %> );
+ changeSelect(what.form.country, <% $cust_main->get($prefix.'country') | js_string %> );
country_changed( what.form.country,
- fix_state_factory( <% $cust_main->state | js_string %>,
- <% $cust_main->county | js_string %>
+ fix_state_factory( <% $cust_main->get($prefix.'state') | js_string %>,
+ <% $cust_main->get($prefix.'county') | js_string %>
)
);
</SCRIPT>
<TR>
- <TH ALIGN="right">Service location</TH>
+ <<%$th%> ALIGN="right"><% $opt{'label'} || 'Service location' %></<%$th%>>
<TD COLSPAN=7>
<SELECT NAME="locationnum" onChange="locationnum_changed(this);">
<OPTION VALUE="">(default service address)
#'onchange' ? probably not
'disabled' => ( $locationnum == -1 ? '' : 'DISABLED' ),
'no_asterisks' => 1,
+ 'no_bold' => $opt{'no_bold'},
)
%>
my %opt = @_;
my $cgi = $opt{'cgi'};
+my $cust_pkg = $opt{'cust_pkg'};
my $cust_main = $opt{'cust_main'};
+my $prefix = length($cust_main->ship_last) ? 'ship_' : '';
+
$cgi->param('locationnum') =~ /^(\-?\d*)$/ or die "illegal locationnum";
my $locationnum = $1;
my $cust_location;
or die "unknown locationnum";
} else {
$cust_location = new FS::cust_location;
- if ( $cgi->param('error') && $locationnum == -1 ) {
+ if ( $locationnum == -1 ) {
$cust_location->$_( $cgi->param($_) ) foreach @location_fields;
+ } elsif ( $cust_pkg && $cust_pkg->locationnum ) {
+ my $pkg_location = $cust_pkg->cust_location;
+ $cust_location->$_( $pkg_location->$_ ) foreach @location_fields;
+ $opt{'empty_label'} ||= 'package address: '.$pkg_location->line;
} else {
- $cust_location->$_( $cust_main->$_() ) foreach @location_fields;
+ $cust_location->$_( $cust_main->get($prefix.$_) ) foreach @location_fields;
}
}
+my $th = $opt{'no_bold'} ? 'TD' : 'TH';
+
</%init>