1 <% include("/elements/header.html","$action Region", menubar(
2 'View all regions' => "${p}browse/rate_region.html",
6 <% include('/elements/error.html') %>
8 <FORM ACTION="<%$p1%>process/rate_region.cgi" METHOD=POST>
10 <INPUT TYPE="hidden" NAME="regionnum" VALUE="<% $rate_region->regionnum %>">
14 <% ntable('#cccccc') %>
17 <TH ALIGN="right">Region name</TH>
18 <TD><INPUT TYPE="text" NAME="regionname" SIZE=32 VALUE="<% $rate_region->regionname %>"></TR>
22 <TH ALIGN="right">Country code</TH>
23 <TD><INPUT TYPE="text" NAME="countrycode" SIZE=4 MAXLENGTH=3 VALUE="<% $countrycode %>"></TR>
29 <BR><FONT SIZE="-1">(comma-separated)</FONT>
32 <TEXTAREA NAME="npa" WRAP=SOFT><% join(', ', map { $_->npa. (length($_->nxx) ? '-'.$_->nxx : '') } @rate_prefix ) %></TEXTAREA>
39 <INPUT TYPE="submit" VALUE="<% $rate_region->regionnum ? "Apply changes" : "Add region" %>">
41 %# rate plan info, if the region has been created yet
43 % if($rate_region->regionnum) {
44 <BR><BR><FONT SIZE="+2">Rates in this region</FONT>
45 % if ( my $select_cdr_type = include('/elements/select-cdr_type.html',
46 % 'curr_value' => $cdrtypenum,
47 % 'onchange' => 'form.submit();',
48 % 'name_col' => 'cdrtypename',
49 % 'value_col' => 'cdrtypenum',
50 % 'empty_label' => '(default)',
52 <FORM ACTION="<%$cgi->url%>" METHOD="GET">
53 <INPUT TYPE="hidden" NAME="regionnum" VALUE="<% $rate_region->regionnum %>">
54 <FONT SIZE="+1">Usage type: <% $select_cdr_type %></FONT>
57 <% include('/edit/elements/rate_detail.html',
58 'regionnum' => $rate_region->regionnum,
59 'cdrtypenum' => $cdrtypenum,
63 <% include('/elements/footer.html') %>
66 tie my %conn_secs, 'Tie::IxHash', FS::rate_detail::conn_secs();
72 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
74 my $conf = new FS::Conf;
75 my $money_char = $conf->config('money_char') || '$';
78 if ( $cgi->param('error') ) {
79 $rate_region = new FS::rate_region ( {
80 map { $_, scalar($cgi->param($_)) } fields('rate_region')
82 } elsif ( $cgi->param('regionnum') ) {
83 $cgi->param('regionnum') =~ /^(\d+)$/ or die "unparseable regionnum";
84 $rate_region = qsearchs( 'rate_region', { 'regionnum' => $1 } )
85 or die "unknown regionnum $1\n";
87 $rate_region = new FS::rate_region {};
89 my $action = $rate_region->regionnum ? 'Edit' : 'Add';
93 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
95 my @rate_prefix = $rate_region->rate_prefix;
98 $countrycode = $rate_prefix[0]->countrycode;
99 foreach my $rate_prefix ( @rate_prefix ) {
100 errorpage('multiple country codes per region not yet supported by web UI')
101 unless $rate_prefix->countrycode eq $countrycode;
105 if ( $cgi->param('cdrtypenum') =~ /^(\d+)$/ ) {