show census tracts for all customer and package locations, #25726
authorMark Wells <mark@freeside.biz>
Fri, 8 Nov 2013 04:05:34 +0000 (20:05 -0800)
committerMark Wells <mark@freeside.biz>
Fri, 8 Nov 2013 04:05:34 +0000 (20:05 -0800)
httemplate/elements/tr-censustract.html [new file with mode: 0644]
httemplate/elements/tr-select-cust_location.html
httemplate/view/cust_main/contacts.html
httemplate/view/cust_main/locations.html
httemplate/view/cust_main/misc.html
httemplate/view/cust_main/packages/location.html

diff --git a/httemplate/elements/tr-censustract.html b/httemplate/elements/tr-censustract.html
new file mode 100644 (file)
index 0000000..bd014f1
--- /dev/null
@@ -0,0 +1,23 @@
+% if ($censustract) {
+<TR>
+  <TD ALIGN="right"><% mt('Census tract') |h %></TD>
+  <TD COLSPAN=5>
+    <SPAN STYLE="background-color: #ffffff; border: 1px solid #ffffff"><% $censustract |h %></SPAN>
+    &nbsp;<% $censusyear |h %>
+  </TD>
+</TR>
+% }
+<%init>
+
+my $location = shift;
+my $conf = FS::Conf->new;
+my ($censustract, $censusyear);
+if ($location->censustract) {
+  $censustract = $location->censustract;
+  $censusyear = '('. ($location->censusyear || mt('unknown year')) . ')';
+} elsif ($conf->exists('cust_main-require_censustract')) {
+  $censustract = mt('unknown');
+  $censusyear = '';
+}
+
+</%init>
index e1fa825..4ed9cd4 100644 (file)
@@ -31,6 +31,9 @@ Example:
       else what.form.<%$_%>.value = '';
       if( ftype != 'SELECT') what.form.<%$_%>.style.backgroundColor = '#dddddd';
 %   } 
+    if(what.form.enter_censustract) {
+      what.form.enter_censustract.disabled = true;
+    }
   }
 
   function location_clear(what) {
@@ -38,6 +41,9 @@ Example:
       var ftype = what.form.<%$_%>.tagName;
       if( ftype == 'INPUT' ) what.form.<%$_%>.value = '';
 %   }
+    if(what.form.enter_censustract) {
+      what.form.enter_censustract.value = '';
+    }
 %   if ( $opt{'alt_format'} ) {
       changeSelect(what.form.location_kind, '');
       changeSelect(what.form.location_type, '');
@@ -51,6 +57,9 @@ Example:
       var ftype = what.form.<%$_%>.tagName;
       if( ftype != 'SELECT') what.form.<%$_%>.style.backgroundColor = '#ffffff';
 %   } 
+    if(what.form.enter_censustract) {
+      what.form.enter_censustract.disabled = false;
+    }
 %   if ( $opt{'alt_format'} ) {
       if ( what.form.location_type &&
            what.form.location_type.options[what.form.location_type.selectedIndex].value ) {
index d65af66..8fe3a9e 100644 (file)
@@ -84,6 +84,7 @@
                                $cust_main->agentnum,
   &>
 % }
+<& /elements/tr-censustract.html, $location &>
   
 % if ( $this eq 'bill' ) {
 %   # billing contact phone numbers
index 7eb52ca..fdbbc39 100755 (executable)
@@ -1,40 +1,60 @@
 <STYLE>
-span.loclabel {
+div.loclabel {
+  display: inline-block;
   padding-left: 4px; 
   padding-right: 4px; 
   background-color: #cccccc;
-  border: 1px solid black
+  border: 1px solid black;
+  border-bottom: 0px;
+  border-radius: 4px 4px 0 0; 
+}
+div.disabled {
+  font-style: italic;
+  color: #808080;
 }
 table.location {
   width: 100%;
   padding: 1px;
   border-spacing: 0px;
 }
+.location-head th {
+  padding-bottom: 0px; 
+  padding-left: 0px; 
+  border-bottom: 1px solid black;
+  vertical-align: bottom;
+  text-align: left;
+  width: 100%;
+}
 </STYLE>
 % foreach my $locationnum (@sorted) {
 %   my $packages = $packages_in{$locationnum};
 %   my $loc = $locations{$locationnum};
 %   next if $loc->disabled and scalar(@$packages) == 0;
 <TABLE CLASS="grid location">
-<TR><TH COLSPAN=3 ALIGN="left" VALIGN="bottom" 
-STYLE="padding-bottom: 0px; 
-  padding-left: 0px; 
-  border-bottom-style: solid;
-  border-bottom-color: black;
-  border-bottom-width: 1px;">
-<SPAN CLASS="loclabel">
-%   if ( $loc->disabled ) {
-<FONT COLOR="#808080"><I>
+<TR CLASS="location-head">
+<TH COLSPAN=5>
+<DIV CLASS="<% $loc->disabled ? 'loclabel disabled' : 'loclabel' %>">
+<% $loc->location_label %>
+%   if ( $loc->censustract ) {
+        <BR>
+        <FONT SIZE=-1>
+        <% $loc->censustract %> (<% $loc->censusyear %> census)
+        </FONT>
+%   } elsif ( $conf->exists('cust_main-require_censustract') ) {
+        <BR>
+        <FONT SIZE=-1 COLOR="#ee3300">
+        <% emt('Census tract unknown') %>
+        </FONT>
 %   }
-<% $loc->location_label %></SPAN>
-<SPAN STYLE="float:right;">
+</DIV>
+<DIV STYLE="display: inline; float:right;">
 % if ( $locationnum && !$loc->disabled && ! $opt{no_links} ) {
 <% edit_location_link($locationnum) %>
 % }
 % if ( $locationnum && !$loc->disabled && !$active{$locationnum} && ! $opt{no_links} ) {
 &nbsp;<% disable_location_link($locationnum) %>
 % }
-</SPAN></TH></TR>
+</DIV></TH></TR>
 %   if (@$packages) {
       <& packages/section.html,
            'packages'  => $packages,
@@ -48,6 +68,7 @@ STYLE="padding-bottom: 0px;
 my %opt = @_;
 my $cust_main = $opt{'cust_main'};
 my $all_packages = $opt{'packages'};
+my $conf = FS::Conf->new;
 
 my %locations = map { $_->locationnum => $_ } qsearch({
     'table'     => 'cust_location',
index 5311aa5..7915195 100644 (file)
 
 % }
 
-% if ( $conf->exists('cust_main-require_censustract') ) {
-
-  <TR>
-    <TD ALIGN="right">
-      <% mt('Census tract ([_1])', $cust_main->ship_location->censusyear) |h %>
-    </TD>
-    <TD BGCOLOR="#ffffff"><% $cust_main->ship_location->censustract  %></TD>
-  </TR>
-
-% }
-
 % if ( $cust_main->district ) {
 
   <TR>
index 5ff2b1e..db67d45 100644 (file)
@@ -1,35 +1,49 @@
 % if ( $cust_pkg->change_from_pkg
-%      and $cust_pkg->change_from_pkg->locationnum == $cust_pkg->locationnum )
+%      and $cust_pkg->change_from_pkg->locationnum == $cust_pkg->locationnum)
 % {
 % # don't show the location
 % } else {
-%   if ( $default ) {
-    <DIV STYLE="font-style: italic; font-size: small">
-%   }
+%   if ( !$conf->exists('cust_pkg-group_by_location') ) {
+%     if ( $default ) {
+        <DIV STYLE="font-style: italic; font-size: small">
+%     }
 
-    <% $loc->location_label( 'join_string'     => '<BR>',
-                             'double_space'    => ' &nbsp; ',
-                             'escape_function' => \&encode_entities,
-                             'countrydefault'  => $countrydefault,
-                           )
-    %>
+      <% $loc->location_label( 'join_string'     => '<BR>',
+                               'double_space'    => ' &nbsp; ',
+                               'escape_function' => \&encode_entities,
+                               'countrydefault'  => $countrydefault,
+                             )
+      %>
 
-%   if ( $loc->latitude && $loc->longitude ) {
-        <BR>
-        <FONT SIZE=-1>
-        <% $loc->latitude %>, <% $loc->longitude %>
-        <& /elements/coord-links.html,
-             $loc->latitude,
-             $loc->longitude,
-             $opt{'cust_main'}->name_short. ': '. $opt{'part_pkg'}->pkg,
-             $opt{'cust_main'}->agentnum,
-        &>
-        </FONT>
-%   }
+%     if ( $loc->latitude && $loc->longitude ) {
+          <BR>
+          <FONT SIZE=-1>
+          <% $loc->latitude %>, <% $loc->longitude %>
+          <& /elements/coord-links.html,
+               $loc->latitude,
+               $loc->longitude,
+               $opt{'cust_main'}->name_short. ': '. $opt{'part_pkg'}->pkg,
+               $opt{'cust_main'}->agentnum,
+          &>
+          </FONT>
+%     }
+%     if ( $loc->censustract ) {
+         <BR>
+         <FONT SIZE=-1>
+         <% $loc->censustract %> (<% $loc->censusyear %> census)
+         </FONT>
+%     } elsif ( $conf->exists('cust_main-require_censustract') ) {
+          <BR>
+          <FONT SIZE=-1 COLOR="#ee3300">
+          <% emt('Census tract unknown') %>
+          </FONT>
+%     }
 
-%   if ( $default ) {
-    </DIV>
-%   }
+%     if ( $default ) {
+      </DIV>
+%     }
+%   } # all of this is hidden if packages are grouped by location, because
+%     # it's in the top banner
 
 %   if ( ! $cust_pkg->get('cancel')
 %      && $FS::CurrentUser::CurrentUser->access_right('Change customer package')
       (&nbsp;<%pkg_change_location_link($cust_pkg)%>&nbsp;)
 %     }
 %     if ( $cust_pkg->locationnum && ! $opt{no_links} ) {
-        (&nbsp;<%edit_location_link($cust_pkg->locationnum)%>&nbsp;)
+        (&nbsp;<%pkg_edit_location_link($cust_pkg->locationnum)%>&nbsp;)
 %     }
   </FONT>
 %   } 
-% }
+% } # if the package is a scheduled future package change without location
+%   # change, then don't show any of this at all.  It's all implied by the
+%   # preceding package.
 <%init>
 
 my $conf = new FS::Conf;
@@ -75,7 +91,7 @@ sub pkg_change_location_link {
   );
 }
 
-sub edit_location_link {
+sub pkg_edit_location_link {
   my $locationnum = shift;
   include( '/elements/popup_link.html',
     'action'      => $p. "edit/cust_location.cgi?locationnum=$locationnum",