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/location.html | 4 + httemplate/elements/tr-select-cust_location.html | 176 +++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 httemplate/elements/tr-select-cust_location.html (limited to 'httemplate/elements') diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html index bf340894a..f21b8ad01 100644 --- a/httemplate/elements/location.html +++ b/httemplate/elements/location.html @@ -20,6 +20,7 @@ Example: @@ -66,6 +69,7 @@ Example: + +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