3 % if ( $curuser->access_right('Qualify service') ) {
4 <% $s++ ? ' | ' : '' %>
5 <% include('qual_link.html', $cust_main) %>
8 % if ( $curuser->access_right('Order customer package') ) {
9 <% $s++ ? ' | ' : '' %>
10 <% include('order_pkg_link.html', $cust_main) %>
13 % if ( $curuser->access_right('One-time charge')
14 % && $conf->config('payby-default') ne 'HIDE'
16 <% $s++ ? ' | ' : '' %>
17 <% include('one_time_charge_link.html', $cust_main) %>
20 % if ( $curuser->access_right('Bulk change customer packages') ) {
21 <% $s++ ? ' | ' : '' %>
22 <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services)
35 % if ( $cust_main->num_cancelled_pkgs ) {
36 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
37 % || ( $conf->exists('hidecancelledpackages')
38 % && ! $cgi->param('showcancelledpackages')
42 % my $prev = $cgi->param('showcancelledpackages');
43 % $cgi->param('showcancelledpackages', 1);
44 ( <a href="<% $cgi->self_url %>">show
45 % $cgi->param('showcancelledpackages', $prev);
47 % $cgi->param('showcancelledpackages', 0);
48 ( <a href="<% $cgi->self_url %>">hide
49 % $cgi->param('showcancelledpackages', 1);
52 cancelled packages</a> )
54 % if ( $num_old_packages ) {
55 % $cgi->param('showoldpackages', 1);
56 ( <a href="<% $cgi->self_url %>">show old packages</a> )
57 % } elsif ( $cgi->param('showoldpackages') ) {
58 % $cgi->param('showoldpackages', 0);
59 ( <a href="<% $cgi->self_url %>">hide old packages</a> )
64 <A HREF="<%$p%>search/report_cust_pkg.html?custnum=<% $cust_main->custnum %>">Package reports</A>
65 % if ( $curuser->access_right('Qualify service') ) {
66 | <A HREF="<%$p%>search/qual.cgi?custnum=<% $cust_main->custnum %>">View Qualifications</A>
70 <A HREF="<%$p%>search/report_svc_acct.html?custnum=<% $cust_main->custnum %>">accounts</A><BR>
72 <A HREF="<%$p%>search/report_cdr.html?custnum=<% $cust_main->custnum %>">CDRs</A>
81 <% include('/elements/table-grid.html') %>
82 % my $bgcolor1 = '#eeeeee';
83 % my $bgcolor2 = '#ffffff';
87 <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH>
88 <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
89 % if ( $show_location ) {
90 <TH CLASS="grid" BGCOLOR="#cccccc">Location</TH>
92 <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
95 % #$FS::cust_pkg::DEBUG = 2;
96 % foreach my $cust_pkg (@$packages) {
98 % if ( $bgcolor eq $bgcolor1 ) {
99 % $bgcolor = $bgcolor2;
101 % $bgcolor = $bgcolor1;
105 % 'bgcolor' => $bgcolor,
106 % 'cust_pkg' => $cust_pkg,
107 % 'part_pkg' => $cust_pkg->part_pkg,
112 <!--pkgnum: <% $cust_pkg->pkgnum %>-->
114 <% include('packages/package.html', %iopt) %>
115 <% include('packages/status.html', %iopt) %>
116 % if ( $show_location ) {
117 <% include('packages/location.html', %iopt) %>
119 <% include('packages/services.html', %iopt) %>
134 % if ( $cgi->param('fragment') =~ /^cust_pkg(\d+)$/ ) {
136 // IE-specific hack. other browsers listen to #fragments
137 // is this even working? or is the #target redirection just working cause
138 // we set the URL params differently?
139 var el = document.getElementById( 'cust_pkg<% $1 %>' );
140 if ( el ) el.scrollIntoView(true);
146 my( $cust_main ) = @_;
147 my $conf = new FS::Conf;
149 my $curuser = $FS::CurrentUser::CurrentUser;
151 my( $packages, $num_old_packages ) = get_packages($cust_main, $conf);
153 my $show_location = $conf->exists('cust_pkg-always_show_location')
154 || ( grep $_->locationnum, @$packages ); # ? '1' : '0';
156 my $countrydefault = scalar($conf->config('countrydefault')) || 'US';
158 #for services.html and status.html
159 'cust_pkg-display_times' => ($conf->exists('cust_pkg-display_times')
160 || $curuser->option('cust_pkg-display_times')),
162 'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'),
163 #for status.html pkg-balances
164 'pkg-balances' => $conf->exists('pkg-balances'),
165 'money_char' => ( $conf->config('money_char') || '$' ),
168 'countrydefault' => $countrydefault,
169 'statedefault' => ( scalar($conf->config('statedefault'))
170 || ($countrydefault eq 'US' ? 'CA' : '') ),
172 'svc_external-skip_manual' => $conf->exists('svc_external-skip_manual'),
173 'legacy_link' => $conf->exists('legacy_link'),
174 'svc_broadband-manage_link' => scalar($conf->config('svc_broadband-manage_link')),
175 'maestro-status_test' => $conf->exists('maestro-status_test'),
176 'cust_pkg-large_pkg_size' => $conf->config('cust_pkg-large_pkg_size'),
182 my $cust_main = shift or return undef;
186 if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
187 || ( $conf->exists('hidecancelledpackages')
188 && ! $cgi->param('showcancelledpackages') )
191 $method = 'ncancelled_pkgs';
193 $method = 'all_pkgs';
196 my $cust_pkg_fields =
197 join(', ', map { "cust_pkg.$_ AS $_" } fields('cust_pkg') );
199 my $part_pkg_fields =
200 join(', ', map { "part_pkg.$_ AS part_pkg_$_" } fields('part_pkg') );
203 join(', ', map "cust_pkg.$_", fields('cust_pkg') ). ', '.
204 join(', ', map "part_pkg.$_", fields('part_pkg') );
206 my $num_svcs = '( SELECT COUNT(*) FROM cust_svc '.
207 ' WHERE cust_svc.pkgnum = cust_pkg.pkgnum ) AS num_svcs';
209 my @packages = $cust_main->$method( {
210 'select' => "$cust_pkg_fields, $part_pkg_fields, $num_svcs",
211 'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )',
213 my $num_old_packages = scalar(@packages);
215 foreach my $cust_pkg ( @packages ) {
216 my %hash = $cust_pkg->hash;
217 my %part_pkg = map { /^part_pkg_(.+)$/ or die; ( $1 => $hash{$_} ); }
218 grep { /^part_pkg_/ } keys %hash;
219 $cust_pkg->{'_pkgpart'} = new FS::part_pkg \%part_pkg;
222 unless ( $cgi->param('showoldpackages') ) {
223 my $years = $conf->config('cust_main-packages-years') || 2;
224 my $then = time - $years * 31556926; #60*60*24*365.2422 is close enough
226 my %hide = ( 'cancelled' => 'cancel',
227 'one-time charge' => 'setup',
231 grep { !exists($hide{$_->status}) or $_->get($hide{$_->status}) > $then
232 or $_->num_svcs #don't hide packages w/services
237 $num_old_packages -= scalar(@packages);
239 ( \@packages, $num_old_packages );