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