freeside/httemplate/edit/process rate.cgi,NONE,1.1 rate_region.cgi,NONE,1.1
ivan
ivan at pouncequick.420.am
Sat Nov 20 09:26:59 PST 2004
Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory pouncequick:/tmp/cvs-serv3612/httemplate/edit/process
Added Files:
rate.cgi rate_region.cgi
Log Message:
first pass at VoIP rating
--- NEW FILE: rate_region.cgi ---
<%
my $regionnum = $cgi->param('regionnum');
my $old = qsearchs('rate_region', { 'regionnum' => $regionnum } ) if $regionnum;
my $new = new FS::rate_region ( {
map {
$_, scalar($cgi->param($_));
} ( fields('rate_region') )
} );
my $countrycode = $cgi->param('countrycode');
my @npa = split(/\s*,\s*/, $cgi->param('npa'));
$npa[0] = '' unless @npa;
my @rate_prefix = map {
new FS::rate_prefix {
'countrycode' => $countrycode,
'npa' => $_,
}
} @npa;
my @dest_detail = map {
my $ratenum = $_->ratenum;
new FS::rate_detail {
'ratenum' => $ratenum,
map { $_ => $cgi->param("$_$ratenum") }
qw( min_included min_charge sec_granularity )
};
} qsearch('rate', {} );
my $error;
if ( $regionnum ) {
$error = $new->replace($old, 'rate_prefix' => \@rate_prefix,
'dest_detail' => \@dest_detail, );
} else {
$error = $new->insert( 'rate_prefix' => \@rate_prefix,
'dest_detail' => \@dest_detail, );
$regionnum = $new->getfield('regionnum');
}
if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "rate_region.cgi?". $cgi->query_string );
} else {
#print $cgi->redirect(popurl(3). "browse/rate_region.cgi");
print $cgi->redirect(popurl(3). "browse/rate.cgi");
}
%>
--- NEW FILE: rate.cgi ---
<%
my $ratenum = $cgi->param('ratenum');
my $old = qsearchs('rate', { 'ratenum' => $ratenum } ) if $ratenum;
my @rate_detail = map {
my $regionnum = $_->regionnum;
new FS::rate_detail {
'dest_regionnum' => $regionnum,
map { $_ => $cgi->param("$_$regionnum") }
qw( min_included min_charge sec_granularity )
};
} qsearch('rate_region', {} );
my $new = new FS::rate ( {
map {
$_, scalar($cgi->param($_));
} fields('rate')
} );
my $error;
if ( $ratenum ) {
$error = $new->replace($old, 'rate_detail' => \@rate_detail );
} else {
$error = $new->insert( 'rate_detail' => \@rate_detail );
$ratenum = $new->getfield('ratenum');
}
if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "rate.cgi?". $cgi->query_string );
} else {
print $cgi->redirect(popurl(3). "browse/rate.cgi");
}
%>
More information about the freeside-commits
mailing list