X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_main.cgi;h=7241b0a3a1f0944187099e337bb3c42af63eb0b9;hb=e5731af379db55e629ad3ea4cd14ea53554e0595;hp=994f9b7ca501eb494cfd6392ba52d557ebb35e0f;hpb=943e96a24a110babfd15f94f95abbf42a95c71ab;p=freeside.git diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 994f9b7ca..7241b0a3a 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -1,7 +1,7 @@ % if ( $error ) { % $cgi->param('error', $error); -% -<% $cgi->redirect(popurl(2). "cust_main.cgi?". $cgi->query_string ) %> +% my $query = $m->scomp('/elements/create_uri_query', 'secure'=>1); +<% $cgi->redirect(popurl(2). "cust_main.cgi?$query" ) %> % % } else { % @@ -16,8 +16,8 @@ my $DEBUG = 0; <%init> -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Edit customer'); +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" unless $curuser->access_right('Edit customer'); my $conf = new FS::Conf; @@ -66,6 +66,8 @@ my $new = new FS::cust_main ( { } fields('cust_main') } ); +$new->invoice_noemail( ($cgi->param('invoice_email') eq 'Y') ? '' : 'Y' ); + $cgi->param('duplicate_of_custnum') =~ /^(\d+)$/; my $duplicate_of = $1; if ( $duplicate_of ) { @@ -76,6 +78,23 @@ if ( $duplicate_of ) { or die "nonexistent existing customer (custnum $duplicate_of)"; } +# if this is enabled, enforce it +if ( $conf->exists('agent-ship_address', $cgi->param('agentnum')) ) { + my $agent = FS::agent->by_key($cgi->param('agentnum')); + my $agent_cust_main = $agent->agent_cust_main; + if ( $agent_cust_main ) { + my $pre = ''; + $pre = 'ship_' if $agent_cust_main->has_ship_address; + foreach (qw(address1 city state zip country latitude longitude)) { + $new->set("ship_$_", $agent_cust_main->get($pre.$_)); + } + foreach (qw(first last company)) { + $new->set("ship_$_", $cgi->param($_)); + } + $cgi->param('same', ''); + } +} + if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { $new->setfield("ship_$_", '') foreach qw( last first company address1 address2 city county state zip @@ -89,9 +108,16 @@ if ( $cgi->param('no_credit_limit') ) { $new->tagnum( [ $cgi->param('tagnum') ] ); -my %usedatetime = ( 'birthdate' => 1 ); +$error ||= $new->set_national_id_from_cgi( $cgi ); -foreach my $dfield (qw( birthdate signupdate )) { +my %usedatetime = ( 'birthdate' => 1, + 'spouse_birthdate' => 1, + 'anniversary_date' => 1, + ); + +foreach my $dfield (qw( + signupdate birthdate spouse_birthdate anniversary_date +)) { if ( $cgi->param($dfield) && $cgi->param($dfield) =~ /^([ 0-9\-\/]{0,10})$/) { @@ -128,8 +154,14 @@ foreach my $dfield (qw( birthdate signupdate )) { $new->setfield('paid', $cgi->param('paid') ) if $cgi->param('paid'); -my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups'); -my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups; +my %options = (); +if ( $curuser->access_right('Edit customer tax exemptions') ) { + my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups'); + my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups; + $options{'tax_exemption'} = { + map { $_ => scalar($cgi->param("tax_$_".'_num')) } @tax_exempt + }; +} #perhaps this stuff should go to cust_main.pm if ( $new->custnum eq '' or $duplicate_of ) { @@ -237,8 +269,8 @@ if ( $new->custnum eq '' or $duplicate_of ) { else { # create the customer $error ||= $new->insert( \%hash, \@invoicing_list, - 'tax_exemption'=> \@tax_exempt, - 'prospectnum' => scalar($cgi->param('prospectnum')), + %options, + prospectnum => scalar($cgi->param('prospectnum')), ); my $conf = new FS::Conf; @@ -295,7 +327,7 @@ if ( $new->custnum eq '' or $duplicate_of ) { local($FS::Record::DEBUG) = $DEBUG if $DEBUG; $error ||= $new->replace( $old, \@invoicing_list, - 'tax_exemption' => \@tax_exempt, + %options, ); warn "$me returned from replace" if $DEBUG;