collapse display of location-changed packages, #25130
[freeside.git] / httemplate / view / cust_main / packages / section.html
1 % if ( @$packages ) { 
2 <TR>
3 % #my $width = $show_location ? 'WIDTH="25%"' : 'WIDTH="33%"';
4   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Package') |h %></TH>
5   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
6   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Contact/Location') |h %></TH>
7   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Services') |h %></TH>
8 </TR>
9
10 % #$FS::cust_pkg::DEBUG = 2;
11 %   foreach my $cust_pkg (@$packages) {
12     <& .packagerow, $cust_pkg,
13         ( map { $_ => $opt{$_} } qw(
14             cust_main bgcolor
15             no_links before_pkg_callback before_svc_callback after_svc_callback
16         )),
17         %conf_opt
18     &>
19 %   }
20 % } else { # there are no packages
21 <BR>
22 % }
23 <%def .packagerow>
24 %
25 % my ($cust_pkg, %iopt) = @_;
26 % $iopt{'cust_pkg'} = $cust_pkg;
27 % $iopt{'part_pkg'} = $cust_pkg->part_pkg;
28   <!--pkgnum: <% $cust_pkg->pkgnum %>-->
29   <TR CLASS="row<%$row % 2%>">
30     <& package.html, %iopt &>
31     <& status.html,  %iopt &>
32     <TD CLASS="inv" BGCOLOR="<% $iopt{bgcolor} %>" WIDTH="20%" VALIGN="top">
33       <& contact.html, %iopt &><BR>
34       <& location.html, %iopt &>
35     </TD>
36     <& services.html, %iopt &>
37   </TR>
38 % # insert hidden predecessors to this package, if any
39 % # and a rolldown button to show them
40 % # (we'll make it do something later)
41 % if ( $cust_pkg->get('changed_from_pkg') ) {
42   <TR CLASS="row<% $row % 2 %>">
43     <TD COLSPAN=4>
44     <BUTTON CLASS="rolldown_button"
45             ID="rolldown_<% $cust_pkg->change_pkgnum %>">
46       History &#x2b07;
47     </BUTTON>
48 % # the hidden block here has ID="cust_pkgX" where X is the first pkgnum
49 % # it contains.
50     <& hidden.html, $cust_pkg->get('changed_from_pkg'),
51        %iopt,
52        'next_pkg' => $cust_pkg,
53     &>
54     </TD>
55   </TR>
56 % }
57 % $row++;
58 % # show the change target, if there is one
59 % if ( $cust_pkg->change_to_pkg ) {
60     <& .packagerow, $cust_pkg->change_to_pkg, %iopt, 'change_from' => 1 &>
61 % }
62 % # include supplemental packages if any
63 % $iopt{'supplemental'} = ($iopt{'supplemental'} || 0) + 1;
64 % foreach my $supp_pkg ($cust_pkg->supplemental_pkgs) {
65     <& .packagerow, $supp_pkg, %iopt &>
66 % }
67 </%def>
68 <%shared>
69 my $row = 0;
70 </%shared>
71 <%init>
72
73 my %opt = @_;
74 my $conf = new FS::Conf;
75
76 my $curuser = $FS::CurrentUser::CurrentUser;
77
78 my $packages = $opt{'packages'};
79
80 # Sort order is hardcoded for now, can change this if needed.
81 @$packages = sort { 
82   ( $a->getfield('cancel') <=> $b->getfield('cancel') )  or
83   ( $a->getfield('setup')  <=> $b->getfield('setup')  )  or
84   ( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') )
85 } @$packages;
86
87 my %change_custnum = map { $_->change_custnum => 1 }
88                        grep { $_->change_custnum }
89                          grep { $_->getfield('cancel') }
90                            @$packages;
91
92 my $pkg_attached = ( scalar(keys %change_custnum) == 1
93                        && ! grep { ! $_->getfield('cancel') } @$packages
94                    );
95
96 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';  
97
98 my %conf_opt = (
99   #for package.html
100   'invoice-unitprice'         => $conf->exists('invoice-unitprice'),
101
102   #for services.html and status.html
103   'cust_pkg-display_times'    => ($conf->exists('cust_pkg-display_times')
104                                  || $curuser->option('cust_pkg-display_times')),
105   #for status.html
106   'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
107   'pkg_attached'              => $pkg_attached,
108   #for status.html pkg-balances
109   'pkg-balances'              => $conf->exists('pkg-balances'),
110   'money_char'                => ( $conf->config('money_char') || '$' ),
111
112   #for location.html
113   'countrydefault'            => $countrydefault,
114   'statedefault'              => ( scalar($conf->config('statedefault'))
115                                   || ($countrydefault eq 'US' ? 'CA' : '') ),
116   #for services.html
117   'svc_external-skip_manual'  => $conf->exists('svc_external-skip_manual'),
118   'legacy_link'               => $conf->exists('legacy_link'),
119   'manage_link'               => scalar($conf->config('svc_broadband-manage_link')),
120   'manage_link_text'          => scalar($conf->config('svc_broadband-manage_link_text')),
121   'manage_link_loc'           => scalar($conf->config('svc_broadband-manage_link_loc')),
122   'manage_link-new_window'    => $conf->exists('svc_broadband-manage_link-new_window'),
123   'cust_pkg-large_pkg_size'   => scalar($conf->config('cust_pkg-large_pkg_size')),
124
125 );
126
127 </%init>