1 % if ( $error ) { #redirect back to edit...
2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(3).'edit/'.$opt{'redirect'}.'?'. $cgi->query_string) %>
4 % } else { #success XXX better msg talking about vacation vs. redirect all
5 <% include('/elements/header-popup.html', 'Rule updated') %>
6 <SCRIPT TYPE="text/javascript">
18 'svcnum' => scalar($cgi->param('svcnum')),
19 'name' => $opt{'name'},
22 my $cgp_rule = qsearchs('cgp_rule', \%hash);
25 if ( $cgp_rule ) { #updating
26 $error = $cgp_rule->delete;
29 $cgp_rule = new FS::cgp_rule { %hash, 'priority' => $opt{'priority'} };
30 $error ||= $cgp_rule->insert;
32 foreach my $condition ( @{ $opt{'conditions'} } ) {
33 my $cgp_rule_condition = new FS::cgp_rule_condition {
35 'rulenum' => $cgp_rule->rulenum,
37 $error ||= $cgp_rule_condition->insert;
40 foreach my $action ( @{ $opt{'actions'} } ) {
41 my $cgp_rule_action = new FS::cgp_rule_action {
43 'rulenum' => $cgp_rule->rulenum,
45 $error ||= $cgp_rule_action->insert;
49 my $export_error = $cgp_rule->svc_export;
50 die $export_error if $export_error; #error handling sucks wrt this... shouldn't happen though