changes to track email addresses for email invoicing
[freeside.git] / htdocs / view / svc_acct.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_acct.cgi,v 1.5 1999-01-18 09:22:36 ivan Exp $
4 #
5 # Usage: svc_acct.cgi svcnum
6 #        http://server.name/path/svc_acct.cgi?svcnum
7 #
8 # Note: Should be run setuid freeside as user nobody.
9 #
10 # ivan@voicenet.com 96-dec-17
11 #
12 # added link to send info
13 # ivan@voicenet.com 97-jan-4
14 #
15 # added navigation bar and ability to change username, etc.
16 # ivan@voicenet.com 97-jan-30
17 #
18 # activate 800 service
19 # ivan@voicenet.com 97-feb-10
20 #
21 # modified navbar code (should be a subroutine?), added link to cancel account (only if not audited)
22 # ivan@voicenet.com 97-apr-16
23 #
24 # INCOMPLETELY rewrote some things for new API
25 # ivan@voicenet.com 97-jul-29
26 #
27 # FS::Search became FS::Record, use strict, etc. ivan@sisd.com 98-mar-9
28 #
29 # Changes to allow page to work at a relative position in server
30 # Changed 'password' to '_password' because Pg6.3 reserves the password word
31 #       bmccane@maxbaud.net     98-apr-3
32 #
33 # /var/spool/freeside/conf/domain ivan@sisd.com 98-jul-17
34 #
35 # displays arbitrary radius attributes ivan@sisd.com 98-aug-16
36 #
37 # $Log: svc_acct.cgi,v $
38 # Revision 1.5  1999-01-18 09:22:36  ivan
39 # changes to track email addresses for email invoicing
40 #
41 # Revision 1.4  1998/12/23 03:09:19  ivan
42 # $cgi->keywords instead of $cgi->query_string
43 #
44 # Revision 1.3  1998/12/17 09:57:23  ivan
45 # s/CGI::(Base|Request)/CGI.pm/;
46 #
47 # Revision 1.2  1998/12/16 05:24:29  ivan
48 # use FS::Conf;
49 #
50
51 use strict;
52 use vars qw( $conf );
53 use CGI;
54 use CGI::Carp qw( fatalsToBrowser );
55 use FS::UID qw( cgisuidsetup );
56 use FS::CGI qw( header popurl );
57 use FS::Record qw( qsearchs fields );
58 use FS::Conf;
59 use FS::svc_acct;
60 use FS::cust_svc;
61 use FS::cust_pkg;
62 use FS::part_svc;
63 use FS::svc_acct_pop;
64
65 my($cgi) = new CGI;
66 &cgisuidsetup($cgi);
67
68 $conf = new FS::Conf;
69 my $mydomain = $conf->config('domain');
70
71 #untaint svcnum
72 my($query) = $cgi->keywords;
73 $query =~ /^(\d+)$/;
74 my($svcnum)=$1;
75 my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svcnum});
76 die "Unkonwn svcnum" unless $svc_acct;
77
78 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum});
79 my($pkgnum)=$cust_svc->getfield('pkgnum');
80 my($cust_pkg,$custnum);
81 if ($pkgnum) {
82   $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
83   $custnum=$cust_pkg->getfield('custnum');
84 }
85
86 my($part_svc)=qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
87 die "Unkonwn svcpart" unless $part_svc;
88
89 print $cgi->header, header('Account View', '');
90
91 my $p = popurl(2);
92 if ($pkgnum || $custnum) {
93   print <<END;
94 <A HREF="${p}view/cust_pkg.cgi?$pkgnum">View this package (#$pkgnum)</A> | 
95 <A HREF="${p}view/cust_main.cgi?$custnum">View this customer (#$custnum)</A> | 
96 END
97 } else {
98   print <<END;
99 <A HREF="${p}misc/cancel-unaudited.cgi?$svcnum">Cancel this (unaudited)account</A> |
100 END
101 }
102
103 print <<END;
104 <A HREF="${p}">Main menu</A></CENTER><BR>
105 <FONT SIZE=+1>Service #$svcnum</FONT>
106 END
107
108 print qq!<BR><A HREF="${p}edit/svc_acct.cgi?$svcnum">Edit this information</A>!;
109 #print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!;
110 print qq!<BR><BR><A HREF="#general">General</A> | <A HREF="#shell">Shell account</A> | !;
111 print qq!<A HREF="#slip">SLIP/PPP account</A></CENTER>!;
112
113 #formatting
114 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="general">General</A></FONT></CENTER>!;
115
116 #svc
117 print "Service: <B>", $part_svc->svc, "</B>";
118
119 #username
120 print "<BR>Username: <B>", $svc_acct->username, "</B>";
121
122 #password
123 if (substr($svc_acct->_password,0,1) eq "*") {
124   print "<BR>Password: <I>(Login disabled)</I><BR>";
125 } else {
126   print "<BR>Password: <I>(hidden)</I><BR>";
127 }
128
129 # popnum -> svc_acct_pop record
130 my($svc_acct_pop)=qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
131
132 #pop
133 print "POP: <B>", $svc_acct_pop->city, ", ", $svc_acct_pop->state,
134       " (", $svc_acct_pop->ac, ")/", $svc_acct_pop->exch, "<\B>"
135   if $svc_acct_pop;
136
137 #shell account
138 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="shell">!;
139 if ($svc_acct->uid ne '') {
140   print "Shell account";
141   print "</A></FONT></CENTER>";
142   print "Uid: <B>", $svc_acct->uid, "</B>";
143   print "<BR>Gid: <B>", $svc_acct->gid, "</B>";
144
145   print qq!<BR>Finger name: <B>!, $svc_acct->finger, qq!</B><BR>!;
146
147   print "Home directory: <B>", $svc_acct->dir, "</B><BR>";
148
149   print "Shell: <B>", $svc_acct->shell, "</B><BR>";
150
151   print "Quota: <B>", $svc_acct->quota, "</B> <I>(unimplemented)</I>";
152 } else {
153   print "No shell account.</A></FONT></CENTER>";
154 }
155
156 # SLIP/PPP
157 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="slip">!;
158 if ($svc_acct->slipip) {
159   print "SLIP/PPP account</A></FONT></CENTER>";
160   print "IP address: <B>", ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) ? "<I>(Dynamic)</I>" : $svc_acct->slipip ,"</B>";
161   my($attribute);
162   foreach $attribute ( grep /^radius_/, fields('svc_acct') ) {
163     #warn $attribute;
164     $attribute =~ /^radius_(.*)$/;
165     my($pattribute) = ($1);
166     $pattribute =~ s/_/-/g;
167     print "<BR>Radius $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
168   }
169 } else {
170   print "No SLIP/PPP account</A></FONT></CENTER>"
171 }
172
173 print "<HR>";
174
175         #formatting
176         print <<END;
177
178   </BODY>
179 </HTML>
180 END
181