RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / process / rate_detail.html
index 6200d61..4020ce9 100644 (file)
@@ -1,13 +1,26 @@
-<% include( 'elements/process.html',
-              'table' => 'rate_detail',
-              'popup_reload' => 'Rate changed', #a popup "parent reload" for now
+<& elements/process.html,
+  'table' => 'rate_detail',
+  'popup_reload' => 'Rate changed', #a popup "parent reload" for now
               #someday change the individual element and go away instead
-          )
-%>
+  #'noerror_callback' => $set_default_detail
+&>
 <%init>
 
 my $conf = new FS::Conf;
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
 
+my $set_default_detail = sub {
+  my ($cgi, $rate_detail) = @_;
+  if (!$rate_detail->dest_regionnum and !$rate_detail->cdrtypenum) {
+    # then this is a global default rate
+    # default_detailnum is no longer used, but maintain it anyway (and point
+    # it at the one with null cdrtypenum)
+    my $rate = $rate_detail->rate;
+    $rate->set('default_detailnum' => $rate_detail->ratedetailnum);
+    my $error = $rate->replace;
+    die "$error (setting default rate)\n" if $error;
+  }
+};
+
 </%init>