From b286638fd4cb875178b0247a04b2706a44cadf6f Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 7 Nov 2013 20:05:34 -0800 Subject: [PATCH] show census tracts for all customer and package locations, #25726 --- httemplate/elements/tr-censustract.html | 23 ++++++++ httemplate/elements/tr-select-cust_location.html | 9 +++ httemplate/view/cust_main/contacts.html | 1 + httemplate/view/cust_main/locations.html | 49 +++++++++++----- httemplate/view/cust_main/misc.html | 11 ---- httemplate/view/cust_main/packages/location.html | 72 +++++++++++++++--------- 6 files changed, 112 insertions(+), 53 deletions(-) create mode 100644 httemplate/elements/tr-censustract.html diff --git a/httemplate/elements/tr-censustract.html b/httemplate/elements/tr-censustract.html new file mode 100644 index 000000000..bd014f11b --- /dev/null +++ b/httemplate/elements/tr-censustract.html @@ -0,0 +1,23 @@ +% if ($censustract) { + + <% mt('Census tract') |h %> + + <% $censustract |h %> +  <% $censusyear |h %> + + +% } +<%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 = ''; +} + + diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html index e1fa825c1..4ed9cd48e 100644 --- a/httemplate/elements/tr-select-cust_location.html +++ b/httemplate/elements/tr-select-cust_location.html @@ -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 ) { diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html index d65af669a..8fe3a9ebb 100644 --- a/httemplate/view/cust_main/contacts.html +++ b/httemplate/view/cust_main/contacts.html @@ -84,6 +84,7 @@ $cust_main->agentnum, &> % } +<& /elements/tr-censustract.html, $location &> % if ( $this eq 'bill' ) { % # billing contact phone numbers diff --git a/httemplate/view/cust_main/locations.html b/httemplate/view/cust_main/locations.html index 7eb52ca46..fdbbc396b 100755 --- a/httemplate/view/cust_main/locations.html +++ b/httemplate/view/cust_main/locations.html @@ -1,40 +1,60 @@ % foreach my $locationnum (@sorted) { % my $packages = $packages_in{$locationnum}; % my $loc = $locations{$locationnum}; % next if $loc->disabled and scalar(@$packages) == 0; - + + % 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', diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html index 5311aa5ae..7915195b4 100644 --- a/httemplate/view/cust_main/misc.html +++ b/httemplate/view/cust_main/misc.html @@ -171,17 +171,6 @@ % } -% if ( $conf->exists('cust_main-require_censustract') ) { - - - - - - -% } - % if ( $cust_main->district ) { diff --git a/httemplate/view/cust_main/packages/location.html b/httemplate/view/cust_main/packages/location.html index 5ff2b1e1f..db67d45b9 100644 --- a/httemplate/view/cust_main/packages/location.html +++ b/httemplate/view/cust_main/packages/location.html @@ -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 ) { -
-% } +% if ( !$conf->exists('cust_pkg-group_by_location') ) { +% if ( $default ) { +
+% } - <% $loc->location_label( 'join_string' => '
', - 'double_space' => '   ', - 'escape_function' => \&encode_entities, - 'countrydefault' => $countrydefault, - ) - %> + <% $loc->location_label( 'join_string' => '
', + 'double_space' => '   ', + 'escape_function' => \&encode_entities, + 'countrydefault' => $countrydefault, + ) + %> -% if ( $loc->latitude && $loc->longitude ) { -
- - <% $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, - &> - -% } +% if ( $loc->latitude && $loc->longitude ) { +
+ + <% $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, + &> + +% } +% if ( $loc->censustract ) { +
+ + <% $loc->censustract %> (<% $loc->censusyear %> census) + +% } elsif ( $conf->exists('cust_main-require_censustract') ) { +
+ + <% emt('Census tract unknown') %> + +% } -% if ( $default ) { -
-% } +% if ( $default ) { +
+% } +% } # 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') @@ -41,11 +55,13 @@ ( <%pkg_change_location_link($cust_pkg)%> ) % } % if ( $cust_pkg->locationnum && ! $opt{no_links} ) { - ( <%edit_location_link($cust_pkg->locationnum)%> ) + ( <%pkg_edit_location_link($cust_pkg->locationnum)%> ) % } % } -% } +% } # 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", -- 2.11.0
- -% if ( $loc->disabled ) { - +
+
+<% $loc->location_label %> +% if ( $loc->censustract ) { +
+ + <% $loc->censustract %> (<% $loc->censusyear %> census) + +% } elsif ( $conf->exists('cust_main-require_censustract') ) { +
+ + <% emt('Census tract unknown') %> + % } -<% $loc->location_label %> - +
+
% if ( $locationnum && !$loc->disabled && ! $opt{no_links} ) { <% edit_location_link($locationnum) %> % } % if ( $locationnum && !$loc->disabled && !$active{$locationnum} && ! $opt{no_links} ) {  <% disable_location_link($locationnum) %> % } -
- <% mt('Census tract ([_1])', $cust_main->ship_location->censusyear) |h %> - <% $cust_main->ship_location->censustract %>