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 {
28 'countrycode' => $countrycode,
33 my @dest_detail = map {
34 my $ratenum = $_->ratenum;
36 'ratenum' => $ratenum,
37 map { $_ => $cgi->param("$_$ratenum") }
38 qw( min_included min_charge sec_granularity )
40 } qsearch('rate', {} );
45 $error = $new->replace($old, 'rate_prefix' => \@rate_prefix,
46 'dest_detail' => \@dest_detail, );
48 $error = $new->insert( 'rate_prefix' => \@rate_prefix,
49 'dest_detail' => \@dest_detail, );
50 $regionnum = $new->getfield('regionnum');