1 <% include( 'elements/edit.html',
2 'post_url' => popurl(1).'process/part_pkg.cgi',
3 'name' => "Package definition",
7 'agent_null_right' => $edit_global,
8 'agent_clone_extra_sql' => $agent_clone_extra_sql,
9 #'viewall_dir' => 'browse',
10 'viewall_url' => $p.'browse/part_pkg.cgi',
11 'html_init' => include('/elements/init_overlib.html').
13 'html_bottom' => $html_bottom,
15 'onLoad="agent_changed(document.edit_topform.agentnum)"',
17 'begin_callback' => $begin_callback,
18 'end_callback' => $end_callback,
19 'new_hashref_callback' => $new_hashref_callback,
20 'new_object_callback' => $new_object_callback,
21 'new_callback' => $new_callback,
22 'clone_callback' => $clone_callback,
23 'edit_callback' => $edit_callback,
24 'error_callback' => $error_callback,
25 'field_callback' => $field_callback,
27 'onsubmit' => 'confirm_submit',
30 'pkgpart' => 'Package Definition',
31 'pkg' => 'Package (customer-visible)',
32 'comment' => 'Comment (customer-hidden)',
33 'classnum' => 'Package class',
34 'addon_classnum' => 'Restrict additional orders to package class',
35 'promo_code' => 'Promotional code',
36 'freq' => 'Recurring fee frequency',
37 'setuptax' => 'Setup fee tax exempt',
38 'recurtax' => 'Recurring fee tax exempt',
39 'taxclass' => 'Tax class',
40 'taxproduct_select'=> 'Tax products',
41 'plan' => 'Price plan',
42 'disabled' => 'Disable new orders',
43 'disable_line_item_date_ranges' => 'Disable line item date ranges',
44 'setup_cost' => 'Setup cost',
45 'recur_cost' => 'Recur cost',
46 'pay_weight' => 'Payment weight',
47 'credit_weight' => 'Credit weight',
48 'agentnum' => 'Agent',
49 'setup_fee' => 'Setup fee',
50 'setup_show_zero' => 'Show zero setup',
51 'recur_fee' => 'Recurring fee',
52 'recur_show_zero' => 'Show zero recurring',
53 'discountnum' => 'Offer discounts for longer terms',
54 'bill_dst_pkgpart' => 'Include line item(s) from package',
55 'svc_dst_pkgpart' => 'Include services of package',
56 'supp_dst_pkgpart' => 'Include complete package',
57 'report_option' => 'Report classes',
58 'fcc_ds0s' => 'Voice-grade equivalents',
59 'fcc_voip_class' => 'Category',
63 { field=>'clone', type=>'hidden',
64 curr_value_callback =>
65 sub { shift->param('clone') },
67 { field=>'pkgnum', type=>'hidden',
68 curr_value_callback =>
69 sub { shift->param('pkgnum') },
72 { field=>'custom', type=>'hidden' },
73 { field=>'family_pkgpart', type=>'hidden' },
74 { field=>'successor', type=>'hidden' },
76 { type => 'columnstart' },
83 {field=>'comment', type=>'text', size=>40 }, #32
84 { field => 'agentnum',
85 type => 'select-agent',
86 disable_empty => ! $acl_edit_global,
87 empty_label => '(global)',
88 onchange => 'agent_changed',
90 {field=>'classnum', type=>'select-pkg_class' },
91 ( $conf->exists('pkg-addon_classnum')
92 ? ( { field=>'addon_classnum',
93 type =>'select-pkg_class',
98 {field=>'disabled', type=>$disabled_type, value=>'Y'},
99 {field=>'disable_line_item_date_ranges', type=>$disabled_type, value=>'Y'},
101 { type => 'tablebreak-tr-title',
102 value => 'Pricing', #better name?
105 type => 'selectlayers-select',
106 options => [ keys %plan_labels ],
107 labels => \%plan_labels,
108 onchange => 'aux_planchanged(what);',
110 { field => 'setup_fee',
112 onchange => 'setup_changed',
114 { field => 'setup_show_zero',
117 disabled => sub { $setup_show_zero_disabled },
120 type => 'part_pkg_freq',
121 onchange => 'freq_changed',
123 { field => 'recur_fee',
125 disabled => sub { $recur_disabled },
126 onchange => 'recur_changed',
129 { field => 'recur_show_zero',
132 disabled => sub { $recur_show_zero_disabled },
138 #recurring fee (auto-disable)
140 { type => 'columnnext' },
142 {type=>'justtitle', value=>'Taxation' },
143 {field=>'setuptax', type=>'checkbox', value=>'Y'},
144 {field=>'recurtax', type=>'checkbox', value=>'Y'},
145 {field=>'taxclass', type=>'select-taxclass' },
146 { field => 'taxproductnums',
148 value => join(',', @taxproductnums),
150 { field => 'taxproduct_select',
151 type => 'selectlayers',
152 options => [ '(default)', @taxproductnums ],
153 curr_value => '(default)',
154 labels => { ( '(default)' => '(default)' ),
155 map {($_=>$usage_class{$_})}
158 layer_fields => \%taxproduct_fields,
159 layer_values_callback => $taxproduct_values,
160 layers_only => !$taxproducts,
161 cell_style => ( !$taxproducts
167 { type => 'tablebreak-tr-title',
168 value => 'Promotions', #better name?
170 { field=>'promo_code', type=>'text', size=>15 },
172 { type => 'tablebreak-tr-title',
173 value => 'Cost tracking', #better name?
175 { field=>'setup_cost', type=>'money', },
176 { field=>'recur_cost', type=>'money', },
178 { type => 'columnnext' },
180 { field => 'agent_type',
181 type => 'select-agent_types',
182 disabled => ! $acl_edit_global,
183 curr_value_callback => sub {
184 my($cgi, $object, $field) = @_;
185 #in the other callbacks..? hmm.
190 { type => 'tablebreak-tr-title',
191 value => 'Line-item revenue recogition', #better name?
193 { field=>'pay_weight', type=>'text', size=>6 },
194 { field=>'credit_weight', type=>'text', size=>6 },
196 ( $conf->exists('cust_pkg-show_fcc_voice_grade_equivalent')
198 { type => 'tablebreak-tr-title',
199 value => 'FCC Form 477 information',
201 { field=>'fcc_voip_class',
202 type=>'select-voip_class',
204 { field=>'fcc_ds0s', type=>'text', size=>6 },
210 { type => 'columnend' },
212 { 'type' => $report_option ? 'tablebreak-tr-title'
214 'value' => 'Optional report classes',
215 'field' => 'census_title',
217 { 'field' => 'report_option',
218 'type' => $report_option ? 'select-table'
220 'table' => 'part_pkg_report_option',
221 'name_col' => 'name',
222 'hashref' => { 'disabled' => '' },
226 { 'type' => 'tablebreak-tr-title',
227 'value' => 'Term discounts',
229 { 'field' => 'discountnum',
230 'type' => 'select-table',
231 'table' => 'discount',
232 'name_col' => 'name',
233 'hashref' => { %$discountnum_hashref },
234 #'extra_sql' => 'AND (months IS NOT NULL OR months != 0)',
235 'empty_label'=> 'Select discount',
236 'm2_label' => 'Offer discounts for longer terms',
237 'm2m_method' => 'part_pkg_discount',
238 'm2m_dstcol' => 'discountnum',
239 'm2_error_callback' => $discount_error_callback,
242 { 'type' => 'tablebreak-tr-title',
243 'value' => 'Supplemental packages',
246 { 'field' => 'supp_dst_pkgpart',
247 'type' => 'select-part_pkg',
248 'm2_label' => 'Include complete package',
249 'm2m_method' => 'supp_part_pkg_link',
250 'm2m_dstcol' => 'dst_pkgpart',
251 'm2_error_callback' =>
252 &{$m2_error_callback_maker}('supp'),
255 { 'type' => 'tablebreak-tr-title',
256 'value' => 'Pricing add-ons',
259 { 'field' => 'bill_dst_pkgpart',
260 'type' => 'select-part_pkg',
261 'extra_sql' => sub { $pkgpart
262 ? "AND pkgpart != $pkgpart"
265 'm2_label' => 'Include line item(s) from package',
266 'm2m_method' => 'bill_part_pkg_link',
267 'm2m_dstcol' => 'dst_pkgpart',
268 'm2_error_callback' =>
269 &{$m2_error_callback_maker}('bill'),
270 'm2_fields' => [ { 'field' => 'hidden',
271 'type' => 'checkbox',
279 { type => 'tablebreak-tr-title',
282 { type => 'pkg_svc', },
284 { 'field' => 'svc_dst_pkgpart',
285 'label' => 'Also include services from package: ',
286 'type' => 'select-part_pkg',
287 'extra_sql' => sub { $pkgpart
288 ? "AND pkgpart != $pkgpart"
291 'm2_label' => 'Include services of package: ',
292 'm2m_method' => 'svc_part_pkg_link',
293 'm2m_dstcol' => 'dst_pkgpart',
294 'm2_error_callback' =>
295 &{$m2_error_callback_maker}('svc'),
298 { type => 'tablebreak-tr-title',
299 value => 'Price plan options',
308 my $curuser = $FS::CurrentUser::CurrentUser;
310 my $edit_global = 'Edit global package definitions';
311 my $acl_edit = $curuser->access_right('Edit package definitions');
312 my $acl_edit_global = $curuser->access_right($edit_global);
314 my $acl_edit_either = $acl_edit || $acl_edit_global;
316 my $begin_callback = sub {
317 my( $cgi, $fields, $opt ) = @_;
319 unless $acl_edit_either
320 || ( $cgi->param('pkgnum')
321 && $curuser->access_right('Customize customer package')
325 my $disabled_type = $acl_edit_either ? 'checkbox' : 'hidden';
327 #arg. access rights for cloning are Hard.
328 # on the one hand we don't really want cloning (customizing a package) to fail
329 # for want of finding the source package in normal usage
330 # on the other hand, we don't want people using the clone link to be able to
332 my $agent_clone_extra_sql =
333 ' ( '. FS::part_pkg->curuser_pkgs_sql.
334 " OR ( part_pkg.custom = 'Y' ) ".
337 my $conf = new FS::Conf;
338 my $taxproducts = $conf->exists('enable_taxproducts');
340 my $sth = dbh->prepare("SELECT COUNT(*) FROM part_pkg_report_option".
341 " WHERE disabled IS NULL OR disabled = '' ")
343 $sth->execute or die $sth->errstr;
344 my $report_option = $sth->fetchrow_arrayref->[0];
347 # - tr-part_pkg_freq: month_increments_only (from price plans)
349 # - test errors cloning
350 # - test custom pricing
351 # - move the selectlayer divs away from lame layer_callback
353 #my ($query) = $cgi->keywords;
358 my %tax_override = ();
360 my %taxproductnums = map { ($_->classnum => 1) }
361 qsearch('usage_class', { 'disabled' => '' });
362 my @taxproductnums = ( qw( setup recur ), sort (keys %taxproductnums) );
365 my $recur_disabled = 1;
366 my $setup_show_zero_disabled = 0;
367 my $recur_show_zero_disabled = 1;
371 my $error_callback = sub {
372 my($cgi, $object, $fields, $opt ) = @_;
374 (@agent_type) = $cgi->param('agent_type');
376 $opt->{action} = 'Custom' if $cgi->param('pkgnum');
378 $setup_show_zero_disabled = ($cgi->param('setup_fee') > 0) ? 1 : 0;
380 $recur_disabled = $cgi->param('freq') ? 0 : 1;
381 $recur_show_zero_disabled =
383 ? $cgi->param('recur_fee') > 0 ? 1 : 0
386 foreach ($cgi->param) {
387 /^usage_taxproductnum_(\d+)$/ && ($taxproductnums{$1} = 1);
389 $tax_override{''} = $cgi->param('tax_override');
390 $tax_override{$_} = $cgi->param('tax_override_$_')
391 foreach(grep { /^tax_override_(\w+)$/ } $cgi->param);
393 #some false laziness w/process
394 $cgi->param('plan') =~ /^(\w+)$/ or die 'unparsable plan';
396 my $options = $cgi->param($plan."__OPTIONS");
397 my @options = split(',', $options);
399 map { my $optionname = $_;
400 my $param = $plan."__$optionname";
401 my $value = join(', ', $cgi->param($param));
402 ( $optionname => $value );
406 $object->set($_ => scalar($cgi->param($_)) )
407 foreach (qw( setup_fee recur_fee disable_line_item_date_ranges ));
409 $pkgpart = $object->pkgpart;
413 my $new_hashref_callback = sub { { 'plan' => 'flat' }; };
415 my $new_object_callback = sub {
416 my( $cgi, $hashref, $fields, $opt ) = @_;
418 my $part_pkg = FS::part_pkg->new( $hashref );
419 $part_pkg->set($_ => '0')
420 foreach (qw( setup_fee recur_fee disable_line_item_date_ranges ));
426 sub set_report_option {
427 my($cgi, $object, $fields ) = @_; #, $opt
429 my @report_option = ();
430 foreach ($object->options) {
431 /^usage_taxproductnum_(\d+)$/ && ($taxproductnums{$1} = 1);
432 /^report_option_(\d+)$/ && (push @report_option, $1);
434 foreach ($object->part_pkg_taxoverride) {
435 $taxproductnums{$_->usage_class} = 1
439 $cgi->param('report_option', join(',', @report_option));
440 foreach my $field ( @$fields ) {
442 ref($field) eq 'HASH' &&
444 $field->{field} eq 'report_option'
446 #$field->{curr_value} = join(',', @report_option);
447 $field->{value} = join(',', @report_option);
452 my $edit_callback = sub {
453 my( $cgi, $object, $fields, $opt ) = @_;
455 $setup_show_zero_disabled = ($object->option('setup_fee') > 0) ? 1 : 0;
457 $recur_disabled = $object->freq ? 0 : 1;
459 $recur_show_zero_disabled =
461 ? $object->option('recur_fee') > 0 ? 1 : 0
465 map {$_->typenum} qsearch('type_pkgs', { 'pkgpart' => $object->pkgpart } );
467 set_report_option( $cgi, $object, $fields);
469 %options = $object->options;
471 $object->set($_ => $object->option($_, 1))
472 foreach (qw( setup_fee recur_fee disable_line_item_date_ranges ));
474 $pkgpart = $object->pkgpart;
478 my $new_callback = sub {
479 my( $cgi, $object, $fields ) = @_;
481 my $conf = new FS::Conf;
483 if ( $conf->exists('agent_defaultpkg') ) {
484 #my @all_agent_types = map {$_->typenum} qsearch('agent_type',{});
485 @agent_type = map {$_->typenum} qsearch('agent_type',{});
488 $options{'suspend_bill'}=1 if $conf->exists('part_pkg-default_suspend_bill');
492 my $clone_callback = sub {
493 my( $cgi, $object, $fields, $opt ) = @_;
495 if ( $cgi->param('pkgnum') ) {
497 my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cgi->param('pkgnum') } );
498 $object->agentnum( $cust_pkg->cust_main->agentnum );
500 $opt->{action} = 'Custom';
502 #my $part_pkg = $clone_part_pkg->clone;
503 #this is all clone does anyway
504 $object->custom('Y');
506 $object->disabled('Y');
508 } else { #when explicitly cloning, not customizing
511 map {$_->typenum} qsearch('type_pkgs',{ 'pkgpart' => $object->pkgpart } );
515 set_report_option( $cgi, $object, $fields);
517 %options = $object->options;
519 $object->set($_ => $options{$_})
520 foreach (qw( setup_fee recur_fee disable_line_item_date_ranges ));
522 $recur_disabled = $object->freq ? 0 : 1;
525 my $discount_error_callback = sub {
526 my( $cgi, $object ) = @_;
528 if ( /^discountnum(\d+)$/ &&
529 ( my $discountnum = $cgi->param("discountnum$1") ) )
531 new FS::part_pkg_discount {
532 'pkgpart' => $object->pkgpart,
533 'discountnum' => $discountnum,
542 my $m2_error_callback_maker = sub {
543 my $link_type = shift; #yay closures
545 my( $cgi, $object ) = @_;
548 if ( /^${link_type}_dst_pkgpart(\d+)$/ &&
549 ( my $dst = $cgi->param("${link_type}_dst_pkgpart$1") ) )
552 my $hidden = $cgi->param("${link_type}_dst_pkgpart__hidden$1")
554 new FS::part_pkg_link {
555 'link_type' => $link_type,
556 'src_pkgpart' => $object->pkgpart,
557 'dst_pkgpart' => $dst,
568 my $javascript = <<'END';
569 <SCRIPT TYPE="text/javascript">
571 function freq_changed(what) {
572 var freq = what.options[what.selectedIndex].value;
575 what.form.recur_fee.disabled = true;
576 what.form.recur_fee.style.backgroundColor = '#dddddd';
577 what.form.recur_show_zero.disabled = true;
578 //what.form.recur_show_zero.style.backgroundColor= '#dddddd';
580 what.form.recur_fee.disabled = false;
581 what.form.recur_fee.style.backgroundColor = '#ffffff';
582 recur_changed( what.form.recur_fee );
583 //what.form.recur_show_zero.style.backgroundColor= '#ffffff';
588 function setup_changed(what) {
589 var setup = what.value;
590 if ( parseFloat(setup) == 0 ) {
591 what.form.setup_show_zero.disabled = false;
593 what.form.setup_show_zero.disabled = true;
597 function recur_changed(what) {
598 var recur = what.value;
599 if ( parseFloat(recur) == 0 ) {
600 what.form.recur_show_zero.disabled = false;
602 what.form.recur_show_zero.disabled = true;
606 function agent_changed(what) {
609 if ( what.type == 'select-one' ) {
610 agentnum = what.options[what.selectedIndex].value;
612 agentnum = what.value;
615 if ( agentnum == 0 ) {
616 what.form.agent_type.disabled = false;
617 //what.form.agent_type.style.backgroundColor = '#ffffff';
618 what.form.agent_type.style.visibility = '';
620 what.form.agent_type.disabled = true;
621 //what.form.agent_type.style.backgroundColor = '#dddddd';
622 what.form.agent_type.style.visibility = 'hidden';
627 function aux_planchanged(what) { //?
630 var plan = what.options[what.selectedIndex].value;
631 var table = document.getElementById('TableNumber7') // XXX NOT ROBUST
633 if ( plan == 'flat' || plan == 'prorate' || plan == 'subscription' ) {
634 //table.disabled = false;
635 table.style.visibility = '';
637 //table.disabled = true;
638 table.style.visibility = 'hidden';
646 'Changing the setup or recurring fee will create a new package definition. '.
649 $javascript .= "function confirm_submit(f) {";
650 if ( $conf->exists('part_pkg-lineage') ) {
653 var fields = Array('setup_fee','recur_fee');
654 for(var i=0; i < fields.length; i++) {
655 if ( f[fields[i]].value != f[fields[i]].defaultValue ) {
656 return confirm('$warning');
666 tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() };
668 tie my %plan_labels, 'Tie::IxHash',
669 map { $_ => ( $plans{$_}->{'shortname'} || $plans{$_}->{'name'} ) }
672 my $html_bottom = sub {
675 #warn join("\n", map { "$_: $options{$_}" } keys %options ). "\n";
677 my $layer_callback = sub {
680 my $html = ntable("#cccccc",2);
684 # <TD ALIGN="right">Recurring fee frequency </TD>
685 # <TD><SELECT NAME="freq">
688 #my @freq = keys %freq;
689 #@freq = grep { /^\d+$/ } @freq
690 #XXX this bit# # if exists($plans{$layer}->{'freq'}) && $plans{$layer}->{'freq'} eq 'm';
691 #foreach my $freq ( @freq ) {
692 # $html .= qq(<OPTION VALUE="$freq");
693 # $html .= ' SELECTED' if $freq eq $part_pkg->freq;
694 # $html .= ">$freq{$freq}";
697 #$html .= '</SELECT></TD></TR>';
699 my $href = $plans{$layer}->{'fields'};
700 my @fields = exists($plans{$layer}->{'fieldorder'})
701 ? @{$plans{$layer}->{'fieldorder'}}
704 foreach my $field ( grep $_ !~ /^(setup|recur)_fee$/, @fields ) {
706 if(!exists($href->{$field})) {
708 warn "nonexistent part_pkg option: '$field'\n";
712 $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>';
714 my $format = sub { shift };
715 $format = $href->{$field}{'format'} if exists($href->{$field}{'format'});
717 #XXX these should use elements/ fields... (or this whole thing should
718 #just use layer_fields instead of layer_callback)
720 if ( ! exists($href->{$field}{'type'}) ) {
722 $html .= qq!<INPUT TYPE="text" NAME="${layer}__$field" VALUE="!.
723 ( exists($options{$field})
724 ? &$format($options{$field})
725 : $href->{$field}{'default'} ).
728 } elsif ( $href->{$field}{'type'} eq 'checkbox' ) {
730 $html .= qq!<INPUT TYPE="checkbox" NAME="${layer}__$field" VALUE=1 !.
731 ( exists($options{$field}) && $options{$field}
736 } elsif ( $href->{$field}{'type'} =~ /^select/ ) {
740 if $href->{$field}{'type'} eq 'select_multiple';
741 $html .= qq! NAME="${layer}__$field">!;
743 $html .= '<OPTION VALUE="">'. $href->{$field}{'empty_label'}
744 if exists($href->{$field}{'disable_empty'})
745 && ! $href->{$field}{'disable_empty'};
747 if ( $href->{$field}{'select_table'} ) {
749 qsearch( $href->{$field}{'select_table'},
750 $href->{$field}{'select_hash'} )
752 my $value = $record->getfield($href->{$field}{'select_key'});
753 $html .= qq!<OPTION VALUE="$value"!.
754 ( $options{$field} =~ /(^|, *)$value *(,|$)/ #?
758 '>'. $record->getfield($href->{$field}{'select_label'});
760 } elsif ( $href->{$field}{'select_options'} ) {
761 foreach my $key ( keys %{ $href->{$field}{'select_options'} } ) {
762 my $label = $href->{$field}{'select_options'}{$key};
763 $html .= qq!<OPTION VALUE="$key"!.
764 ( $options{$field} =~ /(^|, *)$key *(,|$)/ #?
772 $html .= '<font color="#ff0000">warning: '.
773 "don't know how to retreive options for $field select field".
776 $html .= '</SELECT>';
778 } elsif ( $href->{$field}{'type'} eq 'radio' ) {
781 qq!<INPUT TYPE="radio" NAME="${layer}__$field"!;
783 foreach my $key ( keys %{ $href->{$field}{'options'} } ) {
784 my $label = $href->{$field}{'options'}{$key};
785 $html .= qq!$radio VALUE="$key"!.
786 ( $options{$field} =~ /(^|, *)$key *(,|$)/ #?
795 $html .= '</TD></TR>';
799 $html .= qq(<INPUT TYPE="hidden" NAME="${layer}__OPTIONS" VALUE=").
800 join(',', keys %{ $href } ). '">';
808 options => [ keys %plan_labels ],
809 labels => \%plan_labels,
810 curr_value => $object->plan,
811 layer_callback => $layer_callback,
815 include('/elements/selectlayers.html', %selectlayers, 'layers_only'=>1 ).
816 '<SCRIPT TYPE="text/javascript">'.
817 include('/elements/selectlayers.html', %selectlayers, 'js_only'=>1 );
820 "taxproduct_selectchanged(document.getElementById('taxproduct_select'));\n"
823 $return .= '</SCRIPT>';
829 my %usage_class = map { ($_->classnum => $_->classname) }
830 qsearch('usage_class', {});
831 $usage_class{setup} = 'Setup';
832 $usage_class{recur} = 'Recurring';
834 my %taxproduct_fields = ();
835 my $end_callback = sub {
836 my( $cgi, $object, $fields, $opt ) = @_;
838 @taxproductnums = ( qw( setup recur ), sort (keys %taxproductnums) );
840 if ( $object->pkgpart ) {
841 foreach my $usage_class ( '', @taxproductnums ) {
842 $tax_override{$usage_class} =
843 join (",", map $_->taxclassnum,
844 qsearch( 'part_pkg_taxoverride', {
845 'pkgpart' => $object->pkgpart,
846 'usage_class' => $usage_class,
853 map { $_ => [ "taxproductnum_$_",
854 { type => 'select-taxproduct',
855 #label => "$usage_class{$_} tax product",
858 { type => 'select-taxoverride' }
863 $taxproduct_fields{'(default)'} =
864 [ 'taxproductnum', { type => 'select-taxproduct',
865 #label => 'Default tax product',
867 'tax_override', { type => 'select-taxoverride' },
871 my $taxproduct_values = sub {
872 my ($cgi, $object, $flags) = @_;
874 sub { my $layer = shift;
875 my @fields = @{$taxproduct_fields{$layer}};
878 my $field = shift @fields;
880 $field =~ /^taxproductnum_\w+$/ &&
881 push @values, ( $field => $options{"usage_$field"} );
882 $field =~ /^tax_override_(\w+)$/ &&
883 push @values, ( $field => $tax_override{$1} );
884 $field =~ /^taxproductnum$/ &&
885 push @values, ( $field => $object->taxproductnum );
886 $field =~ /^tax_override$/ &&
887 push @values, ( $field => $tax_override{''} );
893 map { ( $_ => { &{$routine}($_) } ) } ( '(default)', @taxproductnums );
898 my $field_callback = sub {
899 my ($cgi, $object, $fieldref) = @_;
901 my $field = $fieldref->{field};
902 if ($field eq 'taxproductnums') {
903 $fieldref->{value} = join(',', @taxproductnums);
904 } elsif ($field eq 'taxproduct_select') {
905 $fieldref->{options} = [ '(default)', @taxproductnums ];
906 $fieldref->{labels} = { ( '(default)' => '(default)' ),
907 map {( $_ => ($usage_class{$_} || $_) )}
910 $fieldref->{layer_fields} = \%taxproduct_fields;
911 $fieldref->{layer_values_callback} = $taxproduct_values;
915 my $discountnum_hashref = {
917 'months' => { 'op' => '>', 'value' => 1 },