summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-05-25 13:38:07 -0700
committerMark Wells <mark@freeside.biz>2012-05-25 13:38:18 -0700
commit01629c3c934f1f6fd2ab9de5f7638f671fd59791 (patch)
treee20740d482c8ce8f47731b3213c65e7910e267f2 /httemplate/edit
parentf2c26594352302de80c2cd0cbba8b0e2abada6f7 (diff)
customer bill/ship location refactoring, #940
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-xhttemplate/edit/cust_main.cgi194
-rw-r--r--httemplate/edit/cust_main/after_bill_location.html12
-rw-r--r--httemplate/edit/cust_main/before_bill_location.html10
-rw-r--r--httemplate/edit/cust_main/birthdate.html1
-rw-r--r--httemplate/edit/cust_main/bottomfixup.js28
-rw-r--r--httemplate/edit/cust_main/company.html7
-rw-r--r--httemplate/edit/cust_main/fax.html5
-rw-r--r--httemplate/edit/cust_main/name.html53
-rw-r--r--httemplate/edit/cust_main/phones.html29
-rw-r--r--httemplate/edit/cust_main/stateid.html39
-rw-r--r--httemplate/edit/cust_main/top_misc.html27
-rw-r--r--httemplate/edit/msg_template.html16
-rw-r--r--httemplate/edit/process/cust_location.cgi6
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi43
14 files changed, 324 insertions, 146 deletions
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 028924669..a30c7c165 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -23,6 +23,8 @@
% }
%# agent, agent_custid, refnum (advertising source), referral_custnum
+%# better section title for this?
+<FONT CLASS="fsinnerbox-title"><% mt('Basics') |h %></FONT>
<& cust_main/top_misc.html, $cust_main, 'custnum' => $custnum &>
%# birthdate
@@ -33,113 +35,77 @@
<BR>
<& cust_main/birthdate.html, $cust_main &>
% }
-
-%# contact info
-
-% my $same_checked = '';
-% my $ship_disabled = '';
-% my @ship_style = ();
-% unless ( $cust_main->ship_last && $same ne 'Y' ) {
-% $same_checked = 'CHECKED';
-% $ship_disabled = 'DISABLED';
-% push @ship_style, 'background-color:#dddddd';
-% foreach (
-% qw( last first company address1 address2 city county state zip country
-% latitude longitude coord_auto
-% daytime night fax mobile )
-% ) {
-% $cust_main->set("ship_$_", $cust_main->get($_) );
-% }
-% }
-
+% my $has_ship_address = '';
+% if ( $cgi->param('error') ) {
+% $has_ship_address = !$cgi->param('same');
+% } elsif ( $cust_main->custnum ) {
+% $has_ship_address = $cust_main->has_ship_address;
+% }
<BR>
-<FONT CLASS="fsinnerbox-title"><% mt('Billing address') |h %></FONT>
-
-<& cust_main/contact.html,
- 'cust_main' => $cust_main,
- 'pre' => '',
- 'onchange' => 'bill_changed(this)',
- 'disabled' => '',
- 'ss' => $ss,
- 'stateid' => $stateid,
- 'same_checked' => $same_checked, #for address2 "Unit #" labeling
-&>
+<TABLE> <TR>
+ <TD STYLE="width:650px">
+%#; padding-right:2px; vertical-align:top">
+ <FONT CLASS="fsinnerbox-title"><% mt('Billing address') |h %></FONT>
+ <TABLE CLASS="fsinnerbox">
+ <& cust_main/before_bill_location.html, $cust_main &>
+ <& /elements/location.html,
+ object => $cust_main->bill_location,
+ prefix => 'bill_',
+ &>
+ <& cust_main/after_bill_location.html, $cust_main &>
+ </TABLE>
+ </TD>
+</TR>
+<TR><TD STYLE="height:40px"></TD></TR>
+<TR>
+ <TD STYLE="width:650px">
+%#; padding-left:2px; vertical-align:top">
+ <FONT CLASS="fsinnerbox-title"><% mt('Service address') |h %></FONT>
+ <INPUT TYPE="checkbox"
+ NAME="same"
+ ID="same"
+ onclick="samechanged(this)"
+ onkeyup="samechanged(this)"
+ VALUE="Y"
+ <% $has_ship_address ? '' : 'CHECKED' %>
+ ><% mt('same as billing address') |h %>
+ <TABLE CLASS="fsinnerbox" ID="table_ship_location">
+ <& /elements/location.html,
+ object => $cust_main->ship_location,
+ prefix => 'ship_',
+ enable_censustract => 1,
+ enable_district => 1,
+ &>
+ </TABLE>
+ <TABLE CLASS="fsinnerbox" ID="table_ship_location_blank"
+ STYLE="display:none">
+ <TR><TD></TD></TR>
+ </TABLE>
+ </TD>
+</TR></TABLE>
<SCRIPT>
-function bill_changed(what) {
- if ( what.form.same.checked ) {
-% for (qw( last first company address1 address2 city zip latitude longitude coord_auto daytime night fax mobile )) {
- what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
-% }
-
- what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
-
- function fix_ship_city() {
- what.form.ship_city_select.selectedIndex = what.form.city_select.selectedIndex;
- what.form.ship_city.style.display = what.form.city.style.display;
- what.form.ship_city_select.style.display = what.form.city_select.style.display;
- }
-
- function fix_ship_county() {
- what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
- ship_county_changed(what.form.ship_county, fix_ship_city );
- }
-
- function fix_ship_state() {
- what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
- ship_state_changed(what.form.ship_state, fix_ship_county );
- }
-
- ship_country_changed(what.form.ship_country, fix_ship_state );
-
- }
-}
function samechanged(what) {
+%# not display = 'none', because we still want it to take up space
+%# document.getElementById('table_ship_location').style.visibility =
+%# what.checked ? 'hidden' : 'visible';
+ var t1 = document.getElementById('table_ship_location');
+ var t2 = document.getElementById('table_ship_location_blank');
if ( what.checked ) {
- bill_changed(what);
-
-% my @fields = qw( last first company address1 address2 city city_select county state zip country latitude longitude daytime night fax mobile );
-% for (@fields) {
- what.form.ship_<%$_%>.disabled = true;
- what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
-% }
-
-% if ( $conf->exists('cust_main-require_address2') ) {
- document.getElementById('address2_required').style.visibility = '';
- document.getElementById('address2_label').style.visibility = '';
- document.getElementById('ship_address2_required').style.visibility = 'hidden';
- document.getElementById('ship_address2_label').style.visibility = 'hidden';
-% }
-
- } else {
-
-% for (@fields) {
- what.form.ship_<%$_%>.disabled = false;
- what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
-% }
-
-% if ( $conf->exists('cust_main-require_address2') ) {
- document.getElementById('address2_required').style.visibility = 'hidden';
- document.getElementById('address2_label').style.visibility = 'hidden';
- document.getElementById('ship_address2_required').style.visibility = '';
- document.getElementById('ship_address2_label').style.visibility = '';
-% }
-
+ t2.style.width = t1.clientWidth + 'px';
+ t2.style.height = t1.clientHeight + 'px';
+ t1.style.display = 'none';
+ t2.style.display = '';
+ }
+ else {
+ t2.style.display = 'none';
+ t1.style.display = '';
}
}
+samechanged(document.getElementById('same'));
</SCRIPT>
<BR>
-<FONT CLASS="fsinnerbox-title"><% mt('Service address') |h %></FONT>
-
-<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$same_checked%>><% mt('same as billing address') |h %>
-<& cust_main/contact.html,
- 'cust_main' => $cust_main,
- 'pre' => 'ship_',
- 'onchange' => '',
- 'disabled' => $ship_disabled,
- 'style' => \@ship_style
-&>
<& cust_main/contacts_new.html,
'cust_main' => $cust_main,
@@ -242,10 +208,28 @@ my $locationnum = '';
if ( $cgi->param('error') ) {
+ # false laziness w/ edit/process/cust_main.cgi
+ my %locations;
+ for my $pre (qw(bill ship)) {
+ my %hash;
+ foreach ( FS::cust_main->location_fields ) {
+ $hash{$_} = scalar($cgi->param($pre.'_'.$_));
+ }
+ $hash{'custnum'} = $cgi->param('custnum');
+ $locations{$pre} = qsearchs('cust_location', \%hash)
+ || FS::cust_location->new( \%hash );
+ }
+
$cust_main = new FS::cust_main ( {
- map { $_, scalar($cgi->param($_)) } fields('cust_main')
+ map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main')),
+ map { ( "ship_$_", '' ) } (FS::cust_main->location_fields)
} );
+ for my $pre (qw(bill ship)) {
+ $cust_main->set($pre.'_location', $locations{$pre});
+ $cust_main->set($pre.'_locationnum', $locations{$pre}->locationnum);
+ }
+
$custnum = $cust_main->custnum;
die "access denied"
@@ -355,6 +339,20 @@ if ( $cgi->param('error') ) {
$svc_dsl{$_} = $qual->$_
foreach qw( phonenum vendor_qual_id );
}
+ else {
+ my $countrydefault = $conf->config('countrydefault') || 'US';
+ my $statedefault = $conf->config('statedefault') || 'CA';
+ $cust_main->set('bill_location',
+ FS::cust_location->new(
+ { country => $countrydefault, state => $statedefault }
+ )
+ );
+ $cust_main->set('ship_location',
+ FS::cust_location->new(
+ { country => $countrydefault, state => $statedefault }
+ )
+ );
+ }
if ( $cgi->param('lock_pkgpart') =~ /^(\d+)$/ ) {
my $pkgpart = $1;
diff --git a/httemplate/edit/cust_main/after_bill_location.html b/httemplate/edit/cust_main/after_bill_location.html
new file mode 100644
index 000000000..2f4c3b51c
--- /dev/null
+++ b/httemplate/edit/cust_main/after_bill_location.html
@@ -0,0 +1,12 @@
+% if ( ! $conf->exists('cust-edit-alt-field-order') ) {
+ <& phones.html, $cust_main &>
+ <& fax.html, $cust_main &>
+% } else {
+ <& fax.html, $cust_main &>
+ <& company.html, $cust_main &>
+% }
+<& stateid.html, $cust_main &>
+<%init>
+my $cust_main = shift;
+my $conf = FS::Conf->new;
+</%init>
diff --git a/httemplate/edit/cust_main/before_bill_location.html b/httemplate/edit/cust_main/before_bill_location.html
new file mode 100644
index 000000000..973201ecb
--- /dev/null
+++ b/httemplate/edit/cust_main/before_bill_location.html
@@ -0,0 +1,10 @@
+<& name.html, $cust_main &>
+% if ( ! $conf->exists('cust-edit-alt-field-order') ) {
+ <& company.html, $cust_main &>
+% } else {
+ <& phones.html, $cust_main &>
+% }
+<%init>
+my $cust_main = shift;
+my $conf = FS::Conf->new;
+</%init>
diff --git a/httemplate/edit/cust_main/birthdate.html b/httemplate/edit/cust_main/birthdate.html
index 6d1c221aa..5d6a123b1 100644
--- a/httemplate/edit/cust_main/birthdate.html
+++ b/httemplate/edit/cust_main/birthdate.html
@@ -1,4 +1,5 @@
<% ntable("#cccccc", 2) %>
+% # maybe put after the contact names?
% if ( $conf->exists('cust_main-enable_birthdate') ) {
<% include( '/elements/tr-input-date-field.html', {
'name' => 'birthdate',
diff --git a/httemplate/edit/cust_main/bottomfixup.js b/httemplate/edit/cust_main/bottomfixup.js
index 800864bc8..77d4294a6 100644
--- a/httemplate/edit/cust_main/bottomfixup.js
+++ b/httemplate/edit/cust_main/bottomfixup.js
@@ -66,21 +66,25 @@ function copy_payby_fields() {
%# call submit_continue() on completion...
%# otherwise not touching standardize_locations for now
<% include( '/elements/standardize_locations.js',
- 'callback' => 'submit_continue();'
+ 'callback' => 'submit_continue();',
+ 'main_prefix' => 'bill_',
+ 'no_company' => 1,
)
%>
+var prefix;
function fetch_censustract() {
//alert('fetch census tract data');
+ prefix = document.getElementById('same').checked ? 'bill_' : 'ship_';
var cf = document.CustomerForm;
- var state_el = cf.elements['ship_state'];
+ var state_el = cf.elements[prefix + 'state'];
var census_data = new Array(
'year', <% $conf->config('census_year') || '2012' %>,
- 'address1', cf.elements['ship_address1'].value,
- 'city', cf.elements['ship_city'].value,
+ 'address1', cf.elements[prefix + 'address1'].value,
+ 'city', cf.elements[prefix + 'city'].value,
'state', state_el.options[ state_el.selectedIndex ].value,
- 'zip', cf.elements['ship_zip'].value
+ 'zip', cf.elements[prefix + 'zip'].value
);
censustract( census_data, update_censustract );
@@ -109,19 +113,21 @@ function update_censustract(arg) {
set_censustract = function () {
- cf.elements['censustract'].value = newcensus;
+ cf.elements[prefix + 'censustract'].value = newcensus;
submit_continue();
}
- if (error || cf.elements['censustract'].value != newcensus) {
+ if (error || cf.elements[prefix + 'censustract'].value != newcensus) {
// popup an entry dialog
if (error) { newcensus = error; }
newcensus.replace(/.*ndefined.*/, 'Not found');
- var latitude = cf.elements['latitude' ].value || '<% $company_latitude %>';
- var longitude= cf.elements['longitude'].value || '<% $company_longitude %>';
+ var latitude = cf.elements[prefix + 'latitude'].value
+ || '<% $company_latitude %>';
+ var longitude= cf.elements[prefix + 'longitude'].value
+ || '<% $company_longitude %>';
var choose_censustract =
'<CENTER><BR><B>Confirm censustract</B><BR>' +
@@ -132,14 +138,14 @@ function update_censustract(arg) {
'" target="_blank">Map service module location</A><BR>' +
'<A href="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?' +
'census_year=<% $conf->config('census_year') || '2012' %>' +
- '&zip_code=' + cf.elements['ship_zip'].value +
+ '&zip_code=' + cf.elements[prefix + 'zip'].value +
'" target="_blank">Map zip code center</A><BR><BR>' +
'<TABLE>';
choose_censustract = choose_censustract +
'<TR><TH style="width:50%">Entered census tract</TH>' +
'<TH style="width:50%">Calculated census tract</TH></TR>' +
- '<TR><TD>' + cf.elements['censustract'].value +
+ '<TR><TD>' + cf.elements[prefix + 'censustract'].value +
'</TD><TD>' + newcensus + '</TD></TR>' +
'<TR><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>';
diff --git a/httemplate/edit/cust_main/company.html b/httemplate/edit/cust_main/company.html
new file mode 100644
index 000000000..8a6ed0bbf
--- /dev/null
+++ b/httemplate/edit/cust_main/company.html
@@ -0,0 +1,7 @@
+% my $cust_main = shift;
+<TR ID="company_row" <% $cust_main->company ? '' : 'STYLE="display:none"' %>>
+ <TD ALIGN="right"><% mt('Company') |h %></TD>
+ <TD COLSPAN=6><INPUT TYPE="text" NAME="company" ID="company" SIZE=60
+ VALUE="<% $cust_main->company |h %>">
+ </TD>
+</TR>
diff --git a/httemplate/edit/cust_main/fax.html b/httemplate/edit/cust_main/fax.html
new file mode 100644
index 000000000..237d4be44
--- /dev/null
+++ b/httemplate/edit/cust_main/fax.html
@@ -0,0 +1,5 @@
+% my $cust_main = shift;
+<TR>
+ <TD ALIGN="right"><% mt('Fax') |h %></TD>
+ <TD><INPUT TYPE="text" NAME="fax" VALUE="<% $cust_main->fax %>" SIZE=18></TD>
+</TR>
diff --git a/httemplate/edit/cust_main/name.html b/httemplate/edit/cust_main/name.html
new file mode 100644
index 000000000..2641ec930
--- /dev/null
+++ b/httemplate/edit/cust_main/name.html
@@ -0,0 +1,53 @@
+<%def .namepart>
+% my ($field, $value, $label, $extra) = @_;
+<TD>
+ <INPUT TYPE="text" NAME="<% $field %>" VALUE="<% $value |h %>" <%$extra%>>
+ <BR><FONT SIZE=-1><% mt($label) %></FONT>
+</TD>
+</%def>
+
+<TR>
+ <TH VALIGN="top" ALIGN="right"><%$r%><% mt('Contact name') |h %></TH>
+ <TD COLSPAN=6>
+ <TABLE CELLSPACING=0 CELLPADDING=0>
+ <TR>
+ <& .namepart, 'last', $cust_main->last, 'Last' &>
+ <TD VALIGN="top"> , </TD>
+ <& .namepart, 'first', $cust_main->first, 'First' &>
+% if ( $conf->exists('show_ss') ) {
+ <TD>&nbsp;</TD>
+ <& .namepart, 'ss', $ss, 'SS#', "SIZE=11" &>
+% } else {
+ <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>">
+% }
+ </TR>
+ </TABLE>
+ </TD>
+</TR>
+
+% if ( $conf->exists('cust-email-high-visibility') ) {
+<TR>
+ <TD ALIGN="right">
+ <% $conf->exists('cust_main-require_invoicing_list_email', $agentnum)
+ ? $r
+ : '' %>Email address(es)
+ </TD>
+ <TD BGCOLOR="#FFFF00">
+ <INPUT TYPE="text" NAME="invoicing_list"
+ VALUE=<% $cust_main->invoicing_list_emailonly_scalar %>>
+ </TD>
+</TR>
+% }
+<%init>
+my $cust_main = shift;
+my $agentnum = $cust_main->agentnum if $cust_main->custnum;
+my $conf = FS::Conf->new;
+my $r = '<font color="#ff0000">*</font>&nbsp;';
+my $ss;
+
+if ( $cgi->param('error') or $conf->exists('unmask_ss') ) {
+ $ss = $cust_main->ss;
+} else {
+ $ss = $cust_main->masked('ss');
+}
+</%init>
diff --git a/httemplate/edit/cust_main/phones.html b/httemplate/edit/cust_main/phones.html
new file mode 100644
index 000000000..9b23e0716
--- /dev/null
+++ b/httemplate/edit/cust_main/phones.html
@@ -0,0 +1,29 @@
+<TR>
+ <TD VALIGN="top" ALIGN="right"><% mt('Phones') |h %></TD>
+ <TD COLSPAN=6>
+ <TABLE CELLSPACING=0 CELLPADDING=0>
+ <TR>
+% foreach my $phone (qw(daytime night mobile)) {
+ <TD>
+ <INPUT TYPE="text"
+ NAME="<% $phone %>"
+ VALUE="<% $cust_main->get($phone) %>"
+ SIZE=18
+ >
+ <BR><FONT SIZE=-1><% mt($phone_label{$phone}) |h %></FONT>
+ </TD>
+ <TD>&nbsp;</TD>
+% }
+ </TR>
+ </TABLE>
+ </TD>
+</TR>
+<%init>
+my $cust_main = shift;
+my $conf = FS::Conf->new;
+my %phone_label = (
+ daytime => 'Day Phone',
+ night => 'Night Phone',
+ mobile => 'Mobile',
+);
+</%init>
diff --git a/httemplate/edit/cust_main/stateid.html b/httemplate/edit/cust_main/stateid.html
new file mode 100644
index 000000000..2655f5142
--- /dev/null
+++ b/httemplate/edit/cust_main/stateid.html
@@ -0,0 +1,39 @@
+% if ( $conf->exists('show_stateid') ) {
+<TR>
+ <TD ALIGN="right"><% $stateid_label %></TD>
+ <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>" SIZE=12></TD>
+ <TD><& /elements/select-state.html,
+ state => $cust_main->stateid_state,
+ country => $cust_main->country, # how does this work on new customer?
+ prefix => 'stateid_',
+ disable_countyupdate => 1,
+ &></TD>
+</TR>
+% } else {
+<INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
+<INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>">
+% }
+
+<%init>
+my $cust_main = shift;
+my $conf = FS::Conf->new;
+my $stateid;
+if ( $cgi->param('error') ) {
+ $stateid = $cust_main->stateid;
+} elsif ( $cust_main->custnum ) {
+ $stateid = $cust_main->masked('stateid');
+} else {
+ $stateid = '';
+}
+$cust_main->set('stateid_state' => $cust_main->state)
+ unless $cust_main->stateid_state;
+
+my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
+ ? 'Driver&rsquo;s License'
+ : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
+
+my $stateid_state_label =
+ FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
+ ? 'Driver&rsquo;s License State'
+ : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License State';
+</%init>
diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html
index 7ba167b7f..7ce283c6c 100644
--- a/httemplate/edit/cust_main/top_misc.html
+++ b/httemplate/edit/cust_main/top_misc.html
@@ -20,27 +20,16 @@
<% $cust_main->residential_commercial eq 'Commercial' ? 'CHECKED' : '' %>
></TD>
</TR>
-
<SCRIPT TYPE="text/javascript">
- function rescom_changed() {
- var f = document.CustomerForm;
-
- if ( f.residential_commercial_Residential.checked ) {
- document.getElementById('contacts_div').style.display = 'none';
- } else { // if ( f.residential_commercial_Commercial.checked ) {
- document.getElementById('contacts_div').style.display = '';
- }
-
- if ( f.residential_commercial_Residential.checked && ! f.company.value.length ) {
- document.getElementById('company_row').style.display = 'none'
- } else { // if ( f.residential_commercial_Commercial.checked ) {
+ function rescom_changed(what) {
+ if ( what.checked == (what.value == 'Commercial' ) ) {
document.getElementById('company_row').style.display = '';
- }
-
- if ( f.residential_commercial_Residential.checked && ! f.ship_company.value.length ) {
- document.getElementById('ship_company_row').style.display = 'none'
- } else { // if ( f.residential_commercial_Commercial.checked ) {
- document.getElementById('ship_company_row').style.display = '';
+ document.getElementById('contacts_div').style.display = '';
+ } else {
+ if ( document.getElementById('company').value.length == 0 ) {
+ document.getElementById('company_row').style.display = 'none';
+ }
+ document.getElementById('contacts_div').style.display = 'none';
}
}
</SCRIPT>
diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html
index f50d66d7c..115032a07 100644
--- a/httemplate/edit/msg_template.html
+++ b/httemplate/edit/msg_template.html
@@ -227,6 +227,15 @@ my %substitutions = (
'$mobile' => 'Mobile phone',
'$fax' => 'Fax',
],
+ 'service' => [
+ '$ship_address1' => 'Address line 1',
+ '$ship_address2' => 'Address line 2',
+ '$ship_city' => 'City',
+ '$ship_county' => 'County',
+ '$ship_state' => 'State',
+ '$ship_zip' => 'Zip',
+ '$ship_country' => 'Country',
+ ],
'cust_bill' => [
'$invnum' => 'Invoice#',
],
@@ -281,15 +290,10 @@ my %substitutions = (
'$error' => 'Decline reason',
],
);
-my @c = @{ $substitutions{'contact'} };
-for (my $i=0; $i<scalar(@c); $i += 2) {
- $c[$i] =~ s/\$(.*)/\$ship_$1/;
-}
-$substitutions{'shipping'} = \@c;
tie my %sections, 'Tie::IxHash', (
'contact' => 'Name and contact info (billing)',
-'shipping' => 'Name and contact info (shipping)',
+'service' => 'Service address',
'cust_main' => 'Customer status and payment info',
'cust_pkg' => 'Package fields',
'cust_bill' => 'Invoice fields',
diff --git a/httemplate/edit/process/cust_location.cgi b/httemplate/edit/process/cust_location.cgi
index 790fc8ea4..b9f93db8b 100644
--- a/httemplate/edit/process/cust_location.cgi
+++ b/httemplate/edit/process/cust_location.cgi
@@ -28,10 +28,12 @@ my $cust_location = qsearchs({
});
die "unknown locationnum $locationnum" unless $cust_location;
-my $new = {
+my $new = FS::cust_location->new({
+ custnum => $cust_location->custnum,
+ prospectnum => $cust_location->prospectnum,
map { $_ => scalar($cgi->param($_)) }
qw( address1 address2 city county state zip country )
-};
+});
my $error = $cust_location->move_to($new);
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index 3f5e19ef3..5ee553b32 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -57,19 +57,40 @@ push @invoicing_list, 'POST' if $cgi->param('invoicing_list_POST');
push @invoicing_list, 'FAX' if $cgi->param('invoicing_list_FAX');
$cgi->param('invoicing_list', join(',', @invoicing_list) );
+# 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
+$cgi->param('duplicate_of_custnum') =~ /^(\d+)$/;
+my $duplicate_of = $1;
+
+my %locations;
+for my $pre (qw(bill ship)) {
+
+ my %hash;
+ foreach ( FS::cust_main->location_fields ) {
+ $hash{$_} = scalar($cgi->param($pre.'_'.$_));
+ }
+ $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 );
+
+}
+
+if ( ($cgi->param('same') || '') eq 'Y' ) {
+ $locations{ship} = $locations{bill};
+}
#create new record object
+# but explicitly avoid setting ship_ fields
my $new = new FS::cust_main ( {
- map {
- $_, scalar($cgi->param($_))
- } fields('cust_main')
+ map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main')),
+ map { ( "ship_$_", '' ) } (FS::cust_main->location_fields)
} );
$new->invoice_noemail( ($cgi->param('invoice_email') eq 'Y') ? '' : 'Y' );
-$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
@@ -78,11 +99,9 @@ if ( $duplicate_of ) {
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
- country daytime night fax
- );
+for my $pre (qw(bill ship)) {
+ $new->set($pre.'_location', $locations{$pre});
+ $new->set($pre.'_locationnum', $locations{$pre}->locationnum);
}
if ( $cgi->param('no_credit_limit') ) {
@@ -261,6 +280,7 @@ if ( $new->custnum eq '' or $duplicate_of ) {
my $old = qsearchs( 'cust_main', { 'custnum' => $new->custnum } );
$error ||= "Old record not found!" unless $old;
+
if ( length($old->paycvv) && $new->paycvv =~ /^\s*\*+\s*$/ ) {
$new->paycvv($old->paycvv);
}
@@ -299,6 +319,9 @@ if ( $new->custnum eq '' or $duplicate_of ) {
local($FS::cust_main::DEBUG) = $DEBUG if $DEBUG;
local($FS::Record::DEBUG) = $DEBUG if $DEBUG;
+ local($Data::Dumper::Sortkeys) = 1;
+ warn Dumper({ new => $new, old => $old }) if $DEBUG;
+
$error ||= $new->replace( $old, \@invoicing_list,
'tax_exemption' => \%tax_exempt,
);