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 ) %>
79 ( $part_pkg->freq ? 'Start billing' : 'Bill on' ),
86 <TD COLSPAN=<%$colspan%>>
88 % if ( $curuser->access_right('Cancel customer package immediately') ) {
89 ( <% pkg_cancel_link($cust_pkg) %> )
97 <% pkg_status_row_colspan($cust_pkg, "Not yet billed ($billed_or_prepaid ". myfreq($part_pkg). ')', '', 'colspan'=>$colspan, %opt ) %>
99 <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
105 % unless ( $part_pkg->freq ) {
107 <% pkg_status_row_colspan($cust_pkg, 'One-time charge', '', 'colspan'=>$colspan, %opt ) %>
109 <% pkg_status_row($cust_pkg, 'Billed', 'setup', %opt) %>
113 % if (scalar($cust_pkg->overlimit)) {
115 <% pkg_status_row_colspan( $cust_pkg,
117 $billed_or_prepaid. ' '. myfreq($part_pkg),
118 'color'=>'FFD000', 'colspan'=>$colspan,
124 <% pkg_status_row_colspan( $cust_pkg,
126 $billed_or_prepaid. ' '. myfreq($part_pkg),
127 'color'=>'00CC00', 'colspan'=>$colspan,
133 <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt) %>
139 % if ( $opt{'cust_pkg-show_autosuspend'} ) {
140 % my $autosuspend = pkg_autosuspend_time( $cust_pkg );
141 % $cust_pkg->set('autosuspend', $autosuspend) if $autosuspend;
144 <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
145 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
146 <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', %opt, curuser=>$curuser ) %>
147 <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', %opt) %>
148 <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', %opt, curuser=>$curuser ) %>
149 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
151 % if ( $part_pkg->freq ) {
154 <TD COLSPAN=<%$colspan%>>
156 % if ( $curuser->access_right('Suspend customer package') ) {
157 ( <% pkg_suspend_link($cust_pkg) %> )
159 % if ( $curuser->access_right('Suspend customer package later') ) {
160 ( <% pkg_adjourn_link($cust_pkg) %> )
162 % if ( $curuser->access_right('Delay suspension events') ) {
163 ( <% pkg_delay_link($cust_pkg) %> )
165 % if ( $curuser->access_right('Cancel customer package immediately') ) {
166 ( <% pkg_cancel_link($cust_pkg) %> )
168 % if ( $curuser->access_right('Cancel customer package later') ) {
169 ( <% pkg_expire_link($cust_pkg) %> )
186 my $bgcolor = $opt{'bgcolor'};
187 my $cust_pkg = $opt{'cust_pkg'};
188 my $part_pkg = $opt{'part_pkg'};
189 my $curuser = $FS::CurrentUser::CurrentUser;
190 my $colspan = $opt{'cust_pkg-display_times'} ? 8 : 4;
191 my $width = $opt{'cust_pkg-display_times'} ? '38%' : '56%';
193 #false laziness w/edit/REAL_cust_pkg.cgi
194 my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
195 unless ( $part_pkg->is_prepaid ) {
196 $billed_or_prepaid = 'billed';
197 $last_bill_or_renewed = 'Last bill';
198 $next_bill_or_prepaid_until = 'Next bill';
200 $billed_or_prepaid = 'prepaid';
201 $last_bill_or_renewed = 'Renewed';
202 $next_bill_or_prepaid_until = 'Prepaid until';
208 my $part_pkg = shift;
209 my $freq = $part_pkg->freq_pretty;
210 $freq =~ s/ / /g;
214 #false laziness w/package.html
216 my($action, $label, $cust_pkg) = @_;
217 return '' unless $cust_pkg;
218 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
222 my( $cust_pkg, $title, $field, %opt ) = @_;
224 my $color = $opt{'color'};
226 my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
227 $html .= qq(<FONT COLOR="#$color"><B>) if length($color);
228 $html .= qq($title );
229 $html .= qq(</B></FONT>) if length($color);
231 if ( $opt{'pkg_balances'} && ! $cust_pkg->{_printed_balance}++ ) { #kludge
232 $html .= ' (Balance: <B>'. $opt{'money_char'}.
233 $cust_pkg->cust_main->balance_pkgnum($cust_pkg->pkgnum).
238 $html .= pkg_datestr($cust_pkg, $field, %opt). '</TR>';
243 sub pkg_status_row_if {
244 my( $cust_pkg, $title, $field, %opt ) = @_;
246 $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title
247 if ( $field eq 'adjourn' &&
248 $opt{curuser}->access_right('Suspend customer package later')
251 $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title
252 if ( $field eq 'expire' &&
253 $opt{curuser}->access_right('Cancel customer package later')
256 $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : '';
259 sub pkg_status_row_changed {
260 my( $cust_pkg, %opt ) = @_;
262 return '' unless $cust_pkg->change_date;
265 pkg_status_row( $cust_pkg, 'Package changed', 'change_date', %opt );
267 my $old = $cust_pkg->old_cust_pkg;
269 my $part_pkg = $old->part_pkg;
270 my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '.
271 $part_pkg->pkg_comment(nopartpkg => 1);
272 $html .= pkg_status_row_colspan( $cust_pkg, $label, '',
275 'colspan' => $opt{'colspan'},
282 sub pkg_status_row_colspan {
283 my($cust_pkg, $title, $addl, %opt) = @_;
285 my $colspan = $opt{'colspan'};
287 my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : '';
288 my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : '';
289 my $size = $opt{'size'} ? 'SIZE="'. $opt{'size'}. '"' : '';
291 my $html = qq(<TR><TD COLSPAN=$colspan $align>);
292 $html .= qq(<FONT $color $size>) if length($color) || $size;
293 $html .= qq(<B>) if $color && !$size;
295 $html .= qq(</B>) if $color && !$size;
296 $html .= qq(</FONT>) if length($color) || $size;
297 $html .= ", $addl" if length($addl);
299 if ( $opt{'pkg-balances'} && ! $cust_pkg->{_printed_balance}++ ) { #kludge
300 $html .= ' (Balance: <B>'. $opt{'money_char'}.
301 $cust_pkg->cust_main->balance_pkgnum($cust_pkg->pkgnum).
305 $html .= qq(</TD></TR>);
312 my($cust_pkg, $field, %opt) = @_ or return '';
313 return ' ' unless $cust_pkg->get($field);
314 my $format = '<TD align="left"><B>%b</B></TD>'.
315 '<TD align="right"><B> %o,</B></TD>'.
316 '<TD align="right"><B> %Y</B></TD>';
317 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
318 $format .= '<TD ALIGN="right"><B> %l</TD>'.
319 '<TD ALIGN="center"><B>:</B></TD>'.
320 '<TD ALIGN="left"><B>%M</B></TD>'.
321 '<TD ALIGN="left"><B> %P</B></TD>'
322 if $opt{'cust_pkg-display_times'};
323 my $strip = time2str($format, $cust_pkg->get($field) );
324 $strip =~ s/ (\d)/$1/g;
328 sub pkg_suspend_link {
329 include( '/elements/popup_link-cust_pkg.html',
330 'action' => $p. 'misc/cancel_pkg.html?method=suspend',
331 'label' => 'Suspend now',
332 'actionlabel' => 'Suspend',
333 'color' => '#FF9900',
338 sub pkg_adjourn_link {
339 include( '/elements/popup_link-cust_pkg.html',
340 'action' => $p. 'misc/cancel_pkg.html?method=adjourn',
341 'label' => 'Suspend later',
342 'actionlabel' => 'Adjourn',
343 'color' => '#CC6600',
349 include( '/elements/popup_link-cust_pkg.html',
350 'action' => $p. 'misc/delay_susp_pkg.html',
351 'label' => 'Delay suspend',
352 'actionlabel' => 'Delay suspend for',
357 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
358 sub pkg_unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); }
359 sub pkg_unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); }
361 sub pkg_cancel_link {
362 include( '/elements/popup_link-cust_pkg.html',
363 'action' => $p. 'misc/cancel_pkg.html?method=cancel',
364 'label' => 'Cancel now',
365 'actionlabel' => 'Cancel',
366 'color' => '#ff0000',
371 sub pkg_expire_link {
372 include( '/elements/popup_link-cust_pkg.html',
373 'action' => $p. 'misc/cancel_pkg.html?method=expire',
374 'label' => 'Cancel later',
375 'actionlabel' => 'Expire', #"Cancel package $num later"
376 'color' => '#CC0000',
381 sub svc_recharge_link {
382 include( '/elements/popup_link-cust_svc.html',
383 'action' => $p. 'misc/recharge_svc.html',
384 'label' => 'Recharge',
385 'actionlabel' => 'Recharge',
386 'color' => '#333399',
391 sub pkg_autosuspend_time {
392 my $cust_pkg = shift or return '';
395 my $pending_suspend = 0;
396 #this seems to be extremely inefficient... and is slowing down all customer
400 grep { $_->part_event->action eq 'suspend' }
401 @{$cust_pkg->cust_main->due_cust_event( time => $time + 86400*$days,
407 $pending_suspend = 1;
411 $pending_suspend ? time + ($days + 1) * 86400 : '';