This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / httemplate / edit / process / cust_pkg.cgi
1 % if ($error) {
2 %   $cgi->param('error', $error);
3 %   $cgi->redirect(popurl(3). 'edit/cust_pkg.cgi?'. $cgi->query_string );
4 % } else {
5 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %>
6 % }
7 <%init>
8
9 my $curuser = $FS::CurrentUser::CurrentUser;
10
11 die "access denied"
12   unless $curuser->access_right('Bulk change customer packages');
13
14 my $error = '';
15
16 #untaint custnum
17 $cgi->param('custnum') =~ /^(\d+)$/;
18 my $custnum = $1;
19
20 my @remove_pkgnums = map {
21   /^(\d+)$/ or die "Illegal remove_pkg value!";
22   $1;
23 } $cgi->param('remove_pkg');
24
25 my( $action, $error_redirect ) = ( '', '' );
26 my @pkgparts = ();
27
28 foreach my $pkgpart ( map /^pkg(\d+)$/ ? $1 : (), $cgi->param ) {
29   if ( $cgi->param("pkg$pkgpart") =~ /^(\d+)$/ ) {
30     my $num_pkgs = $1;
31     while ( $num_pkgs-- ) {
32       push @pkgparts,$pkgpart;
33     }
34   } else {
35     $error = "Illegal quantity";
36     last;
37   }
38 }
39
40 $error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums);
41
42 </%init>