6 background-color: #cccccc;
7 border: 1px solid black;
9 border-radius: 4px 4px 0 0;
23 border-bottom: 1px solid black;
24 vertical-align: bottom;
29 % foreach my $locationnum (@sorted) {
30 % my $packages = $packages_in{$locationnum};
31 % my $loc = $locations{$locationnum};
32 % next if $loc->disabled and scalar(@$packages) == 0;
33 <TABLE CLASS="grid location">
34 <TR CLASS="location-head">
36 <DIV CLASS="<% $loc->disabled ? 'loclabel disabled' : 'loclabel' %>">
37 <% $loc->location_label %>
38 % if ( $loc->country eq 'US' ) { # only U.S. census tracts for now
39 % if ( $loc->censustract ) {
42 <% $loc->censustract %> (<% $loc->censusyear %> census)
44 % } elsif ( $conf->exists('cust_main-require_censustract') ) {
46 <FONT SIZE=-1 COLOR="#ee3300">
47 <% emt('Census tract unknown') %>
52 <DIV STYLE="display: inline; float:right;">
53 % if ( $locationnum && !$loc->disabled && ! $opt{no_links} ) {
54 <% edit_location_link($locationnum) %>
56 % if ( $locationnum && !$loc->disabled && !$active{$locationnum} && ! $opt{no_links} ) {
57 <% disable_location_link($locationnum) %>
62 % $sopt{'packages'} = $packages;
63 <& packages/section.html, %sopt &>
66 % } #foreach $locationnum
69 my $cust_main = $opt{'cust_main'};
70 my $all_packages = $opt{'packages'};
71 my $conf = FS::Conf->new;
73 my %locations = map { $_->locationnum => $_ } qsearch({
74 'table' => 'cust_location',
75 'hashref' => { 'custnum' => $cust_main->custnum },
76 'order_by' => 'ORDER BY country, state, city, address1, locationnum',
78 my @sections = keys %locations;
79 my %packages_in = map { $_ => [] } (@sections);
81 my %active = (); # groups with non-canceled packages
82 foreach my $cust_pkg ( @$all_packages ) {
83 my $key = $cust_pkg->locationnum;
84 push @{ $packages_in{$key} }, $cust_pkg;
85 $active{$key} = 1 if !$cust_pkg->getfield('cancel');
87 # prevent disabling these
88 $active{$cust_main->ship_locationnum} = 1;
89 $active{$cust_main->bill_locationnum} = 1;
92 $cust_main->ship_locationnum,
93 grep ( { $active{$_} && $_ != $cust_main->ship_locationnum } @sections),
94 grep ( { !$active{$_} } @sections),
97 sub edit_location_link {
98 my $locationnum = shift;
99 include( '/elements/popup_link.html',
100 'action' => $p. "edit/cust_location.cgi?locationnum=$locationnum",
101 'label' => '('.emt('Edit location').')',
102 'actionlabel' => emt('Edit'),
106 sub disable_location_link {
107 my $locationnum = shift;
108 include( '/elements/popup_link.html',
109 'action' => $p. "misc/disable-cust_location.cgi?locationnum=$locationnum",
110 'label' => '('.emt('Disable location').')',
111 'actionlabel' => emt('Disable'),