1 <% include('elements/edit.html',
4 'table' => 'rate_detail',
5 'labels' => { 'ratedetailnum' => 'Rate', #should hide...
6 'dest_regionname' => 'Region',
7 'dest_prefixes_short' => 'Prefix(es)',
8 'rate_time_name' => 'Time period',
9 'min_included' => 'Included minutes/calls',
10 'region_group' => 'Region Group',
11 'conn_charge' => 'Retail connection charge',
13 'min_charge' => 'Retail charge per minute/call',
14 'sec_granularity' => 'Granularity',
15 'conn_cost' => 'Wholesale connection cost',
16 'min_cost' => 'Wholesale cost per minute/call',
17 'classnum' => 'Usage class',
20 { field=>'ratenum', type=>'hidden', },
21 { field=>'orig_regionnum', type=>'hidden', },
22 { field=>'dest_regionnum', type=>'hidden', },
23 { field=>'ratetimenum', type=>'hidden', },
24 { field=>'cdrtypenum', type=>'hidden', },
25 { field=>'dest_regionname', type=>'fixed', },
26 { field=>'dest_prefixes_short', type=>'fixed', },
27 { field=>'rate_time_name', type=>'fixed', },
28 { field => 'region_group',
32 { field=>'min_included', type=>'text', size=>5 },
33 { field=>'conn_charge', type=>'money', size=>4 },
34 { field=>'conn_cost', type=>'money', size=>4 },
37 options => [ keys %conn_secs ],
38 labels => \%conn_secs,
41 { field=>'min_charge', type=>'money', size=>4 },
42 { field=>'min_cost', type=>'money', size=>4 },
43 { field =>'sec_granularity',
45 options => [ keys %granularity ],
46 labels => \%granularity,
50 type =>'select-table',
51 table =>'usage_class',
52 name_col =>'classname',
53 empty_label =>'(default)',
54 hashref =>{ disabled => '' },
58 'new_hashref_callback' => sub {
59 { ratenum => scalar($cgi->param('ratenum')),
60 dest_regionnum => scalar($cgi->param('dest_regionnum')),
61 ratetimenum => scalar($cgi->param('ratetimenum')),
62 cdrtypenum => scalar($cgi->param('cdrtypenum')),
71 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
72 tie my %conn_secs, 'Tie::IxHash', FS::rate_detail::conn_secs();
77 my $conf = new FS::Conf;
79 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
81 #slightly inefficient, i suppose an edit+error callback would be better
83 my ($keywords) = $cgi->keywords;
84 if ( $keywords =~ /^(\d+)$/
85 || $cgi->param('ratedetailnum') =~ /^(\d+)$/ ) {
86 my $rate_detail = qsearchs('rate_detail', { 'ratedetailnum' => $1 } )
87 or die "unknown ratedetailnum $1";
89 $rate_detail->rate->ratename. ' rate for '. $rate_detail->dest_regionname;
92 #sec_granularity should default to 60! for new rates when this gets used for em