customer view UI
[freeside.git] / httemplate / view / cust_main / packages / section.html
1 % if ( @$packages ) { 
2 <THEAD>
3 <TR>
4 % #my $width = $show_location ? 'WIDTH="25%"' : 'WIDTH="33%"';
5   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Package') |h %></TH>
6   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
7   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Contact/Location') |h %></TH>
8 % if (!$opt{no_services}) {
9   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Services') |h %></TH>
10 % }
11 </TR>
12 </THEAD>
13
14 % #$FS::cust_pkg::DEBUG = 2;
15 %   foreach my $cust_pkg (@$packages) {
16 %    # if requested, this can override cust_pkg-group_by_location
17     <& .packagerow, $cust_pkg,
18         %conf_opt,
19         ( map { $_ => $opt{$_} } qw(
20             cust_main bgcolor no_links cust_location_cache
21             before_pkg_callback before_svc_callback after_svc_callback
22             cust_pkg-group_by_location
23             no_services
24         )),
25         #for status.html
26         'has_cust_payby_auto' => $opt{cust_main}->has_cust_payby_auto,
27     &>
28 %   }
29 % } else { # there are no packages
30 <BR>
31 % }
32 <%def .packagerow>
33 %
34 % my ($cust_pkg, %iopt) = @_;
35 % $iopt{'cust_pkg'} = $cust_pkg;
36 % $iopt{'part_pkg'} = $cust_pkg->part_pkg;
37   <!--pkgnum: <% $cust_pkg->pkgnum %>-->
38   <TR CLASS="row<%$row % 2%>">
39     <& package.html, %iopt &>
40     <& status.html,  %iopt &>
41     <TD CLASS="inv" BGCOLOR="<% $iopt{bgcolor} %>" WIDTH="20%" VALIGN="top">
42       <& contact.html, %iopt &>
43       <& location.html, %iopt &>
44     </TD>
45 %   if (!$iopt{no_services}) {
46     <& services.html, %iopt &>
47 %   }
48   </TR>
49 % # insert hidden predecessors to this package, if any
50 % # and a rolldown button to show them
51 % # (we'll make it do something later)
52 % if ( $cust_pkg->get('changed_from_pkg') ) {
53   <TR CLASS="row<% $row % 2 %>">
54     <TD COLSPAN=4>
55     <BUTTON CLASS="rolldown_button"
56             ID="rolldown_<% $cust_pkg->change_pkgnum %>">
57       History &#x2b07;
58     </BUTTON>
59 % # the hidden block here has ID="cust_pkgX" where X is the first pkgnum
60 % # it contains.
61     <& hidden.html, $cust_pkg->get('changed_from_pkg'),
62        %iopt,
63        'next_pkg' => $cust_pkg,
64     &>
65     </TD>
66   </TR>
67 % }
68 % $row++;
69 % # show the change target, if there is one
70 % if ( $cust_pkg->change_to_pkg ) {
71     <& .packagerow, $cust_pkg->change_to_pkg, %iopt, 'change_from' => 1 &>
72 % }
73 % # include supplemental packages if any
74 % $iopt{'supplemental'} = ($iopt{'supplemental'} || 0) + 1;
75 % foreach my $supp_pkg ($cust_pkg->supplemental_pkgs) {
76     <& .packagerow, $supp_pkg, %iopt &>
77 % }
78 </%def>
79 <%shared>
80 my $row = 0;
81 </%shared>
82 <%init>
83
84 my %opt = @_;
85 my $conf = new FS::Conf;
86
87 my $curuser = $FS::CurrentUser::CurrentUser;
88
89 my $packages = $opt{'packages'};
90
91 # Sort order is hardcoded for now, can change this if needed.
92 @$packages = sort { 
93   ( $a->getfield('cancel') <=> $b->getfield('cancel') )  or
94   ( $a->getfield('setup')  <=> $b->getfield('setup')  )  or
95   ( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') )
96 } @$packages;
97
98 my %change_custnum = map { $_->change_custnum => 1 }
99                        grep { $_->change_custnum }
100                          grep { $_->getfield('cancel') }
101                            @$packages;
102
103 my $pkg_attached = ( scalar(keys %change_custnum) == 1
104                        && ! grep { ! $_->getfield('cancel') } @$packages
105                    );
106
107 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';  
108
109 my %conf_opt = (
110   #for package.html
111   'invoice-unitprice'         => $conf->exists('invoice-unitprice'),
112   'show_pkgnum'               => $curuser->option('show_pkgnum'),
113   'part_pkg-term_discounts'   => $conf->exists('part_pkg-term_discounts'),
114
115   #for services.html and status.html
116   'cust_pkg-display_times'    => ($conf->exists('cust_pkg-display_times')
117                                  || $curuser->option('cust_pkg-display_times')),
118   #for status.html
119   'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
120   'pkg_attached'              => $pkg_attached,
121   'part_pkg-delay_cancel-days' => $conf->config('part_pkg-delay_cancel-days') || 1,
122   #for status.html pkg-balances
123   'pkg-balances'              => $conf->exists('pkg-balances'),
124   'money_char'                => ( $conf->config('money_char') || '$' ),
125
126   #for location.html
127   'countrydefault'            => $countrydefault,
128   'statedefault'              => ( scalar($conf->config('statedefault'))
129                                   || ($countrydefault eq 'US' ? 'CA' : '') ),
130   'cust_pkg-group_by_location'=> $conf->exists('cust_pkg-group_by_location'),
131   'cust_main-require_censustract'=> $conf->exists('cust_main-require_censustract'),
132   'company_address'           => [ $conf->config('company_address', $opt{cust_main}->agentnum ) ],
133   
134   #for services.html
135   'svc_external-skip_manual'  => $conf->exists('svc_external-skip_manual'),
136   'svc_phone-bulk_provision_simple' => $conf->exists('svc_phone-bulk_provision_simple'),
137   'legacy_link'               => $conf->exists('legacy_link'),
138   'manage_link'               => scalar($conf->config('svc_broadband-manage_link')),
139   'manage_link_text'          => scalar($conf->config('svc_broadband-manage_link_text')),
140   'manage_link_loc'           => scalar($conf->config('svc_broadband-manage_link_loc')),
141   'manage_link-new_window'    => $conf->exists('svc_broadband-manage_link-new_window'),
142   'cust_pkg-large_pkg_size'   => scalar($conf->config('cust_pkg-large_pkg_size')),
143   'cust_pkg-hide_discontinued-part_svc' => $conf->exists('cust_pkg-hide_discontinued-part_svc'),
144
145 );
146
147 </%init>