componentize conflicting %once subroutines (rt#3250)
[freeside.git] / httemplate / elements / popup_link-cust_svc.html
1 <%doc>
2
3 Example:
4
5   <SCRIPT TYPE="text/javascript" SRC="overlibmws.js"></SCRIPT>
6   <SCRIPT TYPE="text/javascript" SRC="iframecontentmws.js"></SCRIPT>
7
8   include( '/elements/svc_popup_link.html', {
9
10     #required
11     'action'         => 'content.html', # uri for content of popup which should
12                                         # be suitable for appending '?svcnum='
13     'label'          => 'click me',     # text of <A> tag
14     'cust_svc'       => $cust_svc       # a FS::cust_svc object
15    
16     #strongly recommended (you want a title, right?)
17     'actionlabel     => 'You clicked',  # popup title
18    
19     #opt
20     'width'          => '540',
21     'color'          => '#ff0000',
22     'closetext'      => 'Go Away',      # the value '' removes the link
23   )
24
25 </%doc>
26 <%init>
27 my($params, $action, $label, $actionlabel, $cust_svc, $color, $width);
28 my $closetext = 'Close';
29 if (ref(@_[0]) eq 'HASH') {
30   $params = shift;
31   foreach (qw(action label actionlabel width color)) {
32     $action      = $params->{'action'}      if exists $params->{'action'};
33     $label       = $params->{'label'}       if exists $params->{'label'};
34     $actionlabel = $params->{'actionlabel'} if exists $params->{'actionlabel'};
35     $width       = $params->{'width'}       if exists $params->{'width'};
36     $color       = $params->{'color'}       if exists $params->{'color'};
37     $closetext   = $params->{'closetext'}   if exists $params->{'closetext'};
38     $cust_svc    = $params->{'cust_svc'}    if exists $params->{'cust_svc'};
39   }
40 }else{  # deprecated
41   ($action, $label, $actionlabel, $cust_svc) = @_;
42 }
43
44 $action .= '?svcnum='. $cust_svc->svcnum;
45 $actionlabel .= ' service '. $cust_svc->svcnum;
46 $width ||= 392;
47
48 </%init>
49 <% $cust_svc
50    ? include('/elements/popup_link.html', { 'action'       => $action,
51                                             'label'        => $label,
52                                             'actionlabel'  => $actionlabel,
53                                             'color'        => $color,
54                                             'width'        => $width,
55                                             'closetext'    => $closetext,
56                                           }
57             )
58    : ''
59 %>