merge NG auth, RT#21563
[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         'cust_main' => $opt{'cust_main'},
14         'bgcolor'   => $opt{'bgcolor'},
15         %conf_opt
16     &>
17 %   }
18 % } else { # there are no packages
19 <BR>
20 % }
21 <%def .packagerow>
22 %
23 % my ($cust_pkg, %iopt) = @_;
24 % $iopt{'cust_pkg'} = $cust_pkg;
25 % $iopt{'part_pkg'} = $cust_pkg->part_pkg;
26   <!--pkgnum: <% $cust_pkg->pkgnum %>-->
27   <TR CLASS="row<%$row % 2%>">
28     <& package.html, %iopt &>
29     <& status.html,  %iopt &>
30     <TD CLASS="inv" BGCOLOR="<% $iopt{bgcolor} %>" WIDTH="20%" VALIGN="top">
31       <& contact.html, %iopt &><BR>
32       <& location.html, %iopt &>
33     </TD>
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     <& .packagerow, $supp_pkg, %iopt &>
41 % }
42 </%def>
43 <%shared>
44 my $row = 0;
45 </%shared>
46 <%init>
47
48 my %opt = @_;
49 my $conf = new FS::Conf;
50
51 my $curuser = $FS::CurrentUser::CurrentUser;
52
53 my $packages = $opt{'packages'};
54
55 # Sort order is hardcoded for now, can change this if needed.
56 @$packages = sort { 
57   ( $a->getfield('cancel') <=> $b->getfield('cancel') )  or
58   ( $a->getfield('setup')  <=> $b->getfield('setup')  )  or
59   ( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') )
60 } @$packages;
61
62 my %change_custnum = map { $_->change_custnum => 1 }
63                        grep { $_->change_custnum }
64                          grep { $_->getfield('cancel') }
65                            @$packages;
66
67 my $pkg_attached = ( scalar(keys %change_custnum) == 1
68                        && ! grep { ! $_->getfield('cancel') } @$packages
69                    );
70
71 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';  
72
73 my %conf_opt = (
74   #for services.html and status.html
75   'cust_pkg-display_times'    => ($conf->exists('cust_pkg-display_times')
76                                  || $curuser->option('cust_pkg-display_times')),
77   #for status.html
78   'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
79   'pkg_attached'              => $pkg_attached,
80   #for status.html pkg-balances
81   'pkg-balances'              => $conf->exists('pkg-balances'),
82   'money_char'                => ( $conf->config('money_char') || '$' ),
83
84   #for location.html
85   'countrydefault'            => $countrydefault,
86   'statedefault'              => ( scalar($conf->config('statedefault'))
87                                   || ($countrydefault eq 'US' ? 'CA' : '') ),
88   #for services.html
89   'svc_external-skip_manual'  => $conf->exists('svc_external-skip_manual'),
90   'legacy_link'               => $conf->exists('legacy_link'),
91   'manage_link'               => scalar($conf->config('svc_broadband-manage_link')),
92   'manage_link_text'          => scalar($conf->config('svc_broadband-manage_link_text')),
93   'manage_link_loc'           => scalar($conf->config('svc_broadband-manage_link_loc')),
94   'manage_link-new_window'    => $conf->exists('svc_broadband-manage_link-new_window'),
95   'maestro-status_test'       => $conf->exists('maestro-status_test'),
96   'cust_pkg-large_pkg_size'   => scalar($conf->config('cust_pkg-large_pkg_size')),
97
98 );
99
100 </%init>