initial checkin of module files for proper perl installation
[freeside.git] / htdocs / edit / process / svc_acct.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_acct.cgi,v 1.6 1999-02-28 00:03:45 ivan Exp $
4 #
5 # Usage: post form to:
6 #        http://server.name/path/svc_acct.cgi
7 #
8 # ivan@voicenet.com 96-dec-18
9 #
10 # Changed /u to /u2
11 # ivan@voicenet.com 97-may-6
12 #
13 # rewrote for new API
14 # ivan@voicenet.com 97-jul-17 - 21
15 #
16 # no FS::Search, FS::svc_acct creates FS::cust_svc record, used for adding
17 # and editing ivan@sisd.com 98-mar-8
18 #
19 # Changes to allow page to work at a relative position in server
20 # Changed 'password' to '_password' because Pg6.3 reserves the password word
21 #       bmccane@maxbaud.net     98-apr-3
22 #
23 # $Log: svc_acct.cgi,v $
24 # Revision 1.6  1999-02-28 00:03:45  ivan
25 # removed misleading comments
26 #
27 # Revision 1.5  1999/02/07 09:59:30  ivan
28 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
29 #
30 # Revision 1.4  1999/01/19 05:13:58  ivan
31 # for mod_perl: no more top-level my() variables; use vars instead
32 # also the last s/create/new/;
33 #
34 # Revision 1.3  1999/01/18 22:47:59  ivan
35 # s/create/new/g; and use fields('table_name')
36 #
37 # Revision 1.2  1998/12/17 08:40:27  ivan
38 # s/CGI::Request/CGI.pm/; etc
39 #
40
41 use strict;
42 use vars qw( $cgi $svcnum $old $new $error );
43 use CGI;
44 use CGI::Carp qw(fatalsToBrowser);
45 use FS::UID qw(cgisuidsetup);
46 use FS::CGI qw(popurl);
47 use FS::Record qw(qsearchs fields);
48 use FS::svc_acct;
49
50 $cgi = new CGI;
51 &cgisuidsetup($cgi);
52
53 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
54 $svcnum = $1;
55
56 $old = qsearchs('svc_acct',{'svcnum'=>$svcnum}) if $svcnum;
57
58 #unmunge popnum
59 $cgi->param('popnum', (split(/:/, $cgi->param('popnum') ))[0] );
60
61 #unmunge passwd
62 if ( $cgi->param('_password') eq '*HIDDEN*' ) {
63   $cgi->param('_password',$old->getfield('_password'));
64 }
65
66 $new = new FS::svc_acct ( {
67   map {
68     $_, scalar($cgi->param($_));
69   #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir
70   #  shell quota slipip)
71   } ( fields('svc_acct'), qw( pkgnum svcpart ) )
72 } );
73
74 if ( $svcnum ) {
75   $error = $new->replace($old);
76 } else {
77   $error = $new->insert;
78   $svcnum = $new->svcnum;
79 }
80
81 if ( $error ) {
82   $cgi->param('error', $error);
83   print $cgi->redirect(popurl(2). "svc_acct.cgi?". $cgi->query_string );
84 } else {
85   print $cgi->redirect(popurl(3). "view/svc_acct.cgi?" . $svcnum );
86 }
87