1 <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A><BR>
4 % if ( $curuser->access_right('Order customer package') ) {
5 <% $s++ ? ' | ' : '' %>
6 <% order_pkg_link($cust_main) %>
9 % if ( $curuser->access_right('One-time charge')
10 % && $conf->config('payby-default') ne 'HIDE'
13 <% $s++ ? ' | ' : '' %>
14 <% popup_link('edit/quick-charge.html?custnum='. $cust_main->custnum, 'One-time charge', 'One-time charge', '#333399', 545) %>
16 % if ( $curuser->access_right('Bulk change customer packages') ) {
17 <% $s++ ? ' | ' : '' %>
18 <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services)
27 % if ( $cust_main->num_cancelled_pkgs ) {
28 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
29 % || ( $conf->exists('hidecancelledpackages')
30 % && ! $cgi->param('showcancelledpackages')
34 % $cgi->param('showcancelledpackages', 1);
37 ( <a href="<% $cgi->self_url %>">show
39 % $cgi->param('showcancelledpackages', 0);
42 ( <a href="<% $cgi->self_url %>">hide
45 cancelled packages</a> )
50 <% include('/elements/table-grid.html') %>
51 % my $bgcolor1 = '#eeeeee';
52 % my $bgcolor2 = '#ffffff';
56 <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH>
57 <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
58 <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
61 %foreach my $cust_pkg (@$packages) {
63 % my $part_pkg = $cust_pkg->part_pkg;
65 % if ( $bgcolor eq $bgcolor1 ) {
66 % $bgcolor = $bgcolor2;
68 % $bgcolor = $bgcolor1;
72 <!--pkgnum: <% $cust_pkg->pkgnum %>-->
75 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
77 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>" ID="cust_pkg<% $cust_pkg->pkgnum %>"><% $cust_pkg->pkgnum %></A>:
78 <% $part_pkg->pkg %> - <% $part_pkg->comment %>
82 % unless ( $cust_pkg->get('cancel') ) {
84 % if ( $curuser->access_right('Change customer package') ) { $br=1;
86 ( <%pkg_change_link($cust_pkg)%> )
88 % if ( $curuser->access_right('Edit customer package dates') ) { $br=1;
90 ( <%pkg_dates_link($cust_pkg)%> )
92 % if ( $curuser->access_right('Customize customer package') ) { $br=1;
94 ( <%pkg_customize_link($cust_pkg,$cust_main->custnum)%> )
96 <% $br ? '<BR>' : '' %>
99 % if ( $cust_pkg->num_cust_event
100 % && ( $curuser->access_right('Billing event reports')
101 % || $curuser->access_right('View customer billing events')
104 ( <%pkg_event_link($cust_pkg)%> )
111 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
112 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
115 % my $part_pkg = shift;
116 % my $freq = $part_pkg->freq_pretty;
117 % $freq =~ s/ / /g;
121 % #this should use cust_pkg->status and cust_pkg->statuscolor eventually
123 % my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
124 % my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
126 % #false laziness w/edit/REAL_cust_pkg.cgi
127 % my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
128 % unless ( $part_pkg->is_prepaid ) {
129 % $billed_or_prepaid = 'billed';
130 % $last_bill_or_renewed = 'Last bill';
131 % $next_bill_or_prepaid_until = 'Next bill';
133 % $billed_or_prepaid = 'prepaid';
134 % $last_bill_or_renewed = 'Renewed';
135 % $next_bill_or_prepaid_until = 'Prepaid until';
139 % if ( $cust_pkg->get('cancel') ) {
140 <!-- #status: cancelled -->
143 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD>
144 <% pkg_datestr($cust_pkg, 'cancel', $conf) %>
147 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000" SIZE="-2">
148 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
151 % unless ( $cust_pkg->get('setup') ) {
155 <TD COLSPAN=<%$colspan%>>Never billed</TD>
161 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
162 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
164 % if ( $cust_pkg->get('last_bill') ) {
167 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
168 <% pkg_datestr($cust_pkg, 'last_bill',$conf) %>
171 % if ( $cust_pkg->get('susp') ) {
174 <TD WIDTH="<%$width%>" ALIGN="right">Suspended </TD>
175 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
180 % if ( $cust_pkg->get('susp') ) {
181 <!-- #status: suspended -->
184 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD>
185 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
188 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900" SIZE="-2">
189 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
192 % unless ( $cust_pkg->get('setup') ) {
196 <TD COLSPAN=<%$colspan%>>Never billed</TD>
202 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
203 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
206 % if ( $cust_pkg->get('last_bill') ) {
209 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
210 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
215 <!-- # next bill ?? -->
216 % if ( $cust_pkg->get('expire') ) {
219 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
220 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
226 <TD COLSPAN=<%$colspan%>>
228 % if ( $curuser->access_right('Unsuspend customer package') ) {
230 ( <% pkg_unsuspend_link($cust_pkg) %> )
232 % if ( $curuser->access_right('Cancel customer package immediately') ) {
234 ( <% pkg_cancel_link($cust_pkg) %> )
241 <!-- #status: active -->
242 % unless ( $cust_pkg->get('setup') ) {
244 % unless ( $part_pkg->freq ) {
248 <TD COLSPAN=<%$colspan%>>Not yet billed (one-time charge)</TD>
252 <TD COLSPAN=<%$colspan%>>
254 % if ( $curuser->access_right('Cancel customer package immediately') ) {
256 ( <% pkg_cancel_link($cust_pkg) %> )
266 <TD COLSPAN=<%$colspan%>>Not yet billed (<% $billed_or_prepaid %> <% myfreq($part_pkg) %>)</TD>
271 % unless ( $part_pkg->freq ) {
275 <TD COLSPAN=<%$colspan%>>One-time charge</TD>
279 <TD WIDTH="<%$width%>" ALIGN="right">Billed </TD>
280 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
283 % if (scalar($cust_pkg->overlimit)) {
285 <TD COLSPAN=<%$colspan%>><FONT COLOR="#FFD000"><B>Overlimit</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
289 <TD COLSPAN=<%$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
293 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
294 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
298 % if ( $cust_pkg->get('last_bill') ) {
301 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
302 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
305 % if ( $cust_pkg->get('bill') ) { #next bill
308 <TD WIDTH="<%$width%>" ALIGN="right"><% $next_bill_or_prepaid_until %> </TD>
309 <% pkg_datestr($cust_pkg, 'bill', $conf) %>
312 % if ( $cust_pkg->get('adjourn') ) {
315 <TD WIDTH="<%$width%>" ALIGN="right">Adjourns </TD>
316 <% pkg_datestr($cust_pkg, 'adjourn', $conf) %>
319 % if ( $cust_pkg->get('expire') ) {
322 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
323 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
326 % if ( $part_pkg->freq ) {
329 <TD COLSPAN=<%$colspan%>>
331 % if ( $curuser->access_right('Suspend customer package') ) {
333 ( <% pkg_suspend_link($cust_pkg) %> )
335 % if ( $curuser->access_right('Suspend customer package later') ) {
337 ( <% pkg_adjourn_link($cust_pkg) %> )
339 % if ( $curuser->access_right('Cancel customer package immediately') ) {
341 ( <% pkg_cancel_link($cust_pkg) %> )
343 % if ( $curuser->access_right('Cancel customer package later') ) {
345 ( <% pkg_expire_link($cust_pkg) %> )
359 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
360 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
362 % #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
363 % foreach my $part_svc ( $cust_pkg->part_svc ) {
365 % #foreach my $service (@{$svcpart->{services}}) {
366 % foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) {
369 <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD>
370 <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD>
374 <TD ALIGN="right" COLSPAN="2" VALIGN="top" STYLE="padding-bottom:1px;padding-top:0px"><FONT SIZE="-2" COLOR="#FFD000">
376 <% $cust_svc->overlimit ? "Overlimit: ". time2str('%b %o %Y' . ($conf->exists('cust_pkg-display_times') ? ' %l:%M %P' : ''), $cust_svc->overlimit) : '' %>
381 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
383 % if ( $curuser->access_right('Recharge customer service')
384 % && $part_svc->svcdb eq 'svc_acct'
385 % && ( $cust_svc->svc_x->seconds ne ''
386 % || $cust_svc->svc_x->upbytes ne ''
387 % || $cust_svc->svc_x->downbytes ne ''
388 % || $cust_svc->svc_x->totalbytes ne ''
391 ( <%svc_recharge_link($cust_svc)%> )
395 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
397 % if ( $curuser->access_right('Unprovision customer service') ) {
398 ( <%svc_unprovision_link($cust_svc)%> )
404 % if ( ! $cust_pkg->get('cancel')
405 % && $curuser->access_right('Provision customer service')
406 % && $part_svc->num_avail
410 <TD COLSPAN=2 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px">
411 <B><% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %></B>
421 % } #end display packages
430 % if ( $cgi->param('fragment') =~ /^cust_pkg(\d+)$/ ) {
432 // IE-specific hack. other browsers listen to #fragments
433 // is this even working? or is the #target redirection just working cause
434 // we set the URL params differently?
435 var el = document.getElementById( 'cust_pkg<% $1 %>' );
436 if ( el ) el.scrollIntoView(true);
441 my( $cust_main ) = @_;
442 my $conf = new FS::Conf;
444 my $curuser = $FS::CurrentUser::CurrentUser;
446 my $packages = get_packages($cust_main, $conf);
453 my $cust_main = shift or return undef;
458 if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
459 || ( $conf->exists('hidecancelledpackages')
460 && ! $cgi->param('showcancelledpackages') )
463 $method = 'ncancelled_pkgs';
465 $method = 'all_pkgs';
468 [ $cust_main->$method() ];
471 sub svc_provision_link {
472 my ($cust_pkg, $part_svc, $conf, $curuser) = @_;
473 ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g;
474 my $num_avail = $part_svc->num_avail;
475 my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'.
476 "svcpart=". $part_svc->svcpart;
478 if ( $part_svc->svcdb eq 'svc_external' #could be generalized
479 && $conf->exists('svc_external-skip_manual')
481 $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart";
486 'part_svc' => $part_svc,
487 'query' => $pkgnum_svcpart,
489 #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
492 my $link = qq!<A CLASS="provision" HREF="$url">!.
493 "Provision $svc_nbsp ($num_avail)</A>";
494 if ( $conf->exists('legacy_link')
495 && $curuser->access_right('View/link unlinked services')
499 qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!.
500 qq!$pkgnum_svcpart">!.
501 "Link to legacy $svc_nbsp ($num_avail)</A>";
506 sub svc_unprovision_link {
507 my $cust_svc = shift or return '';
508 qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum.
509 qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!;
513 my($cust_pkg, $field, $conf) = @_ or return '';
514 return ' ' unless $cust_pkg->get($field);
515 my $format = '<TD align="left"><B>%b</B></TD>'.
516 '<TD align="right"><B> %o,</B></TD>'.
517 '<TD align="right"><B> %Y</B></TD>';
518 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
519 $format .= '<TD ALIGN="right"><B> %l</TD>'.
520 '<TD ALIGN="center"><B>:</B></TD>'.
521 '<TD ALIGN="left"><B>%M</B></TD>'.
522 '<TD ALIGN="left"><B> %P</B></TD>'
523 if $conf->exists('cust_pkg-display_times');
524 my $strip = time2str($format, $cust_pkg->get($field) );
525 $strip =~ s/ (\d)/$1/g;
529 sub pkg_change_link { pkg_popup_link('misc/change_pkg.cgi?dummy=value',
530 'Change package',
537 sub pkg_suspend_link { pkg_popup_link( 'misc/cancel_pkg.html?method=suspend',
545 sub pkg_adjourn_link { pkg_popup_link( 'misc/cancel_pkg.html?method=adjourn',
546 'Suspend later',
553 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
554 sub pkg_expire_link { pkg_link('misc/expire_pkg', 'Cancel later', @_ ); }
555 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); }
557 sub pkg_cancel_link { pkg_popup_link( 'misc/cancel_pkg.html?method=cancel',
565 sub pkg_expire_link { pkg_popup_link( 'misc/cancel_pkg.html?method=expire',
567 'Expire', #"Cancel package $num later"
573 sub svc_recharge_link { svc_popup_link( 'misc/recharge_svc.html',
581 sub order_pkg_link { cust_popup_link( 'misc/order_pkg.html',
582 'Order new package',
591 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
592 'View package events'.
597 my($action, $label, $cust_pkg) = @_;
598 return '' unless $cust_pkg;
599 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
603 my($action, $label, $actionlabel, $color, $cust_pkg) = @_;
604 $action .= '&pkgnum='. $cust_pkg->pkgnum;
605 $actionlabel .= ' package '. $cust_pkg->pkgnum;
606 popup_link($action, $label, $actionlabel, $color);
610 my($action, $label, $actionlabel, $color, $cust_svc) = @_;
611 $action .= '?svcnum='. $cust_svc->svcnum;
612 $actionlabel .= ' service '. $cust_svc->svcnum;
613 popup_link($action, $label, $actionlabel, $color);
616 sub cust_popup_link {
617 my($action, $label, $actionlabel, $color, $cust_main) = @_;
618 $action .= '?'. $cust_main->custnum;
619 popup_link($action, $label, $actionlabel, $color);
623 my($action, $label, $actionlabel, $color, $width) = @_;
624 $color ||= '#333399';
626 qq!<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('$p$action', $width, 336, 'pkg_or_svc_action_popup' ), CAPTION, '$actionlabel', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;">$label</A>!;
629 sub pkg_customize_link {
630 my $cust_pkg = shift or return '';
631 my $custnum = $cust_pkg->custnum;
632 qq!<A HREF="${p}edit/part_pkg.cgi?!.
633 "keywords=$custnum;".
634 "clone=". $cust_pkg->part_pkg->pkgpart. ';'.
635 "pkgnum=". $cust_pkg->pkgnum.