X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fpart_event.html;h=0293af8863eebc43cc8616c8ace46b501765e91f;hb=1aecd5bf33146bf3f374341a3814960ae1d419e8;hp=6a8ddd1ea1ba9ffb471ec9ef51cac5923b2d9cff;hpb=82cdd3bf93ccc681baa762322e123b45eac104a7;p=freeside.git diff --git a/httemplate/edit/process/part_event.html b/httemplate/edit/process/part_event.html index 6a8ddd1ea..0293af886 100644 --- a/httemplate/edit/process/part_event.html +++ b/httemplate/edit/process/part_event.html @@ -39,7 +39,8 @@ split(/\0/, $value) }; } elsif ( $info->{'type'} eq 'freq' ) { - $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"; @@ -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 }; @@ -81,8 +87,36 @@ length($actionfields{'reasonnum'}) == 0 ) { return 'Reason required'; } + 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 { + my ($cgi, $new) = @_; + if ( $cgi->param('_initialize') ) { + my $job = new FS::queue { + 'job' => 'FS::part_event::process_initialize' + }; + my $error = $job->insert('eventpart' => $new->eventpart); + warn "error queueing job: $error\n" if $error; # can't do anything else + } + }, 'agent_virt' => 1, 'agent_null_right' => 'Edit global billing events',