X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fedit%2Fprocess%2Fquick-charge.cgi;h=f614dd5cfd96a07e23c3bf0410df2dc93723abd5;hb=2a863bbb144830dfb8fca4afb3af76a84a647c76;hp=2c5ac81b0a983a7dffbb3219cedc7f001e60d5a7;hpb=d60a734b5602b3a94164f17f7b0ee74d11443008;p=freeside.git diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 2c5ac81b0..f614dd5cf 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -1,41 +1,47 @@ -%#untaint custnum -%$cgi->param('custnum') =~ /^(\d+)$/ -% or die 'illegal custnum '. $cgi->param('custnum'); -%my $custnum = $1; % -%$cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ -% or die 'illegal amount '. $cgi->param('amount'); -%my $amount = $1; -% -%my( $error, $cust_main); -%if ( $cgi->param('taxclass') eq '(select)' ) { -% -% -% $error = 'Must select a tax class'; -%} else { -% -% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) -% or die "unknown custnum $custnum"; -% -% $error = $cust_main->charge( -% $amount, -% $cgi->param('pkg'), -% '$'. sprintf("%.2f",$amount), -% $cgi->param('taxclass') -% ); -% -%} -% -%if ($error) { -% - - -% -% eidiot($error); -%} else { -% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum" ); -%} -% -% - +% my $error = ''; +% my $param = $cgi->Vars; +% +% my @description = (); +% for ( my $row = 0; exists($param->{"description$row"}); $row++ ) { +% push @description, $param->{"description$row"}; +% } +% pop @description until ($description[$#description]); +% +% $param->{"custnum"} =~ /^(\d+)$/ +% or $error .= "Illegal customer number " . $param->{"custnum"} . " "; +% my $custnum = $1; +% +% $param->{"amount"} =~ /^\s*(\d+(\.\d{1,2})?)\s*$/ +% or $error .= "Illegal amount " . $param->{"amount"} . " "; +% my $amount = $1; +% +% if ( $param->{'taxclass'} eq '(select)' ) { +% $error .= "Must select a tax class. "; +% } +% +% unless ( $error ) { +% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) +% or $error .= "Unknown customer number $custnum. "; +% +% $error ||= $cust_main->charge({ 'amount' => $amount, +% 'pkg' => $cgi->param('pkg'), +% 'taxclass' => $cgi->param('taxclass'), +% 'additional' => \@description, +% } +% ); +% } +% +% if ( $error ) { +% +% $cgi->param('error', "$error" ); +% +<% $cgi->redirect($p.'quick-charge.html?'. $cgi->query_string) %> +% +% } +<% header("One-time charge added") %> + +