summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-08-17 22:36:45 -0700
committerIvan Kohler <ivan@freeside.biz>2013-08-17 22:36:45 -0700
commitd4e9d68a229b01207ee9e6f3679bb65e7f13cf08 (patch)
tree74b82996715811859008b18e90a9caa10b481e2b /httemplate/edit
parent90c127d346a6999e6be4a54277339924b73eeb0e (diff)
parent23c8996f73976d52a4380d616ed9276d9640f444 (diff)
Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/bulk-part_pkg.html16
-rw-r--r--httemplate/edit/process/bulk-part_pkg.html25
2 files changed, 22 insertions, 19 deletions
diff --git a/httemplate/edit/bulk-part_pkg.html b/httemplate/edit/bulk-part_pkg.html
index a1c6f0c9b..4665c9f95 100644
--- a/httemplate/edit/bulk-part_pkg.html
+++ b/httemplate/edit/bulk-part_pkg.html
@@ -6,6 +6,7 @@
.row0 { background-color: #eeeeee; }
.row1 { background-color: #ffffff; }
</STYLE>
+<& /elements/error.html &>
<FORM ACTION="process/bulk-part_pkg.html" METHOD="POST">
<DIV>
@@ -22,15 +23,12 @@ The following packages will be changed:<BR>
% foreach my $num (sort keys %report_class) {
<TR CLASS="row<%$row % 2%>">
<TD>
-% if ( defined $initial_state{$num} ) {
- <& /elements/checkbox.html,
- field => 'report_option_'.$num,
- value => 1,
- curr_value => $initial_state{$num}
- &>
-% } else {
+% 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" NAME="report_option_<%$num%>" VALUE="1" <% $initial_state{$num} ? 'CHECKED':'' %>><LABEL />
% }
</TD>
<TD><% $report_class{$num}->name %></TD>
@@ -64,11 +62,11 @@ foreach my $num (keys %report_class) {
}
}
if ( $yes and $no ) {
- $initial_state{$num} = undef;
+ $initial_state{$num} = -1;
} elsif ( $yes ) {
$initial_state{$num} = 1;
} elsif ( $no ) {
- $initial_state{$num} = 0;
+ $initial_state{$num} = '';
} # else, uh, you didn't provide any pkgparts
}
</%init>
diff --git a/httemplate/edit/process/bulk-part_pkg.html b/httemplate/edit/process/bulk-part_pkg.html
index 4775a9334..59c914a5d 100644
--- a/httemplate/edit/process/bulk-part_pkg.html
+++ b/httemplate/edit/process/bulk-part_pkg.html
@@ -1,6 +1,6 @@
% if ( $error ) {
% $cgi->param('error', $error);
-<% $cgi->redirect(popurl(3).'/edit/bulk-part_pkg.cgi?', $cgi->query_string) %>
+<% $cgi->redirect(popurl(3).'/edit/bulk-part_pkg.html?'.$cgi->query_string) %>
% } else {
<% $cgi->redirect(popurl(3).'/browse/part_pkg.cgi') %>
% }
@@ -10,21 +10,26 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edi
my @pkgparts = $cgi->param('pkgpart')
or die "no package definitions selected";
-my %changes;
+my %delete = map { 'report_option_'.($_->num) => 1 }
+ qsearch('part_pkg_report_option', {});
+my %insert;
+
foreach my $param (grep { /^report_option_\d+$/ } $cgi->param) {
- if ( length($cgi->param($param)) ) {
- if ( $cgi->param($param) == 1 ) {
- $changes{$param} = 1;
- } else {
- $changes{$param} = '';
- }
- }
+ if ( $cgi->param($param) == 1 ) {
+ $insert{$param} = 1;
+ delete $delete{$param};
+ } elsif ( $cgi->param($param) == -1 ) {
+ # leave it alone
+ delete $delete{$param};
+ } # else it's empty, so leave it on the delete list
}
+
my $error;
foreach my $pkgpart (@pkgparts) {
my $part_pkg = FS::part_pkg->by_key($pkgpart);
- my %options = ( $part_pkg->options, %changes );
+ my %options = ( $part_pkg->options, %insert );
+ delete $options{$_} foreach keys(%delete);
$error ||= $part_pkg->replace( options => \%options );
}
</%init>