X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2Frate_detail.html;h=73f65d5420c21225d679ee247bfbb174c6b0bddb;hb=f120002baa4ef8d96994c3a6e2129b7e39f003ca;hp=72a86aee78aa0129c299b8ceb086fce4318dfc62;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git
diff --git a/httemplate/edit/elements/rate_detail.html b/httemplate/edit/elements/rate_detail.html
index 72a86aee7..73f65d542 100644
--- a/httemplate/edit/elements/rate_detail.html
+++ b/httemplate/edit/elements/rate_detail.html
@@ -33,9 +33,9 @@ with row headers showing the region name and prefixes.
% $col = 0;
% if ( !$opt{'regionnum'} ) {
% $region = $r;
-% foreach ($r->regionname, $r->prefixes_short) {
+% foreach ($r->regionname, $r->prefixes_short_sql) {
- <% $_ %>
+ <% $_ |h %>
|
% }
% }
@@ -47,31 +47,85 @@ with row headers showing the region name and prefixes.
% }
% foreach my $rate_time (@rate_time, '') {
-% 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++;
+ |
+% } # foreach @rate_time
+
+% $row++;
+% }# foreach @rate_region
+% if ( !$opt{regionnum} ) {
+% # global default for this cdrtypenum
+
+
+ Global default (for calls not matching any prefix)
+ |
+
+% # default rate: set a null region for this cdr type
+
+ <& .detail_box,
+ detail => $rate->default_detail($cdrtypenum),
+ ratetimenum => '',
+ cdrtypenum => $cdrtypenum,
+ regionnum => '',
+ ratenum => $rate->ratenum
+ &>
+
+ |
+% }
+
+<%def .detail_box>
+<%args>
+$detail => undef,
+$ratetimenum
+$cdrtypenum
+$regionnum
+$ratenum
+%args>
+% if ($detail) {
- <% edit_link($detail) %><% $money_char.$detail->min_charge %>
+ |
<% 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) {
+ +
+% }
+% }
+% 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 %>
|
<% granularity_detail($detail) %>
<% min_included_detail($detail) %>
<% conn_charge_detail($detail) %>
- <% ( $rate_time || $cdrtypenum ) ? delete_link($detail) : '' %>
+ |
<% ( $ratetimenum || $cdrtypenum ) ? delete_link($detail) : '' %>
|
-% }
-% else { #!$detail
- <% add_link($rate, $region, $rate_time, $cdrtypenum) %>
-% }
-% $col++;
-
-% } # foreach @rate_time
-
-% $row++;
-% }# foreach @rate_region
-
-
+% } else {
+ <% add_link($ratenum, $regionnum, $ratetimenum, $cdrtypenum) %>
+% }
+%def>
<%once>
tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
@@ -92,25 +146,27 @@ sub edit_link {
include( '/elements/popup_link_onclick.html',
'action' => "${p}edit/rate_detail.html?$ratedetailnum",
'actionlabel' => 'Edit rate',
- 'height' => 420,
+ 'height' => 550,
+ 'width' => 580,
#default# 'width' => 540,
#default# 'color' => '#333399',
) . '">'
}
sub add_link {
- my ($rate, $region, $rate_time, $cdrtypenum) = @_;
+ my ($ratenum, $regionnum, $ratetimenum, $cdrtypenum) = @_;
'ratenum.
+ $ratenum.
';dest_regionnum='.
- $region->regionnum.
+ $regionnum.
';ratetimenum='.
- ($rate_time ? $rate_time->ratetimenum : '').
+ ($ratetimenum || '').
";cdrtypenum=$cdrtypenum",
'actionlabel' => 'Add rate',
- 'height' => 420,
+ 'width' => 580,
+ 'height' => 550,
).'">'.small('(add)').''
}
@@ -130,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) {
''.
small('in '.$granularity{$rate_detail->sec_granularity}.' increments').
' |
';
@@ -157,7 +216,11 @@ sub conn_charge_detail {
#return '' unless $rate_detail->conn_charge > 0 || $rate_detail->conn_sec;
''.
small( $money_char. $rate_detail->conn_charge.
- ' for '.$conn_secs{$rate_detail->conn_sec}
+ ( $rate_detail->conn_cost
+ ? ' ('. $money_char.$rate_detail->conn_cost. ' cost)'
+ : ''
+ ).
+ ' for '. $conn_secs{$rate_detail->conn_sec}
).
' |
'
}
@@ -189,29 +252,46 @@ my @rtns = ( map( { $_->ratetimenum } @rate_time ), '' );
my @details;
my @rows;
+
+my %rate_region = (
+ 'select' => 'rate_region.*, '.
+ "STRING_AGG(countrycode || ' ' || npa, ',') AS prefixes",
+ 'table' => 'rate_region',
+ 'addl_from' => 'LEFT JOIN rate_prefix USING ( regionnum ) ',
+ 'extra_sql' => 'GROUP BY ( rate_region.regionnum )',
+ 'order_by' => 'ORDER BY ( regionname )',
+);
+
if ( $ratenum ) {
+
if ( $regionnum ) {
- @rows = qsearch('rate_region',
- { ratenum => $ratenum, regionnum => $regionnum });
- }
- else {
- my $where = '';
+
+ @rows = qsearch({
+ %rate_region,
+ 'hashref' => { ratenum => $ratenum, regionnum => $regionnum },
+ });
+
+ } else {
+
if ( $opt{'countrycode'} ) {
- $where = "WHERE 0 < (
+ $rate_region{extra_sql} =
+ "WHERE 0 < (
SELECT COUNT(*) FROM rate_prefix
WHERE rate_prefix.regionnum = rate_region.regionnum
AND countrycode = '$opt{countrycode}'
- )";
+ ) ".
+ $rate_region{extra_sql};
}
- @rows = qsearch({ table => 'rate_region',
- hashref => { },
- extra_sql => $where,
- });
- die "no region found" if !@rows;
+ @rows = qsearch({ %rate_region,
+ hashref => {},
+ });
+ #die "no region found" if !@rows;
unshift @header, 'Region', 'Prefix(es)';
unshift @hlinks, '', '';
+
}
+
foreach my $region (@rows) {
push @details, [ map { qsearchs('rate_detail',
{ 'ratenum' => $ratenum,
@@ -221,8 +301,9 @@ if ( $ratenum ) {
} @rtns
];
}
-}
-elsif ( $regionnum ) {
+
+} elsif ( $regionnum ) {
+
@rows = qsearch('rate', {}) or die "no rate plans found";
unshift @header, 'Rate plan';
unshift @hlinks, '';
@@ -235,8 +316,8 @@ elsif ( $regionnum ) {
} @rtns
];
}
-}
-else {
+
+} else {
die "no ratenum or regionnum specified";
}