summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorivan <ivan>2011-03-13 18:56:03 +0000
committerivan <ivan>2011-03-13 18:56:03 +0000
commit528e7e1cb1a6d05f87847bf9fd9b7e0e9fc33f6f (patch)
tree19e5e3331069417f221569dd4e6b9cd915e0500f /httemplate/edit
parentd66bff648dd4d7969f50f956b5c1dd06b8159b8c (diff)
qualification address handling changes, RT#7111
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/process/qual.cgi22
1 files changed, 16 insertions, 6 deletions
diff --git a/httemplate/edit/process/qual.cgi b/httemplate/edit/process/qual.cgi
index de076edda..a702047c5 100644
--- a/httemplate/edit/process/qual.cgi
+++ b/httemplate/edit/process/qual.cgi
@@ -45,14 +45,18 @@ my $locationnum = $1;
my $error = '';
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 )
+);
+
if ( $locationnum == -1 ) { # adding a new one
$cust_location = new FS::cust_location {
$cust_or_prospect."num" => $custnum_or_prospectnum,
- map { $_ => scalar($cgi->param($_)) }
- qw( address1 address2 city county state zip country geocode ),
- grep scalar($cgi->param($_)),
- qw( location_type location_number location_kind )
+ %location_hash,
};
#locationnum '': default service location
@@ -62,15 +66,21 @@ if ( $locationnum == -1 ) { # adding a new one
#locationnum -2: address not required for qual
} elsif ( $locationnum == -2 && $phonenum eq '' ) {
$error = "Nothing to qualify - neither phone number nor address specified";
+
+} else { #existing location, possibly with an edit
+ $cust_location = qsearchs('cust_location', { 'locationnum'=>$locationnum })
+ or die "Unknown locationnum $locationnum";
+ $cust_location->$_($location_hash{$_}) foreach keys %location_hash;
}
my $qual = new FS::qual {
'status' => 'N',
};
-$qual->phonenum($phonenum) if $phonenum ne '';
+$qual->phonenum($phonenum) if $phonenum ne '';
+#$qual->locationnum($locationnum) if $locationnum > 0;
+$qual->exportnum($exportnum) if $exportnum > 0;
$qual->set( $cust_or_prospect."num" => $custnum_or_prospectnum )
unless $locationnum == -1 || $locationnum > 0;
-$qual->exportnum($exportnum) if $exportnum > 0;
$error ||= $qual->insert( 'cust_location' => $cust_location );