3 # $Id: svc_acct.cgi,v 1.10 1999-04-14 11:27:06 ivan Exp $
5 # Usage: svc_acct.cgi {svcnum} | pkgnum{pkgnum}-svcpart{svcpart}
6 # http://server.name/path/svc_acct.cgi? {svcnum} | pkgnum{pkgnum}-svcpart{svcpart}
8 # ivan@voicenet.com 96-dec-18
10 # rewrite ivan@sisd.com 98-mar-8
12 # Changes to allow page to work at a relative position in server
13 # Changed 'password' to '_password' because Pg6.3 reserves the password word
14 # bmccane@maxbaud.net 98-apr-3
16 # use conf/shells and dbdef username length ivan@sisd.com 98-jul-13
18 # $Log: svc_acct.cgi,v $
19 # Revision 1.10 1999-04-14 11:27:06 ivan
20 # showpasswords config option to show passwords
22 # Revision 1.9 1999/02/28 00:03:37 ivan
23 # removed misleading comments
25 # Revision 1.8 1999/02/23 08:09:22 ivan
26 # beginnings of one-screen new customer entry and some other miscellania
28 # Revision 1.7 1999/02/07 09:59:22 ivan
29 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
31 # Revision 1.6 1999/01/19 05:13:43 ivan
32 # for mod_perl: no more top-level my() variables; use vars instead
33 # also the last s/create/new/;
35 # Revision 1.5 1999/01/18 09:41:32 ivan
36 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
39 # Revision 1.4 1998/12/30 23:03:22 ivan
40 # bugfixes; fields isn't exported by derived classes
42 # Revision 1.3 1998/12/17 06:17:08 ivan
43 # fix double // in relative URLs, s/CGI::Base/CGI/;
47 use vars qw( $conf $cgi @shells $action $svcnum $svc_acct $pkgnum $svcpart
48 $part_svc $svc $otaker $username $password $ulen $ulen2 $p1
49 $popnum $uid $gid $finger $dir $shell $quota $slipip );
51 use CGI::Carp qw(fatalsToBrowser);
52 use FS::UID qw(cgisuidsetup getotaker);
53 use FS::CGI qw(header popurl);
54 use FS::Record qw(qsearch qsearchs fields);
62 @shells = $conf->config('shells');
64 if ( $cgi->param('error') ) {
65 $svc_acct = new FS::svc_acct ( {
66 map { $_, scalar($cgi->param($_)) } fields('svc_acct')
68 $svcnum = $svc_acct->svcnum;
69 $pkgnum = $cgi->param('pkgnum');
70 $svcpart = $cgi->param('svcpart');
71 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
72 die "No part_svc entry!" unless $part_svc;
74 my($query) = $cgi->keywords;
75 if ( $query =~ /^(\d+)$/ ) { #editing
77 $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
78 or die "Unknown (svc_acct) svcnum!";
80 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
81 or die "Unknown (cust_svc) svcnum!";
83 $pkgnum=$cust_svc->pkgnum;
84 $svcpart=$cust_svc->svcpart;
86 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
87 die "No part_svc entry!" unless $part_svc;
91 $svc_acct = new FS::svc_acct({});
93 foreach $_ (split(/-/,$query)) {
94 $pkgnum=$1 if /^pkgnum(\d+)$/;
95 $svcpart=$1 if /^svcpart(\d+)$/;
97 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
98 die "No part_svc entry!" unless $part_svc;
103 my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
105 my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } );
106 $svc_acct->setfield('finger',
107 $cust_main->getfield('first') . " " . $cust_main->getfield('last')
111 #set fixed and default fields from part_svc
113 foreach $field ( fields('svc_acct') ) {
114 if ( $part_svc->getfield('svc_acct__'. $field. '_flag') ne '' ) {
115 $svc_acct->setfield($field,$part_svc->getfield('svc_acct__'. $field) );
121 $action = $svcnum ? 'Edit' : 'Add';
123 $svc = $part_svc->getfield('svc');
127 $username = $svc_acct->username;
128 if ( $svc_acct->_password ) {
129 if ( $conf->exists('showpasswords') ) {
130 $password = $svc_acct->_password;
132 $password = "*HIDDEN*";
138 $ulen = $svc_acct->dbdef_table->column('username')->length;
142 print $cgi->header( '-expires' => 'now' ), header("$action $svc account");
144 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
146 if $cgi->param('error');
149 <FORM ACTION="${p1}process/svc_acct.cgi" METHOD=POST>
150 <INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">
151 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
152 <INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">
154 <INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen>
156 <INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
161 $popnum = $svc_acct->popnum || 0;
162 if ( $part_svc->svc_acct__popnum_flag eq "F" ) {
163 print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$popnum">!;
165 print qq!<BR>POP: <SELECT NAME="popnum" SIZE=1><OPTION>\n!;
167 foreach $svc_acct_pop ( qsearch ('svc_acct_pop',{} ) ) {
168 print "<OPTION", $svc_acct_pop->popnum == $popnum ? ' SELECTED' : '', ">",
169 $svc_acct_pop->popnum, ": ",
170 $svc_acct_pop->city, ", ",
171 $svc_acct_pop->state,
172 " (", $svc_acct_pop->ac, ")/",
173 $svc_acct_pop->exch, "\n"
179 ($uid,$gid,$finger,$dir)=(
187 <INPUT TYPE="hidden" NAME="uid" VALUE="$uid">
188 <INPUT TYPE="hidden" NAME="gid" VALUE="$gid">
189 <BR>GECOS: <INPUT TYPE="text" NAME="finger" VALUE="$finger">
190 <INPUT TYPE="hidden" NAME="dir" VALUE="$dir">
193 $shell = $svc_acct->shell;
194 if ( $part_svc->svc_acct__shell_flag eq "F" ) {
195 print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!;
197 print qq!<BR>Shell: <SELECT NAME="shell" SIZE=1>!;
199 foreach $etc_shell (@shells) {
200 print "<OPTION", $etc_shell eq $shell ? ' SELECTED' : '', ">",
211 print qq!<INPUT TYPE="hidden" NAME="quota" VALUE="$quota">!;
213 if ( $part_svc->svc_acct__slipip_flag eq "F" ) {
214 print qq!<INPUT TYPE="hidden" NAME="slipip" VALUE="$slipip">!;
216 print qq!<BR>IP: <INPUT TYPE="text" NAME="slipip" VALUE="$slipip">!;
220 print qq!<P><INPUT TYPE="submit" VALUE="Submit">!;