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