diff options
Diffstat (limited to 'httemplate/edit/process/cust_pkg.cgi')
-rwxr-xr-x | httemplate/edit/process/cust_pkg.cgi | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/httemplate/edit/process/cust_pkg.cgi b/httemplate/edit/process/cust_pkg.cgi new file mode 100755 index 000000000..bdade321f --- /dev/null +++ b/httemplate/edit/process/cust_pkg.cgi @@ -0,0 +1,68 @@ +% if ($error) { +% $cgi->param('error', $error); +% $cgi->redirect(popurl(3). $error_redirect. '?'. $cgi->query_string ); +% } elsif ( $action eq 'change' ) { + + <% header("Package changed") %> + <SCRIPT TYPE="text/javascript"> + window.top.location.reload(); + </SCRIPT> + </BODY> + </HTML> + +% } elsif ( $action eq 'bulk' ) { +<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %> +% } else { +% die "guru exception #5: action is neither change nor bulk!"; +% } +<%init> + +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 $curuser = $FS::CurrentUser::CurrentUser; + +my( $action, $error_redirect ); +my @pkgparts = (); +if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { #came from misc/change_pkg.cgi + + $action = 'change'; + $error_redirect = "misc/change_pkg.cgi"; + @pkgparts = ($1); + + die "access denied" + unless $curuser->access_right('Change customer package'); + +} else { #came from edit/cust_pkg.cgi + + $action = 'bulk'; + $error_redirect = "edit/cust_pkg.cgi"; + + die "access denied" + unless $curuser->access_right('Bulk change customer packages'); + + 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> |