Initial revision
[freeside.git] / htdocs / edit / cust_credit.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # cust_credit.cgi: Add a credit (output form)
4 #
5 # Usage: cust_credit.cgi custnum [ -paybatch ]
6 #        http://server.name/path/cust_credit?custnum [ -paybatch ]
7 #
8 # Note: Should be run setuid root as user nobody.
9 #
10 # some hooks in here for modifications as well as additions, but needs (lots) more work.
11 # also see process/cust_credit.cgi, the script that processes the form.
12 #
13 # ivan@voicenet.com 96-dec-05
14 #
15 # paybatch field, differentiates between credits & credits+refunds by commandline
16 # ivan@voicenet.com 96-dec-08
17 #
18 # added (but commented out) sprintf("%.2f" in amount field.  Hmm.
19 # ivan@voicenet.com 97-jan-3
20 #
21 # paybatch stuff thrown out - has checkbox now instead.  
22 # (well, sort of.  still passed around for backward compatability and possible editing hook)
23 # ivan@voicenet.com 97-apr-21
24 #
25 # rewrite ivan@sisd.com 98-mar-16
26
27 use strict;
28 use Date::Format;
29 use CGI::Base qw(:DEFAULT :CGI); #CGI module
30 use FS::UID qw(cgisuidsetup getotaker);
31
32 my($cgi) = new CGI::Base;
33 $cgi->get;
34 cgisuidsetup($cgi);
35
36 #untaint custnum
37 $QUERY_STRING =~ /^(\d+)$/;
38 my($custnum)=$1;
39
40 #untaint otaker
41 my($otaker)=getotaker;
42
43 SendHeaders(); # one guess.
44 print <<END;
45 <HTML>
46   <HEAD>
47     <TITLE>Post Credit</TITLE>
48   </HEAD>
49   <BODY>
50     <CENTER>
51     <H1>Post Credit</H1>
52     </CENTER>
53     <FORM ACTION="process/cust_credit.cgi" METHOD=POST>
54     <HR><PRE>
55 END
56
57 #crednum
58 my($crednum)="";
59 print qq!Credit #<B>!, $crednum ? $crednum : " <I>(NEW)</I>", qq!</B><INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!;
60
61 #custnum
62 print qq!\nCustomer #<B>$custnum</B><INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!;
63
64 #paybatch
65 print qq!<INPUT TYPE="hidden" NAME="paybatch" VALUE="">!;
66
67 #date
68 my($date)=time;
69 print qq!\nDate: <B>!, time2str("%D",$date), qq!</B><INPUT TYPE="hidden" NAME="_date" VALUE="$date">!;
70
71 #amount
72 my($amount)='';
73 print qq!\nAmount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!;
74
75 #refund?
76 #print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="yes">Also post refund!;
77
78 #otaker (hidden)
79 print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!;
80
81 #reason
82 my($reason)='';
83 print qq!\nReason <INPUT TYPE="text" NAME="reason" VALUE="$reason" SIZE=72>!;
84
85 print <<END;
86 </PRE>
87 <BR>
88 <CENTER><INPUT TYPE="submit" VALUE="Post"></CENTER>
89 END
90
91 print <<END;
92
93     </FORM>
94   </BODY>
95 </HTML>
96 END
97