summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2010-06-07 02:39:35 +0000
committerivan <ivan>2010-06-07 02:39:35 +0000
commit31a9c95e5b7125ef666248699fff31f1f8211364 (patch)
tree3673d519ac208bbf6b4ecc174511d3cef99a1501 /httemplate
parentda99804133e55d5ce02402645b593a6de06d1947 (diff)
domain rules based on templates (rules from other domains), RT#7514
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/cgp_rule.html32
-rw-r--r--httemplate/edit/process/cgp_rule.html6
-rw-r--r--httemplate/edit/process/elements/process.html11
-rw-r--r--httemplate/misc/clone-cgp_rule.html27
4 files changed, 70 insertions, 6 deletions
diff --git a/httemplate/browse/cgp_rule.html b/httemplate/browse/cgp_rule.html
index 5be6bb4aa..8a427b828 100644
--- a/httemplate/browse/cgp_rule.html
+++ b/httemplate/browse/cgp_rule.html
@@ -26,25 +26,45 @@ 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' => $cust_svc->part_svc,
+ 'part_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>!.
+ qq!<A HREF="${p}edit/cgp_rule.html?svcnum=$svcnum">Add new rule</A><BR>!;
+
+if ( $part_svc->svcdb eq 'svc_domain' ) {
+
+ #areyousure 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 );
+ $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(href) {
- if (confirm("Are you sure you want to delete this rule?") == true)
+ 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>
@@ -87,7 +107,7 @@ my $action_sub = sub {
my $edit_sub = [ $p.'edit/cgp_rule.html?', 'rulenum' ];
my $del_sub = sub {
my $rulenum = shift->rulenum;
- [ "javascript:areyousure('${p}misc/delete-cgp_rule.html?$rulenum')", '' ];
+ [ "javascript:areyousure_delete('${p}misc/delete-cgp_rule.html?$rulenum')", '' ];
};
</%init>
diff --git a/httemplate/edit/process/cgp_rule.html b/httemplate/edit/process/cgp_rule.html
index 965341384..5326587cb 100644
--- a/httemplate/edit/process/cgp_rule.html
+++ b/httemplate/edit/process/cgp_rule.html
@@ -11,6 +11,12 @@
'fields' => [qw( action params )],
},
],
+ 'noerror_callback' => sub {
+ my( $cgi, $object ) = @_;
+ my $error = $object->svc_export;
+ #shit, not a good place for error handling :/
+ die $error if $error;
+ },
)
%>
<%init>
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 87cadb774..ebbc2f778 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -65,6 +65,9 @@ Example:
#return an error string or empty for no error
'precheck_callback' => sub { my( $cgi ) = @_; },
+ #after everything's inserted
+ 'noerror_callback' => sub { my( $cgi, $object ) = @_; },
+
#supplies arguments to insert() and replace()
# for use with tables that are FS::option_Common (among other things)
'args_callback' => sub { my( $cgi, $object ) = @_; },
@@ -298,12 +301,20 @@ if ( !$error && $opt{'process_o2m'} ) {
if ( $error ) {
+
$cgi->param('error', $error);
if ( $opt{'clear_on_error'} && scalar(@{$opt{'clear_on_error'}}) ) {
foreach my $field (@{$opt{'clear_on_error'}}) {
$cgi->param($field, '')
}
}
+
+} else {
+
+ if ( $opt{'noerror_callback'} ) {
+ &{ $opt{'noerror_callback'} }( $cgi, $new );
+ }
+
}
</%init>
diff --git a/httemplate/misc/clone-cgp_rule.html b/httemplate/misc/clone-cgp_rule.html
new file mode 100644
index 000000000..d821a2dff
--- /dev/null
+++ b/httemplate/misc/clone-cgp_rule.html
@@ -0,0 +1,27 @@
+% if ( $error ) {
+% errorpage($error);
+% } else {
+<% $cgi->redirect($p. "browse/cgp_rule.html?svcnum=". $svcnum) %>
+% }
+<%init>
+
+# :/ needs agent-virt so you can't futz with arbitrary rules
+
+#die "access denied"
+# unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service');
+
+#untaint svcnum and clone
+$cgi->param('svcnum') =~ /^(\d+)$/ || die "Illegal svcnum";
+my $svcnum = $1;
+$cgi->param('clone') =~ /^(\d+)$/ || die "Illegal clone";
+my $clone = $1;
+
+my @cgp_rule = qsearch('cgp_rule', { 'svcnum' => $clone } );
+
+my $error = '';
+foreach my $cgp_rule ( @cgp_rule ) {
+ $error = $cgp_rule->clone( $svcnum );
+ last if $error;
+}
+
+</%init>