% include('elements/edit.html',
'popup' => 1,
'name' => $name,
'table' => 'rate_detail',
'labels' => { 'ratedetailnum' => 'Rate', #should hide...
'dest_regionname' => 'Region',
'dest_prefixes_short' => 'Prefix(es)',
'rate_time_name' => 'Time period',
'min_included' => 'Included minutes/calls',
'region_group' => 'Region Group',
'conn_charge' => 'Retail connection charge',
'conn_sec' => 'For',
'min_charge' => 'Retail charge per minute/call',
'sec_granularity' => 'Granularity',
'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', },
{ field=>'orig_regionnum', type=>'hidden', },
{ field=>'dest_regionnum', type=>'hidden', },
{ field=>'ratetimenum', type=>'hidden', },
{ field=>'cdrtypenum', type=>'hidden', },
{ field=>'dest_regionname', type=>'fixed', },
{ field=>'dest_prefixes_short', type=>'fixed', },
{ field=>'rate_time_name', type=>'fixed', },
{ field => 'region_group',
type => 'checkbox',
value => 'Y',
},
{ field=>'min_included', type=>'text', size=>5 },
{ field=>'conn_charge', type=>'money', size=>4 },
{ field=>'conn_cost', type=>'money', size=>4 },
{ field =>'conn_sec',
type =>'select',
options => [ keys %conn_secs ],
labels => \%conn_secs,
disable_empty => 1,
},
{ field=>'min_charge', type=>'money', size=>4 },
{ field=>'min_cost', type=>'money', size=>4 },
{ field =>'sec_granularity',
type =>'select',
options => [ keys %granularity ],
labels => \%granularity,
disable_empty => 1,
},
{ 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 {
{ ratenum => scalar($cgi->param('ratenum')),
dest_regionnum => scalar($cgi->param('dest_regionnum')),
ratetimenum => scalar($cgi->param('ratetimenum')),
cdrtypenum => scalar($cgi->param('cdrtypenum')),
min_included => 0,
conn_charge => 0,
upstream_mult_charge => 0,
upstream_mult_cost => 0,
}
},
)
%>
<%once>
tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
tie my %conn_secs, 'Tie::IxHash', FS::rate_detail::conn_secs();
%once>
<%init>
my $conf = new FS::Conf;
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
#slightly inefficient, i suppose an edit+error callback would be better
my $name = 'rate';
my ($keywords) = $cgi->keywords;
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 || 'global default');
}
#sec_granularity should default to 60! for new rates when this gets used for em
%init>