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