%doc>
Example:
include('/elements/tr-select-cust_location.html',
'cgi' => $cgi,
'cust_main' => $cust_main,
)
%doc>
<% include('/elements/xmlhttp.html',
'url' => $p.'misc/location.cgi',
'subs' => [ 'get_location' ],
)
%>
Service location |
|
<% include('/elements/location.html',
'object' => $cust_location,
#'onchange' ? probably not
'disabled' => ( $locationnum == -1 ? '' : 'DISABLED' ),
'no_asterisks' => 1,
)
%>
<%once>
my @location_fields = qw( address1 address2 city county state zip country );
%once>
<%init>
my $conf = new FS::Conf;
my $countrydefault = $conf->config('countrydefault') || 'US';
my $statedefault = $conf->config('statedefault')
|| ($countrydefault eq 'US' ? 'CA' : '');
my %opt = @_;
my $cgi = $opt{'cgi'};
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;
if ( $locationnum && $locationnum != -1 ) {
$cust_location = qsearchs('cust_location', { 'locationnum' => $locationnum } )
or die "unknown locationnum";
} else {
$cust_location = new FS::cust_location;
if ( $locationnum == -1 ) {
$cust_location->$_( $cgi->param($_) ) foreach @location_fields;
} else {
$cust_location->$_( $cust_main->get($prefix.$_) ) foreach @location_fields;
}
}
%init>