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
20 % if ( $opt{'alt_format'} ) {
23 <<%$th%> ALIGN="right">Location kind</<%$th%>>
25 <% include('/elements/select.html',
27 'field' => 'location_kind',
28 'id' => 'location_kind',
29 'disabled' => $disabled,
31 'options' => \@location_kind_options,
32 'labels' => $location_kind_labels,
33 'curr_value' => scalar($cgi->param('location_kind'))
34 || $object->get($pre.'location_kind'),
43 <<%$th%> ALIGN="right"><%$r%><% $opt{'address1_label'} || 'Address' %></<%$th%>>
46 NAME = "<%$pre%>address1"
47 ID = "<%$pre%>address1"
48 VALUE = "<% $object->get($pre.'address1') |h %>"
50 onChange = "<% $onchange %>"
57 % if ( ! $opt{'alt_format'} ) { #regular format
60 <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>
63 NAME = "<%$pre%>address2"
64 ID = "<%$pre%>address2"
65 VALUE = "<% $object->get($pre.'address2') |h %>"
67 onChange = "<% $onchange %>"
74 % } else { # alternate format
76 <INPUT TYPE = "hidden"
77 NAME = "<%$pre%>address2"
78 VALUE = "<% $object->get($pre.'address2') |h %>"
82 <<%$th%> ALIGN="right">Unit type and #</<%$th%>>
85 % my $location_type = scalar($cgi->param('location_type'))
86 % || $object->get($pre.'location_type');
87 % #my $location_number = scalar($cgi->param('location_number'))
88 % # || $object->get($pre.'location_number');
90 % if ( $object->get($pre.'address2') && ! $location_type ) {
93 % if ( 1 ) { #ikano, switch on via config
94 % tie my %location_types, 'Tie::IxHash',
95 % FS::part_export::ikano->location_types;
96 <% include('/elements/select.html',
98 'field' => 'location_type',
99 'id' => 'location_type',
100 'disabled' => $disabled,
102 'options' => [ keys %location_types ],
103 'labels' => \%location_types,
104 'curr_value' => $location_type,
105 'onchange' => 'location_type_changed',
108 <SCRIPT TYPE="text/javascript">
109 function location_type_changed (what) {
110 if ( what.options[what.selectedIndex].value == '' ) {
111 what.form.location_number.disabled = true;
112 what.form.location_number.style.backgroundColor = '#dddddd';
114 what.form.location_number.disabled = false;
115 what.form.location_number.style.backgroundColor = '#ffffff';
121 NAME = "location_type"
123 VALUE = "<% $location_type |h %>"
131 NAME = "location_number"
132 ID = "location_number"
133 VALUE = "<% scalar($cgi->param('location_number')) || $object->get($pre.'location_number') |h %>"
135 <% $disabled || ($location_type ? '' : 'DISABLED') %>
139 % #XXX i don't work so well when the dropdown is changed :/ i probably need to be triggered by "default service address"
140 % $alt_err =~ s/(ship_)?address2/'<B>'.encode_entities($object->get($1.'address2')).'<\/B>'/e;
151 <<%$th%> ALIGN="right"><%$r%>City</<%$th%>>
152 <TD WIDTH="1"><% include('/elements/city.html', %select_hash) %></TD>
153 <<%$th%> ALIGN="right" WIDTH="1" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</<%$th%>>
154 <TD WIDTH="1"><% include('/elements/select-county.html', %select_hash ) %></TD>
155 <<%$th%> ALIGN="right" WIDTH="1"><%$r%>State</<%$th%>>
157 <% include('/elements/select-state.html', %select_hash ) %>
159 <<%$th%> ALIGN="right" WIDTH="1"><%$r%>Zip</<%$th%>>
164 VALUE = "<% $object->get($pre.'zip') |h %>"
166 onChange = "<% $onchange %>"
174 <<%$th%> ALIGN="right"><%$r%>Country</<%$th%>>
175 <TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD>
179 <INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>">
181 % if ( $pre eq 'ship_' && $conf->exists('cust_main-require_censustract') ) {
182 <TR><<%$th%> ALIGN="right">Census tract<BR>(automatic)</<%$th%>>
184 <INPUT TYPE="text" NAME="censustract" VALUE="<% $opt{censustract} %>">
188 <INPUT TYPE="hidden" NAME="censustract" VALUE="<% $opt{censustract} %>">
196 my $pre = $opt{'prefix'};
197 my $object = $opt{'object'};
198 my $onchange = $opt{'onchange'};
199 my $disabled = $opt{'disabled'};
201 my $conf = new FS::Conf;
203 my $r = $opt{'no_asterisks'} ? '' : qq!<font color="#ff0000">*</font> !;
205 #false laziness with ship state
206 my $countrydefault = $conf->config('countrydefault') || 'US';
207 $object->set($pre.'country', $countrydefault )
208 unless $object->get($pre.'country');
210 my $statedefault = $conf->config('statedefault')
211 || ($countrydefault eq 'US' ? 'CA' : '');
212 $object->set($pre.'state', $statedefault )
213 unless $object->get($pre.'state')
214 || $object->get($pre.'country') ne $countrydefault;
216 my $alt_err = ($opt{'alt_format'} && !$disabled) ? $object->alternize : '';
219 push @style, 'background-color: #dddddd' if $disabled;
221 my @address2_label_style = ();
222 push @address2_label_style, 'visibility:hidden'
224 || ! $conf->exists('cust_main-require_address2')
225 || ( !$pre && !$opt{'same_checked'} );
227 my @counties = counties( $object->get($pre.'state'),
228 $object->get($pre.'country'),
230 my @county_style = ();
231 push @county_style, 'display:none' # 'visibility:hidden'
232 unless scalar(@counties) > 1;
236 ? 'STYLE="'. join(';', @style). '"'
238 my $address2_label_style =
239 scalar(@address2_label_style)
240 ? 'STYLE="'. join(';', @address2_label_style). '"'
243 scalar(@county_style)
244 ? 'STYLE="'. join(';', @county_style). '"'
248 'city' => $object->get($pre.'city'),
249 'county' => $object->get($pre.'county'),
250 'state' => $object->get($pre.'state'),
251 'country' => $object->get($pre.'country'),
253 'onchange' => $onchange,
254 'disabled' => $disabled,
258 my $th = $opt{'no_bold'} ? 'TD' : 'TH';
260 my @location_kind_options = ( '', 'R', 'B' );
261 my $location_kind_labels = { '' => '', 'R' => 'Residential', 'B' => 'Business' };