summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/quick-charge.cgi
blob: 024a281e021ab3771b927bb2d9d0e7e6b0083e2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%
%  my $error = '';
%  my $param = $cgi->Vars;
%
%  my @description = ();
%  for ( my $row = 0; exists($param->{"description$row"}); $row++ ) {
%    push @description, $param->{"description$row"}
%      if ($param->{"description$row"} =~ /\S/);
%  }
%
%  $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") %>
  <SCRIPT TYPE="text/javascript">
    window.top.location.reload();
  </SCRIPT>
  </BODY></HTML>