fix "Post manual (offline/POS) credit card refund", RT#18926
[freeside.git] / httemplate / edit / process / part_event.html
index 428025f..a8c434c 100644 (file)
@@ -39,6 +39,7 @@
                                                  split(/\0/, $value)
                                            };
                                 } elsif ( $info->{'type'} eq 'freq' ) {
+                                  $value = '0' if !length($value);
                                   $value .= $params->{$cgi_field.'_units'};
                                 }
 
           @{ $object->option_fields_listref };
 
     },
+    'precheck_callback' => sub {
+      my $cgi = shift;
+      my $action = $cgi->param('action') or return;
+      my %actionfields = map { $_ =~ /^$action\.(.*)/; $1 => $cgi->param($_) }
+                         grep { /^$action\./ } $cgi->param;
+      if ( exists($actionfields{'reasonnum'}) and 
+           length($actionfields{'reasonnum'}) == 0 ) {
+        return 'Reason required';
+      }
+      if ( $cgi->param('_initialize') ) {
+        $cgi->param('disabled', 'Y');
+      }
+      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',