[freeside-commits] freeside/httemplate/misc/process copy-rate_detail.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Sun Jan 4 16:26:56 PST 2009
Update of /home/cvs/cvsroot/freeside/httemplate/misc/process
In directory wavetail.420.am:/tmp/cvs-serv7561/httemplate/misc/process
Added Files:
copy-rate_detail.html
Log Message:
add rate copying, RT#4431
--- NEW FILE: copy-rate_detail.html ---
%# if ( $error ) {
%# <% $cgi->redirect(popurl(2).'copy-rate_detail.html?'. $cgi->query_string ) %>
%# } else {
<% include('/elements/header.html', 'Rates copied',
menubar( 'View all rate plans' => popurl(3).'browse/rate.cgi' ),
) %>
%# }
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
$cgi->param('src_ratenum') =~ /^(\d+)$/ or die 'Illegal src_ratenum';
my $src_ratenum = $1;
$cgi->param('dst_ratenum') =~ /^(\d+)$/ or die 'Illegal src_ratenum';
my $dst_ratenum = $1;
my @countrycodes = map { /^countrycode(\d+)$/ or die; $1 }
grep { /^countrycode(\d+)$/ && $cgi->param($_) }
$cgi->param;
foreach my $countrycode ( @countrycodes ) {
my @src_rate_detail = qsearch({
'table' => 'rate_detail',
'addl_from' => 'JOIN rate_region'.
' ON ( rate_detail.dest_regionnum = rate_region.regionnum )',
'hashref' => { 'ratenum' => $src_ratenum },
'extra_sql' =>
"AND 0 < ( SELECT COUNT(*) FROM rate_prefix
WHERE rate_prefix.regionnum = rate_region.regionnum
AND countrycode = '$countrycode'
)
",
});
foreach my $src_rate_detail ( @src_rate_detail ) {
my %hash = (
'ratenum' => $dst_ratenum,
map { $_ => $src_rate_detail->get($_) }
qw( orig_regionnum dest_regionnum )
);
my $dst_rate_detail = qsearchs( 'rate_detail', \%hash)
|| new FS::rate_detail \%hash;
$dst_rate_detail->$_( $src_rate_detail->get($_) )
foreach qw( min_included min_charge sec_granularity classnum );
my $method = $dst_rate_detail->ratedetailnum ? 'replace' : 'insert';
my $error = $dst_rate_detail->$method();
die $error if $error; # "shouldn't" happen
}
}
</%init>
More information about the freeside-commits
mailing list