supplemental packages, #20689
[freeside.git] / httemplate / edit / part_pkg.cgi
index 50aeb45..7baf84d 100755 (executable)
@@ -53,6 +53,7 @@
                             'discountnum'      => 'Offer discounts for longer terms',
                             'bill_dst_pkgpart' => 'Include line item(s) from package',
                             'svc_dst_pkgpart'  => 'Include services of package',
+                            'supp_dst_pkgpart' => 'Include complete package',
                             'report_option'    => 'Report classes',
                             'fcc_ds0s'         => 'Voice-grade equivalents',
                             'fcc_voip_class'   => 'Category',
                             },
 
                             { 'type'    => 'tablebreak-tr-title',
+                              'value'   => 'Supplemental packages',
+                              'colspan' => '4',
+                            },
+                            { 'field'       => 'supp_dst_pkgpart',
+                              'type'        => 'select-part_pkg',
+                              'm2_label'    => 'Include complete package',
+                              'm2m_method'  => 'supp_part_pkg_link',
+                              'm2m_dstcol'  => 'dst_pkgpart',
+                              'm2_error_callback' =>
+                                &{$m2_error_callback_maker}('supp'),
+                            },
+
+                            { 'type'    => 'tablebreak-tr-title',
                               'value'   => 'Pricing add-ons',
                               'colspan' => 4,
                             },
@@ -409,20 +423,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 +447,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 +505,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{$_})