FCC form 477 reporting #4912
[freeside.git] / httemplate / edit / part_pkg.cgi
index 2b1bab6..a78aa87 100755 (executable)
@@ -5,8 +5,7 @@
 
               'agent_virt'            => 1,
               'agent_null_right'      => $edit_global,
-              'agent_clone_extra_sql' => FS::part_pkg->curuser_pkgs_sql,
-
+              'agent_clone_extra_sql' => $agent_clone_extra_sql,
               #'viewall_dir'           => 'browse',
               'viewall_url'           => $p.'browse/part_pkg.cgi',
               'html_init'             => include('/elements/init_overlib.html').
@@ -38,6 +37,8 @@
                             'taxproduct_select'=> 'Tax products',
                             'plan'             => 'Price plan',
                             'disabled'         => 'Disable new orders',
+                            'setup_cost'       => 'Setup cost',
+                            'recur_cost'       => 'Recur cost',
                             'pay_weight'       => 'Payment weight',
                             'credit_weight'    => 'Credit weight',
                             'agentnum'         => 'Agent',
@@ -45,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' => [
@@ -57,6 +59,8 @@
                                 sub { shift->param('pkgnum') },
                             },
 
+                            { field=>'custom',  type=>'hidden' },
+
                             { type => 'columnstart' },
                             
                               { field     => 'pkg',
                               { field=>'promo_code', type=>'text', size=>15 },
 
                               { type  => 'tablebreak-tr-title',
-                                value => 'Line-item revenue recogition', #better name?
+                                value => 'Cost tracking', #better name?
                               },
-                              { field=>'pay_weight',    type=>'text', size=>6 },
-                              { field=>'credit_weight', type=>'text', size=>6 },
+                              { field=>'setup_cost', type=>'money', },
+                              { field=>'recur_cost', type=>'money', },
 
                             { type => 'columnnext' },
 
                                 },
                               },
 
+                              { type  => 'tablebreak-tr-title',
+                                value => 'Line-item revenue recogition', #better name?
+                              },
+                              { field=>'pay_weight',    type=>'text', size=>6 },
+                              { field=>'credit_weight', type=>'text', size=>6 },
+
+
                             { 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',
                             },
@@ -207,8 +231,14 @@ my $begin_callback = sub {
 
 my $disabled_type = $acl_edit_either ? 'checkbox' : 'hidden';
 
+my $agent_clone_extra_sql = 
+  ' ( '. FS::part_pkg->curuser_pkgs_sql.
+  "   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)
@@ -286,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($_))
@@ -323,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');