diff options
author | Mark Wells <mark@freeside.biz> | 2014-10-10 16:36:07 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-10-10 16:36:07 -0700 |
commit | 83e442de6a041fa3b7580d53912eeb1490ddf47c (patch) | |
tree | 2dc9a967c5e26ec27b083ce40acea6b254b7a29b /httemplate/edit | |
parent | 2a26e4616da323e083c941e9a8c3d2b35377bc3f (diff) |
upstream-markup call rating and global default rates, #30633
Diffstat (limited to 'httemplate/edit')
-rw-r--r-- | httemplate/edit/elements/rate_detail.html | 102 | ||||
-rw-r--r-- | httemplate/edit/process/rate_detail.html | 32 | ||||
-rw-r--r-- | httemplate/edit/rate_detail.html | 22 |
3 files changed, 120 insertions, 36 deletions
diff --git a/httemplate/edit/elements/rate_detail.html b/httemplate/edit/elements/rate_detail.html index 14b52110b..7b5ec314a 100644 --- a/httemplate/edit/elements/rate_detail.html +++ b/httemplate/edit/elements/rate_detail.html @@ -47,34 +47,85 @@ with row headers showing the region name and prefixes. % } % foreach my $rate_time (@rate_time, '') { <TD> -% my $detail = $details[$row][$col]; -% if($detail) { + <& .detail_box, + detail => $details[$row][$col], + ratetimenum => ($rate_time ? $rate_time->ratetimenum : ''), + cdrtypenum => $cdrtypenum, + regionnum => $region->regionnum, + ratenum => $rate->ratenum + &> +% $col++; + </TD> +% } # foreach @rate_time +</TR> +% $row++; +% }# foreach @rate_region +% if ( !$opt{regionnum} ) { +%# global default +<TR> + <TD COLSPAN=2 STYLE="padding-top: 10px"> + <B>Global default</B> (for calls not matching any prefix) + </TD> + <TD STYLE="padding-top: 10px"> +% # default rate: set a null region + <B> + <& .detail_box, + detail => $rate->default_detail, + ratetimenum => '', + cdrtypenum => '', + regionnum => '', + ratenum => $rate->ratenum + &> + </B> + </TD> +% } +</TABLE> +<%def .detail_box> +<%args> +$detail => undef, +$ratetimenum +$cdrtypenum +$regionnum +$ratenum +</%args> +% if ($detail) { <TABLE CLASS="inv" STYLE="border:none"> - <TR><TD><% edit_link($detail) %><% $money_char.$detail->min_charge %> + <TR><TD><% edit_link($detail) %> +% if ( $detail->min_charge > 0 or $detail->conn_charge > 0) { + <% $money_char.$detail->min_charge %> <% $detail->sec_granularity ? ' / minute':' / call' %> % if ( $detail->min_cost ) { (<% $money_char.$detail->min_cost %> cost) % } +% if ( $detail->upstream_mult_charge > 0 +% or $detail->upstream_mult_cost > 0) { + <BR>+ +% } +% } +% if ( $detail->upstream_mult_charge > 0 +% or $detail->upstream_mult_cost > 0) { + <% $detail->upstream_mult_charge %> × upstream price +% if ( $detail->upstream_mult_cost > 0 ) { + (<% $detail->upstream_mult_cost %> cost) +% } +% } +% if ( $detail->upstream_mult_charge == 0 +% and $detail->min_charge == 0 +% and $detail->conn_charge == 0 ) { + Free +% } <% $edit_hint %></A> </TD></TR> <% granularity_detail($detail) %> <% min_included_detail($detail) %> <% conn_charge_detail($detail) %> - <TR><TD><% ( $rate_time || $cdrtypenum ) ? delete_link($detail) : '' %> + <TR><TD><% ( $ratetimenum || $cdrtypenum ) ? delete_link($detail) : '' %> </TD></TR> </TABLE> -% } -% else { #!$detail - <% add_link($rate, $region, $rate_time, $cdrtypenum) %> -% } -% $col++; - </TD> -% } # foreach @rate_time -</TR> -% $row++; -% }# foreach @rate_region -</TABLE> - +% } else { + <% add_link($ratenum, $regionnum, $ratetimenum, $cdrtypenum) %> +% } +</%def> <%once> tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); @@ -95,25 +146,27 @@ sub edit_link { include( '/elements/popup_link_onclick.html', 'action' => "${p}edit/rate_detail.html?$ratedetailnum", 'actionlabel' => 'Edit rate', - 'height' => 460, + 'height' => 550, + 'width' => 580, #default# 'width' => 540, #default# 'color' => '#333399', ) . '">' } sub add_link { - my ($rate, $region, $rate_time, $cdrtypenum) = @_; + my ($ratenum, $regionnum, $ratetimenum, $cdrtypenum) = @_; '<A HREF="javascript:void(0);" onclick="'. include( '/elements/popup_link_onclick.html', 'action' => "${p}edit/rate_detail.html?ratenum=". - $rate->ratenum. + $ratenum. ';dest_regionnum='. - $region->regionnum. + $regionnum. ';ratetimenum='. - ($rate_time ? $rate_time->ratetimenum : ''). + ($ratetimenum || ''). ";cdrtypenum=$cdrtypenum", 'actionlabel' => 'Add rate', - 'height' => 460, + 'width' => 580, + 'height' => 550, ).'">'.small('(add)').'</A>' } @@ -133,7 +186,10 @@ sub delete_link { sub granularity_detail { my $rate_detail = shift; - if($rate_detail->sec_granularity != 60 && $rate_detail->sec_granularity > 0) { + if( + $rate_detail->sec_granularity != 60 + && $rate_detail->sec_granularity > 0 + && $rate_detail->min_charge > 0) { '<TR><TD>'. small('in '.$granularity{$rate_detail->sec_granularity}.' increments'). '</TD></TR>'; 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> diff --git a/httemplate/edit/rate_detail.html b/httemplate/edit/rate_detail.html index 0de6ecc1e..3e800726e 100644 --- a/httemplate/edit/rate_detail.html +++ b/httemplate/edit/rate_detail.html @@ -15,6 +15,8 @@ 'conn_cost' => 'Wholesale connection cost', 'min_cost' => 'Wholesale cost per minute/call', 'classnum' => 'Usage class', + 'upstream_mult_charge'=> 'Upstream multiplier (retail)', + 'upstream_mult_cost' => 'Upstream multiplier (cost)', }, 'fields' => [ { field=>'ratenum', type=>'hidden', }, @@ -46,13 +48,15 @@ labels => \%granularity, disable_empty => 1, }, - { field =>'classnum', - type =>'select-table', - table =>'usage_class', - name_col =>'classname', - empty_label =>'(default)', - hashref =>{ disabled => '' }, + { field => 'classnum', + type => 'select-table', + table => 'usage_class', + name_col => 'classname', + empty_label => '(default)', + hashref => { disabled => '' }, }, + { field => 'upstream_mult_charge', type => 'text', }, + { field => 'upstream_mult_cost', type => 'text', }, ], 'new_hashref_callback' => sub { @@ -62,6 +66,8 @@ cdrtypenum => scalar($cgi->param('cdrtypenum')), min_included => 0, conn_charge => 0, + upstream_mult_charge => 0, + upstream_mult_cost => 0, } }, ) @@ -85,8 +91,8 @@ if ( $keywords =~ /^(\d+)$/ || $cgi->param('ratedetailnum') =~ /^(\d+)$/ ) { my $rate_detail = qsearchs('rate_detail', { 'ratedetailnum' => $1 } ) or die "unknown ratedetailnum $1"; - $name = - $rate_detail->rate->ratename. ' rate for '. $rate_detail->dest_regionname; + $name = $rate_detail->rate->ratename. ' rate for '. + ($rate_detail->dest_regionname || 'global default'); } #sec_granularity should default to 60! for new rates when this gets used for em |