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