RT# 78356 - added speed test fields for broadband service and new modifier to get...
[freeside.git] / httemplate / edit / process / cust_pkg.cgi
index 25b8267..c564c41 100755 (executable)
@@ -1,22 +1,16 @@
 % 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");
+%   $cgi->redirect(popurl(3). 'edit/cust_pkg.cgi?'. $cgi->query_string );
 % } else {
-%   die "guru exception #5: action is neither change nor bulk!";
+<% $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
@@ -28,25 +22,18 @@ my @remove_pkgnums = map {
   $1;
 } $cgi->param('remove_pkg');
 
-my( $action, $error_redirect );
+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);
-} else { #came from edit/cust_pkg.cgi
-  $action = 'bulk';
-  $error_redirect = "edit/cust_pkg.cgi";
-  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;
+
+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;
   }
 }