3 # process/cust_main.cgi: Edit a customer (process form)
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
26 use CGI::Carp qw(fatalsToBrowser);
27 use FS::UID qw(cgisuidsetup);
28 use FS::Record qw(qsearchs);
31 my($req)=new CGI::Request; # create form object
33 &cgisuidsetup($req->cgi);
35 #create new record object
38 $req->param('agentnum',
39 (split(/:/, ($req->param('agentnum'))[0] ))[0]
43 $req->param('tax','') unless defined($req->param('tax'));
47 (split(/:/, ($req->param('refnum'))[0] ))[0]
51 $req->param('state') =~ /^(\w+)( \((\w+)\))?$/;
52 $req->param('state', $1);
53 $req->param('county', $3 || '');
55 my($new) = create FS::cust_main ( {
57 $_, $req->param("$_") || ''
58 } qw(custnum agentnum last first ss company address1 address2 city county
59 state zip country daytime night fax payby payinfo paydate payname tax
63 if ( $new->custnum eq '' ) {
65 my($error)=$new->insert;
66 &idiot($error) if $error;
68 } else { #create old record object
70 my($old) = qsearchs( 'cust_main', { 'custnum', $new->custnum } );
71 &idiot("Old record not found!") unless $old;
72 my($error)=$new->replace($old);
73 &idiot($error) if $error;
77 my($custnum)=$new->custnum;
78 $req->cgi->redirect("../../view/cust_main.cgi?$custnum#cust_main");
82 CGI::Base::SendHeaders(); # one guess
86 <TITLE>Error updating customer information</TITLE>
90 <H4>Error updating customer information</H4>
92 Your update did not occur because of the following error:
94 <P>Hit the <I>Back</I> button in your web browser, correct this mistake, and submit the form again.