4ac2e777974fc5434ec39c061525f4c73b29915d
[freeside.git] / httemplate / view / cust_main / packages / section.html
1 % if ( @$packages ) { 
2 %   my $bgcolor1 = '#eeeeee';
3 %   my $bgcolor2 = '#ffffff';
4 %   my $bgcolor = '';
5
6 <TR>
7 % #my $width = $show_location ? 'WIDTH="25%"' : 'WIDTH="33%"';
8   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Package') |h %></TH>
9   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
10 %   if ( $show_location ) {
11   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Location') |h %></TH>
12 % }
13   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Services') |h %></TH>
14 </TR>
15
16 % #$FS::cust_pkg::DEBUG = 2;
17 %   foreach my $cust_pkg (@$packages) {
18 %
19 %     if ( $bgcolor eq $bgcolor1 ) {
20 %       $bgcolor = $bgcolor2;
21 %     } else {
22 %       $bgcolor = $bgcolor1;
23 %     }
24 %
25 %     my %iopt = (
26 %       'bgcolor'  => $bgcolor,
27 %       'cust_pkg' => $cust_pkg,
28 %       'part_pkg' => $cust_pkg->part_pkg,
29 %       %conf_opt,
30 %     );
31 %
32
33   <!--pkgnum: <% $cust_pkg->pkgnum %>-->
34   <TR>
35     <& package.html, %iopt &>
36     <& status.html, %iopt &>
37 %     if ( $show_location ) {
38     <& location.html, %iopt &>
39 %     }
40     <& services.html, %iopt &>
41   </TR>
42
43 %   } #foreach $cust_pkg
44 %# </TABLE>
45 % } #if @$packages
46 % else {
47 <BR>
48 % }
49
50 <%init>
51
52 my %opt = @_;
53 my $conf = new FS::Conf;
54
55 my $curuser = $FS::CurrentUser::CurrentUser;
56
57 my $packages = $opt{'packages'};
58 my $show_location = $opt{'show_location'};
59
60 # Sort order is hardcoded for now, can change this if needed.
61 @$packages = sort { 
62   ( $a->getfield('cancel') <=> $b->getfield('cancel') )  or
63   ( $a->getfield('setup')  <=> $b->getfield('setup')  )  or
64   ( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') )
65 } @$packages;
66
67 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';  
68
69 my %conf_opt = (
70   #for services.html and status.html
71   'cust_pkg-display_times'    => ($conf->exists('cust_pkg-display_times')
72                                  || $curuser->option('cust_pkg-display_times')),
73   #for status.html
74   'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
75   #for status.html pkg-balances
76   'pkg-balances'              => $conf->exists('pkg-balances'),
77   'money_char'                => ( $conf->config('money_char') || '$' ),
78
79   #for location.html
80   'countrydefault'            => $countrydefault,
81   'statedefault'              => ( scalar($conf->config('statedefault'))
82                                   || ($countrydefault eq 'US' ? 'CA' : '') ),
83   #for services.html
84   'svc_external-skip_manual'  => $conf->exists('svc_external-skip_manual'),
85   'legacy_link'               => $conf->exists('legacy_link'),
86   'svc_broadband-manage_link' => scalar($conf->config('svc_broadband-manage_link')),
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>