+ qq!<A HREF="${p}edit/cgp_rule.html?svcnum=$svcnum">Add new rule</A><BR>!;
+
+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!<A HREF="${p}misc/clone-cgp_rule.html?clone=$t_svcnum;svcnum=$svcnum">!
+ ."Add $t_name rule</A><BR>";
+ }
+
+}
+
+$html_init .=
+ '<BR>'.
+ qq!
+ <SCRIPT>
+ function areyousure_delete(href) {
+ areyousure(href,"Are you sure you want to delete this rule?");
+ }
+ function areyousure(href,message) {
+ if (confirm(message) == true)
+ window.location.href = href;
+ }
+ </SCRIPT>
+!;
+
+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 => '<pre>'.$_->params.'</pre>' }, #gets very big.. limit to
+ { data => $_->params }, # some actions?
+ ];
+ }
+ $cgp_rule->cgp_rule_action
+ ];
+};