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) {
46 <FONT SIZE="+2">Rates in this region</FONT>
47 <% include('/edit/elements/rate_detail.html',
48 'regionnum' => $rate_region->regionnum,
52 <% include('/elements/footer.html') %>
55 tie my %conn_secs, 'Tie::IxHash', FS::rate_detail::conn_secs();
61 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
63 my $conf = new FS::Conf;
64 my $money_char = $conf->config('money_char') || '$';
67 if ( $cgi->param('error') ) {
68 $rate_region = new FS::rate_region ( {
69 map { $_, scalar($cgi->param($_)) } fields('rate_region')
71 } elsif ( $cgi->keywords ) {
72 my($query) = $cgi->keywords;
73 $query =~ /^(\d+)$/ or die "unparsable regionnum";
74 $rate_region = qsearchs( 'rate_region', { 'regionnum' => $1 } )
75 or die "unknown regionnum $1\n";
77 $rate_region = new FS::rate_region {};
79 my $action = $rate_region->regionnum ? 'Edit' : 'Add';
83 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
85 my @rate_prefix = $rate_region->rate_prefix;
88 $countrycode = $rate_prefix[0]->countrycode;
89 foreach my $rate_prefix ( @rate_prefix ) {
90 errorpage('multiple country codes per region not yet supported by web UI')
91 unless $rate_prefix->countrycode eq $countrycode;