optimize CDR rating after timed rate perf regression, RT#15739
[freeside.git] / httemplate / edit / cgp_rule-redirect_all.html
1 <% include('/elements/header-popup.html', 'Redirect all mail') %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM NAME="RedirectAllForm" ACTION="process/cgp_rule-redirect_all.html" METHOD=POST>
6
7 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $opt{'svcnum'} %>">
8
9 <% ntable("#cccccc", 2) %>
10
11 <TR>
12   <TD ALIGN="right">Redirect all mail to</TD>
13   <TD><textarea name="RedirectText" rows="5" cols="50"><% $mirror_or_redir ? $mirror_or_redir->params : '' %></textarea></TD>
14 </TR>
15
16 <% include('/elements/tr-checkbox.html',
17              'field'      => 'RedirKeep',
18              'label'      => 'Keep a copy',
19              'value'      => 1,
20              'curr_value' => ( $cgi->param('error')
21                                  ? scalar($cgi->param('RedirKeep'))
22                                  : ( ($redir_keep || !$cgp_rule) ? '' : 1 )
23                              ),
24           )
25 %>
26
27 <% include('/elements/tr-checkbox.html',
28              'field'      => 'RedirHuman',
29              'label'      => 'Do not redirect automatic messages',
30              'value'      => 1,
31              'curr_value' => ( $cgi->param('error')
32                                  ? scalar($cgi->param('RedirHuman'))
33                                  : ( $redir_human ? 1 : '' )
34                              ),
35           )
36 %>
37
38 <% include('/elements/tr-checkbox.html',
39              'field'      => 'KeepToAndCc',
40              'label'      => 'Preserve To/Cc fields',
41              'value'      => 1,
42              'curr_value' => ( $cgi->param('error')
43                                  ? scalar($cgi->param('KeepToAndCc'))
44                                  : ( $mirror_or_redir &&
45                                      $mirror_or_redir->action eq 'Mirror To' )
46                              ),
47           )
48 %>
49
50 </TABLE>
51
52 <BR>
53 <INPUT TYPE="submit" VALUE="Redirect all mail">
54
55 </FORM>
56
57 </BODY>
58 </HTML>
59 <%init>
60
61 my %opt = @_;
62
63 my $svc_acct = qsearchs('svc_acct', { 'svcnum' => $opt{'svcnum'} } )
64   or die "unknown svcnum";
65
66 #look for existing rule
67 my $cgp_rule = qsearchs('cgp_rule', { 'svcnum' => $svc_acct->svcnum,
68                                       'name'   => '#Redirect'
69                                     }
70                        );
71
72 my( $redir_human, $mirror_or_redir, $redir_keep ) = ( '', '', '' );
73 if ( $cgp_rule ) {
74   $redir_human = qsearchs('cgp_rule_condition', {
75     'rulenum'       => $cgp_rule->rulenum,
76     'conditionname' => 'Human Generated',
77   });
78   $mirror_or_redir = qsearchs({
79     'table'     => 'cgp_rule_action',
80     'hashref'   => { 'rulenum' => $cgp_rule->rulenum, },
81     'extra_sql' => " AND action IN ('Mirror To', 'Redirect To') ",
82   });
83   $redir_keep = qsearchs('cgp_rule_action', {
84     'rulenum' => $cgp_rule->rulenum,
85     'action'  => 'Discard',
86   });
87 }
88
89 </%init>