summaryrefslogtreecommitdiff
path: root/httemplate/edit/process
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-10-10 16:36:07 -0700
committerMark Wells <mark@freeside.biz>2014-10-10 16:36:07 -0700
commit83e442de6a041fa3b7580d53912eeb1490ddf47c (patch)
tree2dc9a967c5e26ec27b083ce40acea6b254b7a29b /httemplate/edit/process
parent2a26e4616da323e083c941e9a8c3d2b35377bc3f (diff)
upstream-markup call rating and global default rates, #30633
Diffstat (limited to 'httemplate/edit/process')
-rw-r--r--httemplate/edit/process/rate_detail.html32
1 files changed, 27 insertions, 5 deletions
diff --git a/httemplate/edit/process/rate_detail.html b/httemplate/edit/process/rate_detail.html
index 6200d615f..0709d5079 100644
--- a/httemplate/edit/process/rate_detail.html
+++ b/httemplate/edit/process/rate_detail.html
@@ -1,13 +1,35 @@
-<% 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) = @_;
+warn Dumper $rate_detail;
+ if (!$rate_detail->dest_regionnum) {
+ # then this is a global default rate
+ my $rate = $rate_detail->rate;
+ if ($rate->default_detailnum) {
+ if ($rate->default_detailnum == $rate_detail->ratedetailnum) {
+ return;
+ } else {
+ # there's somehow an existing default rate. remove it.
+ my $old_default = $rate->default_detail;
+ my $error = $old_default->delete;
+ die "$error (removing old default rate)\n" if $error;
+ }
+ }
+ $rate->set('default_detailnum' => $rate_detail->ratedetailnum);
+ my $error = $rate->replace;
+ die "$error (setting default rate)\n" if $error;
+ }
+};
+
</%init>