'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').
'clone_callback' => $clone_callback,
'edit_callback' => $edit_callback,
'error_callback' => $error_callback,
+ 'field_callback' => $field_callback,
'labels' => {
'pkgpart' => 'Package Definition',
'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',
'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' => [
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',
},
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)
my %taxproductnums = map { ($_->classnum => 1) }
qsearch('usage_class', { 'disabled' => '' });
+my @taxproductnums = ( qw( setup recur ), sort (keys %taxproductnums) );
my %options = ();
my $recur_disabled = 1;
(@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($_))
$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');
$usage_class{setup} = 'Setup';
$usage_class{recur} = 'Recurring';
-my @taxproductnums = ();
my %taxproduct_fields = ();
my $end_callback = sub {
my( $cgi, $object, $fields, $opt ) = @_;
};
+my $field_callback = sub {
+ my ($cgi, $object, $fieldref) = @_;
+
+ my $field = $fieldref->{field};
+ if ($field eq 'taxproductnums') {
+ $fieldref->{value} = join(',', @taxproductnums);
+ } elsif ($field eq 'taxproduct_select') {
+ $fieldref->{options} = [ '(default)', @taxproductnums ];
+ $fieldref->{labels} = { ( '(default)' => '(default)' ),
+ map {( $_ => ($usage_class{$_} || $_) )}
+ @taxproductnums
+ };
+ $fieldref->{layer_fields} = \%taxproduct_fields;
+ $fieldref->{layer_values_callback} = $taxproduct_values;
+ }
+};
+
</%init>