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>
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>
60 <TH CLASS="grid" BGCOLOR="#cccccc">
61 <FONT SIZE=-1>Usage class</FONT>
65 % foreach my $rate ( qsearch('rate', {}) ) {
67 % my $n = $rate->ratenum;
68 % my $rate_detail = $rate->dest_detail($rate_region)
69 % || new FS::rate_region { 'min_included' => 0,
71 % 'sec_granularity' => '60'
74 % if ( $bgcolor eq $bgcolor1 ) {
75 % $bgcolor = $bgcolor2;
77 % $bgcolor = $bgcolor1;
82 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
83 <A HREF="<%$p%>edit/rate.cgi?<% $rate->ratenum %>"><% $rate->ratename %></A>
86 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
87 <INPUT TYPE="text" SIZE=9 NAME="min_included<%$n%>" VALUE="<% $cgi->param("min_included$n") || $rate_detail->min_included |h %>">
90 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
91 $<INPUT TYPE="text" SIZE=6 NAME="min_charge<%$n%>" VALUE="<% $cgi->param("min_charge$n") || $rate_detail->min_charge |h %>">
94 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
95 <SELECT NAME="sec_granularity<%$n%>">
96 % foreach my $granularity ( keys %granularity ) {
97 <OPTION VALUE="<%$granularity%>"<% $granularity == ( $cgi->param("sec_granularity$n") || $rate_detail->sec_granularity ) ? ' SELECTED' : '' %>><%$granularity{$granularity}%>
102 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
103 <% include( '/elements/select-table.html',
104 'element_name' => "classnum$n",
105 'table' => 'usage_class',
106 'name_col' => 'classname',
107 'empty_label' => '(default)',
108 'hashref' => { disabled => '' },
109 'curr_value' => ( $cgi->param("classnum$n") ||
110 $rate_detail->classnum ),
123 <INPUT TYPE="submit" VALUE="<% $rate_region->regionnum ? "Apply changes" : "Add region" %>">
127 <% include('/elements/footer.html') %>
132 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
135 if ( $cgi->param('error') ) {
136 $rate_region = new FS::rate_region ( {
137 map { $_, scalar($cgi->param($_)) } fields('rate_region')
139 } elsif ( $cgi->keywords ) {
140 my($query) = $cgi->keywords;
141 $query =~ /^(\d+)$/ or die "unparsable regionnum";
142 $rate_region = qsearchs( 'rate_region', { 'regionnum' => $1 } )
143 or die "unknown regionnum $1\n";
145 $rate_region = new FS::rate_region {};
147 my $action = $rate_region->regionnum ? 'Edit' : 'Add';
151 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
153 my @rate_prefix = $rate_region->rate_prefix;
154 my $countrycode = '';
155 if ( @rate_prefix ) {
156 $countrycode = $rate_prefix[0]->countrycode;
157 foreach my $rate_prefix ( @rate_prefix ) {
158 errorpage('multiple country codes per region not yet supported by web UI')
159 unless $rate_prefix->countrycode eq $countrycode;