5 include( '/elements/location.html',
6 'object' => $cust_main, # or $cust_location
7 'prefix' => $pre, #only for cust_main objects
8 'onchange' => $javascript,
9 'disabled' => $disabled,
10 'same_checked' => $same_checked,
11 'geocode' => $geocode, #passed through
12 'censustract' => $censustract, #passed through
13 'no_asterisks' => 0, #set true to disable the red asterisks next
15 'address1_label' => 'Address', #label for address
21 <TH ALIGN="right"><%$r%><% $opt{'address1_label'} || 'Address' %></TH>
24 NAME = "<%$pre%>address1"
25 ID = "<%$pre%>address1"
26 VALUE = "<% $object->get($pre.'address1') |h %>"
28 onChange = "<% $onchange %>"
36 <TD ALIGN="right"><FONT ID="<% $pre %>address2_required" color="#ff0000" <% $address2_label_style %>>*</FONT> <FONT ID="<% $pre %>address2_label" <% $address2_label_style %>><B>Unit #</B></FONT></TD>
39 NAME = "<%$pre%>address2"
40 ID = "<%$pre%>address2"
41 VALUE = "<% $object->get($pre.'address2') |h %>"
43 onChange = "<% $onchange %>"
51 <TH ALIGN="right"><%$r%>City</TH>
56 VALUE = "<% $object->get($pre.'city') |h %>"
57 onChange = "<% $onchange %>"
62 <TH ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</TH>
63 <TD><% include('/elements/select-county.html', %select_hash ) %></TD>
64 <TH ALIGN="right" WIDTH="1"><%$r%>State</TH>
66 <% include('/elements/select-state.html', %select_hash ) %>
73 VALUE = "<% $object->get($pre.'zip') |h %>"
75 onChange = "<% $onchange %>"
83 <TH ALIGN="right"><%$r%>Country</TH>
84 <TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD>
88 <INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>">
90 <INPUT TYPE="hidden" NAME="censustract" VALUE="<% $opt{censustract} %>">
97 my $pre = $opt{'prefix'};
98 my $object = $opt{'object'};
99 my $onchange = $opt{'onchange'};
100 my $disabled = $opt{'disabled'};
102 my $conf = new FS::Conf;
104 my $r = $opt{'no_asterisks'} ? '' : qq!<font color="#ff0000">*</font> !;
106 #false laziness with ship state
107 my $countrydefault = $conf->config('countrydefault') || 'US';
108 $object->set($pre.'country', $countrydefault )
109 unless $object->get($pre.'country');
111 my $statedefault = $conf->config('statedefault')
112 || ($countrydefault eq 'US' ? 'CA' : '');
113 $object->set($pre.'state', $statedefault )
114 unless $object->get($pre.'state')
115 || $object->get($pre.'country') ne $countrydefault;
118 push @style, 'background-color: #dddddd"' if $disabled;
120 my @address2_label_style = ();
121 push @address2_label_style, 'visibility:hidden'
123 || ! $conf->exists('cust_main-require_address2')
124 || ( !$pre && !$opt{'same_checked'} );
126 my @counties = counties( $object->get($pre.'state'),
127 $object->get($pre.'country'),
129 my @county_style = ();
130 push @county_style, 'display:none' # 'visibility:hidden'
131 unless scalar(@counties) > 1;
135 ? 'STYLE="'. join(';', @style). '"'
137 my $address2_label_style =
138 scalar(@address2_label_style)
139 ? 'STYLE="'. join(';', @address2_label_style). '"'
142 scalar(@county_style)
143 ? 'STYLE="'. join(';', @county_style). '"'
147 'county' => $object->get($pre.'county'),
148 'state' => $object->get($pre.'state'),
149 'country' => $object->get($pre.'country'),
151 'onchange' => $onchange,
152 'disabled' => $disabled,