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