[freeside-commits] freeside/httemplate/edit/process quick-charge.cgi, 1.7, 1.8

Jeff Finucane,420,, jeff at wavetail.420.am
Thu Jan 11 18:04:51 PST 2007


Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory wavetail:/tmp/cvs-serv21835/httemplate/edit/process

Modified Files:
	quick-charge.cgi 
Log Message:
one-time charge enhancements

Index: quick-charge.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/quick-charge.cgi,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- quick-charge.cgi	29 Dec 2006 08:34:59 -0000	1.7
+++ quick-charge.cgi	12 Jan 2007 02:04:49 -0000	1.8
@@ -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)' ) {
 %
+%  my $error = '';
+%  my $param = $cgi->Vars;
 %
-% $error = 'Must select a tax class';
-%} else {
+%  my @description = ();
+%  for ( my $row = 0; exists($param->{"description$row"}); $row++ ) {
+%    push @description, $param->{"description$row"};
+%  }
+%  pop @description until ($description[$#description]);
 %
-%  my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
-%    or die "unknown custnum $custnum";
+%  $param->{"custnum"} =~ /^(\d+)$/
+%    or $error .= "Illegal customer number " . $param->{"custnum"} . "  ";
+%  my $custnum = $1;
 %
-%  $error = $cust_main->charge(
-%    $amount,
-%    $cgi->param('pkg'),
-%    '$'. sprintf("%.2f",$amount),
-%    $cgi->param('taxclass')
-%  );
+%  $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.  ";
+%  }
 %
-%if ($error) {
+%  unless ( $error ) {
+%    my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+%      or $error .= "Unknown customer number $custnum.  ";
 %
-
-<!-- mason kludge -->
+%    $error ||= $cust_main->charge({ 'amount'   => $amount,
+%                                   'pkg'      => $cgi->param('pkg'),
+%                                   'taxclass' => $cgi->param('taxclass'),
+%                                   'additional' => \@description,
+%                                 }
+%                               );
+%  }
 %
-%  eidiot($error);
-%} else {
-%  print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum" );
-%}
+%  if ( $error ) {
 %
+%    $cgi->param('error', "$error" );
+%    
+<% $cgi->redirect($p.'quick-charge.html?'. $cgi->query_string) %>
 %
-
+% }
+<% header("One-time charge added") %>
+  <SCRIPT TYPE="text/javascript">
+    window.top.location.reload();
+  </SCRIPT>
+  </BODY></HTML>
 



More information about the freeside-commits mailing list