3 # $Id: svc_acct.cgi,v 1.1 2001-07-30 07:36:04 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.1 2001-07-30 07:36:04 ivan
22 # Revision 1.10 1999/04/14 11:27:06 ivan
23 # showpasswords config option to show passwords
25 # Revision 1.9 1999/02/28 00:03:37 ivan
26 # removed misleading comments
28 # Revision 1.8 1999/02/23 08:09:22 ivan
29 # beginnings of one-screen new customer entry and some other miscellania
31 # Revision 1.7 1999/02/07 09:59:22 ivan
32 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
34 # Revision 1.6 1999/01/19 05:13:43 ivan
35 # for mod_perl: no more top-level my() variables; use vars instead
36 # also the last s/create/new/;
38 # Revision 1.5 1999/01/18 09:41:32 ivan
39 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
42 # Revision 1.4 1998/12/30 23:03:22 ivan
43 # bugfixes; fields isn't exported by derived classes
45 # Revision 1.3 1998/12/17 06:17:08 ivan
46 # fix double // in relative URLs, s/CGI::Base/CGI/;
50 use vars qw( $conf $cgi @shells $action $svcnum $svc_acct $pkgnum $svcpart
51 $part_svc $svc $otaker $username $password $ulen $ulen2 $p1
52 $popnum $uid $gid $finger $dir $shell $quota $slipip );
54 use CGI::Carp qw(fatalsToBrowser);
55 use FS::UID qw(cgisuidsetup getotaker);
56 use FS::CGI qw(header popurl);
57 use FS::Record qw(qsearch qsearchs fields);
65 @shells = $conf->config('shells');
67 if ( $cgi->param('error') ) {
68 $svc_acct = new FS::svc_acct ( {
69 map { $_, scalar($cgi->param($_)) } fields('svc_acct')
71 $svcnum = $svc_acct->svcnum;
72 $pkgnum = $cgi->param('pkgnum');
73 $svcpart = $cgi->param('svcpart');
74 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
75 die "No part_svc entry!" unless $part_svc;
77 my($query) = $cgi->keywords;
78 if ( $query =~ /^(\d+)$/ ) { #editing
80 $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
81 or die "Unknown (svc_acct) svcnum!";
83 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
84 or die "Unknown (cust_svc) svcnum!";
86 $pkgnum=$cust_svc->pkgnum;
87 $svcpart=$cust_svc->svcpart;
89 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
90 die "No part_svc entry!" unless $part_svc;
94 $svc_acct = new FS::svc_acct({});
96 foreach $_ (split(/-/,$query)) {
97 $pkgnum=$1 if /^pkgnum(\d+)$/;
98 $svcpart=$1 if /^svcpart(\d+)$/;
100 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
101 die "No part_svc entry!" unless $part_svc;
106 my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
108 my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } );
109 $svc_acct->setfield('finger',
110 $cust_main->getfield('first') . " " . $cust_main->getfield('last')
114 #set fixed and default fields from part_svc
116 foreach $field ( fields('svc_acct') ) {
117 if ( $part_svc->getfield('svc_acct__'. $field. '_flag') ne '' ) {
118 $svc_acct->setfield($field,$part_svc->getfield('svc_acct__'. $field) );
124 $action = $svcnum ? 'Edit' : 'Add';
126 $svc = $part_svc->getfield('svc');
130 $username = $svc_acct->username;
131 if ( $svc_acct->_password ) {
132 if ( $conf->exists('showpasswords') ) {
133 $password = $svc_acct->_password;
135 $password = "*HIDDEN*";
141 $ulen = $svc_acct->dbdef_table->column('username')->length;
145 print $cgi->header( '-expires' => 'now' ), header("$action $svc account");
147 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
149 if $cgi->param('error');
152 <FORM ACTION="${p1}process/svc_acct.cgi" METHOD=POST>
153 <INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">
154 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
155 <INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">
157 <INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen>
159 <INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
164 $popnum = $svc_acct->popnum || 0;
165 if ( $part_svc->svc_acct__popnum_flag eq "F" ) {
166 print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$popnum">!;
168 print qq!<BR>POP: <SELECT NAME="popnum" SIZE=1><OPTION>\n!;
170 foreach $svc_acct_pop ( qsearch ('svc_acct_pop',{} ) ) {
171 print "<OPTION", $svc_acct_pop->popnum == $popnum ? ' SELECTED' : '', ">",
172 $svc_acct_pop->popnum, ": ",
173 $svc_acct_pop->city, ", ",
174 $svc_acct_pop->state,
175 " (", $svc_acct_pop->ac, ")/",
176 $svc_acct_pop->exch, "\n"
182 ($uid,$gid,$finger,$dir)=(
190 <INPUT TYPE="hidden" NAME="uid" VALUE="$uid">
191 <INPUT TYPE="hidden" NAME="gid" VALUE="$gid">
192 <BR>GECOS: <INPUT TYPE="text" NAME="finger" VALUE="$finger">
193 <INPUT TYPE="hidden" NAME="dir" VALUE="$dir">
196 $shell = $svc_acct->shell;
197 if ( $part_svc->svc_acct__shell_flag eq "F" ) {
198 print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!;
200 print qq!<BR>Shell: <SELECT NAME="shell" SIZE=1>!;
202 foreach $etc_shell (@shells) {
203 print "<OPTION", $etc_shell eq $shell ? ' SELECTED' : '', ">",
214 print qq!<INPUT TYPE="hidden" NAME="quota" VALUE="$quota">!;
216 if ( $part_svc->svc_acct__slipip_flag eq "F" ) {
217 print qq!<INPUT TYPE="hidden" NAME="slipip" VALUE="$slipip">!;
219 print qq!<BR>IP: <INPUT TYPE="text" NAME="slipip" VALUE="$slipip">!;
223 print qq!<P><INPUT TYPE="submit" VALUE="Submit">!;