3 # $Id: cust_main.cgi,v 1.2 1998-11-18 08:57:36 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.2 1998-11-18 08:57:36 ivan
26 # i18n, s/CGI-modules/CGI.pm/, FS::CGI::idiot instead of inline, FS::CGI::popurl
31 use CGI::Carp qw(fatalsToBrowser);
32 use FS::UID qw(cgisuidsetup);
33 use FS::CGI qw(eidiot popurl);
34 use FS::Record qw(qsearchs);
41 #create new record object
44 $cgi->param('agentnum',
45 (split(/:/, ($cgi->param('agentnum'))[0] ))[0]
49 $cgi->param('tax','') unless defined($cgi->param('tax'));
53 (split(/:/, ($cgi->param('refnum'))[0] ))[0]
56 #unmunge state/county/country
57 $cgi->param('state') =~ /^(\w+)( \((\w+)\))? \/ (\w+)$/;
58 $cgi->param('state', $1);
59 $cgi->param('county', $3 || '');
60 $cgi->param('country', $4);
62 my($new) = create FS::cust_main ( {
64 $_, $cgi->param("$_") || ''
65 } qw(custnum agentnum last first ss company address1 address2 city county
66 state zip daytime night fax payby payinfo paydate payname tax
70 if ( $new->custnum eq '' ) {
72 my($error)=$new->insert;
73 &eidiot($error) if $error;
75 } else { #create old record object
77 my($old) = qsearchs( 'cust_main', { 'custnum', $new->custnum } );
78 &eidiot("Old record not found!") unless $old;
79 my($error)=$new->replace($old);
80 &eidiot($error) if $error;
84 my($custnum)=$new->custnum;
85 print $cgi->redirect(popurl(3). "/view/cust_main.cgi?$custnum#cust_main");