RT# 82949 - changes section name from fees to pricing, better opiton
[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($dest) %>
21 % }
22 <%init>
23 my $curuser = $FS::CurrentUser::CurrentUser;
24 my $edit_acl = $curuser->access_right('Edit FCC report configuration');
25 my $global_edit_acl = $curuser->access_right('Edit FCC report configuration for all agents');
26 die "access denied" unless $edit_acl or $global_edit_acl;
27
28 # non-atomic; report errors but allow successful changes to go through
29 # not that I even know how you'd get an error doing this
30
31 my %error;
32 foreach my $param ($cgi->param) {
33   $param =~ /^pkgpart(\d+)$/ or next;
34   my $pkgpart = $1;
35   my $part_pkg = FS::part_pkg->by_key($pkgpart);
36   my $hashref = decode_json( $cgi->param($param) );
37   my $error = $part_pkg->set_fcc_options($hashref);
38   $error{$pkgpart} = $error if $error;
39 }
40
41 my $dest = $fsurl.'browse/part_pkg-fcc.html?';
42 foreach (qw(classnum maxrecords offset)) {
43   if ( $cgi->param($_) =~ /^(\d+)$/ ) {
44     $dest .= "$_=$1;";
45   }
46 }
47
48 if ( $cgi->param('jump') =~ /^pkgpart(\d+)$/ ) {
49   $dest .= "#$1";
50 }
51 </%init>