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(
12 ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
13 'align'=>'right', 'color'=>'ff0000', 'size'=>'-2', 'colspan'=>$colspan,
17 % unless ( $cust_pkg->get('setup') ) {
19 <% pkg_status_row_colspan('Never billed', '', 'colspan'=>$colspan, ) %>
23 <% pkg_status_row( $cust_pkg, 'Setup', 'setup', %opt ) %>
24 <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
25 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
26 <% pkg_status_row_if( $cust_pkg, 'Suspended', 'susp', %opt, curuser=>$curuser ) %>
32 % if ( $cust_pkg->get('susp') ) { #status: suspended
33 % my $cpr = $cust_pkg->last_cust_pkg_reason('susp');
35 <% pkg_status_row( $cust_pkg, 'Suspended', 'susp', 'color'=>'FF9900', %opt ) %>
37 <% pkg_status_row_colspan(
38 ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
39 'align'=>'right', 'color'=>'FF9900', 'size'=>'-2', 'colspan'=>$colspan,
43 % unless ( $cust_pkg->get('setup') ) {
44 <% pkg_status_row_colspan('Never billed', '', 'colspan'=>$colspan ) %>
46 <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt ) %>
49 <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
50 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
51 % # pkg_status_row($cust_pkg, 'Next bill', 'bill', %opt)
52 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
55 <TD COLSPAN=<%$colspan%>>
57 % if ( $curuser->access_right('Unsuspend customer package') ) {
58 ( <% pkg_unsuspend_link($cust_pkg) %> )
60 % if ( $curuser->access_right('Cancel customer package immediately') ) {
61 ( <% pkg_cancel_link($cust_pkg) %> )
67 % } else { #status: active
69 % unless ( $cust_pkg->get('setup') ) { #not setup
71 % unless ( $part_pkg->freq ) {
73 <% pkg_status_row_colspan('Not yet billed (one-time charge)', '', 'colspan'=>$colspan, ) %>
75 <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
78 <TD COLSPAN=<%$colspan%>>
80 % if ( $curuser->access_right('Cancel customer package immediately') ) {
81 ( <% pkg_cancel_link($cust_pkg) %> )
89 <% pkg_status_row_colspan("Not yet billed ($billed_or_prepaid ". myfreq($part_pkg). ')', '', 'colspan'=>$colspan ) %>
91 <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
97 % unless ( $part_pkg->freq ) {
99 <% pkg_status_row_colspan('One-time charge', '', 'colspan'=>$colspan, ) %>
101 <% pkg_status_row($cust_pkg, 'Billed', 'setup', %opt) %>
105 % if (scalar($cust_pkg->overlimit)) {
107 <% pkg_status_row_colspan(
109 $billed_or_prepaid. ' '. myfreq($part_pkg),
110 'color'=>'FFD000', 'colspan'=>$colspan,
115 <% pkg_status_row_colspan(
117 $billed_or_prepaid. ' '. myfreq($part_pkg),
118 'color'=>'00CC00', 'colspan'=>$colspan,
123 <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt) %>
129 % if ( $opt{'cust_pkg-show_autosuspend'} ) {
130 % my $autosuspend = pkg_autosuspend_time( $cust_pkg );
131 % $cust_pkg->set('autosuspend', $autosuspend) if $autosuspend;
134 <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
135 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
136 <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', %opt, curuser=>$curuser ) %>
137 <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', %opt) %>
138 <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', %opt, curuser=>$curuser ) %>
139 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
141 % if ( $part_pkg->freq ) {
144 <TD COLSPAN=<%$colspan%>>
146 % if ( $curuser->access_right('Suspend customer package') ) {
147 ( <% pkg_suspend_link($cust_pkg) %> )
149 % if ( $curuser->access_right('Suspend customer package later') ) {
150 ( <% pkg_adjourn_link($cust_pkg) %> )
152 % if ( $curuser->access_right('Delay suspension events') ) {
153 ( <% pkg_delay_link($cust_pkg) %> )
155 % if ( $curuser->access_right('Cancel customer package immediately') ) {
156 ( <% pkg_cancel_link($cust_pkg) %> )
158 % if ( $curuser->access_right('Cancel customer package later') ) {
159 ( <% pkg_expire_link($cust_pkg) %> )
177 my $bgcolor = $opt{'bgcolor'};
178 my $cust_pkg = $opt{'cust_pkg'};
179 my $part_pkg = $opt{'part_pkg'};
180 my $curuser = $FS::CurrentUser::CurrentUser;
181 my $colspan = $opt{'cust_pkg-display_times'} ? 8 : 4;
182 my $width = $opt{'cust_pkg-display_times'} ? '38%' : '56%';
184 #false laziness w/edit/REAL_cust_pkg.cgi
185 my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
186 unless ( $part_pkg->is_prepaid ) {
187 $billed_or_prepaid = 'billed';
188 $last_bill_or_renewed = 'Last bill';
189 $next_bill_or_prepaid_until = 'Next bill';
191 $billed_or_prepaid = 'prepaid';
192 $last_bill_or_renewed = 'Renewed';
193 $next_bill_or_prepaid_until = 'Prepaid until';
199 my $part_pkg = shift;
200 my $freq = $part_pkg->freq_pretty;
201 $freq =~ s/ / /g;
205 #false laziness w/package.html
207 my($action, $label, $cust_pkg) = @_;
208 return '' unless $cust_pkg;
209 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
213 my( $cust_pkg, $title, $field, %opt ) = @_;
215 my $color = $opt{'color'};
217 my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
218 $html .= qq(<FONT COLOR="#$color"><B>) if length($color);
219 $html .= qq($title );
220 $html .= qq(</B></FONT>) if length($color);
222 $html .= pkg_datestr($cust_pkg, $field, %opt).'</TR>';
227 sub pkg_status_row_if {
228 my( $cust_pkg, $title, $field, %opt ) = @_;
230 $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title
231 if ( $field eq 'adjourn' &&
232 $opt{curuser}->access_right('Suspend customer package later')
235 $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title
236 if ( $field eq 'expire' &&
237 $opt{curuser}->access_right('Cancel customer package later')
240 $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : '';
243 sub pkg_status_row_changed {
244 my( $cust_pkg, %opt ) = @_;
246 return '' unless $cust_pkg->change_date;
249 pkg_status_row( $cust_pkg, 'Package changed', 'change_date', %opt );
251 my $old = $cust_pkg->old_cust_pkg;
253 my $part_pkg = $old->part_pkg;
254 my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '.
255 $part_pkg->pkg_comment(nopartpkg => 1);
256 $html .= pkg_status_row_colspan( $label, '',
259 'colspan' => $opt{'colspan'},
266 sub pkg_status_row_colspan {
267 my($title, $addl, %opt) = @_;
269 my $colspan = $opt{'colspan'};
271 my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : '';
272 my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : '';
273 my $size = $opt{'size'} ? 'SIZE="'. $opt{'size'}. '"' : '';
275 my $html = qq(<TR><TD COLSPAN=$colspan $align>);
276 $html .= qq(<FONT $color $size>) if length($color) || $size;
277 $html .= qq(<B>) if $color && !$size;
279 $html .= qq(</B>) if $color && !$size;
280 $html .= qq(</FONT>) if length($color) || $size;
281 $html .= ", $addl" if length($addl);
282 $html .= qq(</TD></TR>);
289 my($cust_pkg, $field, %opt) = @_ or return '';
290 return ' ' unless $cust_pkg->get($field);
291 my $format = '<TD align="left"><B>%b</B></TD>'.
292 '<TD align="right"><B> %o,</B></TD>'.
293 '<TD align="right"><B> %Y</B></TD>';
294 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
295 $format .= '<TD ALIGN="right"><B> %l</TD>'.
296 '<TD ALIGN="center"><B>:</B></TD>'.
297 '<TD ALIGN="left"><B>%M</B></TD>'.
298 '<TD ALIGN="left"><B> %P</B></TD>'
299 if $opt{'cust_pkg-display_times'};
300 my $strip = time2str($format, $cust_pkg->get($field) );
301 $strip =~ s/ (\d)/$1/g;
305 sub pkg_suspend_link {
306 include( '/elements/popup_link-cust_pkg.html',
307 'action' => $p. 'misc/cancel_pkg.html?method=suspend',
308 'label' => 'Suspend now',
309 'actionlabel' => 'Suspend',
310 'color' => '#FF9900',
315 sub pkg_adjourn_link {
316 include( '/elements/popup_link-cust_pkg.html',
317 'action' => $p. 'misc/cancel_pkg.html?method=adjourn',
318 'label' => 'Suspend later',
319 'actionlabel' => 'Adjourn',
320 'color' => '#CC6600',
326 include( '/elements/popup_link-cust_pkg.html',
327 'action' => $p. 'misc/delay_susp_pkg.html',
328 'label' => 'Delay suspend',
329 'actionlabel' => 'Delay suspend for',
334 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
335 sub pkg_unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); }
336 sub pkg_unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); }
338 sub pkg_cancel_link {
339 include( '/elements/popup_link-cust_pkg.html',
340 'action' => $p. 'misc/cancel_pkg.html?method=cancel',
341 'label' => 'Cancel now',
342 'actionlabel' => 'Cancel',
343 'color' => '#ff0000',
348 sub pkg_expire_link {
349 include( '/elements/popup_link-cust_pkg.html',
350 'action' => $p. 'misc/cancel_pkg.html?method=expire',
351 'label' => 'Cancel later',
352 'actionlabel' => 'Expire', #"Cancel package $num later"
353 'color' => '#CC0000',
358 sub svc_recharge_link {
359 include( '/elements/popup_link-cust_svc.html',
360 'action' => $p. 'misc/recharge_svc.html',
361 'label' => 'Recharge',
362 'actionlabel' => 'Recharge',
363 'color' => '#333399',
368 sub pkg_autosuspend_time {
369 my $cust_pkg = shift or return '';
372 my $pending_suspend = 0;
373 #this seems to be extremely inefficient... and is slowing down all customer
377 grep { $_->part_event->action eq 'suspend' }
378 @{$cust_pkg->cust_main->due_cust_event( time => $time + 86400*$days,
384 $pending_suspend = 1;
388 $pending_suspend ? time + ($days + 1) * 86400 : '';