supplemental packages, #20689
[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 %   if ( $show_location ) {
7   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Location') |h %></TH>
8 % }
9   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Services') |h %></TH>
10 </TR>
11
12 % #$FS::cust_pkg::DEBUG = 2;
13 %   foreach my $cust_pkg (@$packages) {
14     <& .packagerow, $cust_pkg,
15         'cust_main' => $opt{'cust_main'},
16         %conf_opt
17     &>
18 %   }
19 % } else { # there are no packages
20 <BR>
21 % }
22 <%def .packagerow>
23 %
24 % my ($cust_pkg, %iopt) = @_;
25 % $iopt{'cust_pkg'} = $cust_pkg;
26 % $iopt{'part_pkg'} = $cust_pkg->part_pkg;
27   <!--pkgnum: <% $cust_pkg->pkgnum %>-->
28   <TR CLASS="row<%$row % 2%>">
29     <& package.html, %iopt &>
30     <& status.html, %iopt &>
31 %     if ( $iopt{'show_location'} ) {
32     <& location.html, %iopt &>
33 %     }
34     <& services.html, %iopt &>
35   </TR>
36 % $row++;
37 % # include supplemental packages if any
38 % $iopt{'supplemental'} = ($iopt{'supplemental'} || 0) + 1;
39 % foreach my $supp_pkg ($cust_pkg->supplemental_pkgs) {
40 % warn $supp_pkg->pkgnum;
41     <& .packagerow, $supp_pkg, %iopt &>
42 % }
43 </%def>
44 <%shared>
45 my $row = 0;
46 </%shared>
47 <%init>
48
49 my %opt = @_;
50 my $conf = new FS::Conf;
51
52 my $curuser = $FS::CurrentUser::CurrentUser;
53
54 my $packages = $opt{'packages'};
55 my $show_location = $opt{'show_location'};
56
57 # Sort order is hardcoded for now, can change this if needed.
58 @$packages = sort { 
59   ( $a->getfield('cancel') <=> $b->getfield('cancel') )  or
60   ( $a->getfield('setup')  <=> $b->getfield('setup')  )  or
61   ( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') )
62 } @$packages;
63
64 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';  
65
66 my %conf_opt = (
67   #for services.html and status.html
68   'cust_pkg-display_times'    => ($conf->exists('cust_pkg-display_times')
69                                  || $curuser->option('cust_pkg-display_times')),
70   #for status.html
71   'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
72   #for status.html pkg-balances
73   'pkg-balances'              => $conf->exists('pkg-balances'),
74   'money_char'                => ( $conf->config('money_char') || '$' ),
75
76   #for location.html
77   'countrydefault'            => $countrydefault,
78   'statedefault'              => ( scalar($conf->config('statedefault'))
79                                   || ($countrydefault eq 'US' ? 'CA' : '') ),
80   #for services.html
81   'svc_external-skip_manual'  => $conf->exists('svc_external-skip_manual'),
82   'legacy_link'               => $conf->exists('legacy_link'),
83   'manage_link'               => scalar($conf->config('svc_broadband-manage_link')),
84   'manage_link_text'          => scalar($conf->config('svc_broadband-manage_link_text')),
85   'manage_link_loc'           => scalar($conf->config('svc_broadband-manage_link_loc')),
86   'manage_link-new_window'    => $conf->exists('svc_broadband-manage_link-new_window'),
87   'maestro-status_test'       => $conf->exists('maestro-status_test'),
88   'cust_pkg-large_pkg_size'   => $conf->config('cust_pkg-large_pkg_size'),
89
90   # for packages.html Change location link
91   'show_location'             => $show_location,
92 );
93
94 </%init>