X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_pkg.cgi;h=272ddcc47158b2794ba523d936ece9844f40956f;hb=baaf20963687533353e65917554ebf968dbc0f8b;hp=df8471c27b792dc37cc82d7ffe0a59b9256ea9b1;hpb=673b9a458d9138523026963df6fa3b4683e09bae;p=freeside.git diff --git a/httemplate/edit/process/cust_pkg.cgi b/httemplate/edit/process/cust_pkg.cgi index df8471c27..272ddcc47 100755 --- a/httemplate/edit/process/cust_pkg.cgi +++ b/httemplate/edit/process/cust_pkg.cgi @@ -1,4 +1,21 @@ -<% +% if ($error) { +% $cgi->param('error', $error); +% $cgi->redirect(popurl(3). $error_redirect. '?'. $cgi->query_string ); +% } elsif ( $action eq 'change' ) { + + <% header("Package changed") %> + + + + +% } 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 = ''; @@ -11,13 +28,32 @@ my @remove_pkgnums = map { $1; } $cgi->param('remove_pkg'); -my $error_redirect; -my @pkgparts; -if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { #came from misc/change_pkg.cgi +my $curuser = $FS::CurrentUser::CurrentUser; + +my( $action, $error_redirect ) = ( '', '' ); +my @pkgparts = (); +if ( $cgi->param('action') eq 'change' ) { #came from misc/change_pkg.cgi + + $action = 'change'; $error_redirect = "misc/change_pkg.cgi"; - @pkgparts = ($1); -} else { #came from edit/cust_pkg.cgi + + die "access denied" + unless $curuser->access_right('Change customer package'); + + if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { + @pkgparts = ($1); + } else { + $error = 'Select a new package'; + } + +} elsif ( $cgi->param('action') eq 'bulk' ) { #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; @@ -29,15 +65,11 @@ if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { #came from misc/change_pkg.cgi last; } } -} -$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums); - -if ($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(3). $error_redirect. '?'. $cgi->query_string ); } else { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); + die "guru exception #5: action is neither change nor bulk!"; } -%> +$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums); + +