1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<% 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 $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' => $cust_svc->part_svc,
'svc' => $cust_svc,
);
my $html_init =
qq(<A HREF="$view">View this $svc_label</A><BR><BR>).
qq!<A HREF="${p}edit/cgp_rule.html?svcnum=$svcnum">Add new rule</A><BR><BR>!;
my $condition_sub = sub {
my $cgp_rule = shift;
[ map {
[
{ data => $_->condition,
#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 => '<pre>'.$_->params.'</pre>' }, #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 = [ $p.'misc/delete-cgp_rule.html?', 'rulenum' ]; #XXX javascript areyousure or something
</%init>
|