<% 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' => 'Connection charge', 'conn_sec' => 'For', 'min_charge' => 'Charge per minute/call', 'sec_granularity' => 'Granularity', 'classnum' => 'Usage class', }, '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_sec', type =>'select', options => [ keys %conn_secs ], labels => \%conn_secs, disable_empty => 1, }, { field=>'min_charge', 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 => '' }, }, ], 'new_hashref_callback' => sub { { ratenum => $cgi->param('ratenum'), dest_regionnum => $cgi->param('dest_regionnum'), ratetimenum => $cgi->param('ratetimenum'), cdrtypenum => $cgi->param('cdrtypenum'), min_included => 0, conn_charge => 0, } }, ) %> <%once> tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); tie my %conn_secs, 'Tie::IxHash', FS::rate_detail::conn_secs(); <%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; } #sec_granularity should default to 60! for new rates when this gets used for em