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 <% include('/elements/popup_link.html',
16 'action' => $p. 'edit/quick-charge.html?custnum='. $cust_main->custnum,
17 'label' => 'One-time charge',
18 'actionlabel' => 'One-time charge',
25 % if ( $curuser->access_right('Bulk change customer packages') ) {
26 <% $s++ ? ' | ' : '' %>
27 <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services)
36 % if ( $cust_main->num_cancelled_pkgs ) {
37 % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
38 % || ( $conf->exists('hidecancelledpackages')
39 % && ! $cgi->param('showcancelledpackages')
43 % $cgi->param('showcancelledpackages', 1);
46 ( <a href="<% $cgi->self_url %>">show
48 % $cgi->param('showcancelledpackages', 0);
51 ( <a href="<% $cgi->self_url %>">hide
54 cancelled packages</a> )
59 <% include('/elements/table-grid.html') %>
60 % my $bgcolor1 = '#eeeeee';
61 % my $bgcolor2 = '#ffffff';
65 <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH>
66 <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
67 <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
70 %foreach my $cust_pkg (@$packages) {
72 % my $part_pkg = $cust_pkg->part_pkg;
74 % if ( $bgcolor eq $bgcolor1 ) {
75 % $bgcolor = $bgcolor2;
77 % $bgcolor = $bgcolor1;
81 <!--pkgnum: <% $cust_pkg->pkgnum %>-->
84 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
86 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>" ID="cust_pkg<% $cust_pkg->pkgnum %>"><% $cust_pkg->pkgnum %></A>:
87 <% $part_pkg->pkg %> - <% $part_pkg->comment %>
90 % if ( $cust_pkg->quantity > 1 ) {
91 Quantity: <B><% $cust_pkg->quantity %></B><BR>
95 % unless ( $cust_pkg->get('cancel') ) {
97 % if ( $curuser->access_right('Change customer package') ) { $br=1;
99 ( <%pkg_change_link($cust_pkg)%> )
101 % if ( $curuser->access_right('Edit customer package dates') ) { $br=1;
103 ( <%pkg_dates_link($cust_pkg)%> )
105 % if ( $curuser->access_right('Customize customer package') ) { $br=1;
107 ( <%pkg_customize_link($cust_pkg,$cust_main->custnum)%> )
109 <% $br ? '<BR>' : '' %>
112 % if ( $cust_pkg->num_cust_event
113 % && ( $curuser->access_right('Billing event reports')
114 % || $curuser->access_right('View customer billing events')
117 ( <%pkg_event_link($cust_pkg)%> )
124 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
125 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
128 % my $part_pkg = shift;
129 % my $freq = $part_pkg->freq_pretty;
130 % $freq =~ s/ / /g;
134 % #this should use cust_pkg->status and cust_pkg->statuscolor eventually
135 % #my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
136 % #my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
138 % #false laziness w/edit/REAL_cust_pkg.cgi
139 % my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
140 % unless ( $part_pkg->is_prepaid ) {
141 % $billed_or_prepaid = 'billed';
142 % $last_bill_or_renewed = 'Last bill';
143 % $next_bill_or_prepaid_until = 'Next bill';
145 % $billed_or_prepaid = 'prepaid';
146 % $last_bill_or_renewed = 'Renewed';
147 % $next_bill_or_prepaid_until = 'Prepaid until';
151 % if ( $cust_pkg->get('cancel') ) { #status: cancelled
152 % my $cpr = $cust_pkg->last_cust_pkg_reason('cancel');
154 <% pkg_status_row($cust_pkg, 'Cancelled', 'cancel', 'color'=>'FF0000', conf=>$conf ) %>
156 <% pkg_status_row_colspan(
157 ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
158 'align' => 'right', 'color' => 'ff0000', 'size' => '-2',
162 % unless ( $cust_pkg->get('setup') ) {
164 <% pkg_status_row_colspan('Never billed') %>
168 <% pkg_status_row( $cust_pkg, 'Setup', 'setup', conf=>$conf ) %>
169 <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
170 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf ) %>
171 <% pkg_status_row_if( $cust_pkg, 'Suspended', 'susp', conf=>$conf ) %>
177 % if ( $cust_pkg->get('susp') ) { #status: suspended
178 % my $cpr = $cust_pkg->last_cust_pkg_reason('susp');
180 <% pkg_status_row( $cust_pkg, 'Suspended', 'susp', 'color'=>'FF9900', conf=>$conf ) %>
182 <% pkg_status_row_colspan(
183 ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
184 'align' => 'right', 'color' => 'FF9900', 'size' => '-2',
188 % unless ( $cust_pkg->get('setup') ) {
189 <% pkg_status_row_colspan('Never billed') %>
191 <% pkg_status_row($cust_pkg, 'Setup', 'setup', conf=>$conf ) %>
194 <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
195 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf ) %>
196 % # pkg_status_row($cust_pkg, 'Next bill', 'bill', conf=>$conf)
197 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', conf=>$conf ) %>
200 <TD COLSPAN=<%$colspan%>>
202 % if ( $curuser->access_right('Unsuspend customer package') ) {
203 ( <% pkg_unsuspend_link($cust_pkg) %> )
205 % if ( $curuser->access_right('Cancel customer package immediately') ) {
206 ( <% pkg_cancel_link($cust_pkg) %> )
212 % } else { #status: active
214 % unless ( $cust_pkg->get('setup') ) { #not setup
216 % unless ( $part_pkg->freq ) {
218 <% pkg_status_row_colspan('Not yet billed (one-time charge)') %>
221 <TD COLSPAN=<%$colspan%>>
223 % if ( $curuser->access_right('Cancel customer package immediately') ) {
224 ( <% pkg_cancel_link($cust_pkg) %> )
232 <% pkg_status_row_colspan("Not yet billed ($billed_or_prepaid ". myfreq($part_pkg). ')' ) %>
238 % unless ( $part_pkg->freq ) {
240 <% pkg_status_row_colspan('One-time charge') %>
242 <% pkg_status_row($cust_pkg, 'Billed', 'setup', conf=>$conf) %>
246 % if (scalar($cust_pkg->overlimit)) {
248 <% pkg_status_row_colspan(
250 $billed_or_prepaid. ' '. myfreq($part_pkg),
256 <% pkg_status_row_colspan(
258 $billed_or_prepaid. ' '. myfreq($part_pkg),
264 <% pkg_status_row($cust_pkg, 'Setup', 'setup', conf=>$conf) %>
270 <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
271 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf ) %>
272 <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', conf=>$conf ) %>
273 <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', conf=>$conf ) %>
274 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', conf=>$conf ) %>
276 % if ( $part_pkg->freq ) {
279 <TD COLSPAN=<%$colspan%>>
281 % if ( $curuser->access_right('Suspend customer package') ) {
282 ( <% pkg_suspend_link($cust_pkg) %> )
284 % if ( $curuser->access_right('Suspend customer package later') ) {
285 ( <% pkg_adjourn_link($cust_pkg) %> )
287 % if ( $curuser->access_right('Cancel customer package immediately') ) {
288 ( <% pkg_cancel_link($cust_pkg) %> )
290 % if ( $curuser->access_right('Cancel customer package later') ) {
291 ( <% pkg_expire_link($cust_pkg) %> )
305 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
306 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
308 % #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
309 % foreach my $part_svc ( $cust_pkg->part_svc ) {
311 % #foreach my $service (@{$svcpart->{services}}) {
312 % foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) {
315 <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD>
316 <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD>
317 <TD><% FS::UI::Web::svc_export_links($m, $part_svc, $cust_svc) %></TD>
321 <TD ALIGN="right" COLSPAN="3" VALIGN="top" STYLE="padding-bottom:1px;padding-top:0px"><FONT SIZE="-2" COLOR="#FFD000">
323 <% $cust_svc->overlimit ? "Overlimit: ". time2str('%b %o %Y' . ($conf->exists('cust_pkg-display_times') ? ' %l:%M %P' : ''), $cust_svc->overlimit) : '' %>
328 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
330 % if ( $curuser->access_right('Recharge customer service')
331 % && $part_svc->svcdb eq 'svc_acct'
332 % && ( $cust_svc->svc_x->seconds ne ''
333 % || $cust_svc->svc_x->upbytes ne ''
334 % || $cust_svc->svc_x->downbytes ne ''
335 % || $cust_svc->svc_x->totalbytes ne ''
338 ( <%svc_recharge_link($cust_svc)%> )
342 <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
344 % if ( $curuser->access_right('Unprovision customer service') ) {
345 ( <%svc_unprovision_link($cust_svc)%> )
351 % if ( ! $cust_pkg->get('cancel')
352 % && $curuser->access_right('Provision customer service')
353 % && $part_svc->num_avail
357 <TD COLSPAN=3 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px">
358 <B><% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %></B>
368 % } #end display packages
377 % if ( $cgi->param('fragment') =~ /^cust_pkg(\d+)$/ ) {
379 // IE-specific hack. other browsers listen to #fragments
380 // is this even working? or is the #target redirection just working cause
381 // we set the URL params differently?
382 var el = document.getElementById( 'cust_pkg<% $1 %>' );
383 if ( el ) el.scrollIntoView(true);
388 my( $cust_main ) = @_;
389 my $conf = new FS::Conf;
391 my $curuser = $FS::CurrentUser::CurrentUser;
393 my $packages = get_packages($cust_main, $conf);
395 my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
396 my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
399 my( $cust_pkg, $title, $field, %opt ) = @_;
401 my $color = $opt{'color'};
403 my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
404 $html .= qq(<FONT COLOR="#$color"><B>) if length($color);
405 $html .= qq($title );
406 $html .= qq(</B></FONT>) if length($color);
408 $html .= pkg_datestr($cust_pkg, $field, $opt{conf}).'</TR>';
413 sub pkg_status_row_if {
414 my( $cust_pkg, $title, $field, %opt ) = @_;
416 $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title
417 if ( $field eq 'adjourn' &&
418 $curuser->access_right('Suspend customer package later')
421 $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title
422 if ( $field eq 'expire' &&
423 $curuser->access_right('Cancel customer package later')
426 $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : '';
429 sub pkg_status_row_changed {
430 my( $cust_pkg, %opt ) = @_;
431 return '' unless $cust_pkg->change_date;
432 my $html = pkg_status_row( $cust_pkg, 'Package changed', 'change_date', conf=>$opt{'conf'} );
433 my $old = $cust_pkg->old_cust_pkg;
435 my $part_pkg = $old->part_pkg;
436 my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '.
437 $part_pkg->pkg. ' - '. $part_pkg->comment;
438 $html .= pkg_status_row_colspan( $label, '', size=>'-1', align=>'right' );
443 sub pkg_status_row_colspan {
444 my($title, $addl, %opt) = @_;
446 my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : '';
447 my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : '';
448 my $size = $opt{'size'} ? 'SIZE="'. $opt{'size'}. '"' : '';
450 my $html = qq(<TR><TD COLSPAN=$colspan $align>);
451 $html .= qq(<FONT $color $size>) if length($color) || $size;
452 $html .= qq(<B>) if $color && !$size;
454 $html .= qq(</B>) if $color && !$size;
455 $html .= qq(</FONT>) if length($color) || $size;
456 $html .= ", $addl" if length($addl);
457 $html .= qq(</TD></TR>);
466 my $cust_main = shift or return undef;
471 if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
472 || ( $conf->exists('hidecancelledpackages')
473 && ! $cgi->param('showcancelledpackages') )
476 $method = 'ncancelled_pkgs';
478 $method = 'all_pkgs';
481 [ $cust_main->$method() ];
484 sub svc_provision_link {
485 my ($cust_pkg, $part_svc, $conf, $curuser) = @_;
486 ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g;
487 my $num_avail = $part_svc->num_avail;
488 my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'.
489 "svcpart=". $part_svc->svcpart;
491 if ( $part_svc->svcdb eq 'svc_external' #could be generalized
492 && $conf->exists('svc_external-skip_manual')
494 $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart";
499 'part_svc' => $part_svc,
500 'query' => $pkgnum_svcpart,
502 #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
505 my $link = qq!<A CLASS="provision" HREF="$url">!.
506 "Provision $svc_nbsp ($num_avail)</A>";
507 if ( $conf->exists('legacy_link')
508 && $curuser->access_right('View/link unlinked services')
512 qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!.
513 qq!$pkgnum_svcpart">!.
514 "Link to legacy $svc_nbsp ($num_avail)</A>";
519 sub svc_unprovision_link {
520 my $cust_svc = shift or return '';
521 qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum.
522 qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!;
526 my($cust_pkg, $field, $conf) = @_ or return '';
527 return ' ' unless $cust_pkg->get($field);
528 my $format = '<TD align="left"><B>%b</B></TD>'.
529 '<TD align="right"><B> %o,</B></TD>'.
530 '<TD align="right"><B> %Y</B></TD>';
531 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
532 $format .= '<TD ALIGN="right"><B> %l</TD>'.
533 '<TD ALIGN="center"><B>:</B></TD>'.
534 '<TD ALIGN="left"><B>%M</B></TD>'.
535 '<TD ALIGN="left"><B> %P</B></TD>'
536 if $conf->exists('cust_pkg-display_times');
537 my $strip = time2str($format, $cust_pkg->get($field) );
538 $strip =~ s/ (\d)/$1/g;
542 sub pkg_change_link { include( '/elements/popup_link-cust_pkg.html',
543 { 'action' => $p. 'misc/change_pkg.cgi?dummy=value',
544 'label' => 'Change package',
545 'actionlabel' => 'Change',
551 sub pkg_suspend_link { include( '/elements/popup_link-cust_pkg.html',
552 { 'action' => $p. 'misc/cancel_pkg.html?method=suspend',
553 'label' => 'Suspend now',
554 'actionlabel' => 'Suspend',
555 'color' => '#FF9900',
562 sub pkg_adjourn_link { include( '/elements/popup_link-cust_pkg.html',
563 { 'action' => $p. 'misc/cancel_pkg.html?method=adjourn',
564 'label' => 'Suspend later',
565 'actionlabel' => 'Adjourn',
566 'color' => '#CC6600',
572 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
573 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); }
574 sub pkg_unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); }
575 sub pkg_unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); }
577 sub pkg_cancel_link { include( '/elements/popup_link-cust_pkg.html',
578 { 'action' => $p. 'misc/cancel_pkg.html?method=cancel',
579 'label' => 'Cancel now',
580 'actionlabel' => 'Cancel',
581 'color' => '#ff0000',
587 sub pkg_expire_link { include( '/elements/popup_link-cust_pkg.html',
588 { 'action' => $p. 'misc/cancel_pkg.html?method=expire',
589 'label' => 'Cancel later',
590 'actionlabel' => 'Expire', #"Cancel package $num later"
591 'color' => '#CC0000',
597 sub svc_recharge_link { include( '/elements/popup_link-cust_svc.html',
598 { 'action' => $p. 'misc/recharge_svc.html',
599 'label' => 'Recharge',
600 'actionlabel' => 'Recharge',
601 'color' => '#333399',
607 sub order_pkg_link { include( '/elements/popup_link-cust_main.html',
608 { 'action' => $p. 'misc/order_pkg.html',
609 'label' => 'Order new package',
610 'actionlabel' => 'Order new package',
611 'color' => '#333399',
612 'cust_main' => shift,
613 'closetext' => 'Close',
620 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
621 'View package events'.
626 my($action, $label, $cust_pkg) = @_;
627 return '' unless $cust_pkg;
628 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
631 sub pkg_customize_link {
632 my $cust_pkg = shift or return '';
633 my $custnum = $cust_pkg->custnum;
634 qq!<A HREF="${p}edit/part_pkg.cgi?!.
635 "clone=". $cust_pkg->part_pkg->pkgpart. ';'.
636 "pkgnum=". $cust_pkg->pkgnum.