X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fpart_event.html;h=bac69241c847eeb64e610442a3ba9c3042624809;hb=ffda3975d8eefa8d08ae9e468dba33448e207ae6;hp=d4d4526e00d725f53f7c109941fda62764e1b1ed;hpb=53ea5a72067a9b0ebcd3417692c3884d6f91f74a;p=freeside.git diff --git a/httemplate/edit/process/part_event.html b/httemplate/edit/process/part_event.html index d4d4526e0..bac69241c 100644 --- a/httemplate/edit/process/part_event.html +++ b/httemplate/edit/process/part_event.html @@ -39,6 +39,7 @@ split(/\0/, $value) }; } elsif ( $info->{'type'} eq 'freq' ) { + $value = '0' if !length($value); $value .= $params->{$cgi_field.'_units'}; } @@ -61,12 +62,17 @@ my $value = join(',', $cgi->param( "$prefix$option" ) ); if ( $option eq 'reasonnum' && $value == -1 ) { - $value = { - 'typenum' => scalar( $cgi->param( "new$prefix${option}T" ) ), - 'reason' => scalar( $cgi->param( "new$prefix${option}" ) ), - }; + my $reason_prefix = $object->action . '_' . $option . '_new_'; + my $new_reason = FS::reason->new; + foreach ( qw( reason_type reason unsuspend pkgpart + unsuspend_hold unused_credit ) ) { + $new_reason->set($_, $cgi->param("$reason_prefix$_")); + } + warn Dumper $new_reason; + my $error = $new_reason->insert; + die "error creating reason: $error" if $error; + $value = $new_reason->reasonnum; } - ( $option => $value ); } @{ $object->option_fields_listref }; @@ -84,6 +90,21 @@ if ( $cgi->param('_initialize') ) { $cgi->param('disabled', 'Y'); } + + my $balance_age_rx = qr/^(condition.+)\.balance_age\.age$/; + + foreach my $param ( keys %{ $cgi->Vars() } ){ + + next unless ( $param =~ /$balance_age_rx/ ); + next unless $cgi->param($1) eq 'balance_age'; + + my $errstr = FS::part_event::Condition::balance_age-> + check_options( { age => $cgi->param($param), + age_units => $cgi->param("${param}_units") } ); + + return $errstr if $errstr; + } + return ''; }, 'noerror_callback' => sub {