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