2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "rate_region.cgi?". $cgi->query_string ) %>
5 <% $cgi->redirect(popurl(3). "browse/rate_region.html") %>
9 my $conf = new FS::Conf;
11 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
13 my $regionnum = $cgi->param('regionnum');
15 my $old = qsearchs('rate_region', { 'regionnum' => $regionnum } ) if $regionnum;
17 my $new = new FS::rate_region ( {
19 $_, scalar($cgi->param($_));
20 } ( fields('rate_region') )
23 my $countrycode = $cgi->param('countrycode');
24 my @npa = split(/\s*,\s*/, $cgi->param('npa'));
25 $npa[0] = '' unless @npa;
26 my @rate_prefix = map {
27 #my($npa,$nxx) = split('-', $_);
30 'countrycode' => $countrycode,
37 my @dest_detail = map {
38 my $ratenum = $_->ratenum;
40 'ratenum' => $ratenum,
41 map { $_ => $cgi->param("$_$ratenum") }
42 qw( min_included min_charge sec_granularity classnum )
44 } qsearch('rate', {} );
49 $error = $new->replace($old, 'rate_prefix' => \@rate_prefix,
50 'dest_detail' => \@dest_detail, );
52 $error = $new->insert( 'rate_prefix' => \@rate_prefix,
53 'dest_detail' => \@dest_detail, );
54 $regionnum = $new->getfield('regionnum');