From 4427ad71b12bf27eac2a05d88141a82f9372d03f Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 7 Jan 2014 22:55:58 -0800 Subject: time/data/etc. unit pricing add-ons, RT#24392 --- httemplate/edit/process/part_pkg.cgi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'httemplate/edit/process/part_pkg.cgi') diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 82c4e1e15..69138bc65 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -264,6 +264,21 @@ if ( $cgi->param('pkgpart') || ! $conf->exists('agent_defaultpkg') ) { }; } +my $targets = FS::part_pkg_usageprice->targets; +foreach my $amount_param ( grep /^usagepricepart(\d+)_amount$/, $cgi->param ) { + $amount_param =~ /^usagepricepart(\d+)_amount$/ or die 'unpossible'; + my $num = $1; + my $amount = $cgi->param($amount_param); + if ( ! $amount && ! $cgi->param("usagepricepart${num}_price") ) { + #don't add empty rows just because the dropdowns have a value + $cgi->param("usagepricepart${num}_$_", '') for qw( currency action target ); + next; + } + my $target = $cgi->param("usagepricepart${num}_target"); + $amount *= $targets->{$target}{multiplier} if $targets->{$target}{multiplier}; + $cgi->param($amount_param, $amount); +} + my @process_o2m = ( { 'table' => 'part_pkg_msgcat', @@ -272,6 +287,7 @@ my @process_o2m = ( { 'table' => 'part_pkg_usageprice', 'fields' => [qw( price currency action target amount )], + } ); -- cgit v1.2.1