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',
17 % unless ( $cust_pkg->get('setup') ) {
19 <% pkg_status_row_colspan('Never billed') %>
23 <% pkg_status_row( $cust_pkg, 'Setup', 'setup', %opt ) %>
24 <% pkg_status_row_changed( $cust_pkg, %opt ) %>
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',
43 % unless ( $cust_pkg->get('setup') ) {
44 <% pkg_status_row_colspan('Never billed') %>
46 <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt ) %>
49 <% pkg_status_row_changed( $cust_pkg, %opt ) %>
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)') %>
76 <TD COLSPAN=<%$colspan%>>
78 % if ( $curuser->access_right('Cancel customer package immediately') ) {
79 ( <% pkg_cancel_link($cust_pkg) %> )
87 <% pkg_status_row_colspan("Not yet billed ($billed_or_prepaid ". myfreq($part_pkg). ')' ) %>
93 % unless ( $part_pkg->freq ) {
95 <% pkg_status_row_colspan('One-time charge') %>
97 <% pkg_status_row($cust_pkg, 'Billed', 'setup', %opt) %>
101 % if (scalar($cust_pkg->overlimit)) {
103 <% pkg_status_row_colspan(
105 $billed_or_prepaid. ' '. myfreq($part_pkg),
111 <% pkg_status_row_colspan(
113 $billed_or_prepaid. ' '. myfreq($part_pkg),
119 <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt) %>
124 % my $autosuspend = pkg_autosuspend_time( $cust_pkg );
125 % $cust_pkg->set('autosuspend', $autosuspend) if $autosuspend;
127 <% pkg_status_row_changed( $cust_pkg, %opt ) %>
128 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
129 <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', %opt, curuser=>$curuser ) %>
130 <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', %opt) %>
131 <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', %opt, curuser=>$curuser ) %>
132 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
134 % if ( $part_pkg->freq ) {
137 <TD COLSPAN=<%$colspan%>>
139 % if ( $curuser->access_right('Suspend customer package') ) {
140 ( <% pkg_suspend_link($cust_pkg) %> )
142 % if ( $curuser->access_right('Suspend customer package later') ) {
143 ( <% pkg_adjourn_link($cust_pkg) %> )
145 % if ( $curuser->access_right('Delay suspension events') ) {
146 ( <% pkg_delay_link($cust_pkg) %> )
148 % if ( $curuser->access_right('Cancel customer package immediately') ) {
149 ( <% pkg_cancel_link($cust_pkg) %> )
151 % if ( $curuser->access_right('Cancel customer package later') ) {
152 ( <% pkg_expire_link($cust_pkg) %> )
170 my $bgcolor = $opt{'bgcolor'};
171 my $cust_pkg = $opt{'cust_pkg'};
172 my $part_pkg = $opt{'part_pkg'};
173 my $curuser = $FS::CurrentUser::CurrentUser;
174 my $colspan = $opt{'cust_pkg-display_times'} ? 8 : 4;
175 my $width = $opt{'cust_pkg-display_times'} ? '38%' : '56%';
177 #false laziness w/edit/REAL_cust_pkg.cgi
178 my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
179 unless ( $part_pkg->is_prepaid ) {
180 $billed_or_prepaid = 'billed';
181 $last_bill_or_renewed = 'Last bill';
182 $next_bill_or_prepaid_until = 'Next bill';
184 $billed_or_prepaid = 'prepaid';
185 $last_bill_or_renewed = 'Renewed';
186 $next_bill_or_prepaid_until = 'Prepaid until';
192 my $part_pkg = shift;
193 my $freq = $part_pkg->freq_pretty;
194 $freq =~ s/ / /g;
198 #false laziness w/package.html
200 my($action, $label, $cust_pkg) = @_;
201 return '' unless $cust_pkg;
202 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
206 my( $cust_pkg, $title, $field, %opt ) = @_;
208 my $color = $opt{'color'};
210 my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
211 $html .= qq(<FONT COLOR="#$color"><B>) if length($color);
212 $html .= qq($title );
213 $html .= qq(</B></FONT>) if length($color);
215 $html .= pkg_datestr($cust_pkg, $field, %opt).'</TR>';
220 sub pkg_status_row_if {
221 my( $cust_pkg, $title, $field, %opt ) = @_;
223 $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title
224 if ( $field eq 'adjourn' &&
225 $opt{curuser}->access_right('Suspend customer package later')
228 $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title
229 if ( $field eq 'expire' &&
230 $opt{curuser}->access_right('Cancel customer package later')
233 $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : '';
236 sub pkg_status_row_changed {
237 my( $cust_pkg, %opt ) = @_;
238 return '' unless $cust_pkg->change_date;
239 my $html = pkg_status_row( $cust_pkg, 'Package changed', 'change_date', %opt );
240 my $old = $cust_pkg->old_cust_pkg;
242 my $part_pkg = $old->part_pkg;
243 my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '.
244 $part_pkg->pkg. ' - '. $part_pkg->comment;
245 $html .= pkg_status_row_colspan( $label, '', size=>'-1', align=>'right' );
250 sub pkg_status_row_colspan {
251 my($title, $addl, %opt) = @_;
253 my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : '';
254 my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : '';
255 my $size = $opt{'size'} ? 'SIZE="'. $opt{'size'}. '"' : '';
257 my $html = qq(<TR><TD COLSPAN=$colspan $align>);
258 $html .= qq(<FONT $color $size>) if length($color) || $size;
259 $html .= qq(<B>) if $color && !$size;
261 $html .= qq(</B>) if $color && !$size;
262 $html .= qq(</FONT>) if length($color) || $size;
263 $html .= ", $addl" if length($addl);
264 $html .= qq(</TD></TR>);
271 my($cust_pkg, $field, %opt) = @_ or return '';
272 return ' ' unless $cust_pkg->get($field);
273 my $format = '<TD align="left"><B>%b</B></TD>'.
274 '<TD align="right"><B> %o,</B></TD>'.
275 '<TD align="right"><B> %Y</B></TD>';
276 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
277 $format .= '<TD ALIGN="right"><B> %l</TD>'.
278 '<TD ALIGN="center"><B>:</B></TD>'.
279 '<TD ALIGN="left"><B>%M</B></TD>'.
280 '<TD ALIGN="left"><B> %P</B></TD>'
281 if $opt{'cust_pkg-display_times'};
282 my $strip = time2str($format, $cust_pkg->get($field) );
283 $strip =~ s/ (\d)/$1/g;
287 sub pkg_suspend_link {
288 include( '/elements/popup_link-cust_pkg.html',
289 'action' => $p. 'misc/cancel_pkg.html?method=suspend',
290 'label' => 'Suspend now',
291 'actionlabel' => 'Suspend',
292 'color' => '#FF9900',
297 sub pkg_adjourn_link {
298 include( '/elements/popup_link-cust_pkg.html',
299 'action' => $p. 'misc/cancel_pkg.html?method=adjourn',
300 'label' => 'Suspend later',
301 'actionlabel' => 'Adjourn',
302 'color' => '#CC6600',
308 include( '/elements/popup_link-cust_pkg.html',
309 'action' => $p. 'misc/delay_susp_pkg.html',
310 'label' => 'Delay suspend',
311 'actionlabel' => 'Delay suspend for',
316 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
317 sub pkg_unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); }
318 sub pkg_unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); }
320 sub pkg_cancel_link {
321 include( '/elements/popup_link-cust_pkg.html',
322 'action' => $p. 'misc/cancel_pkg.html?method=cancel',
323 'label' => 'Cancel now',
324 'actionlabel' => 'Cancel',
325 'color' => '#ff0000',
330 sub pkg_expire_link {
331 include( '/elements/popup_link-cust_pkg.html',
332 'action' => $p. 'misc/cancel_pkg.html?method=expire',
333 'label' => 'Cancel later',
334 'actionlabel' => 'Expire', #"Cancel package $num later"
335 'color' => '#CC0000',
340 sub svc_recharge_link {
341 include( '/elements/popup_link-cust_svc.html',
342 'action' => $p. 'misc/recharge_svc.html',
343 'label' => 'Recharge',
344 'actionlabel' => 'Recharge',
345 'color' => '#333399',
350 sub pkg_autosuspend_time {
351 my $cust_pkg = shift or return '';
354 my $pending_suspend = 0;
355 #this seems to be extremely inefficient...
358 grep { $_->part_event->action eq 'suspend' }
359 @{$cust_pkg->cust_main->due_cust_event( time => $time + 86400*$days,
365 $pending_suspend = 1;
369 $pending_suspend ? time + ($days + 1) * 86400 : '';