s/create/new/g; and use fields('table_name')
[freeside.git] / htdocs / edit / process / svc_acct_sm.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_acct_sm.cgi,v 1.3 1999-01-18 22:48:01 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.3  1999-01-18 22:48:01  ivan
28 # s/create/new/g; and use fields('table_name')
29 #
30 # Revision 1.2  1998/12/17 08:40:29  ivan
31 # s/CGI::Request/CGI.pm/; etc
32 #
33
34 use strict;
35 use CGI;
36 use CGI::Carp qw(fatalsToBrowser);
37 use FS::UID qw(cgisuidsetup);
38 use FS::Record qw(qsearchs fields);
39 use FS::svc_acct_sm;
40
41 my($cgi)=new CGI;
42 cgisuidsetup($cgi);
43
44 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
45 my($svcnum)=$1;
46
47 my($old)=qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}) if $svcnum;
48
49 #unmunge domsvc and domuid
50 $cgi->param('domsvc',(split(/:/, $cgi->param('domsvc') ))[0] );
51 $cgi->param('domuid',(split(/:/, $cgi->param('domuid') ))[0] );
52
53 my($new) = new FS::svc_acct_sm ( {
54   map {
55     ($_, scalar($cgi->param($_)));
56   #} qw(svcnum pkgnum svcpart domuser domuid domsvc)
57   } ( fields('svc_acct_sm'), qw( pkgnum svcpart) )
58 } );
59
60 my($error);
61 if ( $svcnum ) {
62   $error = $new->replace($old);
63 } else {
64   $error = $new->insert;
65   $svcnum = $new->getfield('svcnum');
66
67
68 unless ($error) {
69   print $cgi->redirect(popurl(3). "view/svc_acct_sm.cgi?$svcnum");
70 } else {
71   idiot($error);
72 }
73