fix report classes when cloning, RT#20753
authorIvan Kohler <ivan@freeside.biz>
Wed, 26 Dec 2012 18:05:31 +0000 (10:05 -0800)
committerIvan Kohler <ivan@freeside.biz>
Wed, 26 Dec 2012 18:05:31 +0000 (10:05 -0800)
httemplate/edit/part_pkg.cgi

index 50aeb45..c3f4f88 100755 (executable)
@@ -409,20 +409,8 @@ my $new_object_callback = sub {
 
 };
 
-my $edit_callback = sub {
-  my( $cgi, $object, $fields, $opt ) = @_;
-
-  $setup_show_zero_disabled = ($object->option('setup_fee') > 0) ? 1 : 0;
-
-  $recur_disabled = $object->freq ? 0 : 1;
-
-  $recur_show_zero_disabled =
-    $object->freq
-      ? $object->option('recur_fee') > 0 ? 1 : 0
-      : 1;
-
-  (@agent_type) =
-    map {$_->typenum} qsearch('type_pkgs', { 'pkgpart' => $object->pkgpart } );
+sub set_report_option {
+  my($cgi, $object, $fields ) = @_; #, $opt
 
   my @report_option = ();
   foreach ($object->options) {
@@ -445,6 +433,25 @@ my $edit_callback = sub {
     $field->{value} = join(',', @report_option);
   }
 
+}
+
+my $edit_callback = sub {
+  my( $cgi, $object, $fields, $opt ) = @_;
+
+  $setup_show_zero_disabled = ($object->option('setup_fee') > 0) ? 1 : 0;
+
+  $recur_disabled = $object->freq ? 0 : 1;
+
+  $recur_show_zero_disabled =
+    $object->freq
+      ? $object->option('recur_fee') > 0 ? 1 : 0
+      : 1;
+
+  (@agent_type) =
+    map {$_->typenum} qsearch('type_pkgs', { 'pkgpart' => $object->pkgpart } );
+
+  set_report_option( $cgi, $object, $fields);
+
   %options = $object->options;
 
   $object->set($_ => $object->option($_, 1))
@@ -484,13 +491,15 @@ my $clone_callback = sub {
 
     $object->disabled('Y');
 
-  } else { #not when cloning...
+  } else { #when explicitly cloning, not customizing
 
     (@agent_type) =
       map {$_->typenum} qsearch('type_pkgs',{ 'pkgpart' => $object->pkgpart } );
 
   }
 
+  set_report_option( $cgi, $object, $fields);
+
   %options = $object->options;
 
   $object->set($_ => $options{$_})