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