fix XSS
[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 ( defined $initial_state{$num} ) {
26       <& /elements/checkbox.html,
27             field => 'report_option_'.$num,
28             value => 1,
29             curr_value => $initial_state{$num}
30       &>
31 %   } else {
32 %     # needs to be a tristate so that you can say "don't change it"
33       <& /elements/checkbox-tristate.html, field => 'report_option_'.$num &>
34 %   }
35     </TD>
36     <TD><% $report_class{$num}->name %></TD>
37   </TR>
38 %   $row++;
39 % }
40 </TABLE>
41 <BR>
42 <INPUT TYPE="submit">
43 </FORM>
44 <& /elements/footer.html &>
45 <%init>
46 die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions');
47 my @pkgparts = $cgi->param('pkgpart')
48   or die "no package definitions selected";
49
50 my %part_pkg = map { $_ => FS::part_pkg->by_key($_) } @pkgparts;
51 my %part_pkg_option = map { $_ => { $part_pkg{$_}->options } } @pkgparts;
52 my %report_class = map { $_->num => $_ }
53   qsearch('part_pkg_report_option', { disabled => '' });
54
55 my %initial_state;
56 foreach my $num (keys %report_class) {
57   my $yes = 0;
58   my $no = 0;
59   foreach my $option (values %part_pkg_option) {
60     if ( $option->{"report_option_$num"} ) {
61       $yes = 1;
62     } else {
63       $no = 1;
64     }
65   }
66   if ( $yes and $no ) {
67     $initial_state{$num} = undef;
68   } elsif ( $yes ) {
69     $initial_state{$num} = 1;
70   } elsif ( $no ) {
71     $initial_state{$num} = 0;
72   } # else, uh, you didn't provide any pkgparts
73 }
74 </%init>