-my $cust_location;
-if ( $locationnum == -1 ) { # adding a new one
- my %location_hash = map { $_ => scalar($cgi->param($_)) }
- qw( address1 address2 city county state zip country geocode );
- $location_hash{$cust_or_prospect."num"} = $custnum_or_prospectnum;
- $location_hash{location_type} = $cgi->param('location_type')
- if $cgi->param('location_type');
- $location_hash{location_number} = $cgi->param('location_number')
- if $cgi->param('location_number');
- $location_hash{location_kind} = $cgi->param('location_kind')
- if $cgi->param('location_kind');
- $cust_location = new FS::cust_location ( { %location_hash } );
- $error = $cust_location->insert;
- die "Unable to insert cust_location: $error" if $error;
-}
-elsif ( $locationnum eq '' ) { # default service location
- if ( $custnum ) {
- $cust_location = new FS::cust_location ( {
- $cust_main_or_prospect_main->location_hash,
- custnum => $custnum,
- } );
- } elsif ( $prospectnum ) {
- die "a location must be specified explicitly for prospects";
- }
-}
-elsif ( $locationnum != -2 ) { # -2 = address not required for qual
- $cust_location = qsearchs('cust_location', { 'locationnum' => $locationnum })
- or die 'Invalid locationnum';
-}
+my $cust_location = '';
+my %location_hash = (
+ map { $_ => scalar($cgi->param($_)) }
+ qw( address1 address2 city county state zip country geocode ),
+ grep scalar($cgi->param($_)),
+ qw( location_type location_number location_kind )
+);