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 'Charge per<BR>minute',
24 sub { shift->dest_region->prefixes_short },
25 sub { shift->min_included.
26 ' <FONT SIZE="-1">(edit)</FONT>';
28 sub { $money_char. shift->min_charge.
29 ' <FONT SIZE="-1">(edit)</FONT>';
31 sub { $granularity{ shift->sec_granularity } },
34 'links' => [ '', '', $edit_link, $edit_link, '', '' ],
35 'link_onclicks' => [ '', '', $edit_onclick, $edit_onclick, '', '' ],
41 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
43 my $conf = new FS::Conf;
44 my $money_char = $conf->config('money_char') || '$';
47 ' JOIN rate_region ON ( rate_detail.dest_regionnum = rate_region.regionnum )';
49 my $edit_link = [ 'javascript:void(0);', sub { ''; } ];
51 my $edit_onclick = sub {
52 my $rate_detail = shift;
53 my $ratedetailnum = $rate_detail->ratedetailnum;
54 include( '/elements/popup_link_onclick.html',
55 'action' => "${p}edit/rate_detail.html?$ratedetailnum",
56 'actionlabel' => 'Edit rate',
58 #default# 'width' => 540,
59 #default# 'color' => '#333399',
67 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
69 my $html_init = include('/elements/init_overlib.html');
71 $cgi->param('ratenum') =~ /^(\d+)$/ or die "unparsable ratenum";
73 my $rate = qsearchs('rate', { 'ratenum' => $ratenum } )
74 or die "unknown ratenum $ratenum";
75 my $ratename = $rate->ratename;
76 my $title = "$ratename rates";
80 if ( $cgi->param('countrycode') =~ /^(\d+)$/ ) {
82 push @where, "0 < ( SELECT COUNT(*) FROM rate_prefix
83 WHERE rate_prefix.regionnum = rate_region.regionnum
84 AND countrycode = '$countrycode'
87 $title .= " for +$countrycode";
90 my $where = scalar(@where) ? ' AND '.join(' AND ', @where ) : '';