1 % my( $cust_main ) = @_;
2 % my $conf = new FS::Conf;
4 % my $curuser = $FS::CurrentUser::CurrentUser;
6 % my $packages = get_packages($cust_main, $conf);
9 <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A>
10 % if ( $curuser->access_right('Order customer package') ) {
12 <% include('order_pkg.html', $cust_main ) %>
14 % if ( $curuser->access_right('One-time charge')
15 % && $conf->config('payby-default') ne 'HIDE'
19 <% include('quick-charge.html', $cust_main ) %>
21 % if ( $curuser->access_right('Bulk change customer packages') ) {
23 <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services)
32 % if ( $cust_main->num_cancelled_pkgs ) {
33 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
34 % || ( $conf->exists('hidecancelledpackages')
35 % && ! $cgi->param('showcancelledpackages')
39 % $cgi->param('showcancelledpackages', 1);
42 ( <a href="<% $cgi->self_url %>">show
44 % $cgi->param('showcancelledpackages', 0);
47 ( <a href="<% $cgi->self_url %>">hide
50 cancelled packages</a> )
55 <% include('/elements/table-grid.html') %>
56 % my $bgcolor1 = '#eeeeee';
57 % my $bgcolor2 = '#ffffff';
61 <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH>
62 <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
63 <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
66 %foreach my $cust_pkg (@$packages) {
68 % my $part_pkg = $cust_pkg->part_pkg;
70 % if ( $bgcolor eq $bgcolor1 ) {
71 % $bgcolor = $bgcolor2;
73 % $bgcolor = $bgcolor1;
77 <!--pkgnum: <% $cust_pkg->pkgnum %>-->
79 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
80 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"><% $cust_pkg->pkgnum %></A>:
81 <% $part_pkg->pkg %> - <% $part_pkg->comment %><BR>
83 % unless ( $cust_pkg->get('cancel') ) {
84 % if ( $curuser->access_right('Change customer package') ) {
86 ( <%pkg_change_link($cust_pkg)%> )
88 % if ( $curuser->access_right('Edit customer package dates') ) {
90 ( <%pkg_dates_link($cust_pkg)%> )
92 % if ( $curuser->access_right('Customize customer package') ) {
94 ( <%pkg_customize_link($cust_pkg,$cust_main->custnum)%> )
100 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
101 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
104 % my $part_pkg = shift;
105 % my $freq = $part_pkg->freq_pretty;
106 % $freq =~ s/ / /g;
110 % #this should use cust_pkg->status and cust_pkg->statuscolor eventually
112 % my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
113 % my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
115 % #false laziness w/edit/REAL_cust_pkg.cgi
116 % my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
117 % unless ( $part_pkg->is_prepaid ) {
118 % $billed_or_prepaid = 'billed';
119 % $last_bill_or_renewed = 'Last bill';
120 % $next_bill_or_prepaid_until = 'Next bill';
122 % $billed_or_prepaid = 'prepaid';
123 % $last_bill_or_renewed = 'Renewed';
124 % $next_bill_or_prepaid_until = 'Prepaid until';
128 % if ( $cust_pkg->get('cancel') ) {
129 <!-- #status: cancelled -->
132 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD>
133 <% pkg_datestr($cust_pkg, 'cancel', $conf) %>
136 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000" SIZE="-2">
137 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
140 % unless ( $cust_pkg->get('setup') ) {
144 <TD COLSPAN=<%$colspan%>>Never billed</TD>
150 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
151 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
153 % if ( $cust_pkg->get('last_bill') ) {
156 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
157 <% pkg_datestr($cust_pkg, 'last_bill',$conf) %>
160 % if ( $cust_pkg->get('susp') ) {
163 <TD WIDTH="<%$width%>" ALIGN="right">Suspended </TD>
164 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
169 % if ( $cust_pkg->get('susp') ) {
170 <!-- #status: suspended -->
173 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD>
174 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
177 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900" SIZE="-2">
178 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
181 % unless ( $cust_pkg->get('setup') ) {
185 <TD COLSPAN=<%$colspan%>>Never billed</TD>
191 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
192 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
195 % if ( $cust_pkg->get('last_bill') ) {
198 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
199 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
204 <!-- # next bill ?? -->
205 % if ( $cust_pkg->get('expire') ) {
208 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
209 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
215 <TD COLSPAN=<%$colspan%>>
217 % if ( $curuser->access_right('Unsuspend customer package') ) {
219 ( <% pkg_unsuspend_link($cust_pkg) %> )
221 % if ( $curuser->access_right('Cancel customer package') ) {
223 ( <% pkg_cancel_link($cust_pkg) %> )
230 <!-- #status: active -->
231 % unless ( $cust_pkg->get('setup') ) {
233 % unless ( $part_pkg->freq ) {
237 <TD COLSPAN=<%$colspan%>>Not yet billed (one-time charge)</TD>
241 <TD COLSPAN=<%$colspan%>>
243 % if ( $curuser->access_right('Cancel customer package immediately') ) {
245 ( <% pkg_cancel_link($cust_pkg) %> )
255 <TD COLSPAN=<%$colspan%>>Not yet billed (<% $billed_or_prepaid %> <% myfreq($part_pkg) %>)</TD>
260 % unless ( $part_pkg->freq ) {
264 <TD COLSPAN=<%$colspan%>>One-time charge</TD>
268 <TD WIDTH="<%$width%>" ALIGN="right">Billed </TD>
269 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
275 <TD COLSPAN=<%$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
279 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
280 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
284 % if ( $cust_pkg->get('last_bill') ) {
287 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
288 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
291 % if ( $cust_pkg->get('bill') ) { #next bill
294 <TD WIDTH="<%$width%>" ALIGN="right"><% $next_bill_or_prepaid_until %> </TD>
295 <% pkg_datestr($cust_pkg, 'bill', $conf) %>
298 % if ( $cust_pkg->get('expire') ) {
301 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
302 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
305 % if ( $part_pkg->freq ) {
308 <TD COLSPAN=<%$colspan%>>
310 % if ( $curuser->access_right('Suspend customer package') ) {
312 ( <% pkg_suspend_link($cust_pkg) %> )
314 % if ( $curuser->access_right('Cancel customer package immediately') ) {
316 ( <% pkg_cancel_link($cust_pkg) %> )
318 % if ( $curuser->access_right('Cancel customer package later') ) {
320 ( <% pkg_expire_link($cust_pkg) %> )
334 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
335 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
337 % #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
338 % foreach my $part_svc ( $cust_pkg->part_svc ) {
340 % #foreach my $service (@{$svcpart->{services}}) {
341 % foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) {
344 <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD>
345 <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD>
349 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
351 % if ( $curuser->access_right('Recharge customer service')
352 % && $cust_svc->svcdb eq 'svc_acct'
353 % && ( $cust_svc->svc_x->seconds ne ''
354 % || $cust_svc->svc_x->upbytes ne ''
355 % || $cust_svc->svc_x->downbytes ne ''
356 % || $cust_svc->svc_x->totalbytes ne ''
359 ( <%svc_recharge_link($cust_svc)%> )
363 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
365 % if ( $curuser->access_right('Unprovision customer service') ) {
366 ( <%svc_unprovision_link($cust_svc)%> )
372 % if ( ! $cust_pkg->get('cancel')
373 % && $curuser->access_right('Provision customer service')
374 % && $part_svc->num_avail
378 <TD COLSPAN=2 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px">
379 <B><% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %></B>
389 % } #end display packages
402 % my $cust_main = shift or return undef;
407 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
408 % || ( $conf->exists('hidecancelledpackages')
409 % && ! $cgi->param('showcancelledpackages') )
412 % $method = 'ncancelled_pkgs';
414 % $method = 'all_pkgs';
417 % [ $cust_main->$method() ];
420 %sub svc_provision_link {
421 % my ($cust_pkg, $part_svc, $conf, $curuser) = @_;
422 % ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g;
423 % my $num_avail = $part_svc->num_avail;
424 % my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'.
425 % "svcpart=". $part_svc->svcpart;
427 % if ( $part_svc->svcdb eq 'svc_external' #could be generalized
428 % && $conf->exists('svc_external-skip_manual')
430 % $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart";
432 % $url = FS::UI::Web::svc_url(
434 % 'action' => 'edit',
435 % 'part_svc' => $part_svc,
436 % 'query' => $pkgnum_svcpart,
438 % #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
441 % my $link = qq!<A CLASS="provision" HREF="$url">!.
442 % "Provision $svc_nbsp ($num_avail)</A>";
443 % if ( $conf->exists('legacy_link')
444 % && $curuser->access_right('View/link unlinked services')
448 % qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!.
449 % qq!$pkgnum_svcpart">!.
450 % "Link to legacy $svc_nbsp ($num_avail)</A>";
455 %sub svc_unprovision_link {
456 % my $cust_svc = shift or return '';
457 % qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum.
458 % qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!;
462 % my($cust_pkg, $field, $conf) = @_ or return '';
463 % return ' ' unless $cust_pkg->get($field);
464 % my $format = '<TD align="left"><B>%b</B></TD>'.
465 % '<TD align="right"><B> %o,</B></TD>'.
466 % '<TD align="right"><B> %Y</B></TD>';
467 % #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
468 % $format .= '<TD ALIGN="right"><B> %l</TD>'.
469 % '<TD ALIGN="center"><B>:</B></TD>'.
470 % '<TD ALIGN="left"><B>%M</B></TD>'.
471 % '<TD ALIGN="left"><B> %P</B></TD>'
472 % if $conf->exists('cust_pkg-display_times');
473 % my $strip = time2str($format, $cust_pkg->get($field) );
474 % $strip =~ s/ (\d)/$1/g;
478 %sub pkg_change_link { pkg_link('misc/change_pkg', 'Change package', @_ ); }
480 %sub pkg_suspend_link { pkg_popup_link( 'misc/cancel_pkg/html?method=suspend',
487 %sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
488 %sub pkg_expire_link { pkg_link('misc/expire_pkg', 'Cancel later', @_ ); }
489 %sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); }
491 %sub pkg_cancel_link { pkg_popup_link( 'misc/cancel_pkg.html?method=cancel',
497 %sub pkg_expire_link { pkg_popup_link( 'misc/cancel_pkg.html?method=expire',
498 % 'Cancel later',
499 % 'Expire', #"Cancel package $num later"
504 %sub svc_recharge_link { svc_popup_link( 'misc/recharge_svc.html',
512 % my($action, $label, $cust_pkg) = @_;
513 % return '' unless $cust_pkg;
514 % qq!<a href="${p}$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
517 %sub pkg_popup_link {
518 % my($action, $label, $actionlabel, $cust_pkg) = @_;
519 % $action .= '&pkgnum='. $cust_pkg->pkgnum;
520 % $actionlabel .= ' package '. $cust_pkg->pkgnum;
521 % popup_link($action, $label, $actionlabel);
524 %sub svc_popup_link {
525 % my($action, $label, $actionlabel, $cust_svc) = @_;
526 % $action .= '?svcnum='. $cust_svc->svcnum;
527 % $actionlabel .= ' service '. $cust_svc->svcnum;
528 % popup_link($action, $label, $actionlabel);
532 % my($action, $label, $actionlabel) = @_;
533 % qq!<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('$p$action', 392, 336, 'pkg_or_svc_action_popup' ), CAPTION, '$actionlabel', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">$label</A>!;
536 %sub pkg_customize_link {
537 % my $cust_pkg = shift or return '';
538 % my $custnum = $cust_pkg->custnum;
539 % qq!<A HREF="${p}edit/part_pkg.cgi?!.
540 % "keywords=$custnum;".
541 % "clone=". $cust_pkg->part_pkg->pkgpart. ';'.
542 % "pkgnum=". $cust_pkg->pkgnum.
543 % qq!">Customize</A>!;