2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "rate_region.cgi?". $cgi->query_string ) %>
4 %} elsif ( $action eq 'Add' ) {
5 <% $cgi->redirect(popurl(2). "rate_region.cgi?regionnum=$regionnum") %>
7 <% $cgi->redirect(popurl(3). "browse/rate_region.html") %>
11 my $conf = new FS::Conf;
13 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
15 my $regionnum = $cgi->param('regionnum');
16 my $action = $regionnum ? 'Edit' : 'Add';
18 my $old = qsearchs('rate_region', { 'regionnum' => $regionnum } ) if $regionnum;
20 my $new = new FS::rate_region ( {
22 $_, scalar($cgi->param($_));
23 } ( fields('rate_region') )
26 my $countrycode = $cgi->param('countrycode');
27 my @npa = split(/\s*,\s*/, $cgi->param('npa'));
28 my %npa = map { $_, 1 } @npa; #removing duplicates
29 @npa = sort keys %npa;
30 $npa[0] = '' unless @npa;
31 my @rate_prefix = map {
32 #my($npa,$nxx) = split('-', $_);
35 'countrycode' => $countrycode,
41 # we no longer process dest_detail records here
44 $error = $new->replace($old, 'rate_prefix' => \@rate_prefix );
46 $error = $new->insert( 'rate_prefix' => \@rate_prefix );
47 $regionnum = $new->getfield('regionnum');