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