This commit was generated by cvs2svn to compensate for changes in r10640,
[freeside.git] / httemplate / elements / location.html
1 <%doc>
2
3 Example:
4
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
14                                     #to required fields
15              'address1_label' => 'Address', #label for address
16          )
17
18 </%doc>
19
20 <TR>
21   <<%$th%> ALIGN="right"><%$r%><% $opt{'address1_label'} || 'Address' %></<%$th%>>
22   <TD COLSPAN=7>
23     <INPUT TYPE     = "text"
24            NAME     = "<%$pre%>address1"
25            ID       = "<%$pre%>address1"
26            VALUE    = "<% $object->get($pre.'address1') |h %>"
27            SIZE     = 54
28            onChange = "<% $onchange %>"
29            <% $disabled %>
30            <% $style %>
31     >
32   </TD>
33 </TR>
34 <TR>
35       <TD ALIGN="right"><FONT ID="<% $pre %>address2_required" color="#ff0000" <% $address2_label_style %>>*</FONT>&nbsp;<FONT ID="<% $pre %>address2_label" <% $address2_label_style %>><B>Unit&nbsp;#</B></FONT></TD>
36       <TD COLSPAN=7>
37         <INPUT TYPE     = "text"
38                NAME     = "<%$pre%>address2"
39                ID       = "<%$pre%>address2"
40                VALUE    = "<% $object->get($pre.'address2') |h %>"
41                SIZE     = 54
42                onChange = "<% $onchange %>"
43                <% $disabled %>
44                <% $style %>
45         >
46       </TD>
47 </TR>
48
49
50 % if ( $opt{'alt_format'} ) { 
51 <TR>
52     <<%$th%> ALIGN="right">Location Type</<%$th%>>
53     <TD><INPUT  TYPE="text" 
54                 NAME="location_type" 
55                 ID="location_type"
56                 VALUE="<% $object->get('location_type') |h %>"
57                 SIZE="10"
58                <% $disabled %>
59                <% $style %>
60         >
61     </TD>
62     <TD></TD>
63     <<%$th%> ALIGN="right">Number</<%$th%>>
64     <TD><INPUT  TYPE="text" 
65                 NAME="location_number"
66                 ID="location_number"
67                 VALUE="<% $object->get('location_number') |h %>"
68                 SIZE="5"
69                <% $disabled %>
70                <% $style %>
71         >
72     </TD>
73     <<%$th%> ALIGN="right">Kind</<%$th%>>
74     <TD>
75     <% include('/elements/select.html',
76              'cgi'       => $cgi,
77              'field'    => 'location_kind',
78              'disabled' => $disabled,
79              'style' => $style, 
80              'options'  => \@location_kind_options,
81              'labels'   => $location_kind_labels,
82              'curr_value' => $cgi->param('location_kind'),
83           )
84     %>
85     </TD>
86 </TR>
87 % } 
88
89 <TR>
90   <<%$th%> ALIGN="right"><%$r%>City</<%$th%>>
91   <TD WIDTH="1"><% include('/elements/city.html', %select_hash) %></TD>
92   <<%$th%> ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</<%$th%>>
93   <TD><% include('/elements/select-county.html', %select_hash ) %></TD>
94   <<%$th%> ALIGN="right" WIDTH="1"><%$r%>State</<%$th%>>
95   <TD WIDTH="1">
96     <% include('/elements/select-state.html', %select_hash ) %>
97   </TD>
98   <<%$th%>><%$r%>Zip</<%$th%>>
99   <TD>
100     <INPUT TYPE     = "text"
101            NAME     = "<%$pre%>zip"
102            ID       = "<%$pre%>zip"
103            VALUE    = "<% $object->get($pre.'zip') |h %>"
104            SIZE     = 10
105            onChange = "<% $onchange %>"
106            <% $disabled %>
107            <% $style %>
108     >
109   </TD>
110 </TR>
111
112 <TR>
113   <<%$th%> ALIGN="right"><%$r%>Country</<%$th%>>
114   <TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD>
115 </TR>
116
117 % if ( !$pre ) { 
118   <INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>">
119 % } else {
120 %   if ( $pre eq 'ship_' && $conf->exists('cust_main-require_censustract') ) {
121       <TR><<%$th%> ALIGN="right">Census tract<BR>(automatic)</<%$th%>>
122         <TD>
123           <INPUT TYPE="text" NAME="censustract" VALUE="<% $opt{censustract} %>">
124         </TD>
125       </TR>
126 %   } else {
127       <INPUT TYPE="hidden" NAME="censustract" VALUE="<% $opt{censustract} %>">
128 %   } 
129 % } 
130
131 <%init>
132
133 my %opt = @_;
134
135 my $pre      = $opt{'prefix'};
136 my $object   = $opt{'object'};
137 my $onchange = $opt{'onchange'};
138 my $disabled = $opt{'disabled'};
139
140 my $conf = new FS::Conf;
141
142 my $r = $opt{'no_asterisks'} ? '' : qq!<font color="#ff0000">*</font>&nbsp;!;
143
144 #false laziness with ship state
145 my $countrydefault = $conf->config('countrydefault') || 'US';
146 $object->set($pre.'country', $countrydefault )
147   unless $object->get($pre.'country');
148
149 my $statedefault = $conf->config('statedefault')
150                    || ($countrydefault eq 'US' ? 'CA' : '');
151 $object->set($pre.'state', $statedefault )
152   unless $object->get($pre.'state')
153          || $object->get($pre.'country') ne $countrydefault;
154
155 my @style = ();
156 push @style, 'background-color: #dddddd' if $disabled;
157
158 my @address2_label_style = ();
159 push @address2_label_style, 'visibility:hidden'
160   if $disabled
161   || ! $conf->exists('cust_main-require_address2')
162   || ( !$pre && !$opt{'same_checked'} );
163
164 my @counties = counties( $object->get($pre.'state'),
165                          $object->get($pre.'country'),
166                        );
167 my @county_style = ();
168 push @county_style, 'display:none' # 'visibility:hidden'
169   unless scalar(@counties) > 1;
170
171 my $style =
172   scalar(@style)
173     ? 'STYLE="'. join(';', @style). '"'
174     : '';
175 my $address2_label_style =
176   scalar(@address2_label_style)
177     ? 'STYLE="'. join(';', @address2_label_style). '"'
178     : '';
179 my $county_style = 
180   scalar(@county_style)
181     ? 'STYLE="'. join(';', @county_style). '"'
182     : '';
183
184 my %select_hash = (
185   'city'     => $object->get($pre.'city'),
186   'county'   => $object->get($pre.'county'),
187   'state'    => $object->get($pre.'state'),
188   'country'  => $object->get($pre.'country'),
189   'prefix'   => $pre,
190   'onchange' => $onchange,
191   'disabled' => $disabled,
192   'style'    => \@style,
193 );
194
195 my $th = $opt{'no_bold'} ? 'TD' : 'TH';
196
197 my @location_kind_options = ( '', 'R', 'B' );
198 my $location_kind_labels = { '' => '', 'R' => 'Residential', 'B' => 'Business' };
199
200 </%init>