X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Frate.cgi;h=c0e8d93f07162e7e04e7b72b41f908403519c615;hp=4a4b70ea32a3f521f6a5b2382145c973b9d7c558;hb=c49cfd25a8f92c7a2f44b51d72506a21f6b8d09f;hpb=2f41d7382dac4f151de86ce06ad9846c89f56791 diff --git a/httemplate/edit/rate.cgi b/httemplate/edit/rate.cgi index 4a4b70ea3..c0e8d93f0 100644 --- a/httemplate/edit/rate.cgi +++ b/httemplate/edit/rate.cgi @@ -1,147 +1,94 @@ -<% - -my($rate, $error); - -if ( $cgi->param('magic') eq 'process' ) { - - my $ratenum = $cgi->param('ratenum'); - - my $old = qsearchs('rate', { 'ratenum' => $ratenum } ) if $ratenum; - - my @rate_detail = map { - my $regionnum = $_->regionnum; - if ( $cgi->param("sec_granularity$regionnum") ) { - new FS::rate_detail { - 'dest_regionnum' => $regionnum, - map { $_ => scalar($cgi->param("$_$regionnum")) } - qw( min_included min_charge sec_granularity ) - }; - } else { - new FS::rate_detail { - 'dest_regionnum' => $regionnum, - 'min_included' => 0, - 'min_charge' => 0, - 'sec_granularity' => '60' - }; - } - } qsearch('rate_region', {} ); - - $rate = new FS::rate ( { - map { - $_, scalar($cgi->param($_)); - } fields('rate') - } ); - - if ( $ratenum ) { - warn "$rate replacing $old ($ratenum)\n"; - $error = $rate->replace($old, 'rate_detail' => \@rate_detail ); - } else { - warn "inserting $rate\n"; - $error = $rate->insert( 'rate_detail' => \@rate_detail ); - $ratenum = $rate->getfield('ratenum'); - } - - unless ( $error ) { - print $cgi->redirect("${p}browse/rate.cgi"); - myexit; - } - -} elsif ( $cgi->keywords ) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $rate = qsearchs( 'rate', { 'ratenum' => $1 } ); -} else { #adding - $rate = new FS::rate {}; -} -my $action = $rate->ratenum ? 'Edit' : 'Add'; - -my $p1 = popurl(1); - -my %granularity = ( - '6' => '6 second', - '60' => 'minute', -); - -my $nous = < - -<%= header("$action Rate plan", menubar( - 'Main Menu' => $p, +<& /elements/header.html, + "$action Rate plan", + menubar( 'View all rate plans' => "${p}browse/rate.cgi", - )) + 'View packages that use this plan' => "${p}browse/part_pkg.cgi?ratenum=" + . $rate->ratenum, + ) +&> + +<% include('/elements/progress-init.html', + 'OneTrueForm', + [ 'rate', 'agentnum' ], + 'process/rate.cgi', + $p.'browse/rate.cgi', + ) %> +
+ -<% if ( $error ) { %> -Error: <%= $error %>
-<% } %> + - - - +<& /elements/tr-select-agent.html, + disable_empty => ! $FS::CurrentUser::CurrentUser->access_right('Configuration'), #, 'Edit global CDR rates' + empty_label => '(global)', +&> -Rate plan - -

+% if ( $rate->agent_rateid ) { + + + + +% } -<%= table() %> - - - - - + + - -<% foreach my $rate_region ( - qsearch( 'rate_region', - {}, - '', - "$nous ORDER BY regionname", - ) - ) { - my $n = $rate_region->regionnum; - my $rate_detail = - $rate->dest_detail($rate_region) - || new FS::rate_detail { 'min_included' => 0, - 'min_charge' => 0, - 'sec_granularity' => '60' - }; -%> - - - - - - -<% } %> - - - - -
Legacy #<% $rate->agent_rateid |h %>
RegionPrefix(es)Included
minutes
Charge per
minute
GranularityRate plan
<%= $rate_region->regionname %><%= $rate_region->prefixes_short %>min_included %>">$min_charge ) %>"> - -
- Add a region -
+
-
"> -Please be patient, <%= $rate->ratenum ? 'editing' : 'adding' %> -a rate plan can take a few minutes... +%>" onClick="document.OneTrueForm.submit.disabled=true; process();"> +
+ +% if($rate->ratenum) { +

Rates in this plan +% if ( my $select_cdr_type = include('/elements/select-cdr_type.html', +% 'curr_value' => $cdrtypenum, +% 'onchange' => 'form.submit();', +% 'name_col' => 'cdrtypename', +% 'value_col' => 'cdrtypenum', +% 'empty_label' => '(default)', +% ) ) { +
+ + +Usage type: <% $select_cdr_type %> +
+% } + +<% include('/edit/elements/rate_detail.html', + 'ratenum' => $rate->ratenum, + 'countrycode' => $countrycode, + 'cdrtypenum' => $cdrtypenum, +) %> +% } + +<% include('/elements/footer.html') %> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $rate; +if ( $cgi->param('ratenum') ) { + $cgi->param('ratenum') =~ /^(\d+)$/; + $rate = qsearchs( 'rate', { 'ratenum' => $1 } ); +} else { #adding + $rate = new FS::rate {}; +} +my $action = $rate->ratenum ? 'Edit' : 'Add'; - - - +my $countrycode = ''; +if ( $cgi->param('countrycode') =~ /^(\d+)$/ ) { + $countrycode = $1; +} +my $cdrtypenum = ''; +if ( $cgi->param('cdrtypenum') =~ /^(\d+)$/ ) { + $cdrtypenum = $1; +} +