<% include('elements/browse.html', 'title' => "Rules for $svc_label: $svc_value", 'name_singular' => 'rule', 'html_init' => $html_init, 'query' => { 'table' => 'cgp_rule', 'hashref' => { 'svcnum' => $svcnum }, 'order_by' => 'ORDER BY priority DESC', }, 'count_query' => $count_query, 'header' => [ 'Priority', 'Name', 'Conditions', 'Actions', '' ], 'fields' => [ sub { shift->priority || 'Inactive'; }, 'name', $condition_sub, $action_sub, sub { 'Delete'; }, ], #'align' 'links' => [ $edit_sub, $edit_sub, '', '', $del_sub ], ) %> <%init> $cgi->param('svcnum') =~ /^(\d+)$/ or die 'no svcnum'; my $svcnum = $1; #agent virt so you can't do cross-agent communigate rules my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svcnum }) or die 'unknown svcnum'; my $part_svc = $cust_svc->part_svc; my $count_query = "SELECT COUNT(*) FROM cgp_rule WHERE svcnum = $svcnum"; my($svc_label, $svc_value, $svcdb) = $cust_svc->label; my $view = FS::UI::Web::svc_url( 'm' => $m, 'action' => 'view', 'part_svc' => $part_svc, 'svc' => $cust_svc, ); my $html_init = qq(View this $svc_label
). qq!Add new rule
!; if ( $part_svc->svcdb eq 'svc_domain' ) { #XXX add areyousure javscript confirmation for adding these foreach my $line ( FS::Conf->new->config('cgp_rule-domain_templates') ) { $line =~ /^\s*(\d+)\s+(.+)\s*$/ or next; my($t_svcnum, $t_name) = ( $1, $2 ); next if $t_svcnum == $svcnum; $html_init .= qq!! ."Add $t_name rule
"; } } $html_init .= '
'. qq!
!; my $condition_sub = sub { my $cgp_rule = shift; [ map { [ { data => $_->conditionname, #align => }, { data => $_->op, align => 'center', }, { data => $_->params, #align => }, ]; } $cgp_rule->cgp_rule_condition ]; }; my $action_sub = sub { my $cgp_rule = shift; [ map { [ { data => $_->action }, #{ data => '

    '.$_->params.'

' }, #gets very big.. limit to { data => $_->params }, # some actions? ]; } $cgp_rule->cgp_rule_action ]; }; my $edit_sub = [ $p.'edit/cgp_rule.html?', 'rulenum' ]; my $del_sub = sub { my $rulenum = shift->rulenum; [ "javascript:areyousure_delete('${p}misc/delete-cgp_rule.html?$rulenum')", '' ]; };