& /elements/header.html, 'Edit package report classes' &> %# change that title if we add any other editing controls %# this should be centralized somewhere <& /elements/error.html &>
<& /elements/footer.html &> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions'); my @pkgparts = $cgi->param('pkgpart') or die "no package definitions selected"; my %part_pkg = map { $_ => FS::part_pkg->by_key($_) } @pkgparts; my %part_pkg_option = map { $_ => { $part_pkg{$_}->options } } @pkgparts; my %report_class = map { $_->num => $_ } qsearch('part_pkg_report_option', { disabled => '' }); my %initial_state; foreach my $num (keys %report_class) { my $yes = 0; my $no = 0; foreach my $option (values %part_pkg_option) { if ( $option->{"report_option_$num"} ) { $yes = 1; } else { $no = 1; } } if ( $yes and $no ) { $initial_state{$num} = -1; } elsif ( $yes ) { $initial_state{$num} = 1; } elsif ( $no ) { $initial_state{$num} = ''; } # else, uh, you didn't provide any pkgparts } %init>