diff options
| author | Ivan Kohler <ivan@freeside.biz> | 2014-10-19 12:19:17 -0700 |
|---|---|---|
| committer | Ivan Kohler <ivan@freeside.biz> | 2014-10-19 12:19:17 -0700 |
| commit | 706da330626bab472bf6f4e50cf3c181bfa0cf9f (patch) | |
| tree | 85e4ef7dab7f25a965537fbecb455f2377113815 /httemplate/edit/process | |
| parent | 686acdfba1e10deaceea97cde1dccd99c928263a (diff) | |
| parent | 98ea15536afc6896cce08a41b877d6cb52444d14 (diff) | |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/edit/process')
| -rw-r--r-- | httemplate/edit/process/rate_detail.html | 32 |
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> |
