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