Option to ignore old CDRs, RT#81480
[freeside.git] / httemplate / edit / bulk-part_pkg.html
1 <& /elements/header.html, 'Edit package report classes' &>
2 %# change that title if we add any other editing controls
3
4 %# this should be centralized somewhere
5 <STYLE TYPE="text/css">
6 .row0 { background-color: #eeeeee; }
7 .row1 { background-color: #ffffff; }
8 </STYLE>
9 <& /elements/error.html &>
10
11 <FORM ACTION="process/bulk-part_pkg.html" METHOD="POST">
12 <DIV>
13 The following packages will be changed:<BR>
14 % foreach my $pkgpart (sort keys(%part_pkg)) {
15 <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $pkgpart %>">
16 <% $part_pkg{$pkgpart}->pkg_comment |h %><BR>
17 % }
18 </DIV>
19 <BR>
20 <& /elements/table-grid.html &>\
21 <& /elements/tr-justtitle.html, value => mt('Report classes') &>
22 % my $row = 0;
23 % foreach my $num (sort keys %report_class) {
24   <TR CLASS="row<%$row % 2%>">
25     <TD>
26 %   if ( $initial_state{$num} == -1 ) {
27 %     # needs to be a tristate so that you can say "don't change it"
28       <& /elements/checkbox-tristate.html, field => 'report_option_'.$num &>
29 %   } else {
30 %# for visual consistency
31       <INPUT TYPE="checkbox" CLASS="partial" NAME="report_option_<%$num%>" VALUE="1" <% $initial_state{$num} ? 'CHECKED':'' %>><LABEL />
32 %   }
33     </TD>
34     <TD><% $report_class{$num}->name %></TD>
35   </TR>
36 %   $row++;
37 % }
38 </TABLE>
39 <BR>
40 <INPUT TYPE="submit">
41 </FORM>
42 <& /elements/footer.html &>
43 <%init>
44 die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions');
45 my @pkgparts = $cgi->param('pkgpart')
46   or die "no package definitions selected";
47
48 my %part_pkg = map { $_ => FS::part_pkg->by_key($_) } @pkgparts;
49 my %part_pkg_option = map { $_ => { $part_pkg{$_}->options } } @pkgparts;
50 my %report_class = map { $_->num => $_ }
51   qsearch('part_pkg_report_option', { disabled => '' });
52
53 my %initial_state;
54 foreach my $num (keys %report_class) {
55   my $yes = 0;
56   my $no = 0;
57   foreach my $option (values %part_pkg_option) {
58     if ( $option->{"report_option_$num"} ) {
59       $yes = 1;
60     } else {
61       $no = 1;
62     }
63   }
64   if ( $yes and $no ) {
65     $initial_state{$num} = -1;
66   } elsif ( $yes ) {
67     $initial_state{$num} = 1;
68   } elsif ( $no ) {
69     $initial_state{$num} = '';
70   } # else, uh, you didn't provide any pkgparts
71 }
72 </%init>