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