for mod_perl: no more top-level my() variables; use vars instead
[freeside.git] / htdocs / view / svc_acct.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_acct.cgi,v 1.7 1999-01-19 05:14:21 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.7  1999-01-19 05:14:21  ivan
39 # for mod_perl: no more top-level my() variables; use vars instead
40 # also the last s/create/new/;
41 #
42 # Revision 1.6  1999/01/18 09:41:45  ivan
43 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
44 # (good idea anyway)
45 #
46 # Revision 1.5  1999/01/18 09:22:36  ivan
47 # changes to track email addresses for email invoicing
48 #
49 # Revision 1.4  1998/12/23 03:09:19  ivan
50 # $cgi->keywords instead of $cgi->query_string
51 #
52 # Revision 1.3  1998/12/17 09:57:23  ivan
53 # s/CGI::(Base|Request)/CGI.pm/;
54 #
55 # Revision 1.2  1998/12/16 05:24:29  ivan
56 # use FS::Conf;
57 #
58
59 use strict;
60 use vars qw( $conf $cgi $mydomain $query $svcnum $svc_acct $cust_svc $pkgnum
61              $cust_pkg $custnum $part_svc $p $svc_acct_pop );
62 use CGI;
63 use CGI::Carp qw( fatalsToBrowser );
64 use FS::UID qw( cgisuidsetup );
65 use FS::CGI qw( header popurl );
66 use FS::Record qw( qsearchs fields );
67 use FS::Conf;
68 use FS::svc_acct;
69 use FS::cust_svc;
70 use FS::cust_pkg;
71 use FS::part_svc;
72 use FS::svc_acct_pop;
73
74 $cgi = new CGI;
75 &cgisuidsetup($cgi);
76
77 $conf = new FS::Conf;
78 $mydomain = $conf->config('domain');
79
80 #untaint svcnum
81 ($query) = $cgi->keywords;
82 $query =~ /^(\d+)$/;
83 $svcnum = $1;
84 $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum});
85 die "Unkonwn svcnum" unless $svc_acct;
86
87 $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
88 $pkgnum = $cust_svc->getfield('pkgnum');
89 if ($pkgnum) {
90   $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
91   $custnum=$cust_pkg->getfield('custnum');
92 }
93
94 $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
95 die "Unkonwn svcpart" unless $part_svc;
96
97 print $cgi->header( '-expires' => 'now' ), header('Account View', '');
98
99 $p = popurl(2);
100 if ($pkgnum || $custnum) {
101   print <<END;
102 <A HREF="${p}view/cust_pkg.cgi?$pkgnum">View this package (#$pkgnum)</A> | 
103 <A HREF="${p}view/cust_main.cgi?$custnum">View this customer (#$custnum)</A> | 
104 END
105 } else {
106   print <<END;
107 <A HREF="${p}misc/cancel-unaudited.cgi?$svcnum">Cancel this (unaudited)account</A> |
108 END
109 }
110
111 print <<END;
112 <A HREF="${p}">Main menu</A></CENTER><BR>
113 <FONT SIZE=+1>Service #$svcnum</FONT>
114 END
115
116 print qq!<BR><A HREF="${p}edit/svc_acct.cgi?$svcnum">Edit this information</A>!;
117 #print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!;
118 print qq!<BR><BR><A HREF="#general">General</A> | <A HREF="#shell">Shell account</A> | !;
119 print qq!<A HREF="#slip">SLIP/PPP account</A></CENTER>!;
120
121 #formatting
122 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="general">General</A></FONT></CENTER>!;
123
124 #svc
125 print "Service: <B>", $part_svc->svc, "</B>";
126
127 #username
128 print "<BR>Username: <B>", $svc_acct->username, "</B>";
129
130 #password
131 if (substr($svc_acct->_password,0,1) eq "*") {
132   print "<BR>Password: <I>(Login disabled)</I><BR>";
133 } else {
134   print "<BR>Password: <I>(hidden)</I><BR>";
135 }
136
137 # popnum -> svc_acct_pop record
138 $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
139
140 #pop
141 print "POP: <B>", $svc_acct_pop->city, ", ", $svc_acct_pop->state,
142       " (", $svc_acct_pop->ac, ")/", $svc_acct_pop->exch, "<\B>"
143   if $svc_acct_pop;
144
145 #shell account
146 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="shell">!;
147 if ($svc_acct->uid ne '') {
148   print "Shell account";
149   print "</A></FONT></CENTER>";
150   print "Uid: <B>", $svc_acct->uid, "</B>";
151   print "<BR>Gid: <B>", $svc_acct->gid, "</B>";
152
153   print qq!<BR>Finger name: <B>!, $svc_acct->finger, qq!</B><BR>!;
154
155   print "Home directory: <B>", $svc_acct->dir, "</B><BR>";
156
157   print "Shell: <B>", $svc_acct->shell, "</B><BR>";
158
159   print "Quota: <B>", $svc_acct->quota, "</B> <I>(unimplemented)</I>";
160 } else {
161   print "No shell account.</A></FONT></CENTER>";
162 }
163
164 # SLIP/PPP
165 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="slip">!;
166 if ($svc_acct->slipip) {
167   print "SLIP/PPP account</A></FONT></CENTER>";
168   print "IP address: <B>", ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) ? "<I>(Dynamic)</I>" : $svc_acct->slipip ,"</B>";
169   my($attribute);
170   foreach $attribute ( grep /^radius_/, fields('svc_acct') ) {
171     #warn $attribute;
172     $attribute =~ /^radius_(.*)$/;
173     my($pattribute) = ($1);
174     $pattribute =~ s/_/-/g;
175     print "<BR>Radius $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
176   }
177 } else {
178   print "No SLIP/PPP account</A></FONT></CENTER>"
179 }
180
181 print "<HR>";
182
183         #formatting
184         print <<END;
185
186   </BODY>
187 </HTML>
188 END
189