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/edit/process/quick-cust_pkg.cgi | 38 ++++- httemplate/elements/location.html | 4 + httemplate/elements/tr-select-cust_location.html | 176 +++++++++++++++++++++++ httemplate/misc/location.cgi | 1 + httemplate/misc/order_pkg.html | 112 +-------------- httemplate/view/cust_main/packages.html | 9 +- 6 files changed, 226 insertions(+), 114 deletions(-) create mode 100644 httemplate/elements/tr-select-cust_location.html (limited to 'httemplate') diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 2aec344c5..9c2474330 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -2,7 +2,7 @@ % $cgi->param('error', $error); <% $cgi->redirect(popurl(3). 'misc/order_pkg.html?'. $cgi->query_string ) %> %} else { -% my $frag = "cust_pkg". $cust_pkg[0]->pkgnum; +% my $frag = "cust_pkg". $cust_pkg->pkgnum; <% header('Package ordered') %> + + + 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; + } +} + + diff --git a/httemplate/misc/location.cgi b/httemplate/misc/location.cgi index 3c3a85545..419c59f2e 100644 --- a/httemplate/misc/location.cgi +++ b/httemplate/misc/location.cgi @@ -4,6 +4,7 @@ my $locationnum = $cgi->param('arg'); my $cust_location = qsearchs({ + 'select' => 'cust_location.*', 'table' => 'cust_location', 'hashref' => { 'locationnum' => $locationnum }, 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index f91143154..2c8335154 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -1,71 +1,7 @@ <% include('/elements/header-popup.html', 'Order new package' ) %> -<% include('/elements/xmlhttp.html', - 'url' => $p.'misc/location.cgi', - 'subs' => [ 'get_location' ], - ) -%> -