disabling a taxclass, RT#5472
[freeside.git] / httemplate / edit / part_pkg.cgi
index 6391db9..a78aa87 100755 (executable)
@@ -46,6 +46,7 @@
                             'recur_fee'        => 'Recurring fee',
                             'bill_dst_pkgpart' => 'Include line item(s) from package',
                             'svc_dst_pkgpart'  => 'Include services of package',
+                            'report_option'    => 'Report classes',
                           },
 
               'fields' => [
@@ -58,6 +59,8 @@
                                 sub { shift->param('pkgnum') },
                             },
 
+                            { field=>'custom',  type=>'hidden' },
+
                             { type => 'columnstart' },
                             
                               { field     => 'pkg',
 
                             { type => 'columnend' },
 
+                            { 'type'  => $census ? 'tablebreak-tr-title'
+                                                 : 'hidden',
+                              'value' => 'Optional report classes',
+                              'field' => 'census_title',
+                            },
+                            { 'field'    => 'report_option',
+                              'type'     => $census ? 'select-table' : 'hidden',
+                              'table'    => 'part_pkg_report_option',
+                              'name_col' => 'name',
+                              'multiple' => 1,
+                            },
+
+
                             { 'type'  => 'tablebreak-tr-title',
                               'value' => 'Pricing add-ons',
                             },
@@ -217,14 +233,12 @@ my $disabled_type = $acl_edit_either ? 'checkbox' : 'hidden';
 
 my $agent_clone_extra_sql = 
   ' ( '. FS::part_pkg->curuser_pkgs_sql.
-  #kludge to clone custom customer packages you otherwise couldn't see
-  #really need a proper "CUSTOM" flag that's distinct from disabled
-  #"   OR ( part_pkg.disabled = 'Y' AND part_pkg.comment LIKE '(CUSTOM)%' ) ".
-  "   OR ( part_pkg.disabled = 'Y' ) ".
+  "   OR ( part_pkg.custom = 'Y' ) ".
   ' ) ';
 
 my $conf = new FS::Conf;
 my $taxproducts = $conf->exists('enable_taxproducts');
+my $census = scalar( qsearch( 'part_pkg_report_option', {} ) );
 
 #XXX
 # - tr-part_pkg_freq: month_increments_only (from price plans)
@@ -302,14 +316,27 @@ my $edit_callback = sub {
 
   (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1});
 
+  my @report_option = ();
   foreach ($object->options) {
     /^usage_taxproductnum_(\d+)$/ && ($taxproductnums{$1} = 1);
+    /^report_option_(\d+)$/ && (push @report_option, $1);
   }
   foreach ($object->part_pkg_taxoverride) {
     $taxproductnums{$_->usage_class} = 1
       if $_->usage_class;
   }
 
+  $cgi->param('report_option', join(',', @report_option));
+  foreach my $field ( @$fields ) {
+    next unless ( 
+      ref($field) eq 'HASH' &&
+      $field->{field} &&
+      $field->{field} eq 'report_option'
+    );
+    #$field->{curr_value} = join(',', @report_option);
+    $field->{value} = join(',', @report_option);
+  }
+
   %options = $object->options;
 
   $object->set($_ => $object->option($_))
@@ -339,9 +366,8 @@ my $clone_callback = sub {
     $opt->{action} = 'Custom';
 
     #my $part_pkg = $clone_part_pkg->clone;
-    #this is all clone did anyway
-    $object->comment( '(CUSTOM) '. $object->comment )
-      unless $object->comment =~ /^\(CUSTOM\) /;
+    #this is all clone does anyway
+    $object->custom('Y');
 
     $object->disabled('Y');