-<!-- mason kludge -->
<%
my $rate;
-if ( $cgi->param('error') ) {
- $rate = new FS::rate ( {
- map { $_, scalar($cgi->param($_)) } fields('rate')
- } );
-} elsif ( $cgi->keywords ) {
+if ( $cgi->keywords ) {
my($query) = $cgi->keywords;
$query =~ /^(\d+)$/;
$rate = qsearchs( 'rate', { 'ratenum' => $1 } );
'60' => 'minute',
);
+my $nous = <<END;
+ WHERE 0 < ( SELECT COUNT(*) FROM rate_prefix
+ WHERE rate_region.regionnum = rate_prefix.regionnum
+ AND countrycode != '1'
+ )
+END
+
%>
<%= header("$action Rate plan", menubar(
))
%>
-<% if ( $cgi->param('error') ) { %>
-<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT><BR>
-<% } %>
+<!-- <FORM ACTION="<%=$p1%>rate.cgi" NAME="OneTrueForm" METHOD=POST onSubmit="document.OneTrueForm.submit.disabled=true"> -->
+
+<SCRIPT TYPE="text/javascript" SRC="../elements/jsrsClient.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript">
+function process () {
+ document.OneTrueForm.submit.disabled=true;
+
+ var Hash = new Array();
+ var x = 0;
+ var fieldName;
+ for (var i = 0; i<document.OneTrueForm.elements.length; i++) {
+ fieldName = document.OneTrueForm.elements[i].name;
+ if ( (fieldName.indexOf('rate') > -1)
+ || (fieldName.indexOf('min_') > -1)
+ || (fieldName.indexOf('sec_') > -1)
+ )
+ {
+ Hash[x++] = fieldName;
+ Hash[x++] = document.OneTrueForm.elements[i].value;
+ }
+ }
+
+ jsrsPOST = true;
+ jsrsExecute( 'process/rate.cgi', myCallback, 'process_rate', Hash );
+
+ function myCallback( jobnum ) {
+ var progressWindow = window.open('../../misc/progress.html?jobnum=' + jobnum + ';url=<%=$p%>browse/rate.cgi', 'progressWindow', 'toolbar=no,location=no,directories=no,scrollbars=no,menubar=no,status=no,width=420,height=128');
+ progressWindow.opener = self;
+ //progressWindow.opener = document;
+ }
-<FORM ACTION="<%=$p1%>process/rate.cgi" METHOD=POST>
+}
+</SCRIPT>
+<FORM NAME="OneTrueForm">
<INPUT TYPE="hidden" NAME="ratenum" VALUE="<%= $rate->ratenum %>">
Rate plan
</TR>
<% foreach my $rate_region (
- qsearch('rate_region', {}, '', 'ORDER BY regionname' )
+ qsearch( 'rate_region',
+ {},
+ '',
+ "$nous ORDER BY regionname",
+ )
) {
my $n = $rate_region->regionnum;
my $rate_detail =
$rate->dest_detail($rate_region)
- || new FS::rate_region { 'min_included' => 0,
+ || new FS::rate_detail { 'min_included' => 0,
'min_charge' => 0,
'sec_granularity' => '60'
};
</TABLE>
-<BR><INPUT TYPE="submit" VALUE="<%=
+<BR><INPUT NAME="submit" TYPE="button" VALUE="<%=
$rate->ratenum ? "Apply changes" : "Add rate plan"
-%>">
+%>" onClick="document.OneTrueForm.submit.disabled=true; process();">
+Please make sure to allow popups from this site in order to view the progress window.
+<!-- Please be patient, <%= $rate->ratenum ? 'editing' : 'adding' %>
+a rate plan can take a few minutes... -->
</FORM>
</BODY>