future package change, #20687
[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 % $row++;
39 % # show the change target, if there is one
40 % if ( $cust_pkg->change_to_pkg ) {
41     <& .packagerow, $cust_pkg->change_to_pkg, %iopt, 'change_from' => 1 &>
42 % }
43 % # include supplemental packages if any
44 % $iopt{'supplemental'} = ($iopt{'supplemental'} || 0) + 1;
45 % foreach my $supp_pkg ($cust_pkg->supplemental_pkgs) {
46     <& .packagerow, $supp_pkg, %iopt &>
47 % }
48 </%def>
49 <%shared>
50 my $row = 0;
51 </%shared>
52 <%init>
53
54 my %opt = @_;
55 my $conf = new FS::Conf;
56
57 my $curuser = $FS::CurrentUser::CurrentUser;
58
59 my $packages = $opt{'packages'};
60
61 # Sort order is hardcoded for now, can change this if needed.
62 @$packages = sort { 
63   ( $a->getfield('cancel') <=> $b->getfield('cancel') )  or
64   ( $a->getfield('setup')  <=> $b->getfield('setup')  )  or
65   ( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') )
66 } @$packages;
67
68 my %change_custnum = map { $_->change_custnum => 1 }
69                        grep { $_->change_custnum }
70                          grep { $_->getfield('cancel') }
71                            @$packages;
72
73 my $pkg_attached = ( scalar(keys %change_custnum) == 1
74                        && ! grep { ! $_->getfield('cancel') } @$packages
75                    );
76
77 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';  
78
79 my %conf_opt = (
80   #for services.html and status.html
81   'cust_pkg-display_times'    => ($conf->exists('cust_pkg-display_times')
82                                  || $curuser->option('cust_pkg-display_times')),
83   #for status.html
84   'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
85   'pkg_attached'              => $pkg_attached,
86   #for status.html pkg-balances
87   'pkg-balances'              => $conf->exists('pkg-balances'),
88   'money_char'                => ( $conf->config('money_char') || '$' ),
89
90   #for location.html
91   'countrydefault'            => $countrydefault,
92   'statedefault'              => ( scalar($conf->config('statedefault'))
93                                   || ($countrydefault eq 'US' ? 'CA' : '') ),
94   #for services.html
95   'svc_external-skip_manual'  => $conf->exists('svc_external-skip_manual'),
96   'legacy_link'               => $conf->exists('legacy_link'),
97   'manage_link'               => scalar($conf->config('svc_broadband-manage_link')),
98   'manage_link_text'          => scalar($conf->config('svc_broadband-manage_link_text')),
99   'manage_link_loc'           => scalar($conf->config('svc_broadband-manage_link_loc')),
100   'manage_link-new_window'    => $conf->exists('svc_broadband-manage_link-new_window'),
101   'cust_pkg-large_pkg_size'   => scalar($conf->config('cust_pkg-large_pkg_size')),
102
103 );
104
105 </%init>