s/CGI::Request/CGI.pm/; etc
[freeside.git] / htdocs / edit / process / svc_acct_sm.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_acct_sm.cgi,v 1.2 1998-12-17 08:40:29 ivan Exp $
4 #
5 # Usage: post form to:
6 #        http://server.name/path/svc_acct_sm.cgi
7 #
8 # Note: Should br run setuid root as user nobody.
9 #
10 # lots of crufty stuff from svc_acct still in here, and modifications are (unelegantly) disabled.
11 #
12 # ivan@voicenet.com 97-jan-6
13 #
14 # enabled modifications
15
16 # ivan@voicenet.com 97-may-7
17 #
18 # fixed removal of cust_svc record on modifications!
19 # ivan@voicenet.com 97-jun-5
20 #
21 # rewrite ivan@sisd.com 98-mar-15
22 #
23 # Changes to allow page to work at a relative position in server
24 #       bmccane@maxbaud.net     98-apr-3
25 #
26 # $Log: svc_acct_sm.cgi,v $
27 # Revision 1.2  1998-12-17 08:40:29  ivan
28 # s/CGI::Request/CGI.pm/; etc
29 #
30
31 use strict;
32 use CGI;
33 use CGI::Carp qw(fatalsToBrowser);
34 use FS::UID qw(cgisuidsetup);
35 use FS::Record qw(qsearchs);
36 use FS::svc_acct_sm;
37
38 my($cgi)=new CGI; # create form object
39 cgisuidsetup($cgi);
40
41 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
42 my($svcnum)=$1;
43
44 my($old)=qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}) if $svcnum;
45
46 #unmunge domsvc and domuid
47 $cgi->param('domsvc',(split(/:/, $cgi->param('domsvc') ))[0] );
48 $cgi->param('domuid',(split(/:/, $cgi->param('domuid') ))[0] );
49
50 my($new) = create FS::svc_acct_sm ( {
51   map {
52     ($_, scalar($cgi->param($_)));
53   } qw(svcnum pkgnum svcpart domuser domuid domsvc)
54 } );
55
56 my($error);
57 if ( $svcnum ) {
58   $error = $new->replace($old);
59 } else {
60   $error = $new->insert;
61   $svcnum = $new->getfield('svcnum');
62
63
64 unless ($error) {
65   print $cgi->redirect(popurl(3). "view/svc_acct_sm.cgi?$svcnum");
66 } else {
67   idiot($error);
68 }
69