blob: d060a242ef8c86c6cdb673c0ca2bc45711661f4b (
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
|
% if ( keys %error ) {
% foreach my $pkgpart (keys %error) {
% # stuff all the errors back into $cgi
% $cgi->param("error$pkgpart", $error{$pkgpart});
% }
% my $session = int(rand(4294967296)); #XXX
% my $pref = new FS::access_user_pref({
% 'usernum' => $FS::CurrentUser::CurrentUser->usernum,
% 'prefname' => "redirect$session",
% 'prefvalue' => $cgi->query_string,
% 'expiration' => time + 3600, #1h? 1m?
% });
% my $pref_error = $pref->insert;
% if ( $pref_error ) {
% die "FATAL: couldn't even set redirect cookie: $pref_error".
% " attempting to set redirect$session to ". $cgi->query_string."\n";
% }
<% $cgi->redirect($fsurl.'browse/part_pkg-fcc.html?redirect='.$session) %>
% } else {
<% $cgi->redirect($dest) %>
% }
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
my $edit_acl = $curuser->access_right('Edit FCC report configuration');
my $global_edit_acl = $curuser->access_right('Edit FCC report configuration for all agents');
die "access denied" unless $edit_acl or $global_edit_acl;
# non-atomic; report errors but allow successful changes to go through
# not that I even know how you'd get an error doing this
my %error;
foreach my $param ($cgi->param) {
$param =~ /^pkgpart(\d+)$/ or next;
my $pkgpart = $1;
my $part_pkg = FS::part_pkg->by_key($pkgpart);
my $hashref = decode_json( $cgi->param($param) );
my $error = $part_pkg->set_fcc_options($hashref);
$error{$pkgpart} = $error if $error;
}
my $dest = $fsurl.'browse/part_pkg-fcc.html?';
foreach (qw(classnum maxrecords offset)) {
if ( $cgi->param($_) =~ /^(\d+)$/ ) {
$dest .= "$_=$1;";
}
}
if ( $cgi->param('jump') =~ /^pkgpart(\d+)$/ ) {
$dest .= "#$1";
}
</%init>
|