3 %my $regionnum = $cgi->param('regionnum');
5 %my $old = qsearchs('rate_region', { 'regionnum' => $regionnum } ) if $regionnum;
7 %my $new = new FS::rate_region ( {
9 % $_, scalar($cgi->param($_));
10 % } ( fields('rate_region') )
13 %my $countrycode = $cgi->param('countrycode');
14 %my @npa = split(/\s*,\s*/, $cgi->param('npa'));
15 %$npa[0] = '' unless @npa;
16 %my @rate_prefix = map {
17 % new FS::rate_prefix {
18 % 'countrycode' => $countrycode,
23 %my @dest_detail = map {
24 % my $ratenum = $_->ratenum;
25 % new FS::rate_detail {
26 % 'ratenum' => $ratenum,
27 % map { $_ => $cgi->param("$_$ratenum") }
28 % qw( min_included min_charge sec_granularity )
30 %} qsearch('rate', {} );
35 % $error = $new->replace($old, 'rate_prefix' => \@rate_prefix,
36 % 'dest_detail' => \@dest_detail, );
38 % $error = $new->insert( 'rate_prefix' => \@rate_prefix,
39 % 'dest_detail' => \@dest_detail, );
40 % $regionnum = $new->getfield('regionnum');
44 % $cgi->param('error', $error);
45 % print $cgi->redirect(popurl(2). "rate_region.cgi?". $cgi->query_string );
47 % #print $cgi->redirect(popurl(3). "browse/rate_region.cgi");
48 % print $cgi->redirect(popurl(3). "browse/rate.cgi");