% 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 {
%
# is this actually used? if so, we need to clone locations...
# but I can't find anything that sets this parameter to a non-empty value
+# yes, fec48523d3cf056da08813f9b2b7d633b27aaf8d for #16582 is where it came in,
+# for "duplicate address checking for new customers". afaict still in
+# edit/cust_main/bottomfixup.html (and working?)
$cgi->param('duplicate_of_custnum') =~ /^(\d+)$/;
my $duplicate_of = $1;
+# 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 $agent_location = $agent_cust_main->ship_location;
+ foreach (qw(address1 city state zip country latitude longitude district)) {
+ $cgi->param("ship_$_", $agent_location->get($_));
+ }
+ }
+}
+
my %locations;
for my $pre (qw(bill ship)) {
}
$hash{'custnum'} = $cgi->param('custnum');
warn Dumper \%hash if $DEBUG;
- # if we can qsearchs it, then it's unchanged, so use that
- $locations{$pre} = qsearchs('cust_location', \%hash)
- || FS::cust_location->new( \%hash );
-
+ $locations{$pre} = FS::cust_location->new(\%hash);
}
if ( ($cgi->param('same') || '') eq 'Y' ) {
# but explicitly avoid setting ship_ fields
my $new = new FS::cust_main ( {
- map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main')),
- map { ( "ship_$_", '' ) } (FS::cust_main->location_fields)
+ (map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main'))),
+ (map { ( "ship_$_", '' ) } (FS::cust_main->location_fields))
} );
$new->invoice_noemail( ($cgi->param('invoice_email') eq 'Y') ? '' : 'Y' );
#later 'custnum' => $custnum,
'pkgpart' => $pkgpart,
'locationnum' => scalar($cgi->param('locationnum')),
+ 'salesnum' => scalar($cgi->param('salesnum')),
} );
}
-unless ( $error ) { #XXX i guess i should be transactional... all in the insert
+unless ( $error ) { #XXX i should be transactional... all in the insert
# or replace call
- my @contact_fields = qw( classnum first last title comment emailaddress );
- foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
- push @contact_fields, 'phonetypenum'.$phone_type->phonetypenum;
- }
$error = $new->process_o2m( 'table' => 'contact',
- 'fields' => \@contact_fields,
+ 'fields' => FS::contact->cgi_contact_fields,
'params' => scalar($cgi->Vars),
);
}