From e6b0e9237c4bbc31c820b06ece0029f75166506d Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 27 Dec 2004 09:23:23 +0000 Subject: [PATCH] UI: rework shipping address javascript, closes: Bug#1085 --- FS/FS/cust_main_county.pm | 10 +- httemplate/edit/cust_main.cgi | 258 ++++++++++----------------------- httemplate/edit/cust_main/contact.html | 113 +++++++++++++++ 3 files changed, 194 insertions(+), 187 deletions(-) create mode 100644 httemplate/edit/cust_main/contact.html diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index ef2793ad1..d96bd41de 100644 --- a/FS/FS/cust_main_county.pm +++ b/FS/FS/cust_main_county.pm @@ -157,13 +157,13 @@ sub recurtax { =over 4 -=item regionselector [ COUNTY STATE COUNTRY [ PREFIX [ ONCHANGE ] ] ] +=item regionselector [ COUNTY STATE COUNTRY [ PREFIX [ ONCHANGE [ DISABLED ] ] ] ] =cut sub regionselector { my ( $selected_county, $selected_state, $selected_country, - $prefix, $onchange ) = @_; + $prefix, $onchange, $disabled ) = @_; $prefix = '' unless defined $prefix; @@ -238,7 +238,7 @@ END my $county_html = $script_html; if ( $countyflag ) { - $county_html .= qq!!; $county_html .= ''; } else { $county_html .= @@ -246,7 +246,7 @@ END } my $state_html = qq!'; my $country_html = qq!!, - qq!Customer # !, ( $custnum ? "$custnum" : " (NEW)" ), - -; +<%= header("Customer $action", '', ' onUnload="myclose()"') %> + +<% if ( $error ) { %> +Error: <%= $error %> +<% } %> + +
+ +ustomer # <%= $custnum ? "$custnum" : " (NEW)" %> -# agent + + +<% my $r = qq!* !; @@ -87,21 +90,22 @@ my @agents = qsearch( 'agent', \%agent_search ); #die "No agents created!" unless @agents; eidiot "You have not created any agents (or all agents are disabled). You must create at least one agent before adding a customer. Go to ". popurl(2). "browse/agent.cgi and create one or more agents." unless @agents; my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first -if ( scalar(@agents) == 1 ) { - print qq!!; -} else { - print qq!

${r}Agent "; -} + +%> + +<% if ( scalar(@agents) == 1 ) { %> + +<% } else { %> +

<%=$r%>Agent +<% } %> + +<% + +# (referral and referring customer still need to be "template"ized) #referral @@ -150,110 +154,54 @@ if ( $cust_main->referral_custnum print ''; } -# contact info - -my($last,$first,$ss,$company,$address1,$address2,$city,$zip)=( - $cust_main->last, - $cust_main->first, - $cust_main->ss, - $cust_main->company, - $cust_main->address1, - $cust_main->address2, - $cust_main->city, - $cust_main->zip, -); - -print "

Billing address", &itable("#cccccc"), <${r}Contact name
(last, first) -END - -print < , - - -END - -if ( $conf->exists('show_ss') ) { - print qq!SS#!; -} else { - print qq!!; -} - -print < -Company -${r}Address -${r}City${r}State -END - -#false laziness with ship state -my $countrydefault = $conf->config('countrydefault') || 'US'; -$cust_main->country( $countrydefault ) unless $cust_main->country; - -my $statedefault = $conf->config('statedefault') - || ($countrydefault eq 'US' ? 'CA' : ''); -$cust_main->state( $statedefault ) - unless $cust_main->state || $cust_main->country ne $countrydefault; - -my($county_html, $state_html, $country_html) = - FS::cust_main_county::regionselector( $cust_main->county, - $cust_main->state, - $cust_main->country ); - -print "$county_html $state_html"; - -print qq!${r}Zip!; - -my($daytime,$night,$fax)=( - $cust_main->daytime, - $cust_main->night, - $cust_main->fax, - '', - 'changed(this)', -); - -my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; -my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; +%> -print <${r}Country$country_html -$daytime_label -$night_label -Fax -END + -print "${r}required fields
"; +

+Billing address +<%= include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %> -# service address + -if ( defined $cust_main->dbdef_table->column('ship_last') ) { +<% if ( defined $cust_main->dbdef_table->column('ship_last') ) { %> - print "\n", < - function changed(what) { - what.form.same.checked = false; + -END +} + - print '
Service address ', - '(ship_last && $cgi->param('same') ne 'Y' ) { - print ' CHECKED'; + $checked = 'CHECKED'; + $disabled = 'DISABLED style="background-color: #dddddd"'; foreach ( qw( last first company address1 address2 city county state zip country daytime night fax ) @@ -261,70 +209,16 @@ END $cust_main->set("ship_$_", $cust_main->get($_) ); } } - print '>same as billing address)
'; - - my($ship_last,$ship_first,$ship_company,$ship_address1,$ship_address2,$ship_city,$ship_zip)=( - $cust_main->ship_last, - $cust_main->ship_first, - $cust_main->ship_company, - $cust_main->ship_address1, - $cust_main->ship_address2, - $cust_main->ship_city, - $cust_main->ship_zip, - ); - - print &itable("#cccccc"), <${r}Contact name
(last, first) -END - - print < , - -END - - print < - Company - ${r}Address -   - ${r}City${r}State -END - - #false laziness with regular state - $cust_main->ship_country( $countrydefault ) unless $cust_main->ship_country; - - $cust_main->ship_state( $statedefault ) - unless $cust_main->ship_state - || $cust_main->ship_country ne $countrydefault; - - my($ship_county_html, $ship_state_html, $ship_country_html) = - FS::cust_main_county::regionselector( $cust_main->ship_county, - $cust_main->ship_state, - $cust_main->ship_country, - 'ship_', - 'changed(this)', ); - - print "$ship_county_html $ship_state_html"; - - print qq!${r}Zip!; - - my($ship_daytime,$ship_night,$ship_fax)=( - $cust_main->ship_daytime, - $cust_main->ship_night, - $cust_main->ship_fax, - ); - - print <${r}Country$ship_country_html - $daytime_label - $night_label - Fax -END +%> - print "${r}required fields
"; +
+Service address +(>same as billing address) +<%= include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %> -} +<% } %> +<% # billing info sub expselect { diff --git a/httemplate/edit/cust_main/contact.html b/httemplate/edit/cust_main/contact.html new file mode 100644 index 000000000..7b88ccbcb --- /dev/null +++ b/httemplate/edit/cust_main/contact.html @@ -0,0 +1,113 @@ +<% + +my( $cust_main, $pre, $onchange, $disabled ) = @_; +my $conf = new FS::Conf; + +#false laziness with ship state +my $countrydefault = $conf->config('countrydefault') || 'US'; +$cust_main->set($pre.'country', $countrydefault ) + unless $cust_main->get($pre.'country'); + +my $statedefault = $conf->config('statedefault') + || ($countrydefault eq 'US' ? 'CA' : ''); +$cust_main->set($pre.'state', $statedefault ) + unless $cust_main->get($pre.'state') + || $cust_main->get($pre.'country') ne $countrydefault; + +my($county_html, $state_html, $country_html) = + FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), + $cust_main->get($pre.'state'), + $cust_main->get($pre.'country'), + $pre, + $onchange, + $disabled, + ); + +my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; +my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; + +my $r = qq!* !; + +%> + +<%= &itable("#cccccc") %> + + + <%=$r%>Contact name
(last, first) + + > , + > + + +<% if ( $conf->exists('show_ss') && !$pre ) { %> + SS# + +<% } else { %> + +<% } %> + + + + + Company + + > + + + + + <%=$r%>Address + + > + + + + +   + + > + + + + + <%=$r%>City + + > + + <%=$r%>State + <%= $county_html. $state_html %> + <%=$r%>Zip + + > + + + + + <%=$r%>Country + <%= $country_html %> + + + + <%= $daytime_label %> + + > + + + + + <%= $night_label %> + + > + + + + + Fax + + > + + + + +<%=$r%>required fields
+ -- 2.11.0