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