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