RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / bulk-part_pkg.html
1 <% include('/elements/header-popup.html', 'Bulk edit packages') %>
2
3 %# this should be centralized somewhere
4 <STYLE TYPE="text/css">
5 .row0 { background-color: #eeeeee; }
6 .row1 { background-color: #ffffff; }
7 </STYLE>
8 <& /elements/error.html &>
9
10 <SCRIPT>
11   function areyousure() {
12     var warning = 'Edit these packages?';
13     if(confirm(warning)) { process(); }
14   }
15
16   function toggle_section(what) {
17     var id = what.id;
18     var isDisabled;
19     if (document.getElementById(id).checked == true)  { isDisabled = false; }
20     else { isDisabled = true; }
21
22     var whatDiv = document.getElementById(id+'_div');
23     if (isDisabled) { whatDiv.style.display = "none"; }
24     else { whatDiv.style.display = "block"; }
25
26   }
27 </SCRIPT>
28
29 <FORM ACTION="process/bulk-part_pkg.html" METHOD="POST">
30 <TABLE>
31   <TR>
32     <TD VALIGN="top">
33 <B>Select the package information to change</B><BR>
34 <INPUT TYPE="checkbox" ID="report_class" NAME="report_class" VALUE="1" onChange='toggle_section(this);'>
35 Edit report classes
36 <BR>
37 <DIV ID="report_class_div" STYLE="display: none;">
38  <& /elements/table-grid.html &>\
39   <& /elements/tr-justtitle.html, value => mt('Report classes') &>
40 % my $row = 0;
41 % foreach my $num (sort keys %report_class) {
42     <TR CLASS="row<%$row % 2%>">
43      <TD>
44 %   if ( $initial_state{$num} == -1 ) {
45 %     # needs to be a tristate so that you can say "don't change it"
46       <& /elements/checkbox-tristate.html, field => 'report_option_'.$num &>
47 %   } else {
48 %# for visual consistency
49       <INPUT TYPE="checkbox" CLASS="partial" ID="report_option_<%$num%>" NAME="report_option_<%$num%>" VALUE="1" <% $initial_state{$num} ? 'CHECKED':'' %>><LABEL />
50 %   }
51      </TD>
52       <TD><% $report_class{$num}->name %></TD>
53     </TR>
54 %   $row++;
55 % }
56   </TABLE>
57 </DIV>
58 <BR>
59 <INPUT TYPE="checkbox" ID="pricing" NAME="pricing" VALUE="1" onChange='toggle_section(this);'>
60 Edit pricing fields.
61 <BR>
62 <DIV ID="pricing_div" STYLE="display: none;">
63  <& /elements/table-grid.html &>\
64   <& /elements/tr-justtitle.html, value => mt('Package pricing') &>
65   <TR>
66     <TD>Percentage of setup fee increase </TD>
67     <TD><INPUT TYPE="text" ID="setup_fee_increase" NAME="setup_fee_increase">%</TD>
68   </TR>
69     <TD>Percentage of recurring fee increase </TD>
70     <TD><INPUT TYPE="text" ID="recurring_fee_increase" NAME="recurring_fee_increase">%</TD>
71   </TR>
72  </TABLE>
73 </DIV>
74 <BR>
75 <INPUT TYPE="submit" VALUE="Bulk change packages" onclick="areyousure()">
76     </TD>
77     <TD WIDTH="5">&nbsp;</TD>
78     <TD VALIGN="top">
79       <B>The following packages will be changed:</B><BR>
80 %     foreach my $pkgpart (sort keys(%part_pkg)) {
81         <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $pkgpart %>">
82         <% $part_pkg{$pkgpart}->pkg_comment |h %><BR>
83 %     }
84     </TD>
85   </TR>
86 </TABLE>
87 </FORM>
88 <& /elements/footer.html &>
89 <%init>
90 die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions');
91 my @pkgparts = $cgi->param('pkgpart')
92   or die "no package definitions selected";
93
94 my %part_pkg = map { $_ => FS::part_pkg->by_key($_) } @pkgparts;
95 my %part_pkg_option = map { $_ => { $part_pkg{$_}->options } } @pkgparts;
96 my %report_class = map { $_->num => $_ }
97   qsearch('part_pkg_report_option', { disabled => '' });
98
99 my %initial_state;
100 foreach my $num (keys %report_class) {
101   my $yes = 0;
102   my $no = 0;
103   foreach my $option (values %part_pkg_option) {
104     if ( $option->{"report_option_$num"} ) {
105       $yes = 1;
106     } else {
107       $no = 1;
108     }
109   }
110   if ( $yes and $no ) {
111     $initial_state{$num} = -1;
112   } elsif ( $yes ) {
113     $initial_state{$num} = 1;
114   } elsif ( $no ) {
115     $initial_state{$num} = '';
116   } # else, uh, you didn't provide any pkgparts
117 }
118 </%init>