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