From 20bddf47a41b6d064b3cfa4c41e55c157cf0c3de Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 9 Jan 2009 04:06:26 +0000 Subject: pick/enter a location when ordering a package, RT#4499 --- httemplate/misc/order_pkg.html | 131 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 123 insertions(+), 8 deletions(-) (limited to 'httemplate/misc/order_pkg.html') diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index 852b51ce4..f91143154 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -1,13 +1,79 @@ <% include('/elements/header-popup.html', 'Order new package' ) %> +<% include('/elements/xmlhttp.html', + 'url' => $p.'misc/location.cgi', + 'subs' => [ 'get_location' ], + ) +%> + <% include('/elements/error.html') %> @@ -19,7 +85,7 @@ function enable_order_pkg () { <% ntable("#cccccc", 2) %> Package - + <% include('/elements/select-cust-part_pkg.html', 'curr_value' => $pkgpart, 'cust_main' => $cust_main, @@ -34,10 +100,36 @@ function enable_order_pkg () { 'curr_value' => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum, 'disable_empty' => 1, 'multiple' => $conf->exists('pkg_referral-multiple'), + 'colspan' => 7, ) %> % } + + Service location + + + + + +<% include('/elements/location.html', + 'object' => $cust_location, + #'onchange' ? probably not + 'disabled' => ( $locationnum == -1 ? '' : 'DISABLED' ), + 'no_asterisks' => 1, + ) +%> +
@@ -46,14 +138,22 @@ function enable_order_pkg () { +<%once> + +my @location_fields = qw( address1 address2 city county state zip country ); + + <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Order customer package'); my $conf = new FS::Conf; +my $countrydefault = $conf->config('countrydefault') || 'US'; +my $statedefault = $conf->config('statedefault') + || ($countrydefault eq 'US' ? 'CA' : ''); -$cgi->param('custnum') =~ /^(\d+)$/; +$cgi->param('custnum') =~ /^(\d+)$/ or die "no custnum"; my $custnum = $1; my $cust_main = qsearchs({ 'table' => 'cust_main', @@ -63,4 +163,19 @@ my $cust_main = qsearchs({ my $pkgpart = scalar($cgi->param('pkgpart')); +$cgi->param('locationnum') =~ /^(\d*)$/ or die "illegal locationnum"; +my $locationnum = $1; +my $cust_location; +if ( $locationnum ) { + $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