1 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
2 <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
4 %#this should use cust_pkg->status and cust_pkg->statuscolor eventually
6 % if ( $cust_pkg->get('cancel') ) { #status: cancelled
7 % my $cpr = $cust_pkg->last_cust_pkg_reason('cancel');
9 <% pkg_status_row($cust_pkg, 'Cancelled', 'cancel', 'color'=>'FF0000', %opt ) %>
11 <% pkg_status_row_colspan( $cust_pkg,
12 ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
13 'align'=>'right', 'color'=>'ff0000', 'size'=>'-2', 'colspan'=>$colspan,
18 % unless ( $cust_pkg->get('setup') ) {
20 <% pkg_status_row_colspan( $cust_pkg, 'Never billed', '', 'colspan'=>$colspan, %opt, ) %>
24 <% pkg_status_row( $cust_pkg, 'Setup', 'setup', %opt ) %>
25 <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
26 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
27 <% pkg_status_row_if( $cust_pkg, 'Suspended', 'susp', %opt, curuser=>$curuser ) %>
33 % if ( $cust_pkg->get('susp') ) { #status: suspended
34 % my $cpr = $cust_pkg->last_cust_pkg_reason('susp');
36 <% pkg_status_row( $cust_pkg, 'Suspended', 'susp', 'color'=>'FF9900', %opt ) %>
38 <% pkg_status_row_colspan( $cust_pkg,
39 ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
40 'align'=>'right', 'color'=>'FF9900', 'size'=>'-2', 'colspan'=>$colspan,
45 % unless ( $cust_pkg->get('setup') ) {
46 <% pkg_status_row_colspan( $cust_pkg, 'Never billed', '', 'colspan'=>$colspan, %opt ) %>
48 <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt ) %>
51 <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
52 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
53 % # pkg_status_row($cust_pkg, 'Next bill', 'bill', %opt)
54 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
57 <TD COLSPAN=<%$colspan%>>
59 % if ( $curuser->access_right('Unsuspend customer package') ) {
60 ( <% pkg_unsuspend_link($cust_pkg) %> )
62 % if ( $curuser->access_right('Cancel customer package immediately') ) {
63 ( <% pkg_cancel_link($cust_pkg) %> )
69 % } else { #status: active
71 % unless ( $cust_pkg->get('setup') ) { #not setup
73 % unless ( $part_pkg->freq ) {
75 <% pkg_status_row_colspan( $cust_pkg, 'Not yet billed (one-time charge)', '', 'colspan'=>$colspan, %opt ) %>
77 <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
80 <TD COLSPAN=<%$colspan%>>
82 % if ( $curuser->access_right('Cancel customer package immediately') ) {
83 ( <% pkg_cancel_link($cust_pkg) %> )
91 <% pkg_status_row_colspan($cust_pkg, "Not yet billed ($billed_or_prepaid ". myfreq($part_pkg). ')', '', 'colspan'=>$colspan, %opt ) %>
93 <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
99 % unless ( $part_pkg->freq ) {
101 <% pkg_status_row_colspan($cust_pkg, 'One-time charge', '', 'colspan'=>$colspan, %opt ) %>
103 <% pkg_status_row($cust_pkg, 'Billed', 'setup', %opt) %>
107 % if (scalar($cust_pkg->overlimit)) {
109 <% pkg_status_row_colspan( $cust_pkg,
111 $billed_or_prepaid. ' '. myfreq($part_pkg),
112 'color'=>'FFD000', 'colspan'=>$colspan,
118 <% pkg_status_row_colspan( $cust_pkg,
120 $billed_or_prepaid. ' '. myfreq($part_pkg),
121 'color'=>'00CC00', 'colspan'=>$colspan,
127 <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt) %>
133 % if ( $opt{'cust_pkg-show_autosuspend'} ) {
134 % my $autosuspend = pkg_autosuspend_time( $cust_pkg );
135 % $cust_pkg->set('autosuspend', $autosuspend) if $autosuspend;
138 <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
139 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
140 <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', %opt, curuser=>$curuser ) %>
141 <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', %opt) %>
142 <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', %opt, curuser=>$curuser ) %>
143 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
145 % if ( $part_pkg->freq ) {
148 <TD COLSPAN=<%$colspan%>>
150 % if ( $curuser->access_right('Suspend customer package') ) {
151 ( <% pkg_suspend_link($cust_pkg) %> )
153 % if ( $curuser->access_right('Suspend customer package later') ) {
154 ( <% pkg_adjourn_link($cust_pkg) %> )
156 % if ( $curuser->access_right('Delay suspension events') ) {
157 ( <% pkg_delay_link($cust_pkg) %> )
159 % if ( $curuser->access_right('Cancel customer package immediately') ) {
160 ( <% pkg_cancel_link($cust_pkg) %> )
162 % if ( $curuser->access_right('Cancel customer package later') ) {
163 ( <% pkg_expire_link($cust_pkg) %> )
180 my $bgcolor = $opt{'bgcolor'};
181 my $cust_pkg = $opt{'cust_pkg'};
182 my $part_pkg = $opt{'part_pkg'};
183 my $curuser = $FS::CurrentUser::CurrentUser;
184 my $colspan = $opt{'cust_pkg-display_times'} ? 8 : 4;
185 my $width = $opt{'cust_pkg-display_times'} ? '38%' : '56%';
187 #false laziness w/edit/REAL_cust_pkg.cgi
188 my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
189 unless ( $part_pkg->is_prepaid ) {
190 $billed_or_prepaid = 'billed';
191 $last_bill_or_renewed = 'Last bill';
192 $next_bill_or_prepaid_until = 'Next bill';
194 $billed_or_prepaid = 'prepaid';
195 $last_bill_or_renewed = 'Renewed';
196 $next_bill_or_prepaid_until = 'Prepaid until';
202 my $part_pkg = shift;
203 my $freq = $part_pkg->freq_pretty;
204 $freq =~ s/ / /g;
208 #false laziness w/package.html
210 my($action, $label, $cust_pkg) = @_;
211 return '' unless $cust_pkg;
212 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
216 my( $cust_pkg, $title, $field, %opt ) = @_;
218 my $color = $opt{'color'};
220 my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
221 $html .= qq(<FONT COLOR="#$color"><B>) if length($color);
222 $html .= qq($title );
223 $html .= qq(</B></FONT>) if length($color);
225 if ( $opt{'pkg_balances'} && ! $cust_pkg->{_printed_balance}++ ) { #kludge
226 $html .= ' (Balance: <B>'. $opt{'money_char'}.
227 $cust_pkg->cust_main->balance_pkgnum($cust_pkg->pkgnum).
232 $html .= pkg_datestr($cust_pkg, $field, %opt). '</TR>';
237 sub pkg_status_row_if {
238 my( $cust_pkg, $title, $field, %opt ) = @_;
240 $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title
241 if ( $field eq 'adjourn' &&
242 $opt{curuser}->access_right('Suspend customer package later')
245 $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title
246 if ( $field eq 'expire' &&
247 $opt{curuser}->access_right('Cancel customer package later')
250 $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : '';
253 sub pkg_status_row_changed {
254 my( $cust_pkg, %opt ) = @_;
256 return '' unless $cust_pkg->change_date;
259 pkg_status_row( $cust_pkg, 'Package changed', 'change_date', %opt );
261 my $old = $cust_pkg->old_cust_pkg;
263 my $part_pkg = $old->part_pkg;
264 my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '.
265 $part_pkg->pkg_comment(nopartpkg => 1);
266 $html .= pkg_status_row_colspan( $cust_pkg, $label, '',
269 'colspan' => $opt{'colspan'},
276 sub pkg_status_row_colspan {
277 my($cust_pkg, $title, $addl, %opt) = @_;
279 my $colspan = $opt{'colspan'};
281 my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : '';
282 my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : '';
283 my $size = $opt{'size'} ? 'SIZE="'. $opt{'size'}. '"' : '';
285 my $html = qq(<TR><TD COLSPAN=$colspan $align>);
286 $html .= qq(<FONT $color $size>) if length($color) || $size;
287 $html .= qq(<B>) if $color && !$size;
289 $html .= qq(</B>) if $color && !$size;
290 $html .= qq(</FONT>) if length($color) || $size;
291 $html .= ", $addl" if length($addl);
293 if ( $opt{'pkg-balances'} && ! $cust_pkg->{_printed_balance}++ ) { #kludge
294 $html .= ' (Balance: <B>'. $opt{'money_char'}.
295 $cust_pkg->cust_main->balance_pkgnum($cust_pkg->pkgnum).
299 $html .= qq(</TD></TR>);
306 my($cust_pkg, $field, %opt) = @_ or return '';
307 return ' ' unless $cust_pkg->get($field);
308 my $format = '<TD align="left"><B>%b</B></TD>'.
309 '<TD align="right"><B> %o,</B></TD>'.
310 '<TD align="right"><B> %Y</B></TD>';
311 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
312 $format .= '<TD ALIGN="right"><B> %l</TD>'.
313 '<TD ALIGN="center"><B>:</B></TD>'.
314 '<TD ALIGN="left"><B>%M</B></TD>'.
315 '<TD ALIGN="left"><B> %P</B></TD>'
316 if $opt{'cust_pkg-display_times'};
317 my $strip = time2str($format, $cust_pkg->get($field) );
318 $strip =~ s/ (\d)/$1/g;
322 sub pkg_suspend_link {
323 include( '/elements/popup_link-cust_pkg.html',
324 'action' => $p. 'misc/cancel_pkg.html?method=suspend',
325 'label' => 'Suspend now',
326 'actionlabel' => 'Suspend',
327 'color' => '#FF9900',
332 sub pkg_adjourn_link {
333 include( '/elements/popup_link-cust_pkg.html',
334 'action' => $p. 'misc/cancel_pkg.html?method=adjourn',
335 'label' => 'Suspend later',
336 'actionlabel' => 'Adjourn',
337 'color' => '#CC6600',
343 include( '/elements/popup_link-cust_pkg.html',
344 'action' => $p. 'misc/delay_susp_pkg.html',
345 'label' => 'Delay suspend',
346 'actionlabel' => 'Delay suspend for',
351 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
352 sub pkg_unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); }
353 sub pkg_unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); }
355 sub pkg_cancel_link {
356 include( '/elements/popup_link-cust_pkg.html',
357 'action' => $p. 'misc/cancel_pkg.html?method=cancel',
358 'label' => 'Cancel now',
359 'actionlabel' => 'Cancel',
360 'color' => '#ff0000',
365 sub pkg_expire_link {
366 include( '/elements/popup_link-cust_pkg.html',
367 'action' => $p. 'misc/cancel_pkg.html?method=expire',
368 'label' => 'Cancel later',
369 'actionlabel' => 'Expire', #"Cancel package $num later"
370 'color' => '#CC0000',
375 sub svc_recharge_link {
376 include( '/elements/popup_link-cust_svc.html',
377 'action' => $p. 'misc/recharge_svc.html',
378 'label' => 'Recharge',
379 'actionlabel' => 'Recharge',
380 'color' => '#333399',
385 sub pkg_autosuspend_time {
386 my $cust_pkg = shift or return '';
389 my $pending_suspend = 0;
390 #this seems to be extremely inefficient... and is slowing down all customer
394 grep { $_->part_event->action eq 'suspend' }
395 @{$cust_pkg->cust_main->due_cust_event( time => $time + 86400*$days,
401 $pending_suspend = 1;
405 $pending_suspend ? time + ($days + 1) * 86400 : '';