1 <% include('elements/browse.html',
2 'title' => "Rules for $svc_label: $svc_value",
3 'name_singular' => 'rule',
4 'html_init' => $html_init,
5 'query' => { 'table' => 'cgp_rule',
6 'hashref' => { 'svcnum' => $svcnum },
7 'order_by' => 'ORDER BY priority DESC',
9 'count_query' => $count_query,
10 'header' => [ 'Priority', 'Name', 'Conditions', 'Actions', '' ],
11 'fields' => [ sub { shift->priority || 'Inactive'; },
18 'links' => [ $edit_sub, $edit_sub, '', '', $del_sub ],
23 $cgi->param('svcnum') =~ /^(\d+)$/ or die 'no svcnum';
26 #agent virt so you can't do cross-agent communigate rules
27 my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svcnum })
28 or die 'unknown svcnum';
29 my $part_svc = $cust_svc->part_svc;
31 my $count_query = "SELECT COUNT(*) FROM cgp_rule WHERE svcnum = $svcnum";
33 my($svc_label, $svc_value, $svcdb) = $cust_svc->label;
35 my $view = FS::UI::Web::svc_url( 'm' => $m,
37 'part_svc' => $part_svc,
42 qq(<A HREF="$view">View this $svc_label</A><BR><BR>).
43 qq!<A HREF="${p}edit/cgp_rule.html?svcnum=$svcnum">Add new rule</A><BR>!;
45 if ( $part_svc->svcdb eq 'svc_domain' ) {
47 #XXX add areyousure javscript confirmation for adding these
49 foreach my $line ( FS::Conf->new->config('cgp_rule-domain_templates') ) {
50 $line =~ /^\s*(\d+)\s+(.+)\s*$/ or next;
51 my($t_svcnum, $t_name) = ( $1, $2 );
52 next if $t_svcnum == $svcnum;
54 qq!<A HREF="${p}misc/clone-cgp_rule.html?clone=$t_svcnum;svcnum=$svcnum">!
55 ."Add $t_name rule</A><BR>";
64 function areyousure_delete(href) {
65 areyousure(href,"Are you sure you want to delete this rule?");
67 function areyousure(href,message) {
68 if (confirm(message) == true)
69 window.location.href = href;
74 my $condition_sub = sub {
79 { data => $_->conditionname,
90 $cgp_rule->cgp_rule_condition
94 my $action_sub = sub {
99 { data => $_->action },
100 #{ data => '<pre>'.$_->params.'</pre>' }, #gets very big.. limit to
101 { data => $_->params }, # some actions?
104 $cgp_rule->cgp_rule_action
108 my $edit_sub = [ $p.'edit/cgp_rule.html?', 'rulenum' ];
110 my $rulenum = shift->rulenum;
111 [ "javascript:areyousure_delete('${p}misc/delete-cgp_rule.html?$rulenum')", '' ];