summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-cgp_rule_action.html
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements/select-cgp_rule_action.html')
-rw-r--r--httemplate/elements/select-cgp_rule_action.html116
1 files changed, 116 insertions, 0 deletions
diff --git a/httemplate/elements/select-cgp_rule_action.html b/httemplate/elements/select-cgp_rule_action.html
new file mode 100644
index 0000000..7cefdc4
--- /dev/null
+++ b/httemplate/elements/select-cgp_rule_action.html
@@ -0,0 +1,116 @@
+% unless ( $opt{'js_only'} ) {
+
+ <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<%$curr_value%>">
+
+ <% include( 'select.html',
+ 'field' => $name.'_action',
+ 'id' => $id.'_action',
+ 'options' => \@actions,
+ 'curr_value' => $action,
+ 'labels' => { '' => 'Select Action' },
+ 'onchange' => $name.'_changed',
+ 'style' => 'vertical-align:top',
+ )
+ %>
+
+ <TEXTAREA NAME = "<% $name %>_params"
+ ID = "<% $id %>_params"
+ <% $disabled %>
+ <% $style %>
+%# <% $rows %>
+%# <% $cols %>
+%# <% $onchange %>
+ ><% scalar($cgi->param($name.'_params')) || $cgp_rule_action->params |h %></TEXTAREA>
+
+% }
+% unless ( $opt{'html_only'} || $opt{'js_only'} ) {
+ <SCRIPT TYPE="text/javascript">
+% }
+% unless ( $opt{'html_only'} ) {
+
+ function <% $name %>_changed(what) {
+
+ <% $opt{'onchange'} %>
+
+ var <% $name %>_value = what.options[what.selectedIndex].value;
+
+ var params_Element = what.form.<% $name %>_params;
+
+ // if bool, hide/disable _op and _params entirely
+ if ( <%$name%>_value == '' || <%$name%>_value == 'Stop Processing' || <%$name%>_value == 'Discard' ) {
+ params_Element.disabled = true;
+ params_Element.style.visibility = "hidden";
+ } else {
+ params_Element.disabled = false;
+ params_Element.style.visibility = "visible";
+
+ }
+
+ }
+
+% }
+% unless ( $opt{'html_only'} || $opt{'js_only'} ) {
+ </SCRIPT>
+% }
+<%once>
+
+my @actions = (
+ '',
+
+ #generic http://www.communigate.com/CommunigatePro/Rules.html#Actions
+ 'Reject',
+ 'SendURL',
+ 'Send IM',
+ 'FingerNotify',
+ 'Write To Log',
+ "Remember 'From' in",
+
+ #email http://www.communigate.com/CommunigatePro/QueueRules.html#Actions
+ 'Stop Processing',
+ 'Discard',
+ 'Reject With',
+ 'Mark',
+ 'Add Header',
+ 'Tag Subject',
+ 'Store in',
+ 'Redirect to',
+ 'Forward to',
+ 'Mirror to',
+ 'Reply with',
+ 'Reply to All with',
+ 'React with',
+ 'store Encrypted in',
+ 'Copy attachments into',
+ 'Execute',
+ 'ExternalFilter',
+ 'Accept Request',
+);
+
+my %noparam = ( map { $_=>1 } '', 'Stop Processing', 'Discard' );
+
+</%once>
+<%init>
+
+my %opt = @_;
+
+my $name = $opt{'element_name'} || $opt{'field'} || 'ruleactionnum';
+#my $id = $opt{'id'} || 'contactnum';
+my $id = $opt{'id'} || $opt{'field'} || 'ruleactionnum';
+
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+my $cgp_rule_action;
+if ( $curr_value ) {
+ $cgp_rule_action = qsearchs('cgp_rule_action',
+ { 'ruleactionnum' => $curr_value } );
+} else {
+ $cgp_rule_action = new FS::cgp_rule_action {};
+}
+
+my $action = scalar($cgi->param($name.'_action'))
+ || $cgp_rule_action->action;
+
+my $disabled = $noparam{$action} ? 'DISABLED' : '';
+my $style = $disabled ? 'STYLE="visibility:hidden"' : '';
+
+</%init>