spurious 'suspended'
[freeside.git] / httemplate / view / cust_main / packages.html
1 <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A><BR>
2
3 % my $s = 0;
4 % if ( $curuser->access_right('Order customer package') ) { 
5   <% $s++ ? ' | ' : '' %>
6   <% order_pkg_link($cust_main) %>
7 % } 
8
9 % if ( $curuser->access_right('One-time charge')
10 %        && $conf->config('payby-default') ne 'HIDE'
11 %      ) {
12 %
13   <% $s++ ? ' | ' : '' %>
14   <% include('/elements/popup_link.html',
15      { 
16        'action'      => $p. 'edit/quick-charge.html?custnum='. $cust_main->custnum,
17        'label'       => 'One-time charge',
18        'actionlabel' => 'One-time charge',
19        'color'       => '#333399',
20        'width'       => 545,
21      })
22   %>
23
24 % } 
25 % if ( $curuser->access_right('Bulk change customer packages') ) { 
26   <% $s++ ? ' | ' : '' %>
27   <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services)
28 % } 
29
30
31 <BR><BR>
32 % if ( @$packages ) { 
33
34 Current packages
35 % } 
36 % if ( $cust_main->num_cancelled_pkgs ) {
37 %     if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
38 %          || ( $conf->exists('hidecancelledpackages')
39 %               && ! $cgi->param('showcancelledpackages')
40 %             )
41 %        )
42 %     {
43 %       $cgi->param('showcancelledpackages', 1);
44 %
45
46   ( <a href="<% $cgi->self_url %>">show
47 %   } else {
48 %       $cgi->param('showcancelledpackages', 0);
49 %
50
51   ( <a href="<% $cgi->self_url %>">hide
52 %   } 
53
54  cancelled packages</a> )
55 % } 
56 % if ( @$packages ) { 
57
58
59 <% include('/elements/table-grid.html') %>
60 % my $bgcolor1 = '#eeeeee';
61 %   my $bgcolor2 = '#ffffff';
62 %   my $bgcolor = '';
63
64 <TR>
65   <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH>
66   <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
67   <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
68 </TR>
69
70 %foreach my $cust_pkg (@$packages) {
71 %
72 %  my $part_pkg = $cust_pkg->part_pkg;
73 %
74 %  if ( $bgcolor eq $bgcolor1 ) {
75 %    $bgcolor = $bgcolor2;
76 %  } else {
77 %    $bgcolor = $bgcolor1;
78 %  }
79
80
81 <!--pkgnum: <% $cust_pkg->pkgnum %>-->
82 <TR>
83
84   <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
85
86     <A NAME="cust_pkg<% $cust_pkg->pkgnum %>" ID="cust_pkg<% $cust_pkg->pkgnum %>"><% $cust_pkg->pkgnum %></A>:
87     <% $part_pkg->pkg %> - <% $part_pkg->comment %>
88     <BR>
89
90 %   if ( $cust_pkg->quantity > 1 ) {
91         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Quantity: <B><% $cust_pkg->quantity %></B><BR>
92 %   }
93
94     <FONT SIZE=-1>
95 % unless ( $cust_pkg->get('cancel') ) { 
96 %   my $br = 0;
97 %   if ( $curuser->access_right('Change customer package') ) { $br=1;
98
99             (&nbsp;<%pkg_change_link($cust_pkg)%>&nbsp;)
100 %   } 
101 %   if ( $curuser->access_right('Edit customer package dates') ) { $br=1;
102
103             (&nbsp;<%pkg_dates_link($cust_pkg)%>&nbsp;)
104 %   } 
105 %   if ( $curuser->access_right('Customize customer package') ) { $br=1;
106
107             (&nbsp;<%pkg_customize_link($cust_pkg,$cust_main->custnum)%>&nbsp;)
108 %   } 
109     <% $br ? '<BR>' : '' %>
110 % } 
111
112 % if ( $cust_pkg->num_cust_event
113 %      && (    $curuser->access_right('Billing event reports')
114 %           || $curuser->access_right('View customer billing events')
115 %         )
116 %    ) {
117     (&nbsp;<%pkg_event_link($cust_pkg)%>&nbsp;)
118 % }
119
120     </FONT>
121
122   </TD>
123
124   <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
125     <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
126 %
127 %  sub myfreq {
128 %    my $part_pkg = shift;
129 %    my $freq = $part_pkg->freq_pretty;
130 %    $freq =~ s/ /&nbsp;/g;
131 %    $freq;
132 %  }
133 %
134 %  #this should use cust_pkg->status and cust_pkg->statuscolor eventually
135 %  #my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
136 %  #my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
137 %
138 %  #false laziness w/edit/REAL_cust_pkg.cgi
139 %  my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until );
140 %  unless ( $part_pkg->is_prepaid ) {
141 %    $billed_or_prepaid = 'billed';
142 %    $last_bill_or_renewed = 'Last&nbsp;bill';
143 %    $next_bill_or_prepaid_until = 'Next&nbsp;bill';
144 %  } else {
145 %    $billed_or_prepaid = 'prepaid';
146 %    $last_bill_or_renewed = 'Renewed';
147 %    $next_bill_or_prepaid_until = 'Prepaid&nbsp;until';
148 %  }
149 %
150 %
151 % if ( $cust_pkg->get('cancel') ) { #status: cancelled
152 %   my $cpr = $cust_pkg->last_cust_pkg_reason;
153
154     <% pkg_status_row($cust_pkg, 'Cancelled', 'cancel', 'color'=>'FF0000', conf=>$conf ) %>
155
156     <% pkg_status_row_colspan(
157          ( ( $cpr && ( $cpr->date == $cust_pkg->get('cancel') ||
158                        $cpr->date == $cust_pkg->expire
159                      )
160            ) ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
161          'align' => 'right', 'color' => 'ff0000', 'size' => '-2',
162        )
163     %>
164
165 %   unless ( $cust_pkg->get('setup') ) { 
166
167         <% pkg_status_row_colspan('Never billed') %>
168
169 %   } else { 
170
171        <% pkg_status_row( $cust_pkg, 'Setup', 'setup', conf=>$conf ) %>
172        <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
173        <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf ) %>
174        <% pkg_status_row_if( $cust_pkg, 'Suspended', 'susp', conf=>$conf ) %>
175
176 %   } 
177 %
178 % } else { 
179 %
180 %   if ( $cust_pkg->get('susp') ) { #status: suspended
181 %     my $cpr = $cust_pkg->last_cust_pkg_reason;
182
183     <% pkg_status_row( $cust_pkg, 'Suspended', 'susp', 'color'=>'FF9900', conf=>$conf ) %>
184
185     <% pkg_status_row_colspan(
186          ( ( $cpr && ( $cpr->date == $cust_pkg->susp ||
187                        $cpr->date == $cust_pkg->adjourn
188                      )
189            ) ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '',
190          'align' => 'right', 'color' => 'FF9900', 'size' => '-2',
191        )
192     %>
193
194 %   unless ( $cust_pkg->get('setup') ) { 
195       <% pkg_status_row_colspan('Never billed') %>
196 %   } else { 
197       <% pkg_status_row($cust_pkg, 'Setup', 'setup', conf=>$conf ) %>
198 %   } 
199
200     <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
201     <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf ) %>
202 %   # pkg_status_row($cust_pkg, 'Next bill', 'bill', conf=>$conf)
203     <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', conf=>$conf ) %>
204
205     <TR>
206       <TD COLSPAN=<%$colspan%>>
207         <FONT SIZE=-1>
208 %         if ( $curuser->access_right('Unsuspend customer package') ) { 
209             (&nbsp;<% pkg_unsuspend_link($cust_pkg) %>&nbsp;)
210 %         } 
211 %         if ( $curuser->access_right('Cancel customer package immediately') ) {
212             (&nbsp;<% pkg_cancel_link($cust_pkg) %>&nbsp;)
213 %         } 
214         </FONT>
215       </TD>
216     </TR>
217
218 %   } else { #status: active
219 %
220 %     unless ( $cust_pkg->get('setup') ) { #not setup
221 %
222 %       unless ( $part_pkg->freq ) { 
223
224           <% pkg_status_row_colspan('Not&nbsp;yet&nbsp;billed&nbsp;(one-time&nbsp;charge)') %>
225
226           <TR>
227             <TD COLSPAN=<%$colspan%>>
228               <FONT SIZE=-1>
229 %               if ( $curuser->access_right('Cancel customer package immediately') ) { 
230                   (&nbsp;<% pkg_cancel_link($cust_pkg) %>&nbsp;)
231 %               } 
232               </FONT>
233             </TD>
234           </TR>
235
236 %       } else { 
237
238          <% pkg_status_row_colspan("Not&nbsp;yet&nbsp;billed&nbsp;($billed_or_prepaid&nbsp;". myfreq($part_pkg). ')' ) %>
239
240 %       } 
241 %
242 %     } else { #setup
243 %
244 %       unless ( $part_pkg->freq ) { 
245
246           <% pkg_status_row_colspan('One-time&nbsp;charge') %>
247
248           <% pkg_status_row($cust_pkg, 'Billed', 'setup', conf=>$conf) %>
249
250 %       } else { 
251 %
252 %         if (scalar($cust_pkg->overlimit)) {
253
254             <% pkg_status_row_colspan(
255                  'Overlimit',
256                  $billed_or_prepaid. '&nbsp;'. myfreq($part_pkg),
257                  'color' => 'FFD000',
258                )
259             %>
260
261 %         } else {
262             <% pkg_status_row_colspan(
263                  'Active',
264                  $billed_or_prepaid. '&nbsp;'. myfreq($part_pkg),
265                  'color' => '00CC00',
266                )
267             %>
268 %         } 
269
270           <% pkg_status_row($cust_pkg, 'Setup', 'setup', conf=>$conf) %>
271
272 %       } 
273 %
274 %     } 
275
276       <% pkg_status_row_changed( $cust_pkg, conf=>$conf ) %>
277       <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', conf=>$conf ) %>
278       <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', conf=>$conf ) %>
279       <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', conf=>$conf ) %>
280       <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', conf=>$conf ) %>
281
282 %     if ( $part_pkg->freq ) { 
283
284         <TR>
285           <TD COLSPAN=<%$colspan%>>
286             <FONT SIZE=-1>
287 %             if ( $curuser->access_right('Suspend customer package') ) { 
288                 (&nbsp;<% pkg_suspend_link($cust_pkg) %>&nbsp;)
289 %             } 
290 %             if ( $curuser->access_right('Suspend customer package later') ) { 
291                 (&nbsp;<% pkg_adjourn_link($cust_pkg) %>&nbsp;)
292 %             } 
293 %             if ( $curuser->access_right('Cancel customer package immediately') ) { 
294                 (&nbsp;<% pkg_cancel_link($cust_pkg) %>&nbsp;)
295 %             } 
296 %             if ( $curuser->access_right('Cancel customer package later') ) { 
297                 (&nbsp;<% pkg_expire_link($cust_pkg) %>&nbsp;)
298 %             } 
299
300             <FONT>
301           </TD>
302         </TR>
303 %     }
304 %
305 %   } 
306 % } 
307
308 </TABLE>
309 </TD>
310
311 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
312   <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
313
314 %  #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
315 %  foreach my $part_svc ( $cust_pkg->part_svc ) {
316
317 %    #foreach my $service (@{$svcpart->{services}}) {
318 %    foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) {
319
320       <TR>
321         <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD>
322         <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD>
323         <TD><% FS::UI::Web::svc_export_links($m, $part_svc, $cust_svc) %></TD>
324       </TR>
325
326       <TR>
327         <TD ALIGN="right" COLSPAN="3" VALIGN="top" STYLE="padding-bottom:1px;padding-top:0px"><FONT SIZE="-2" COLOR="#FFD000">
328
329             <% $cust_svc->overlimit ? "Overlimit: ". time2str('%b %o %Y' . ($conf->exists('cust_pkg-display_times') ? ' %l:%M %P' : ''), $cust_svc->overlimit) : '' %>
330           </FONT></TD>
331       </TR>
332
333       <TR>
334         <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
335
336 %         if ( $curuser->access_right('Recharge customer service')
337 %              && $part_svc->svcdb eq 'svc_acct'
338 %              && (    $cust_svc->svc_x->seconds    ne ''
339 %                   || $cust_svc->svc_x->upbytes    ne ''
340 %                   || $cust_svc->svc_x->downbytes  ne ''
341 %                   || $cust_svc->svc_x->totalbytes ne ''
342 %                 )
343 %         ) { 
344             (&nbsp;<%svc_recharge_link($cust_svc)%>&nbsp;)
345 %         } 
346           </FONT></TD>
347
348           <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
349
350 %         if ( $curuser->access_right('Unprovision customer service') ) { 
351             (&nbsp;<%svc_unprovision_link($cust_svc)%>&nbsp;)
352 %         } 
353           </FONT></TD>
354         </TR>
355 %   } 
356
357 %   if (    ! $cust_pkg->get('cancel')
358 %        && $curuser->access_right('Provision customer service') 
359 %        && $part_svc->num_avail
360 %      ) {
361
362       <TR>
363         <TD COLSPAN=3 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px">
364           <B><% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %></B>
365         </TD>
366       </TR>
367
368 %   } 
369
370 % } 
371
372 </TABLE>
373 </TD>
374 % } #end display packages
375 %
376
377
378 </TABLE>
379 % } else { 
380
381 <BR>
382 % } 
383 % if ( $cgi->param('fragment') =~ /^cust_pkg(\d+)$/ ) {
384   <SCRIPT>
385     // IE-specific hack.  other browsers listen to #fragments
386     // is this even working?  or is the #target redirection just working cause
387     // we set the URL params differently?
388     var el = document.getElementById( 'cust_pkg<% $1 %>' );
389     if ( el ) el.scrollIntoView(true);
390   </SCRIPT>
391 % }
392 <%init>
393
394 my( $cust_main ) = @_;
395 my $conf = new FS::Conf;
396
397 my $curuser = $FS::CurrentUser::CurrentUser;
398
399 my $packages = get_packages($cust_main, $conf);
400
401 my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4;
402 my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%';
403
404 sub pkg_status_row {
405   my( $cust_pkg, $title, $field, %opt ) = @_;
406
407   my $color = $opt{'color'};
408
409   my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">);
410   $html   .= qq(<FONT COLOR="#$color"><B>) if length($color);
411   $html   .= qq($title&nbsp;);
412   $html   .= qq(</B></FONT>) if length($color);
413   $html   .= qq(</TD>);
414   $html   .= pkg_datestr($cust_pkg, $field, $opt{conf}).'</TR>';
415
416   $html;
417 }
418
419 sub pkg_status_row_if {
420   my( $cust_pkg, $title, $field, %opt ) = @_;
421   $cust_pkg->get($field) ? pkg_status_row(@_) : '';
422 }
423
424 sub pkg_status_row_changed {
425   my( $cust_pkg, %opt ) = @_;
426   return '' unless $cust_pkg->change_date;
427   my $html = pkg_status_row( $cust_pkg, 'Package&nbsp;changed', 'change_date', conf=>$opt{'conf'} );
428   my $old = $cust_pkg->old_cust_pkg;
429   if ( $old ) {
430     my $part_pkg = $old->part_pkg;
431     my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '.
432                 $part_pkg->pkg. ' - '. $part_pkg->comment;
433     $html .= pkg_status_row_colspan( $label, '', size=>'-1', align=>'right' );
434   }
435   $html;
436 }
437
438 sub pkg_status_row_colspan {
439   my($title, $addl, %opt) = @_;
440
441   my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : '';
442   my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : '';
443   my $size  = $opt{'size'}  ? 'SIZE="'.  $opt{'size'}. '"' : '';
444
445   my $html = qq(<TR><TD COLSPAN=$colspan $align>);
446   $html   .= qq(<FONT $color $size>) if length($color) || $size;
447   $html   .= qq(<B>) if $color && !$size;
448   $html   .= $title;
449   $html   .= qq(</B>) if $color && !$size;
450   $html   .= qq(</FONT>) if length($color) || $size;
451   $html   .= ",&nbsp;$addl" if length($addl);
452   $html   .= qq(</TD></TR>);
453
454   $html;
455
456 }
457
458 #subroutines
459
460 sub get_packages {
461   my $cust_main = shift or return undef;
462   my $conf = shift;
463   
464   my @packages = ();
465   my $method;
466   if (  $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
467      || ( $conf->exists('hidecancelledpackages')
468            && ! $cgi->param('showcancelledpackages') )
469      )
470   {
471     $method = 'ncancelled_pkgs';
472   } else {
473     $method = 'all_pkgs';
474   }
475
476   [ $cust_main->$method() ];
477 }
478
479 sub svc_provision_link {
480   my ($cust_pkg, $part_svc, $conf, $curuser) = @_;
481   ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/&nbsp;/g;
482   my $num_avail = $part_svc->num_avail;
483   my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'.
484                        "svcpart=". $part_svc->svcpart;
485   my $url;
486   if ( $part_svc->svcdb eq 'svc_external' #could be generalized
487        && $conf->exists('svc_external-skip_manual')
488   ) {
489     $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart";
490   } else {
491     $url = svc_url(
492                     'm'        => $m,
493                     'action'   => 'edit',
494                     'part_svc' => $part_svc, 
495                     'query'    => $pkgnum_svcpart,
496                   );
497     #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
498   }
499
500   my $link = qq!<A CLASS="provision" HREF="$url">!.
501              "Provision&nbsp;$svc_nbsp&nbsp;($num_avail)</A>";
502   if ( $conf->exists('legacy_link')
503        && $curuser->access_right('View/link unlinked services')
504      )
505   {
506     $link .= '<BR>'.
507              qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!.
508              qq!$pkgnum_svcpart">!.
509             "Link&nbsp;to&nbsp;legacy&nbsp;$svc_nbsp&nbsp;($num_avail)</A>";
510   }
511   $link;
512 }
513
514 sub svc_unprovision_link {
515   my $cust_svc = shift or return '';
516   qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum.
517   qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!;
518 }
519
520 sub pkg_datestr {
521   my($cust_pkg, $field, $conf) = @_ or return '';
522   return '&nbsp;' unless $cust_pkg->get($field);
523   my $format = '<TD align="left"><B>%b</B></TD>'.
524                '<TD align="right"><B>&nbsp;%o,</B></TD>'.
525                '<TD align="right"><B>&nbsp;%Y</B></TD>';
526   #$format .= '&nbsp;<FONT SIZE=-3>%l:%M:%S%P&nbsp;%z</FONT>'
527   $format .= '<TD ALIGN="right"><B>&nbsp;%l</TD>'.
528              '<TD ALIGN="center"><B>:</B></TD>'.
529              '<TD ALIGN="left"><B>%M</B></TD>'.
530              '<TD ALIGN="left"><B>&nbsp;%P</B></TD>'
531     if $conf->exists('cust_pkg-display_times');
532   my $strip = time2str($format, $cust_pkg->get($field) );
533   $strip =~ s/ (\d)/$1/g;
534   $strip;
535 }
536
537 sub pkg_change_link { include( '/elements/popup_link-cust_pkg.html',
538                                { 'action'      => $p. 'misc/change_pkg.cgi?dummy=value',
539                                  'label'       => 'Change&nbsp;package',
540                                  'actionlabel' => 'Change',
541                                  'cust_pkg'    => shift,
542                                }
543                              )
544                      }
545
546 sub pkg_suspend_link { include( '/elements/popup_link-cust_pkg.html',
547                                 { 'action'      => $p. 'misc/cancel_pkg.html?method=suspend',
548                                   'label'       => 'Suspend&nbsp;now',
549                                   'actionlabel' => 'Suspend',
550                                   'color'       => '#FF9900',
551                                   'cust_pkg'    => shift,
552                                 }
553                               )
554                      }
555
556
557 sub pkg_adjourn_link { include( '/elements/popup_link-cust_pkg.html',
558                                 { 'action'      => $p. 'misc/cancel_pkg.html?method=adjourn',
559                                   'label'       => 'Suspend&nbsp;later',
560                                   'actionlabel' => 'Adjourn',
561                                   'color'       => '#CC6600',
562                                   'cust_pkg'    => shift,
563                                 }
564                               )
565                      }
566
567 sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg',    'Unsuspend',           @_ ); }
568 sub pkg_dates_link     { pkg_link('edit/REAL_cust_pkg', 'Edit&nbsp;dates',     @_ ); }
569
570 sub pkg_cancel_link { include( '/elements/popup_link-cust_pkg.html',
571                                { 'action'      => $p. 'misc/cancel_pkg.html?method=cancel',
572                                  'label'       => 'Cancel&nbsp;now',
573                                  'actionlabel' => 'Cancel',
574                                  'color'       => '#ff0000',
575                                  'cust_pkg'    => shift,
576                                }
577                              )
578                     }
579
580 sub pkg_expire_link { include( '/elements/popup_link-cust_pkg.html',
581                                { 'action'      => $p. 'misc/cancel_pkg.html?method=expire',
582                                  'label'       => 'Cancel&nbsp;later',
583                                  'actionlabel' => 'Expire', #"Cancel package $num later"
584                                  'color'       => '#CC0000',
585                                  'cust_pkg'    => shift,
586                                }
587                              )
588                     }
589
590 sub svc_recharge_link { include( '/elements/popup_link-cust_svc.html',
591                                  { 'action'      => $p. 'misc/recharge_svc.html',
592                                    'label'       => 'Recharge',
593                                    'actionlabel' => 'Recharge',
594                                    'color'       => '#333399',
595                                    'cust_svc'    => shift,
596                                  }
597                                )
598                       }
599
600 sub order_pkg_link { include( '/elements/popup_link-cust_main.html',
601                               { 'action'      => $p. 'misc/order_pkg.html',
602                                 'label'       => 'Order&nbsp;new&nbsp;package',
603                                 'actionlabel' => 'Order new package',
604                                 'color'       => '#333399',
605                                 'cust_main'   => shift,
606                                 'closetext'   => 'Close',
607                               }
608                             )
609                    }
610
611 sub pkg_event_link {
612   my($cust_pkg) = @_;
613   qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
614   'View package events'.
615   '</a>';
616 }
617
618 sub pkg_link {
619   my($action, $label, $cust_pkg) = @_;
620   return '' unless $cust_pkg;
621   qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
622 }
623
624 sub pkg_customize_link {
625   my $cust_pkg = shift or return '';
626   my $custnum = $cust_pkg->custnum;
627   qq!<A HREF="${p}edit/part_pkg.cgi?!.
628     "clone=". $cust_pkg->part_pkg->pkgpart. ';'.
629     "pkgnum=". $cust_pkg->pkgnum.
630     qq!">Customize</A>!;
631 }
632
633 </%init>