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', conf=>$conf ) %>
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', conf=>$conf ) %>
24 <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
25 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf, curuser=>$curuser ) %>
26 <% pkg_status_row_if( $cust_pkg, 'Suspended', 'susp', conf=>$conf, 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', conf=>$conf ) %>
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', conf=>$conf ) %>
49 <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
50 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf, curuser=>$curuser ) %>
51 % # pkg_status_row($cust_pkg, 'Next bill', 'bill', conf=>$conf)
52 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', conf=>$conf, 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', conf=>$conf) %>
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', conf=>$conf) %>
124 % my $autosuspend = pkg_autosuspend_time( $cust_pkg );
125 % $cust_pkg->set('autosuspend', $autosuspend) if $autosuspend;
127 <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
128 <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf, curuser=>$curuser ) %>
129 <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', conf=>$conf, curuser=>$curuser ) %>
130 <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', conf=>$conf) %>
131 <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', conf=>$conf, curuser=>$curuser ) %>
132 <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', conf=>$conf, 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 $conf = new FS::Conf;
175 my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
176 my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
178 #false laziness w/edit/REAL_cust_pkg.cgi
179 my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
180 unless ( $part_pkg->is_prepaid ) {
181 $billed_or_prepaid = 'billed';
182 $last_bill_or_renewed = 'Last bill';
183 $next_bill_or_prepaid_until = 'Next bill';
185 $billed_or_prepaid = 'prepaid';
186 $last_bill_or_renewed = 'Renewed';
187 $next_bill_or_prepaid_until = 'Prepaid until';
193 my $part_pkg = shift;
194 my $freq = $part_pkg->freq_pretty;
195 $freq =~ s/ / /g;
199 #false laziness w/package.html
201 my($action, $label, $cust_pkg) = @_;
202 return '' unless $cust_pkg;
203 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
207 my( $cust_pkg, $title, $field, %opt ) = @_;
209 my $color = $opt{'color'};
211 my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
212 $html .= qq(<FONT COLOR="#$color"><B>) if length($color);
213 $html .= qq($title );
214 $html .= qq(</B></FONT>) if length($color);
216 $html .= pkg_datestr($cust_pkg, $field, $opt{conf}).'</TR>';
221 sub pkg_status_row_if {
222 my( $cust_pkg, $title, $field, %opt ) = @_;
224 $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title
225 if ( $field eq 'adjourn' &&
226 $opt{curuser}->access_right('Suspend customer package later')
229 $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title
230 if ( $field eq 'expire' &&
231 $opt{curuser}->access_right('Cancel customer package later')
234 $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : '';
237 sub pkg_status_row_changed {
238 my( $cust_pkg, %opt ) = @_;
239 return '' unless $cust_pkg->change_date;
240 my $html = pkg_status_row( $cust_pkg, 'Package changed', 'change_date', conf=>$opt{'conf'} );
241 my $old = $cust_pkg->old_cust_pkg;
243 my $part_pkg = $old->part_pkg;
244 my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '.
245 $part_pkg->pkg. ' - '. $part_pkg->comment;
246 $html .= pkg_status_row_colspan( $label, '', size=>'-1', align=>'right' );
251 sub pkg_status_row_colspan {
252 my($title, $addl, %opt) = @_;
254 my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : '';
255 my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : '';
256 my $size = $opt{'size'} ? 'SIZE="'. $opt{'size'}. '"' : '';
258 my $html = qq(<TR><TD COLSPAN=$colspan $align>);
259 $html .= qq(<FONT $color $size>) if length($color) || $size;
260 $html .= qq(<B>) if $color && !$size;
262 $html .= qq(</B>) if $color && !$size;
263 $html .= qq(</FONT>) if length($color) || $size;
264 $html .= ", $addl" if length($addl);
265 $html .= qq(</TD></TR>);
272 my($cust_pkg, $field, $conf) = @_ or return '';
273 return ' ' unless $cust_pkg->get($field);
274 my $format = '<TD align="left"><B>%b</B></TD>'.
275 '<TD align="right"><B> %o,</B></TD>'.
276 '<TD align="right"><B> %Y</B></TD>';
277 #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>'
278 $format .= '<TD ALIGN="right"><B> %l</TD>'.
279 '<TD ALIGN="center"><B>:</B></TD>'.
280 '<TD ALIGN="left"><B>%M</B></TD>'.
281 '<TD ALIGN="left"><B> %P</B></TD>'
282 if $conf->exists('cust_pkg-display_times');
283 my $strip = time2str($format, $cust_pkg->get($field) );
284 $strip =~ s/ (\d)/$1/g;
288 sub pkg_suspend_link {
289 include( '/elements/popup_link-cust_pkg.html',
290 'action' => $p. 'misc/cancel_pkg.html?method=suspend',
291 'label' => 'Suspend now',
292 'actionlabel' => 'Suspend',
293 'color' => '#FF9900',
298 sub pkg_adjourn_link {
299 include( '/elements/popup_link-cust_pkg.html',
300 'action' => $p. 'misc/cancel_pkg.html?method=adjourn',
301 'label' => 'Suspend later',
302 'actionlabel' => 'Adjourn',
303 'color' => '#CC6600',
309 include( '/elements/popup_link-cust_pkg.html',
310 'action' => $p. 'misc/delay_susp_pkg.html',
311 'label' => 'Delay suspend',
312 'actionlabel' => 'Delay suspend for',
317 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); }
318 sub pkg_unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); }
319 sub pkg_unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); }
321 sub pkg_cancel_link {
322 include( '/elements/popup_link-cust_pkg.html',
323 'action' => $p. 'misc/cancel_pkg.html?method=cancel',
324 'label' => 'Cancel now',
325 'actionlabel' => 'Cancel',
326 'color' => '#ff0000',
331 sub pkg_expire_link {
332 include( '/elements/popup_link-cust_pkg.html',
333 'action' => $p. 'misc/cancel_pkg.html?method=expire',
334 'label' => 'Cancel later',
335 'actionlabel' => 'Expire', #"Cancel package $num later"
336 'color' => '#CC0000',
341 sub svc_recharge_link {
342 include( '/elements/popup_link-cust_svc.html',
343 'action' => $p. 'misc/recharge_svc.html',
344 'label' => 'Recharge',
345 'actionlabel' => 'Recharge',
346 'color' => '#333399',
351 sub pkg_autosuspend_time {
352 my $cust_pkg = shift or return '';
355 my $pending_suspend = 0;
356 #this seems to be extremely inefficient...
359 grep { $_->part_event->action eq 'suspend' }
360 @{$cust_pkg->cust_main->due_cust_event( time => $time + 86400*$days,
366 $pending_suspend = 1;
370 $pending_suspend ? time + ($days + 1) * 86400 : '';