sales tax districts, #15089
[freeside.git] / httemplate / elements / location.html
index b5f7640..13797fe 100644 (file)
@@ -17,8 +17,30 @@ Example:
 
 </%doc>
 
+% if ( $opt{'alt_format'} ) {
+
+<TR>
+    <<%$th%> ALIGN="right">Location&nbsp;kind</<%$th%>>
+    <TD>
+    <% include('/elements/select.html',
+                 'cgi'        => $cgi,
+                 'field'      => 'location_kind',
+                 'id'         => 'location_kind',
+                 'disabled'   => $disabled,
+                 #'style'      => \@style,
+                 'options'    => \@location_kind_options,
+                 'labels'     => $location_kind_labels,
+                 'curr_value' => scalar($cgi->param('location_kind'))
+                                   || $object->get($pre.'location_kind'),
+              )
+    %>
+    </TD>
+  </TR>
+
+% } 
+
 <TR>
-  <<%$th%> ALIGN="right"><%$r%><% $opt{'address1_label'} || 'Address' %></<%$th%>>
+  <<%$th%> ALIGN="right"><%$r%><% $opt{'address1_label'} || emt('Address') %></<%$th%>>
   <TD COLSPAN=7>
     <INPUT TYPE     = "text"
            NAME     = "<%$pre%>address1"
@@ -31,71 +53,110 @@ Example:
     >
   </TD>
 </TR>
+
+% if ( ! $opt{'alt_format'} ) { #regular format
+
 <TR>
       <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>
       <TD COLSPAN=7>
-       <INPUT TYPE     = "text"
-              NAME     = "<%$pre%>address2"
-              ID       = "<%$pre%>address2"
-              VALUE    = "<% $object->get($pre.'address2') |h %>"
-              SIZE     = 54
-              onChange = "<% $onchange %>"
-              <% $disabled %>
-              <% $style %>
-       >
+        <INPUT TYPE     = "text"
+               NAME     = "<%$pre%>address2"
+               ID       = "<%$pre%>address2"
+               VALUE    = "<% $object->get($pre.'address2') |h %>"
+               SIZE     = 54
+               onChange = "<% $onchange %>"
+               <% $disabled %>
+               <% $style %>
+        >
       </TD>
 </TR>
 
+% } else { # alternate format
+
+      <INPUT TYPE  = "hidden"
+             NAME  = "<%$pre%>address2"
+             VALUE = "<% $object->get($pre.'address2') |h %>"
+      >
 
-% if ( $opt{'alt_format'} ) { 
 <TR>
-    <<%$th%> ALIGN="right">Location Type</<%$th%>>
-    <TD><INPUT         TYPE="text" 
-               NAME="location_type" 
-               ID="location_type"
-               VALUE="<% $object->get('location_type') |h %>"
-               SIZE="10"
-              <% $disabled %>
-              <% $style %>
-       >
-    </TD>
-    <TD></TD>
-    <<%$th%> ALIGN="right">Number</<%$th%>>
-    <TD><INPUT TYPE="text" 
-               NAME="location_number"
-               ID="location_number"
-               VALUE="<% $object->get('location_number') |h %>"
-               SIZE="5"
-              <% $disabled %>
-              <% $style %>
-       >
-    </TD>
-    <<%$th%> ALIGN="right">Kind</<%$th%>>
-    <TD>
-    <% include('/elements/select.html',
-             'cgi'       => $cgi,
-            'field'    => 'location_kind',
-            'disabled' => $disabled,
-            'style' => $style, 
-            'options'  => \@location_kind_options,
-            'labels'   => $location_kind_labels,
-            'curr_value' => $cgi->param('location_kind'),
-         )
-    %>
+    <<%$th%> ALIGN="right">Unit&nbsp;type&nbsp;and&nbsp;#</<%$th%>>
+    <TD COLSPAN=7>
+
+%     my $location_type = scalar($cgi->param('location_type'))
+%                           || $object->get($pre.'location_type');
+%     #my $location_number = scalar($cgi->param('location_number'))
+%     #                        || $object->get($pre.'location_number');
+%
+%   if ( $object->get($pre.'address2') && ! $location_type ) {
+%   }
+%
+%     if ( 1 ) { #ikano, switch on via config
+%       tie my %location_types, 'Tie::IxHash',
+%         FS::part_export::ikano->location_types;
+        <% include('/elements/select.html',
+                     'cgi'        => $cgi,
+                     'field'      => 'location_type',
+                     'id'         => 'location_type',
+                     'disabled'   => $disabled,
+                     #'style'      => \@style,
+                     'options'    => [ keys %location_types ],
+                     'labels'     => \%location_types,
+                     'curr_value' => $location_type,
+                     'onchange'   => 'location_type_changed',
+                  )
+        %>
+        <SCRIPT TYPE="text/javascript">
+          function location_type_changed (what) {
+            if ( what.options[what.selectedIndex].value == '' ) {
+              what.form.location_number.disabled = true;
+              what.form.location_number.style.backgroundColor = '#dddddd';
+            } else {
+              what.form.location_number.disabled = false;
+              what.form.location_number.style.backgroundColor = '#ffffff';
+            }
+          }
+        </SCRIPT>
+%     } else {
+        <INPUT TYPE  = "text" 
+               NAME  = "location_type" 
+               ID    = "location_type"
+               VALUE = "<% $location_type |h %>"
+               SIZE  = "10"
+               <% $disabled %>
+               <% $style %>
+        >
+%     }
+
+    <INPUT TYPE="text" 
+               NAME  = "location_number"
+               ID    = "location_number"
+               VALUE = "<% scalar($cgi->param('location_number')) || $object->get($pre.'location_number') |h %>"
+               SIZE  = "5"
+               <% $disabled || ($location_type ? '' : 'DISABLED') %>
+               <% $style %>
+        >
+
+%    #XXX i don't work so well when the dropdown is changed :/  i probably need to be triggered by "default service address"
+%    $alt_err =~ s/(ship_)?address2/'<B>'.encode_entities($object->get($1.'address2')).'<\/B>'/e;
+     <% $alt_err %>
+
     </TD>
+
 </TR>
+
 % } 
 
+
 <TR>
-  <<%$th%> ALIGN="right"><%$r%>City</<%$th%>>
-  <TD WIDTH="1"><% include('/elements/city.html', %select_hash) %></TD>
-  <<%$th%> ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</<%$th%>>
-  <TD><% include('/elements/select-county.html', %select_hash ) %></TD>
-  <<%$th%> ALIGN="right" WIDTH="1"><%$r%>State</<%$th%>>
+  <<%$th%> ALIGN="right"><%$r%><% mt('City') |h %></<%$th%>>
+  <TD WIDTH="1"><% include('/elements/city.html', %select_hash, 'text_style' => \@style ) %></TD>
+  <<%$th%> ALIGN="right" WIDTH="1" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</<%$th%>>
+  <TD WIDTH="1"><% include('/elements/select-county.html', %select_hash ) %></TD>
+  <<%$th%> ALIGN="right" WIDTH="1"><%$r%><% mt('State') |h %></<%$th%>>
   <TD WIDTH="1">
     <% include('/elements/select-state.html', %select_hash ) %>
   </TD>
-  <<%$th%>><%$r%>Zip</<%$th%>>
+  <<%$th%> ALIGN="right" WIDTH="1"><%$r%><% mt('Zip') |h %></<%$th%>>
   <TD>
     <INPUT TYPE     = "text"
            NAME     = "<%$pre%>zip"
@@ -110,10 +171,32 @@ Example:
 </TR>
 
 <TR>
-  <<%$th%> ALIGN="right"><%$r%>Country</<%$th%>>
+  <<%$th%> ALIGN="right"><%$r%><% mt('Country') |h %></<%$th%>>
   <TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD>
 </TR>
 
+<TR>
+  <TD ALIGN="right"><% mt('Latitude') |h %></TH>
+  <TD COLSPAN=7>
+    <INPUT TYPE  = "text"
+           NAME  = "<%$pre%>latitude"
+           ID    = "<%$pre%>latitude"
+           VALUE = "<% $object->get($pre.'latitude') |h %>"
+           <% $disabled %>
+           <% $style %>
+    >
+    <% mt('Longitude') |h %>
+    <INPUT TYPE  = "text"
+           NAME  = "<%$pre%>longitude"
+           ID    = "<%$pre%>longitude"
+           VALUE = "<% $object->get($pre.'longitude') |h %>"
+           <% $disabled %>
+           <% $style %>
+    >
+  </TD>
+</TR>
+<INPUT TYPE="hidden" NAME="<%$pre%>coord_auto" VALUE="<% $object->get($pre.'coord_auto') %>">
+
 % if ( !$pre ) { 
   <INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>">
 % } else {
@@ -126,6 +209,14 @@ Example:
 %   } else {
       <INPUT TYPE="hidden" NAME="censustract" VALUE="<% $opt{censustract} %>">
 %   } 
+%   if ( $conf->config('tax_district_method') or $object->get('district') ) {
+    <TR>
+      <<%$th%> ALIGN="right">Tax district<BR>(automatic)</<%$th%>>
+      <TD>
+        <INPUT TYPE="text" NAME="district" VALUE="<%$object->get('district')%>">
+      </TD>
+    </TR>
+%   }
 % } 
 
 <%init>
@@ -152,6 +243,8 @@ $object->set($pre.'state', $statedefault )
   unless $object->get($pre.'state')
          || $object->get($pre.'country') ne $countrydefault;
 
+my $alt_err = ($opt{'alt_format'} && !$disabled) ? $object->alternize : '';
+
 my @style = ();
 push @style, 'background-color: #dddddd' if $disabled;
 
@@ -189,7 +282,7 @@ my %select_hash = (
   'prefix'   => $pre,
   'onchange' => $onchange,
   'disabled' => $disabled,
-  'style'    => \@style,
+  #'style'    => \@style,
 );
 
 my $th = $opt{'no_bold'} ? 'TD' : 'TH';