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, @rate_prefix ) %></TEXTAREA>
42 <% include('/elements/table-grid.html') %>
43 % my $bgcolor1 = '#eeeeee';
44 % my $bgcolor2 = '#ffffff';
48 <TH CLASS="grid" BGCOLOR="#cccccc">
51 <TH CLASS="grid" BGCOLOR="#cccccc">
52 <FONT SIZE=-1>Included<BR>minutes/calls</FONT>
54 <TH CLASS="grid" BGCOLOR="#cccccc">
55 <FONT SIZE=-1>Charge per<BR>minute/call</FONT>
57 <TH CLASS="grid" BGCOLOR="#cccccc">
58 <FONT SIZE=-1>Granularity</FONT>
62 % foreach my $rate ( qsearch('rate', {}) ) {
64 % my $n = $rate->ratenum;
65 % my $rate_detail = $rate->dest_detail($rate_region)
66 % || new FS::rate_region { 'min_included' => 0,
68 % 'sec_granularity' => '60'
71 % if ( $bgcolor eq $bgcolor1 ) {
72 % $bgcolor = $bgcolor2;
74 % $bgcolor = $bgcolor1;
79 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
80 <A HREF="<%$p%>edit/rate.cgi?<% $rate->ratenum %>"><% $rate->ratename %></A>
83 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
84 <INPUT TYPE="text" SIZE=9 NAME="min_included<%$n%>" VALUE="<% $cgi->param("min_included$n") || $rate_detail->min_included |h %>">
87 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
88 $<INPUT TYPE="text" SIZE=6 NAME="min_charge<%$n%>" VALUE="<% sprintf('%.2f', $cgi->param("min_charge$n") || $rate_detail->min_charge ) %>">
91 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
92 <SELECT NAME="sec_granularity<%$n%>">
93 % foreach my $granularity ( keys %granularity ) {
94 <OPTION VALUE="<%$granularity%>"<% $granularity == ( $cgi->param("sec_granularity$n") || $rate_detail->sec_granularity ) ? ' SELECTED' : '' %>><%$granularity{$granularity}%>
107 <INPUT TYPE="submit" VALUE="<% $rate_region->regionnum ? "Apply changes" : "Add region" %>">
111 <% include('/elements/footer.html') %>
116 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
119 if ( $cgi->param('error') ) {
120 $rate_region = new FS::rate_region ( {
121 map { $_, scalar($cgi->param($_)) } fields('rate_region')
123 } elsif ( $cgi->keywords ) {
124 my($query) = $cgi->keywords;
125 $query =~ /^(\d+)$/ or die "unparsable regionnum";
126 $rate_region = qsearchs( 'rate_region', { 'regionnum' => $1 } )
127 or die "unknown regionnum $1\n";
129 $rate_region = new FS::rate_region {};
131 my $action = $rate_region->regionnum ? 'Edit' : 'Add';
135 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
137 my @rate_prefix = $rate_region->rate_prefix;
138 my $countrycode = '';
139 if ( @rate_prefix ) {
140 $countrycode = $rate_prefix[0]->countrycode;
141 foreach my $rate_prefix ( @rate_prefix ) {
142 errorpage('multiple country codes per region not yet supported by web UI')
143 unless $rate_prefix->countrycode eq $countrycode;