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') ) {
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) %>
276 <TD COLSPAN=<%$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <% $billed_or_prepaid %> <% myfreq($part_pkg) %></TD>
280 <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD>
281 <% pkg_datestr($cust_pkg, 'setup', $conf) %>
285 % if ( $cust_pkg->get('last_bill') ) {
288 <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD>
289 <% pkg_datestr($cust_pkg, 'last_bill', $conf) %>
292 % if ( $cust_pkg->get('bill') ) { #next bill
295 <TD WIDTH="<%$width%>" ALIGN="right"><% $next_bill_or_prepaid_until %> </TD>
296 <% pkg_datestr($cust_pkg, 'bill', $conf) %>
299 % if ( $cust_pkg->get('expire') ) {
302 <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD>
303 <% pkg_datestr($cust_pkg, 'expire', $conf) %>
306 % if ( $part_pkg->freq ) {
309 <TD COLSPAN=<%$colspan%>>
311 % if ( $curuser->access_right('Suspend customer package') ) {
313 ( <% pkg_suspend_link($cust_pkg) %> )
315 % if ( $curuser->access_right('Cancel customer package immediately') ) {
317 ( <% pkg_cancel_link($cust_pkg) %> )
319 % if ( $curuser->access_right('Cancel customer package later') ) {
321 ( <% pkg_expire_link($cust_pkg) %> )
335 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
336 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
338 % #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
339 % foreach my $part_svc ( $cust_pkg->part_svc ) {
341 % #foreach my $service (@{$svcpart->{services}}) {
342 % foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) {
345 <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD>
346 <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD>
350 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
352 % if ( $curuser->access_right('Recharge customer service')
353 % && $cust_svc->svcdb eq 'svc_acct'
354 % && ( $cust_svc->svc_x->seconds ne ''
355 % || $cust_svc->svc_x->upbytes ne ''
356 % || $cust_svc->svc_x->downbytes ne ''
357 % || $cust_svc->svc_x->totalbytes ne ''
360 ( <%svc_recharge_link($cust_svc)%> )
364 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
366 % if ( $curuser->access_right('Unprovision customer service') ) {
367 ( <%svc_unprovision_link($cust_svc)%> )
373 % if ( ! $cust_pkg->get('cancel')
374 % && $curuser->access_right('Provision customer service')
375 % && $part_svc->num_avail
379 <TD COLSPAN=2 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px">
380 <B><% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %></B>
390 % } #end display packages
403 % my $cust_main = shift or return undef;
408 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
409 % || ( $conf->exists('hidecancelledpackages')
410 % && ! $cgi->param('showcancelledpackages') )
413 % $method = 'ncancelled_pkgs';
415 % $method = 'all_pkgs';
418 % [ $cust_main->$method() ];
421 %sub svc_provision_link {
422 % my ($cust_pkg, $part_svc, $conf, $curuser) = @_;
423 % ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g;
424 % my $num_avail = $part_svc->num_avail;
425 % my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'.
426 % "svcpart=". $part_svc->svcpart;
428 % if ( $part_svc->svcdb eq 'svc_external' #could be generalized
429 % && $conf->exists('svc_external-skip_manual')
431 % $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart";
433 % $url = FS::UI::Web::svc_url(
435 % 'action' => 'edit',
436 % 'part_svc' => $part_svc,
437 % 'query' => $pkgnum_svcpart,
439 % #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
442 % my $link = qq!<A CLASS="provision" HREF="$url">!.
443 % "Provision $svc_nbsp ($num_avail)</A>";
444 % if ( $conf->exists('legacy_link')
445 % && $curuser->access_right('View/link unlinked services')
449 % qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!.
450 % qq!$pkgnum_svcpart">!.
451 % "Link to legacy $svc_nbsp ($num_avail)</A>";
456 %sub svc_unprovision_link {
457 % my $cust_svc = shift or return '';
458 % qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum.
459 % qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!;
463 % my($cust_pkg, $field, $conf) = @_ or return '';
464 % return ' ' unless $cust_pkg->get($field);
465 % my $format = '<TD align="left"><B>%b</B></TD>'.
466 % '<TD align="right"><B> %o,</B></TD>'.
467 % '<TD align="right"><B> %Y</B></TD>';
468 % #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
469 % $format .= '<TD ALIGN="right"><B> %l</TD>'.
470 % '<TD ALIGN="center"><B>:</B></TD>'.
471 % '<TD ALIGN="left"><B>%M</B></TD>'.
472 % '<TD ALIGN="left"><B> %P</B></TD>'
473 % if $conf->exists('cust_pkg-display_times');
474 % my $strip = time2str($format, $cust_pkg->get($field) );
475 % $strip =~ s/ (\d)/$1/g;
479 %sub pkg_change_link { pkg_link('misc/change_pkg', 'Change package', @_ ); }
481 %sub pkg_suspend_link { pkg_popup_link( 'misc/cancel_pkg.html?method=suspend',
488 %sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
489 %sub pkg_expire_link { pkg_link('misc/expire_pkg', 'Cancel later', @_ ); }
490 %sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); }
492 %sub pkg_cancel_link { pkg_popup_link( 'misc/cancel_pkg.html?method=cancel',
498 %sub pkg_expire_link { pkg_popup_link( 'misc/cancel_pkg.html?method=expire',
499 % 'Cancel later',
500 % 'Expire', #"Cancel package $num later"
505 %sub svc_recharge_link { svc_popup_link( 'misc/recharge_svc.html',
513 % my($action, $label, $cust_pkg) = @_;
514 % return '' unless $cust_pkg;
515 % qq!<a href="${p}$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
518 %sub pkg_popup_link {
519 % my($action, $label, $actionlabel, $cust_pkg) = @_;
520 % $action .= '&pkgnum='. $cust_pkg->pkgnum;
521 % $actionlabel .= ' package '. $cust_pkg->pkgnum;
522 % popup_link($action, $label, $actionlabel, 392);
525 %sub svc_popup_link {
526 % my($action, $label, $actionlabel, $cust_svc) = @_;
527 % $action .= '?svcnum='. $cust_svc->svcnum;
528 % $actionlabel .= ' service '. $cust_svc->svcnum;
529 % popup_link($action, $label, $actionlabel, 392);
533 % my($action, $label, $actionlabel, $width) = @_;
534 % 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>!;
537 %sub pkg_customize_link {
538 % my $cust_pkg = shift or return '';
539 % my $custnum = $cust_pkg->custnum;
540 % qq!<A HREF="${p}edit/part_pkg.cgi?!.
541 % "keywords=$custnum;".
542 % "clone=". $cust_pkg->part_pkg->pkgpart. ';'.
543 % "pkgnum=". $cust_pkg->pkgnum.
544 % qq!">Customize</A>!;