enable CardFortress in test database, #71513
[freeside.git] / httemplate / elements / select-cgp_rule_action.html
1 % unless ( $opt{'js_only'} ) {
2
3     <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<%$curr_value%>">
4
5     <% include( 'select.html',
6                   'field'      => $name.'_action',
7                   'id'         => $id.'_action',
8                   'options'    => \@actions,
9                   'curr_value' => $action,
10                   'labels'     => { '' => 'Select Action' },
11                   'onchange'   => $name.'_changed',
12                   'style'      => 'vertical-align:top',
13               )
14     %>
15
16     <TEXTAREA NAME          = "<% $name %>_params"
17                 ID          = "<% $id %>_params"
18                 <% $disabled %>
19                 <% $style %>
20 %#                <% $rows %>
21 %#                <% $cols %>
22 %#                <% $onchange %>
23       ><% scalar($cgi->param($name.'_params')) || $cgp_rule_action->params |h %></TEXTAREA>
24
25 % }
26 % unless ( $opt{'html_only'} || $opt{'js_only'} ) {
27     <SCRIPT TYPE="text/javascript">
28 % }
29 % unless ( $opt{'html_only'} ) {
30
31     function <% $name %>_changed(what) {
32
33         <% $opt{'onchange'} %>
34
35         var <% $name %>_value = what.options[what.selectedIndex].value;
36
37         var params_Element = what.form.<% $name %>_params;
38
39         // if bool, hide/disable _op and _params entirely
40         if ( <%$name%>_value == '' || <%$name%>_value == 'Stop Processing' || <%$name%>_value == 'Discard' ) {
41           params_Element.disabled = true;
42           params_Element.style.visibility = "hidden";
43         } else {
44           params_Element.disabled = false;
45           params_Element.style.visibility = "visible";
46
47         }
48         
49     }
50
51 % }
52 % unless ( $opt{'html_only'} || $opt{'js_only'} ) {
53     </SCRIPT>
54 % }
55 <%once>
56
57 my @actions = (
58   '',
59
60   #generic http://www.communigate.com/CommunigatePro/Rules.html#Actions
61   'Reject',
62   'SendURL',
63   'Send IM',
64   'FingerNotify',
65   'Write To Log',
66   "Remember 'From' in",
67
68   #email http://www.communigate.com/CommunigatePro/QueueRules.html#Actions
69   'Stop Processing',
70   'Discard',
71   'Reject With',
72   'Mark',
73   'Add Header',
74   'Tag Subject',
75   'Store in',
76   'Redirect to',
77   'Forward to',
78   'Mirror to',
79   'Reply with',
80   'Reply to All with',
81   'React with',
82   'store Encrypted in',
83   'Copy attachments into',
84   'Execute',
85   'ExternalFilter',
86   'Accept Request',
87 );
88
89 my %noparam = ( map { $_=>1 } '', 'Stop Processing', 'Discard' );
90
91 </%once>
92 <%init>
93
94 my %opt = @_;
95
96 my $name = $opt{'element_name'} || $opt{'field'} || 'ruleactionnum';
97 #my $id = $opt{'id'} || 'contactnum';
98 my $id = $opt{'id'} || $opt{'field'} || 'ruleactionnum';
99
100 my $curr_value = $opt{'curr_value'} || $opt{'value'};
101
102 my $cgp_rule_action;
103 if ( $curr_value ) {
104   $cgp_rule_action = qsearchs('cgp_rule_action',
105                                 { 'ruleactionnum' => $curr_value } );
106 } else {
107   $cgp_rule_action = new FS::cgp_rule_action {};
108 }
109
110 my $action = scalar($cgi->param($name.'_action'))
111              || $cgp_rule_action->action;
112
113 my $disabled = $noparam{$action} ? 'DISABLED' : '';
114 my $style = $disabled ? 'STYLE="visibility:hidden"' : '';
115
116 </%init>