From a661ced3f9f678a645780eaa0b183d2de5f100fa Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 10 Jan 2009 00:43:06 +0000 Subject: more work on package service addresses: hide locations when they're all the default, config to show them anyway / finish implementing package ordering, fix all the state/county weirdness when changing the location dropdown. RT#4499 --- httemplate/elements/tr-select-cust_location.html | 176 +++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 httemplate/elements/tr-select-cust_location.html (limited to 'httemplate/elements/tr-select-cust_location.html') diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html new file mode 100644 index 000000000..b62c65c03 --- /dev/null +++ b/httemplate/elements/tr-select-cust_location.html @@ -0,0 +1,176 @@ +<%doc> + +Example: + + include('/elements/tr-select-cust_location.html', + 'cgi' => $cgi, + 'cust_main' => $cust_main, + ) + + + +<% 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 ); + + +<%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'}; + +$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 ( $cgi->param('error') && $locationnum == -1 ) { + $cust_location->$_( $cgi->param($_) ) foreach @location_fields; + } else { + $cust_location->$_( $cust_main->$_() ) foreach @location_fields; + } +} + + -- cgit v1.2.1