diff options
author | Mark Wells <mark@freeside.biz> | 2012-03-01 12:34:46 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-03-01 12:34:46 -0800 |
commit | fec48523d3cf056da08813f9b2b7d633b27aaf8d (patch) | |
tree | 900f1bc04c8c4dbd98a89c9d35666cdff6e8b9b3 /httemplate/edit/process/cust_main.cgi | |
parent | 0924aec8b98b4056357bfdd19f45686a3e9008e2 (diff) |
duplicate address checking for new customers, #16582
Diffstat (limited to 'httemplate/edit/process/cust_main.cgi')
-rwxr-xr-x | httemplate/edit/process/cust_main.cgi | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index f75e2a6ae..994f9b7ca 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -66,6 +66,16 @@ my $new = new FS::cust_main ( { } fields('cust_main') } ); +$cgi->param('duplicate_of_custnum') =~ /^(\d+)$/; +my $duplicate_of = $1; +if ( $duplicate_of ) { + # then negate all changes to the customer; the only change we should + # make is to order a package, if requested + $new = qsearchs('cust_main', { 'custnum' => $duplicate_of }) + # this should never happen + or die "nonexistent existing customer (custnum $duplicate_of)"; +} + if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { $new->setfield("ship_$_", '') foreach qw( last first company address1 address2 city county state zip @@ -122,7 +132,7 @@ my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups'); my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups; #perhaps this stuff should go to cust_main.pm -if ( $new->custnum eq '' ) { +if ( $new->custnum eq '' or $duplicate_of ) { my $cust_pkg = ''; my $svc; @@ -216,23 +226,31 @@ if ( $new->custnum eq '' ) { } + use Tie::RefHash; tie my %hash, 'Tie::RefHash'; %hash = ( $cust_pkg => [ $svc ] ) if $cust_pkg; - $error ||= $new->insert( \%hash, \@invoicing_list, + if ( $duplicate_of ) { + # order the package and service normally + $error ||= $new->order_pkgs( \%hash ) if $cust_pkg; + } + else { + # create the customer + $error ||= $new->insert( \%hash, \@invoicing_list, 'tax_exemption'=> \@tax_exempt, 'prospectnum' => scalar($cgi->param('prospectnum')), - ); + ); - my $conf = new FS::Conf; - if ( $conf->exists('backend-realtime') && ! $error ) { + my $conf = new FS::Conf; + if ( $conf->exists('backend-realtime') && ! $error ) { - my $berror = $new->bill - || $new->apply_payments_and_credits - || $new->collect( 'realtime' => 1 ); - warn "Warning, error billing during backend-realtime: $berror" if $berror; + my $berror = $new->bill + || $new->apply_payments_and_credits + || $new->collect( 'realtime' => 1 ); + warn "Warning, error billing during backend-realtime: $berror" if $berror; - } + } + } #if $duplicate_of } else { #create old record object |