better UI for package report classes, #13507
[freeside.git] / httemplate / edit / process / bulk-part_pkg.html
1 % if ( $error ) {
2 %  $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(3).'/edit/bulk-part_pkg.cgi?', $cgi->query_string) %>
4 % } else {
5 <% $cgi->redirect(popurl(3).'/browse/part_pkg.cgi') %>
6 % }
7 <%init>
8 die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions');
9
10 my @pkgparts = $cgi->param('pkgpart')
11   or die "no package definitions selected";
12
13 my %changes;
14 foreach my $param (grep { /^report_option_\d+$/ } $cgi->param) {
15   if ( length($cgi->param($param)) ) {
16     if ( $cgi->param($param) == 1 ) {
17       $changes{$param} = 1;
18     } else {
19       $changes{$param} = '';
20     }
21   }
22 }
23
24 my $error;
25 foreach my $pkgpart (@pkgparts) {
26   my $part_pkg = FS::part_pkg->by_key($pkgpart);
27   my %options = ( $part_pkg->options, %changes );
28   $error ||= $part_pkg->replace( options => \%options );
29 }
30 </%init>