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 <% popup_link('edit/quick-charge.html?custnum='. $cust_main->custnum, 'One-time charge', 'One-time charge', 545) %>
22 % if ( $curuser->access_right('Bulk change customer packages') ) {
24 <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services)
33 % if ( $cust_main->num_cancelled_pkgs ) {
34 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
35 % || ( $conf->exists('hidecancelledpackages')
36 % && ! $cgi->param('showcancelledpackages')
40 % $cgi->param('showcancelledpackages', 1);
43 ( <a href="<% $cgi->self_url %>">show
45 % $cgi->param('showcancelledpackages', 0);
48 ( <a href="<% $cgi->self_url %>">hide
51 cancelled packages</a> )
56 <% include('/elements/table-grid.html') %>
57 % my $bgcolor1 = '#eeeeee';
58 % my $bgcolor2 = '#ffffff';
62 <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH>
63 <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
64 <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
67 %foreach my $cust_pkg (@$packages) {
69 % my $part_pkg = $cust_pkg->part_pkg;
71 % if ( $bgcolor eq $bgcolor1 ) {
72 % $bgcolor = $bgcolor2;
74 % $bgcolor = $bgcolor1;
78 <!--pkgnum: <% $cust_pkg->pkgnum %>-->
80 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
81 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"><% $cust_pkg->pkgnum %></A>:
82 <% $part_pkg->pkg %> - <% $part_pkg->comment %><BR>
84 % unless ( $cust_pkg->get('cancel') ) {
85 % if ( $curuser->access_right('Change customer package') ) {
87 ( <%pkg_change_link($cust_pkg)%> )
89 % if ( $curuser->access_right('Edit customer package dates') ) {
91 ( <%pkg_dates_link($cust_pkg)%> )
93 % if ( $curuser->access_right('Customize customer package') ) {
95 ( <%pkg_customize_link($cust_pkg,$cust_main->custnum)%> )
101 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
102 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
105 % my $part_pkg = shift;
106 % my $freq = $part_pkg->freq_pretty;
107 % $freq =~ s/ / /g;
111 % #this should use cust_pkg->status and cust_pkg->statuscolor eventually
113 % my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
114 % my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
116 % #false laziness w/edit/REAL_cust_pkg.cgi
117 % my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
118 % unless ( $part_pkg->is_prepaid ) {
119 % $billed_or_prepaid = 'billed';
120 % $last_bill_or_renewed = 'Last bill';
121 % $next_bill_or_prepaid_until = 'Next bill';
123 % $billed_or_prepaid = 'prepaid';
124 % $last_bill_or_renewed = 'Renewed';
125 % $next_bill_or_prepaid_until = 'Prepaid until';
129 % if ( $cust_pkg->get('cancel') ) {
130 <!-- #status: cancelled -->
133 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD>
134 <% pkg_datestr($cust_pkg, 'cancel', $conf) %>
137 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000" SIZE="-2">
138 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
141 % unless ( $cust_pkg->get('setup') ) {
145 <TD COLSPAN=<%$colspan%>>Never billed</TD>
151 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
152 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
154 % if ( $cust_pkg->get('last_bill') ) {
157 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
158 <% pkg_datestr($cust_pkg, 'last_bill',$conf) %>
161 % if ( $cust_pkg->get('susp') ) {
164 <TD WIDTH="<%$width%>" ALIGN="right">Suspended </TD>
165 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
170 % if ( $cust_pkg->get('susp') ) {
171 <!-- #status: suspended -->
174 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD>
175 <% pkg_datestr($cust_pkg, 'susp', $conf) %>
178 <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900" SIZE="-2">
179 <% $cust_pkg->last_reason ? $cust_pkg->last_reason->reason : '' %>
182 % unless ( $cust_pkg->get('setup') ) {
186 <TD COLSPAN=<%$colspan%>>Never billed</TD>
192 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
193 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
196 % if ( $cust_pkg->get('last_bill') ) {
199 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
200 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
205 <!-- # next bill ?? -->
206 % if ( $cust_pkg->get('expire') ) {
209 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
210 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
216 <TD COLSPAN=<%$colspan%>>
218 % if ( $curuser->access_right('Unsuspend customer package') ) {
220 ( <% pkg_unsuspend_link($cust_pkg) %> )
222 % if ( $curuser->access_right('Cancel customer package immediately') ) {
224 ( <% pkg_cancel_link($cust_pkg) %> )
231 <!-- #status: active -->
232 % unless ( $cust_pkg->get('setup') ) {
234 % unless ( $part_pkg->freq ) {
238 <TD COLSPAN=<%$colspan%>>Not yet billed (one-time charge)</TD>
242 <TD COLSPAN=<%$colspan%>>
244 % if ( $curuser->access_right('Cancel customer package immediately') ) {
246 ( <% pkg_cancel_link($cust_pkg) %> )
256 <TD COLSPAN=<%$colspan%>>Not yet billed (<% $billed_or_prepaid %> <% myfreq($part_pkg) %>)</TD>
261 % unless ( $part_pkg->freq ) {
265 <TD COLSPAN=<%$colspan%>>One-time charge</TD>
269 <TD WIDTH="<%$width%>" ALIGN="right">Billed </TD>
270 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
273 % if (scalar($cust_pkg->overlimit)) {
275 <TD COLSPAN=<%$colspan%>><FONT COLOR="#FFD000"><B>Overlimit</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
279 <TD COLSPAN=<%$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
283 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
284 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
288 % if ( $cust_pkg->get('last_bill') ) {
291 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
292 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
295 % if ( $cust_pkg->get('bill') ) { #next bill
298 <TD WIDTH="<%$width%>" ALIGN="right"><% $next_bill_or_prepaid_until %> </TD>
299 <% pkg_datestr($cust_pkg, 'bill', $conf) %>
302 % if ( $cust_pkg->get('expire') ) {
305 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
306 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
309 % if ( $part_pkg->freq ) {
312 <TD COLSPAN=<%$colspan%>>
314 % if ( $curuser->access_right('Suspend customer package') ) {
316 ( <% pkg_suspend_link($cust_pkg) %> )
318 % if ( $curuser->access_right('Cancel customer package immediately') ) {
320 ( <% pkg_cancel_link($cust_pkg) %> )
322 % if ( $curuser->access_right('Cancel customer package later') ) {
324 ( <% pkg_expire_link($cust_pkg) %> )
338 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
339 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
341 % #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
342 % foreach my $part_svc ( $cust_pkg->part_svc ) {
344 % #foreach my $service (@{$svcpart->{services}}) {
345 % foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) {
348 <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD>
349 <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD>
353 <TD ALIGN="right" COLSPAN="2" VALIGN="top" STYLE="padding-bottom:1px;padding-top:0px"><FONT SIZE="-2" COLOR="#FFD000">
355 <% $cust_svc->overlimit ? "Overlimit: ". time2str('%b %o %Y' . ($conf->exists('cust_pkg-display_times') ? ' %l:%M %P' : ''), $cust_svc->overlimit) : '' %>
360 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
362 % if ( $curuser->access_right('Recharge customer service')
363 % && $part_svc->svcdb eq 'svc_acct'
364 % && ( $cust_svc->svc_x->seconds ne ''
365 % || $cust_svc->svc_x->upbytes ne ''
366 % || $cust_svc->svc_x->downbytes ne ''
367 % || $cust_svc->svc_x->totalbytes ne ''
370 ( <%svc_recharge_link($cust_svc)%> )
374 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
376 % if ( $curuser->access_right('Unprovision customer service') ) {
377 ( <%svc_unprovision_link($cust_svc)%> )
383 % if ( ! $cust_pkg->get('cancel')
384 % && $curuser->access_right('Provision customer service')
385 % && $part_svc->num_avail
389 <TD COLSPAN=2 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px">
390 <B><% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %></B>
400 % } #end display packages
413 % my $cust_main = shift or return undef;
418 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
419 % || ( $conf->exists('hidecancelledpackages')
420 % && ! $cgi->param('showcancelledpackages') )
423 % $method = 'ncancelled_pkgs';
425 % $method = 'all_pkgs';
428 % [ $cust_main->$method() ];
431 %sub svc_provision_link {
432 % my ($cust_pkg, $part_svc, $conf, $curuser) = @_;
433 % ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g;
434 % my $num_avail = $part_svc->num_avail;
435 % my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'.
436 % "svcpart=". $part_svc->svcpart;
438 % if ( $part_svc->svcdb eq 'svc_external' #could be generalized
439 % && $conf->exists('svc_external-skip_manual')
441 % $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart";
445 % 'action' => 'edit',
446 % 'part_svc' => $part_svc,
447 % 'query' => $pkgnum_svcpart,
449 % #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
452 % my $link = qq!<A CLASS="provision" HREF="$url">!.
453 % "Provision $svc_nbsp ($num_avail)</A>";
454 % if ( $conf->exists('legacy_link')
455 % && $curuser->access_right('View/link unlinked services')
459 % qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!.
460 % qq!$pkgnum_svcpart">!.
461 % "Link to legacy $svc_nbsp ($num_avail)</A>";
466 %sub svc_unprovision_link {
467 % my $cust_svc = shift or return '';
468 % qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum.
469 % qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!;
473 % my($cust_pkg, $field, $conf) = @_ or return '';
474 % return ' ' unless $cust_pkg->get($field);
475 % my $format = '<TD align="left"><B>%b</B></TD>'.
476 % '<TD align="right"><B> %o,</B></TD>'.
477 % '<TD align="right"><B> %Y</B></TD>';
478 % #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
479 % $format .= '<TD ALIGN="right"><B> %l</TD>'.
480 % '<TD ALIGN="center"><B>:</B></TD>'.
481 % '<TD ALIGN="left"><B>%M</B></TD>'.
482 % '<TD ALIGN="left"><B> %P</B></TD>'
483 % if $conf->exists('cust_pkg-display_times');
484 % my $strip = time2str($format, $cust_pkg->get($field) );
485 % $strip =~ s/ (\d)/$1/g;
489 %sub pkg_change_link { pkg_link('misc/change_pkg', 'Change package', @_ ); }
491 %sub pkg_suspend_link { pkg_popup_link( 'misc/cancel_pkg.html?method=suspend',
498 %sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
499 %sub pkg_expire_link { pkg_link('misc/expire_pkg', 'Cancel later', @_ ); }
500 %sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); }
502 %sub pkg_cancel_link { pkg_popup_link( 'misc/cancel_pkg.html?method=cancel',
508 %sub pkg_expire_link { pkg_popup_link( 'misc/cancel_pkg.html?method=expire',
509 % 'Cancel later',
510 % 'Expire', #"Cancel package $num later"
515 %sub svc_recharge_link { svc_popup_link( 'misc/recharge_svc.html',
523 % my($action, $label, $cust_pkg) = @_;
524 % return '' unless $cust_pkg;
525 % qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
528 %sub pkg_popup_link {
529 % my($action, $label, $actionlabel, $cust_pkg) = @_;
530 % $action .= '&pkgnum='. $cust_pkg->pkgnum;
531 % $actionlabel .= ' package '. $cust_pkg->pkgnum;
532 % popup_link($action, $label, $actionlabel, 392);
535 %sub svc_popup_link {
536 % my($action, $label, $actionlabel, $cust_svc) = @_;
537 % $action .= '?svcnum='. $cust_svc->svcnum;
538 % $actionlabel .= ' service '. $cust_svc->svcnum;
539 % popup_link($action, $label, $actionlabel, 392);
543 % my($action, $label, $actionlabel, $width) = @_;
544 % 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 ); return false;">$label</A>!;
547 %sub pkg_customize_link {
548 % my $cust_pkg = shift or return '';
549 % my $custnum = $cust_pkg->custnum;
550 % qq!<A HREF="${p}edit/part_pkg.cgi?!.
551 % "keywords=$custnum;".
552 % "clone=". $cust_pkg->part_pkg->pkgpart. ';'.
553 % "pkgnum=". $cust_pkg->pkgnum.
554 % qq!">Customize</A>!;