1 <% include( 'elements/browse.html',
3 'name_singular' => 'rate',
4 'html_init' => $html_init,
5 'menubar' => [ 'Rate plans' => $p.'browse/rate.cgi' ],
7 'table' => 'rate_detail',
9 'hashref' => { 'ratenum' => $ratenum },
10 'extra_sql' => $where,
12 'count_query' => "SELECT COUNT(*) FROM rate_detail $join".
13 " WHERE ratenum = $ratenum $where",
17 'Included<BR>minutes',
18 'Connection<BR>charge',
19 'Charge per<BR>minute',
25 sub { shift->dest_region->prefixes_short },
26 sub { shift->min_included. $edit_hint },
28 sub { $money_char. shift->min_charge. $edit_hint },
29 sub { $granularity{ shift->sec_granularity } },
32 'links' => [ '', '', $edit_link, $edit_link, '', '' ],
33 'link_onclicks' => [ '', '', $edit_onclick, $edit_onclick, '', '' ],
39 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
40 tie my %conn_secs, 'Tie::IxHash', FS::rate_detail::conn_secs();
42 my $conf = new FS::Conf;
43 my $money_char = $conf->config('money_char') || '$';
46 ' JOIN rate_region ON ( rate_detail.dest_regionnum = rate_region.regionnum )';
48 my $edit_link = [ 'javascript:void(0);', sub { ''; } ];
50 my $edit_onclick = sub {
51 my $rate_detail = shift;
52 my $ratedetailnum = $rate_detail->ratedetailnum;
53 include( '/elements/popup_link_onclick.html',
54 'action' => "${p}edit/rate_detail.html?$ratedetailnum",
55 'actionlabel' => 'Edit rate',
57 #default# 'width' => 540,
58 #default# 'color' => '#333399',
61 my $edit_hint = ' <FONT SIZE="-1">(edit)</FONT>';
63 my $conn_charge_sub = sub {
64 my $rate_detail = shift;
65 #return '' unless $rate_detail->conn_charge > 0 || $rate_detail->conn_sec;
66 $money_char. $rate_detail->conn_charge.
67 ($rate_detail->conn_sec ? ' for '.$conn_secs{$rate_detail->conn_sec} : '').
75 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
77 my $html_init = include('/elements/init_overlib.html');
79 $cgi->param('ratenum') =~ /^(\d+)$/ or die "unparsable ratenum";
81 my $rate = qsearchs('rate', { 'ratenum' => $ratenum } )
82 or die "unknown ratenum $ratenum";
83 my $ratename = $rate->ratename;
84 my $title = "$ratename rates";
88 if ( $cgi->param('countrycode') =~ /^(\d+)$/ ) {
90 push @where, "0 < ( SELECT COUNT(*) FROM rate_prefix
91 WHERE rate_prefix.regionnum = rate_region.regionnum
92 AND countrycode = '$countrycode'
95 $title .= " for +$countrycode";
98 my $where = scalar(@where) ? ' AND '.join(' AND ', @where ) : '';