fdb821fa698cf8d3690c63841581e54915198c1c
[freeside.git] / htdocs / edit / cust_credit.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: cust_credit.cgi,v 1.5 1999-01-19 05:13:33 ivan Exp $
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 # $Log: cust_credit.cgi,v $
28 # Revision 1.5  1999-01-19 05:13:33  ivan
29 # for mod_perl: no more top-level my() variables; use vars instead
30 # also the last s/create/new/;
31 #
32 # Revision 1.4  1999/01/18 09:41:23  ivan
33 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
34 # (good idea anyway)
35 #
36 # Revision 1.3  1998/12/23 02:26:06  ivan
37 # *** empty log message ***
38 #
39 # Revision 1.2  1998/12/17 06:16:59  ivan
40 # fix double // in relative URLs, s/CGI::Base/CGI/;
41 #
42
43 use strict;
44 use vars qw( $cgi $query $custnum $otaker $p1 $crednum $date $amount $reason );
45 use Date::Format;
46 use CGI;
47 use CGI::Carp qw(fatalsToBrowser);
48 use FS::UID qw(cgisuidsetup getotaker);
49 use FS::CGI qw(header popurl);
50
51 $cgi = new CGI;
52
53 cgisuidsetup($cgi);
54
55 ($query) = $cgi->keywords;
56 $query =~ /^(\d+)$/;
57 $custnum = $1;
58
59 $otaker = getotaker;
60
61 $p1 = popurl(1);
62
63 print $cgi->header( '-expires' => 'now' ), header("Post Credit", ''), <<END;
64     <FORM ACTION="${p1}process/cust_credit.cgi" METHOD=POST>
65     <HR><PRE>
66 END
67
68 #crednum
69 $crednum = "";
70 print qq!Credit #<B>!, $crednum ? $crednum : " <I>(NEW)</I>", qq!</B><INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!;
71
72 #custnum
73 print qq!\nCustomer #<B>$custnum</B><INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!;
74
75 #paybatch
76 print qq!<INPUT TYPE="hidden" NAME="paybatch" VALUE="">!;
77
78 #date
79 $date = time;
80 print qq!\nDate: <B>!, time2str("%D",$date), qq!</B><INPUT TYPE="hidden" NAME="_date" VALUE="$date">!;
81
82 #amount
83 $amount = '';
84 print qq!\nAmount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!;
85
86 #refund?
87 #print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="yes">Also post refund!;
88
89 #otaker (hidden)
90 print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!;
91
92 #reason
93 $reason = '';
94 print qq!\nReason <INPUT TYPE="text" NAME="reason" VALUE="$reason" SIZE=72>!;
95
96 print <<END;
97 </PRE>
98 <BR>
99 <CENTER><INPUT TYPE="submit" VALUE="Post"></CENTER>
100 END
101
102 print <<END;
103
104     </FORM>
105   </BODY>
106 </HTML>
107 END
108