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