move services between packages, RT#22619
[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 % # include supplemental packages if any
40 % $iopt{'supplemental'} = ($iopt{'supplemental'} || 0) + 1;
41 % foreach my $supp_pkg ($cust_pkg->supplemental_pkgs) {
42     <& .packagerow, $supp_pkg, %iopt &>
43 % }
44 </%def>
45 <%shared>
46 my $row = 0;
47 </%shared>
48 <%init>
49
50 my %opt = @_;
51 my $conf = new FS::Conf;
52
53 my $curuser = $FS::CurrentUser::CurrentUser;
54
55 my $packages = $opt{'packages'};
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 %change_custnum = map { $_->change_custnum => 1 }
65                        grep { $_->change_custnum }
66                          grep { $_->getfield('cancel') }
67                            @$packages;
68
69 my $pkg_attached = ( scalar(keys %change_custnum) == 1
70                        && ! grep { ! $_->getfield('cancel') } @$packages
71                    );
72
73 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';  
74
75 my %conf_opt = (
76   #for services.html and status.html
77   'cust_pkg-display_times'    => ($conf->exists('cust_pkg-display_times')
78                                  || $curuser->option('cust_pkg-display_times')),
79   #for status.html
80   'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
81   'pkg_attached'              => $pkg_attached,
82   #for status.html pkg-balances
83   'pkg-balances'              => $conf->exists('pkg-balances'),
84   'money_char'                => ( $conf->config('money_char') || '$' ),
85
86   #for location.html
87   'countrydefault'            => $countrydefault,
88   'statedefault'              => ( scalar($conf->config('statedefault'))
89                                   || ($countrydefault eq 'US' ? 'CA' : '') ),
90   #for services.html
91   'svc_external-skip_manual'  => $conf->exists('svc_external-skip_manual'),
92   'legacy_link'               => $conf->exists('legacy_link'),
93   'manage_link'               => scalar($conf->config('svc_broadband-manage_link')),
94   'manage_link_text'          => scalar($conf->config('svc_broadband-manage_link_text')),
95   'manage_link_loc'           => scalar($conf->config('svc_broadband-manage_link_loc')),
96   'manage_link-new_window'    => $conf->exists('svc_broadband-manage_link-new_window'),
97   'cust_pkg-large_pkg_size'   => scalar($conf->config('cust_pkg-large_pkg_size')),
98
99 );
100
101 </%init>