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'
14 <% popup_link('edit/quick-charge.html?custnum='. $cust_main->custnum, 'One-time charge', 'One-time charge', '#333399', 545) %>
17 % if ( $curuser->access_right('Bulk change customer packages') ) {
19 <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services)
28 % if ( $cust_main->num_cancelled_pkgs ) {
29 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
30 % || ( $conf->exists('hidecancelledpackages')
31 % && ! $cgi->param('showcancelledpackages')
35 % $cgi->param('showcancelledpackages', 1);
38 ( <a href="<% $cgi->self_url %>">show
40 % $cgi->param('showcancelledpackages', 0);
43 ( <a href="<% $cgi->self_url %>">hide
46 cancelled packages</a> )
51 <% include('/elements/table-grid.html') %>
52 % my $bgcolor1 = '#eeeeee';
53 % my $bgcolor2 = '#ffffff';
57 <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH>
58 <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
59 <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
62 %foreach my $cust_pkg (@$packages) {
64 % my $part_pkg = $cust_pkg->part_pkg;
66 % if ( $bgcolor eq $bgcolor1 ) {
67 % $bgcolor = $bgcolor2;
69 % $bgcolor = $bgcolor1;
73 <!--pkgnum: <% $cust_pkg->pkgnum %>-->
76 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
78 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>" ID="cust_pkg<% $cust_pkg->pkgnum %>"><% $cust_pkg->pkgnum %></A>:
79 <% $part_pkg->pkg %> - <% $part_pkg->comment %>
83 % unless ( $cust_pkg->get('cancel') ) {
85 % if ( $curuser->access_right('Change customer package') ) { $br=1;
87 ( <%pkg_change_link($cust_pkg)%> )
89 % if ( $curuser->access_right('Edit customer package dates') ) { $br=1;
91 ( <%pkg_dates_link($cust_pkg)%> )
93 % if ( $curuser->access_right('Customize customer package') ) { $br=1;
95 ( <%pkg_customize_link($cust_pkg,$cust_main->custnum)%> )
97 <% $br ? '<BR>' : '' %>
100 % if ( $cust_pkg->num_cust_event
101 % && ( $curuser->access_right('Billing event reports')
102 % || $curuser->access_right('View customer billing events')
105 ( <%pkg_event_link($cust_pkg)%> )
112 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
113 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
116 % my $part_pkg = shift;
117 % my $freq = $part_pkg->freq_pretty;
118 % $freq =~ s/ / /g;
122 % #this should use cust_pkg->status and cust_pkg->statuscolor eventually
124 % my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
125 % my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
127 % #false laziness w/edit/REAL_cust_pkg.cgi
128 % my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
129 % unless ( $part_pkg->is_prepaid ) {
130 % $billed_or_prepaid = 'billed';
131 % $last_bill_or_renewed = 'Last bill';
132 % $next_bill_or_prepaid_until = 'Next bill';
134 % $billed_or_prepaid = 'prepaid';
135 % $last_bill_or_renewed = 'Renewed';
136 % $next_bill_or_prepaid_until = 'Prepaid until';
140 % if ( $cust_pkg->get('cancel') ) {
141 <!-- #status: cancelled -->
144 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD>
145 <% pkg_datestr($cust_pkg, 'cancel', $conf) %>
148 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000" SIZE="-2">
149 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
152 % unless ( $cust_pkg->get('setup') ) {
156 <TD COLSPAN=<%$colspan%>>Never billed</TD>
162 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
163 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
165 % if ( $cust_pkg->get('last_bill') ) {
168 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
169 <% pkg_datestr($cust_pkg, 'last_bill',$conf) %>
172 % if ( $cust_pkg->get('susp') ) {
175 <TD WIDTH="<%$width%>" ALIGN="right">Suspended </TD>
176 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
181 % if ( $cust_pkg->get('susp') ) {
182 <!-- #status: suspended -->
185 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD>
186 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
189 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900" SIZE="-2">
190 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
193 % unless ( $cust_pkg->get('setup') ) {
197 <TD COLSPAN=<%$colspan%>>Never billed</TD>
203 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
204 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
207 % if ( $cust_pkg->get('last_bill') ) {
210 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
211 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
216 <!-- # next bill ?? -->
217 % if ( $cust_pkg->get('expire') ) {
220 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
221 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
227 <TD COLSPAN=<%$colspan%>>
229 % if ( $curuser->access_right('Unsuspend customer package') ) {
231 ( <% pkg_unsuspend_link($cust_pkg) %> )
233 % if ( $curuser->access_right('Cancel customer package immediately') ) {
235 ( <% pkg_cancel_link($cust_pkg) %> )
242 <!-- #status: active -->
243 % unless ( $cust_pkg->get('setup') ) {
245 % unless ( $part_pkg->freq ) {
249 <TD COLSPAN=<%$colspan%>>Not yet billed (one-time charge)</TD>
253 <TD COLSPAN=<%$colspan%>>
255 % if ( $curuser->access_right('Cancel customer package immediately') ) {
257 ( <% pkg_cancel_link($cust_pkg) %> )
267 <TD COLSPAN=<%$colspan%>>Not yet billed (<% $billed_or_prepaid %> <% myfreq($part_pkg) %>)</TD>
272 % unless ( $part_pkg->freq ) {
276 <TD COLSPAN=<%$colspan%>>One-time charge</TD>
280 <TD WIDTH="<%$width%>" ALIGN="right">Billed </TD>
281 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
284 % if (scalar($cust_pkg->overlimit)) {
286 <TD COLSPAN=<%$colspan%>><FONT COLOR="#FFD000"><B>Overlimit</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
290 <TD COLSPAN=<%$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
294 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
295 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
299 % if ( $cust_pkg->get('last_bill') ) {
302 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
303 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
306 % if ( $cust_pkg->get('bill') ) { #next bill
309 <TD WIDTH="<%$width%>" ALIGN="right"><% $next_bill_or_prepaid_until %> </TD>
310 <% pkg_datestr($cust_pkg, 'bill', $conf) %>
313 % if ( $cust_pkg->get('adjourn') ) {
316 <TD WIDTH="<%$width%>" ALIGN="right">Adjourns </TD>
317 <% pkg_datestr($cust_pkg, 'adjourn', $conf) %>
320 % if ( $cust_pkg->get('expire') ) {
323 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
324 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
327 % if ( $part_pkg->freq ) {
330 <TD COLSPAN=<%$colspan%>>
332 % if ( $curuser->access_right('Suspend customer package') ) {
334 ( <% pkg_suspend_link($cust_pkg) %> )
336 % if ( $curuser->access_right('Suspend customer package later') ) {
338 ( <% pkg_adjourn_link($cust_pkg) %> )
340 % if ( $curuser->access_right('Cancel customer package immediately') ) {
342 ( <% pkg_cancel_link($cust_pkg) %> )
344 % if ( $curuser->access_right('Cancel customer package later') ) {
346 ( <% pkg_expire_link($cust_pkg) %> )
360 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
361 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
363 % #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
364 % foreach my $part_svc ( $cust_pkg->part_svc ) {
366 % #foreach my $service (@{$svcpart->{services}}) {
367 % foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) {
370 <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD>
371 <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD>
375 <TD ALIGN="right" COLSPAN="2" VALIGN="top" STYLE="padding-bottom:1px;padding-top:0px"><FONT SIZE="-2" COLOR="#FFD000">
377 <% $cust_svc->overlimit ? "Overlimit: ". time2str('%b %o %Y' . ($conf->exists('cust_pkg-display_times') ? ' %l:%M %P' : ''), $cust_svc->overlimit) : '' %>
382 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
384 % if ( $curuser->access_right('Recharge customer service')
385 % && $part_svc->svcdb eq 'svc_acct'
386 % && ( $cust_svc->svc_x->seconds ne ''
387 % || $cust_svc->svc_x->upbytes ne ''
388 % || $cust_svc->svc_x->downbytes ne ''
389 % || $cust_svc->svc_x->totalbytes ne ''
392 ( <%svc_recharge_link($cust_svc)%> )
396 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
398 % if ( $curuser->access_right('Unprovision customer service') ) {
399 ( <%svc_unprovision_link($cust_svc)%> )
405 % if ( ! $cust_pkg->get('cancel')
406 % && $curuser->access_right('Provision customer service')
407 % && $part_svc->num_avail
411 <TD COLSPAN=2 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px">
412 <B><% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %></B>
422 % } #end display packages
431 % if ( $cgi->param('fragment') =~ /^cust_pkg(\d+)$/ ) {
433 // IE-specific hack. other browsers listen to #fragments
434 // is this even working? or is the #target redirection just working cause
435 // we set the URL params differently?
436 var el = document.getElementById( 'cust_pkg<% $1 %>' );
437 if ( el ) el.scrollIntoView(true);
442 my( $cust_main ) = @_;
443 my $conf = new FS::Conf;
445 my $curuser = $FS::CurrentUser::CurrentUser;
447 my $packages = get_packages($cust_main, $conf);
454 my $cust_main = shift or return undef;
459 if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
460 || ( $conf->exists('hidecancelledpackages')
461 && ! $cgi->param('showcancelledpackages') )
464 $method = 'ncancelled_pkgs';
466 $method = 'all_pkgs';
469 [ $cust_main->$method() ];
472 sub svc_provision_link {
473 my ($cust_pkg, $part_svc, $conf, $curuser) = @_;
474 ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g;
475 my $num_avail = $part_svc->num_avail;
476 my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'.
477 "svcpart=". $part_svc->svcpart;
479 if ( $part_svc->svcdb eq 'svc_external' #could be generalized
480 && $conf->exists('svc_external-skip_manual')
482 $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart";
487 'part_svc' => $part_svc,
488 'query' => $pkgnum_svcpart,
490 #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
493 my $link = qq!<A CLASS="provision" HREF="$url">!.
494 "Provision $svc_nbsp ($num_avail)</A>";
495 if ( $conf->exists('legacy_link')
496 && $curuser->access_right('View/link unlinked services')
500 qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!.
501 qq!$pkgnum_svcpart">!.
502 "Link to legacy $svc_nbsp ($num_avail)</A>";
507 sub svc_unprovision_link {
508 my $cust_svc = shift or return '';
509 qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum.
510 qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!;
514 my($cust_pkg, $field, $conf) = @_ or return '';
515 return ' ' unless $cust_pkg->get($field);
516 my $format = '<TD align="left"><B>%b</B></TD>'.
517 '<TD align="right"><B> %o,</B></TD>'.
518 '<TD align="right"><B> %Y</B></TD>';
519 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
520 $format .= '<TD ALIGN="right"><B> %l</TD>'.
521 '<TD ALIGN="center"><B>:</B></TD>'.
522 '<TD ALIGN="left"><B>%M</B></TD>'.
523 '<TD ALIGN="left"><B> %P</B></TD>'
524 if $conf->exists('cust_pkg-display_times');
525 my $strip = time2str($format, $cust_pkg->get($field) );
526 $strip =~ s/ (\d)/$1/g;
530 sub pkg_change_link { pkg_link('misc/change_pkg', 'Change package', @_ ); }
532 sub pkg_suspend_link { pkg_popup_link( 'misc/cancel_pkg.html?method=suspend',
540 sub pkg_adjourn_link { pkg_popup_link( 'misc/cancel_pkg.html?method=adjourn',
541 'Suspend later',
548 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
549 sub pkg_expire_link { pkg_link('misc/expire_pkg', 'Cancel later', @_ ); }
550 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); }
552 sub pkg_cancel_link { pkg_popup_link( 'misc/cancel_pkg.html?method=cancel',
560 sub pkg_expire_link { pkg_popup_link( 'misc/cancel_pkg.html?method=expire',
562 'Expire', #"Cancel package $num later"
568 sub svc_recharge_link { svc_popup_link( 'misc/recharge_svc.html',
576 sub order_pkg_link { cust_popup_link( 'misc/order_pkg.html',
577 'Order new package',
586 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
587 'View package events'.
592 my($action, $label, $cust_pkg) = @_;
593 return '' unless $cust_pkg;
594 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
598 my($action, $label, $actionlabel, $color, $cust_pkg) = @_;
599 $action .= '&pkgnum='. $cust_pkg->pkgnum;
600 $actionlabel .= ' package '. $cust_pkg->pkgnum;
601 popup_link($action, $label, $actionlabel, $color);
605 my($action, $label, $actionlabel, $color, $cust_svc) = @_;
606 $action .= '?svcnum='. $cust_svc->svcnum;
607 $actionlabel .= ' service '. $cust_svc->svcnum;
608 popup_link($action, $label, $actionlabel, $color);
611 sub cust_popup_link {
612 my($action, $label, $actionlabel, $color, $cust_main) = @_;
613 $action .= '?'. $cust_main->custnum;
614 popup_link($action, $label, $actionlabel, $color);
618 my($action, $label, $actionlabel, $color, $width) = @_;
619 $color ||= '#333399';
621 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>!;
624 sub pkg_customize_link {
625 my $cust_pkg = shift or return '';
626 my $custnum = $cust_pkg->custnum;
627 qq!<A HREF="${p}edit/part_pkg.cgi?!.
628 "keywords=$custnum;".
629 "clone=". $cust_pkg->part_pkg->pkgpart. ';'.
630 "pkgnum=". $cust_pkg->pkgnum.