a68478898069eb6d9f6f1b38b4cdb10dcd90dbdb
[freeside.git] / httemplate / edit / process / svc_acct_sm.cgi
1 <%
2 #
3 # $Id: svc_acct_sm.cgi,v 1.1 2001-07-30 07:36:04 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.1  2001-07-30 07:36:04  ivan
26 # templates!!!
27 #
28 # Revision 1.6  1999/02/28 00:03:46  ivan
29 # removed misleading comments
30 #
31 # Revision 1.5  1999/02/07 09:59:32  ivan
32 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
33 #
34 # Revision 1.4  1999/01/19 05:14:00  ivan
35 # for mod_perl: no more top-level my() variables; use vars instead
36 # also the last s/create/new/;
37 #
38 # Revision 1.3  1999/01/18 22:48:01  ivan
39 # s/create/new/g; and use fields('table_name')
40 #
41 # Revision 1.2  1998/12/17 08:40:29  ivan
42 # s/CGI::Request/CGI.pm/; etc
43 #
44
45 use strict;
46 use vars qw( $cgi $svcnum $old $new $error );
47 use CGI;
48 use CGI::Carp qw(fatalsToBrowser);
49 use FS::UID qw(cgisuidsetup);
50 use FS::Record qw(qsearchs fields);
51 use FS::svc_acct_sm;
52 use FS::CGI qw(popurl);
53
54 $cgi = new CGI;
55 cgisuidsetup($cgi);
56
57 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
58 $svcnum =$1;
59
60 $old = qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}) if $svcnum;
61
62 #unmunge domsvc and domuid
63 #$cgi->param('domsvc',(split(/:/, $cgi->param('domsvc') ))[0] );
64 #$cgi->param('domuid',(split(/:/, $cgi->param('domuid') ))[0] );
65
66 $new = new FS::svc_acct_sm ( {
67   map {
68     ($_, scalar($cgi->param($_)));
69   #} qw(svcnum pkgnum svcpart domuser domuid domsvc)
70   } ( fields('svc_acct_sm'), qw( pkgnum svcpart ) )
71 } );
72
73 if ( $svcnum ) {
74   $error = $new->replace($old);
75 } else {
76   $error = $new->insert;
77   $svcnum = $new->getfield('svcnum');
78
79
80 if ($error) {
81   $cgi->param('error', $error);
82   print $cgi->redirect(popurl(2). "svc_acct_sm.cgi?". $cgi->query_string );
83 } else {
84   print $cgi->redirect(popurl(3). "view/svc_acct_sm.cgi?$svcnum");
85 }
86
87 %>