templates!!!
[freeside.git] / httemplate / edit / cust_credit.cgi
1 <%
2 #
3 # $Id: cust_credit.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $
4 #
5 # Usage: cust_credit.cgi custnum [ -paybatch ]
6 #        http://server.name/path/cust_credit?custnum [ -paybatch ]
7 #
8 # some hooks in here for modifications as well as additions, but needs (lots) more work.
9 # also see process/cust_credit.cgi, the script that processes the form.
10 #
11 # ivan@voicenet.com 96-dec-05
12 #
13 # paybatch field, differentiates between credits & credits+refunds by commandline
14 # ivan@voicenet.com 96-dec-08
15 #
16 # added (but commented out) sprintf("%.2f" in amount field.  Hmm.
17 # ivan@voicenet.com 97-jan-3
18 #
19 # paybatch stuff thrown out - has checkbox now instead.  
20 # (well, sort of.  still passed around for backward compatability and possible editing hook)
21 # ivan@voicenet.com 97-apr-21
22 #
23 # rewrite ivan@sisd.com 98-mar-16
24 #
25 # $Log: cust_credit.cgi,v $
26 # Revision 1.1  2001-07-30 07:36:04  ivan
27 # templates!!!
28 #
29 # Revision 1.7  1999/02/28 00:03:33  ivan
30 # removed misleading comments
31 #
32 # Revision 1.6  1999/01/25 12:09:52  ivan
33 # yet more mod_perl stuff
34 #
35 # Revision 1.5  1999/01/19 05:13:33  ivan
36 # for mod_perl: no more top-level my() variables; use vars instead
37 # also the last s/create/new/;
38 #
39 # Revision 1.4  1999/01/18 09:41:23  ivan
40 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
41 # (good idea anyway)
42 #
43 # Revision 1.3  1998/12/23 02:26:06  ivan
44 # *** empty log message ***
45 #
46 # Revision 1.2  1998/12/17 06:16:59  ivan
47 # fix double // in relative URLs, s/CGI::Base/CGI/;
48 #
49
50 use strict;
51 use vars qw( $cgi $query $custnum $otaker $p1 $crednum $_date $amount $reason );
52 use Date::Format;
53 use CGI;
54 use CGI::Carp qw(fatalsToBrowser);
55 use FS::UID qw(cgisuidsetup getotaker);
56 use FS::CGI qw(header popurl);
57 use FS::Record qw(fields);
58 #use FS::cust_credit;
59
60 $cgi = new CGI;
61 cgisuidsetup($cgi);
62
63 if ( $cgi->param('error') ) {
64   #$cust_credit = new FS::cust_credit ( {
65   #  map { $_, scalar($cgi->param($_)) } fields('cust_credit')
66   #} );
67   $custnum = $cgi->param('custnum');
68   $amount = $cgi->param('amount');
69   #$refund = $cgi->param('refund');
70   $reason = $cgi->param('reason');
71 } else {
72   ($query) = $cgi->keywords;
73   $query =~ /^(\d+)$/;
74   $custnum = $1;
75   $amount = '';
76   #$refund = 'yes';
77   $reason = '';
78 }
79 $_date = time;
80
81 $otaker = getotaker;
82
83 $p1 = popurl(1);
84
85 print $cgi->header( '-expires' => 'now' ), header("Post Credit", '');
86 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
87       "</FONT>"
88   if $cgi->param('error');
89 print <<END;
90     <FORM ACTION="${p1}process/cust_credit.cgi" METHOD=POST>
91     <PRE>
92 END
93
94 $crednum = "";
95 print qq!Credit #<B>!, $crednum ? $crednum : " <I>(NEW)</I>", qq!</B><INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!;
96
97 print qq!\nCustomer #<B>$custnum</B><INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!;
98
99 print qq!<INPUT TYPE="hidden" NAME="paybatch" VALUE="">!;
100
101 print qq!\nDate: <B>!, time2str("%D",$_date), qq!</B><INPUT TYPE="hidden" NAME="_date" VALUE="">!;
102
103 print qq!\nAmount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!;
104 print qq!<INPUT TYPE="hidden" NAME="credited" VALUE="">!;
105
106 #print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!;
107
108 print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!;
109
110 print qq!\nReason <INPUT TYPE="text" NAME="reason" VALUE="$reason" SIZE=72>!;
111
112 print <<END;
113 </PRE>
114 <BR>
115 <CENTER><INPUT TYPE="submit" VALUE="Post"></CENTER>
116 END
117
118 print <<END;
119
120     </FORM>
121   </BODY>
122 </HTML>
123 END
124
125 %>