summaryrefslogtreecommitdiff
path: root/htdocs/edit/process/cust_pay.cgi
blob: 9ec97532b9b564118b45b58603f760e0a0e55a2c (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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl -Tw
#
# process/cust_pay.cgi: Add a payment (process form)
#
# Usage: post form to:
#        http://server.name/path/cust_pay.cgi
#
# Note: Should be run setuid root as user nobody.
#
# ivan@voicenet.com 96-dec-11
#
# rewrite ivan@sisd.com 98-mar-16
#
# Changes to allow page to work at a relative position in server
#       bmccane@maxbaud.net     98-apr-3

use strict;
use CGI::Request;
use FS::UID qw(cgisuidsetup);
use FS::cust_pay qw(fields);

my($req)=new CGI::Request;
&cgisuidsetup($req->cgi);

$req->param('invnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
my($invnum)=$1;

my($new) = create FS::cust_pay ( {
  map {
    $_, $req->param($_);
  } qw(invnum paid _date payby payinfo paybatch)
} );

my($error);
$error=$new->insert;

if ($error) { #error!
  CGI::Base::SendHeaders(); # one guess
  print <<END;
<HTML>
  <HEAD>
    <TITLE>Error posting payment</TITLE>
  </HEAD>
  <BODY>
    <CENTER>
    <H4>Error posting payment</H4>
    </CENTER>
    Your update did not occur because of the following error:
    <P><B>$error</B>
    <P>Hit the <I>Back</I> button in your web browser, correct this mistake, and press the <I>Post</I> button again.
  </BODY>
</HTML>
END
} else { #no errors!
  $req->cgi->redirect("../../view/cust_bill.cgi?$invnum");
}