diff options
author | Mitch Jackson <mitch@freeside.biz> | 2018-11-27 15:39:01 -0500 |
---|---|---|
committer | Mitch Jackson <mitch@freeside.biz> | 2018-11-27 15:44:05 -0500 |
commit | 28051580bf12b079a4631647a5c0defc7f55c9dc (patch) | |
tree | 913528ed9861660fe387ff0bf72db10ee7663d73 /httemplate/edit/process | |
parent | 0339cd666b4c39ef3772f1d28dc3a5f30f422966 (diff) |
RT# 32243 Package Bulk Edit UI Update
Diffstat (limited to 'httemplate/edit/process')
-rwxr-xr-x | httemplate/edit/process/cust_pkg.cgi | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/httemplate/edit/process/cust_pkg.cgi b/httemplate/edit/process/cust_pkg.cgi index c564c417e..82a9e2375 100755 --- a/httemplate/edit/process/cust_pkg.cgi +++ b/httemplate/edit/process/cust_pkg.cgi @@ -5,38 +5,61 @@ <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %> % } <%init> - +use Data::Dumper; +my $DEBUG = 0; my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('Bulk change customer packages'); my $error = ''; +my %param = $cgi->Vars; + +my $custnum = $param{custnum}; +$error = "Invalid custnum ($custnum)" if $custnum =~ /\D/; + +my $locationnum = $param{locationnum}; +$error = "Invalid locationnum ($locationnum)" if $locationnum =~ /\D/; + +my @remove_pkgnum = + map { $_ =~ /remove_cust_pkg\[(\d+)\]/ ? $1 : () } + keys %param; + +my @pkgparts; +for my $k ( keys %param ) { + next unless $k =~ /qty_part_pkg\[(\d+)\]/; + my $pkgpart = $1; + my $qty = $param{$k}; + $qty =~ s/(^\s+|\s+$)//g; -#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"; + warn "k($k) param{k}($param{$k}) pkgpart($pkgpart) qty($qty)\n" + if $DEBUG; + + if ( $qty =~ /\D/ ) { + $error = "Invalid quantity $qty for pkgpart $pkgpart - please use a number"; last; } + + next if $qty == 0; + + push ( @pkgparts, $pkgpart ) for ( 1..$qty ); +} + +if ( $DEBUG ) { + warn Dumper({ + custnum => $custnum, + locationnum => $locationnum, + remove_pkgnum => \@remove_pkgnum, + pkgparts => \@pkgparts, + param => \%param, + }); } -$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums); +$error ||= FS::cust_pkg::order({ + custnum => $custnum, + pkgparts => \@pkgparts, + remove_pkgnum => \@remove_pkgnum, + locationnum => $locationnum, +}); </%init> |