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