3 # $Id: cust_main.cgi,v 1.3 1998-12-17 08:40:19 ivan Exp $
6 # http://server.name/path/cust_main.cgi
8 # Note: Should be run setuid root as user nobody.
10 # ivan@voicenet.com 96-dec-04
12 # added referral check
13 # ivan@voicenet.com 97-jun-4
16 # ivan@voicenet.com 97-jul-28
18 # same as above (again) and clean up some stuff ivan@sisd.com 98-feb-23
20 # Changes to allow page to work at a relative position in server
21 # Changed 'day' to 'daytime' because Pg6.3 reserves the day word
22 # bmccane@maxbaud.net 98-apr-3
24 # $Log: cust_main.cgi,v $
25 # Revision 1.3 1998-12-17 08:40:19 ivan
26 # s/CGI::Request/CGI.pm/; etc
28 # Revision 1.2 1998/11/18 08:57:36 ivan
29 # i18n, s/CGI-modules/CGI.pm/, FS::CGI::idiot instead of inline, FS::CGI::popurl
34 use CGI::Carp qw(fatalsToBrowser);
35 use FS::UID qw(cgisuidsetup);
36 use FS::CGI qw(eidiot popurl);
37 use FS::Record qw(qsearchs);
44 #create new record object
47 $cgi->param('agentnum',
48 (split(/:/, ($cgi->param('agentnum'))[0] ))[0]
52 $cgi->param('tax','') unless defined($cgi->param('tax'));
56 (split(/:/, ($cgi->param('refnum'))[0] ))[0]
59 #unmunge state/county/country
60 $cgi->param('state') =~ /^(\w+)( \((\w+)\))? \/ (\w+)$/;
61 $cgi->param('state', $1);
62 $cgi->param('county', $3 || '');
63 $cgi->param('country', $4);
65 my($new) = create FS::cust_main ( {
67 $_, scalar($cgi->param($_))
68 } qw(custnum agentnum last first ss company address1 address2 city county
69 state zip daytime night fax payby payinfo paydate payname tax
73 if ( $new->custnum eq '' ) {
75 my($error)=$new->insert;
76 &eidiot($error) if $error;
78 } else { #create old record object
80 my($old) = qsearchs( 'cust_main', { 'custnum', $new->custnum } );
81 &eidiot("Old record not found!") unless $old;
82 my($error)=$new->replace($old);
83 &eidiot($error) if $error;
87 my($custnum)=$new->custnum;
88 print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum#cust_main");