blob: 94c084eae9d62936b0ccc4ee068d2f20fc2f906d (
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
|
% if ($error) {
% $cgi->param('error', $error);
% $cgi->redirect(popurl(3). 'edit/cust_pkg.cgi?'. $cgi->query_string );
% } else {
<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
unless $curuser->access_right('Bulk change customer packages');
my $error = '';
#untaint custnum
$cgi->param('custnum') =~ /^(\d+)$/;
my $custnum = $1;
my @remove_pkgnums = map {
/^(\d+)$/ or die "Illegal remove_pkg value!";
$1;
} $cgi->param('remove_pkg');
my( $action, $error_redirect ) = ( '', '' );
my @pkgparts = ();
foreach my $pkgpart ( map /^pkg(\d+)$/ ? $1 : (), $cgi->param ) {
if ( $cgi->param("pkg$pkgpart") =~ /^(\d+)$/ ) {
my $num_pkgs = $1;
while ( $num_pkgs-- ) {
push @pkgparts,$pkgpart;
}
} else {
$error = "Illegal quantity";
last;
}
}
$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums);
</%init>
|