X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fpart_event.html;h=4d52e7bc60edbce9ed21fcf18614dc86425a5312;hp=481439d5302e0ff4ba89180dea03806ed6c9bf2a;hb=c69e68e25b519c7f9d2ad47cb0ae6fc90c0f016c;hpb=c9b7e9bd253b26a35e9821a877d0ae5d30105d38 diff --git a/httemplate/edit/process/part_event.html b/httemplate/edit/process/part_event.html index 481439d53..4d52e7bc6 100644 --- a/httemplate/edit/process/part_event.html +++ b/httemplate/edit/process/part_event.html @@ -39,8 +39,8 @@ split(/\0/, $value) }; } elsif ( $info->{'type'} eq 'freq' ) { - $value = '0' if !length($value); - $value .= $params->{$cgi_field.'_units'}; + $value = '0' if !length($value) and !$info->{'allow_blank'}; + $value .= $params->{$cgi_field.'_units'} if length($value); } #warn "value of $cgi_field is $value\n"; @@ -62,21 +62,26 @@ 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 }; + @{ $object->option_fields_listref || [] }; }, 'precheck_callback' => sub { my $cgi = shift; my $action = $cgi->param('action') or return; - my %actionfields = map { $_ =~ /^$action\.(.*)/; $1 => $cgi->param($_) } + my %actionfields = map { $_ =~ /^$action\.(.*)/; $1 => scalar($cgi->param($_)) } grep { /^$action\./ } $cgi->param; if ( exists($actionfields{'reasonnum'}) and length($actionfields{'reasonnum'}) == 0 ) { @@ -94,8 +99,10 @@ 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") } ); + check_options( { age => scalar($cgi->param($param)), + age_units => scalar($cgi->param("${param}_units")), + } + ); return $errstr if $errstr; }