X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fpart_pkg.cgi;h=b8042026a93c0842d90fe984c6103ca0669a37a7;hb=41aef8bd93f7cc3a39056a8fd997d3072dfcdf8a;hp=82c4e1e1583b31e9d7a911e92bfbc3a63ac15011;hpb=013646e6629fc94b4cda03c495aa56677f2de381;p=freeside.git diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 82c4e1e15..b8042026a 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -50,8 +50,7 @@ my $precheck_callback = sub { } return "At least one agent type must be specified." unless scalar(@agents) - || ( $cgi->param('clone') && $cgi->param('clone') =~ /^\d+$/ ) - || ( !$cgi->param('pkgpart') && $conf->exists('agent-defaultpkg') ) + #wtf? || ( $cgi->param('clone') && $cgi->param('clone') =~ /^\d+$/ ) || $cgi->param('disabled') || $cgi->param('agentnum'); @@ -97,11 +96,30 @@ my $args_callback = sub { grep { $_ !~ /^report_option_/ } @options; - foreach ( split(',', $cgi->param('taxproductnums') ) ) { - my $value = $cgi->param("taxproductnum_$_"); - $error ||= "Illegal taxproductnum_$_: $value" + foreach my $class ( '', split(',', $cgi->param('taxproductnums') ) ) { + my $param = "taxproductnum_$class"; + my $value = $cgi->param($param); + + if ( $value == -1 ) { + my $desc = $cgi->param($param.'_description'); + # insert a new part_pkg_taxproduct + my $engine = FS::TaxEngine->new; + my $obj_or_error = $engine->add_taxproduct($desc); + if (ref $obj_or_error) { + $value = $obj_or_error->taxproductnum; + $cgi->param($param, $value); # for error handling + } else { + die "$obj_or_error (adding tax product)"; + } + } + + $error ||= "Illegal $param: $value" unless ( $value =~ /^\d*$/ ); - $options{"usage_taxproductnum_$_"} = $value; + if (length($class)) { + $options{"usage_taxproductnum_$class"} = $value; + } else { + $new->set('taxproductnum', $value); + } } foreach ( grep $_, $cgi->param('report_option') ) { @@ -128,12 +146,21 @@ my $args_callback = sub { push @args, 'part_pkg_currency' => \%part_pkg_currency; ### + # fcc options + ### + my $fcc_options_string = $cgi->param('fcc_options_string'); + if ($fcc_options_string) { + push @args, 'fcc_options' => decode_json($fcc_options_string); + } + + ### #pkg_svc ### my @svcparts = map { $_->svcpart } qsearch('part_svc', {}); my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_" )) } @svcparts; my %hidden_svc = map { $_ => scalar($cgi->param("hidden$_" )) } @svcparts; + my %provision_hold = map { $_ => scalar($cgi->param("provision_hold$_" )) } @svcparts; my %bulk_skip = map { $_ => ( $cgi->param("no_bulk_skip$_") eq 'Y' ? '' : 'Y' ) @@ -141,6 +168,7 @@ my $args_callback = sub { push @args, 'pkg_svc' => \%pkg_svc, 'hidden_svc' => \%hidden_svc, + 'provision_hold' => \%provision_hold, 'bulk_skip' => \%bulk_skip; ### @@ -161,6 +189,9 @@ my $args_callback = sub { push @args, 'part_pkg_vendor' => \%part_pkg_vendor; } + push @args, 'part_pkg_restrict_soft_override' => 1 + if $cgi->param('part_pkg_restrict_soft_override'); + #warn "args: ".join('/', @args). "\n"; @args; @@ -251,17 +282,30 @@ foreach my $override_class ($cgi->param) { my $conf = new FS::Conf; -if ( $cgi->param('pkgpart') || ! $conf->exists('agent_defaultpkg') ) { - my @agents = (); - foreach ($cgi->param('agent_type')) { - /^(\d+)$/; - push @agents, $1 if $1; - } - push @process_m2m, { - 'link_table' => 'type_pkgs', - 'target_table' => 'agent_type', - 'params' => \@agents, - }; +my @agents = (); +foreach ($cgi->param('agent_type')) { + /^(\d+)$/; + push @agents, $1 if $1; +} +push @process_m2m, { + 'link_table' => 'type_pkgs', + 'target_table' => 'agent_type', + 'params' => \@agents, +}; + +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 = ( @@ -272,6 +316,7 @@ my @process_o2m = ( { 'table' => 'part_pkg_usageprice', 'fields' => [qw( price currency action target amount )], + } );