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