477 report: improve browse-edit UI
[freeside.git] / httemplate / edit / process / bulk-part_pkg-fcc.html
1 % if ( keys %error ) {
2 %   foreach my $pkgpart (keys %error) {
3 %     # stuff all the errors back into $cgi
4 %     $cgi->param("error$pkgpart", $error{$pkgpart});
5 %   }
6 %   my $session = int(rand(4294967296)); #XXX
7 %   my $pref = new FS::access_user_pref({
8 %     'usernum'    => $FS::CurrentUser::CurrentUser->usernum,
9 %     'prefname'   => "redirect$session",
10 %     'prefvalue'  => $cgi->query_string,
11 %     'expiration' => time + 3600, #1h?  1m?
12 %   });
13 %   my $pref_error = $pref->insert;
14 %   if ( $pref_error ) {
15 %     die "FATAL: couldn't even set redirect cookie: $pref_error".
16 %         " attempting to set redirect$session to ". $cgi->query_string."\n";
17 %   }
18 <% $cgi->redirect($fsurl.'browse/part_pkg-fcc.html?redirect='.$session) %>
19 % } else {
20 <% $cgi->redirect($fsurl.'browse/part_pkg-fcc.html?classnum='.$classnum) %>
21 % }
22 <%init>
23 my $curuser = $FS::CurrentUser::CurrentUser;
24 die "access denied"
25   unless $curuser->access_right('Bulk edit package definitions');
26
27 # non-atomic; report errors but allow successful changes to go through
28 # not that I even know how you'd get an error doing this
29
30 my %error;
31 foreach my $param ($cgi->param) {
32   $param =~ /^pkgpart(\d+)$/ or next;
33   my $pkgpart = $1;
34   my $part_pkg = FS::part_pkg->by_key($pkgpart);
35   my $hashref = decode_json( $cgi->param($param) );
36   my $error = $part_pkg->set_fcc_options($hashref);
37   $error{$pkgpart} = $error if $error;
38 }
39
40 my $classnum = $cgi->param('classnum');
41
42 </%init>