5 background-color: #cccccc;
6 border: 1px solid black
14 % foreach my $locationnum (@sorted) {
15 % my $packages = $packages_in{$locationnum};
16 % my $loc = $locations{$locationnum};
17 % next if $loc->disabled and scalar(@$packages) == 0;
18 <TABLE CLASS="grid location">
19 <TR><TH COLSPAN=3 ALIGN="left" VALIGN="bottom"
20 STYLE="padding-bottom: 0px;
22 border-bottom-style: solid;
23 border-bottom-color: black;
24 border-bottom-width: 1px;">
25 <SPAN CLASS="loclabel">
26 % if ( $loc->disabled ) {
27 <FONT COLOR="#808080"><I>
29 <% $loc->location_label %></SPAN>
30 <SPAN STYLE="float:right;">
31 % if ( $locationnum and !$loc->disabled ) {
32 <% edit_location_link($locationnum) %>
34 % if ( $locationnum and !$loc->disabled and !$active{$locationnum} ) {
35 <% disable_location_link($locationnum) %>
39 <& packages/section.html, 'packages' => $packages, 'cust_main' => $cust_main &>
42 % } #foreach $locationnum
45 my $cust_main = $opt{'cust_main'};
46 my $all_packages = $opt{'packages'};
48 my %locations = map { $_->locationnum => $_ } qsearch({
49 'table' => 'cust_location',
50 'hashref' => { 'custnum' => $cust_main->custnum },
51 'order_by' => 'ORDER BY country, state, city, address1, locationnum',
53 my @sections = keys %locations;
54 my %packages_in = map { $_ => [] } (@sections);
56 my %active = (); # groups with non-canceled packages
57 foreach my $cust_pkg ( @$all_packages ) {
58 my $key = $cust_pkg->locationnum;
59 push @{ $packages_in{$key} }, $cust_pkg;
60 $active{$key} = 1 if !$cust_pkg->getfield('cancel');
62 # prevent disabling these
63 $active{$cust_main->ship_locationnum} = 1;
64 $active{$cust_main->bill_locationnum} = 1;
67 $cust_main->ship_locationnum,
68 grep ( { $active{$_} && $_ != $cust_main->ship_locationnum } @sections),
69 grep ( { !$active{$_} } @sections),
72 sub edit_location_link {
73 my $locationnum = shift;
74 include( '/elements/popup_link.html',
75 'action' => $p. "edit/cust_location.cgi?locationnum=$locationnum",
76 'label' => '('.emt('Edit location').')',
77 'actionlabel' => emt('Edit'),
81 sub disable_location_link {
82 my $locationnum = shift;
83 include( '/elements/popup_link.html',
84 'action' => $p. "misc/disable-cust_location.cgi?locationnum=$locationnum",
85 'label' => '('.emt('Disable location').')',
86 'actionlabel' => emt('Disable'),