Initial revision
[freeside.git] / htdocs / edit / process / cust_pay.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # process/cust_pay.cgi: Add a payment (process form)
4 #
5 # Usage: post form to:
6 #        http://server.name/path/cust_pay.cgi
7 #
8 # Note: Should be run setuid root as user nobody.
9 #
10 # ivan@voicenet.com 96-dec-11
11 #
12 # rewrite ivan@sisd.com 98-mar-16
13 #
14 # Changes to allow page to work at a relative position in server
15 #       bmccane@maxbaud.net     98-apr-3
16
17 use strict;
18 use CGI::Request;
19 use FS::UID qw(cgisuidsetup);
20 use FS::cust_pay qw(fields);
21
22 my($req)=new CGI::Request;
23 &cgisuidsetup($req->cgi);
24
25 $req->param('invnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
26 my($invnum)=$1;
27
28 my($new) = create FS::cust_pay ( {
29   map {
30     $_, $req->param($_);
31   } qw(invnum paid _date payby payinfo paybatch)
32 } );
33
34 my($error);
35 $error=$new->insert;
36
37 if ($error) { #error!
38   CGI::Base::SendHeaders(); # one guess
39   print <<END;
40 <HTML>
41   <HEAD>
42     <TITLE>Error posting payment</TITLE>
43   </HEAD>
44   <BODY>
45     <CENTER>
46     <H4>Error posting payment</H4>
47     </CENTER>
48     Your update did not occur because of the following error:
49     <P><B>$error</B>
50     <P>Hit the <I>Back</I> button in your web browser, correct this mistake, and press the <I>Post</I> button again.
51   </BODY>
52 </HTML>
53 END
54 } else { #no errors!
55   $req->cgi->redirect("../../view/cust_bill.cgi?$invnum");
56 }
57