3 # $Id: cust_main.cgi,v 1.6 1999-01-25 12:10:00 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.6 1999-01-25 12:10:00 ivan
26 # yet more mod_perl stuff
28 # Revision 1.5 1999/01/19 05:13:50 ivan
29 # for mod_perl: no more top-level my() variables; use vars instead
30 # also the last s/create/new/;
32 # Revision 1.4 1999/01/18 09:22:32 ivan
33 # changes to track email addresses for email invoicing
35 # Revision 1.3 1998/12/17 08:40:19 ivan
36 # s/CGI::Request/CGI.pm/; etc
38 # Revision 1.2 1998/11/18 08:57:36 ivan
39 # i18n, s/CGI-modules/CGI.pm/, FS::CGI::idiot instead of inline, FS::CGI::popurl
43 use vars qw( $cgi $payby @invoicing_list $new $custnum $error );
45 use CGI::Carp qw(fatalsToBrowser);
46 use FS::UID qw(cgisuidsetup getotaker);
47 use FS::CGI qw( popurl );
48 use FS::Record qw(qsearchs fields);
56 $cgi->param('tax','') unless defined($cgi->param('tax'));
58 $cgi->param('refnum', (split(/:/, ($cgi->param('refnum'))[0] ))[0] );
60 $cgi->param('state') =~ /^(\w+)( \((\w+)\))? \/ (\w+)$/;
61 $cgi->param('state', $1);
62 $cgi->param('county', $3 || '');
63 $cgi->param('country', $4);
65 if ( $payby = $cgi->param('payby') ) {
66 $cgi->param('payinfo', $cgi->param( $payby. '_payinfo' ) );
67 $cgi->param('paydate',
68 $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' ) );
69 $cgi->param('payname', $cgi->param( $payby. '_payname' ) );
72 $cgi->param('otaker', &getotaker );
74 @invoicing_list = split( /\s*\,\s*/, $cgi->param('invoicing_list') );
75 push @invoicing_list, 'POST' if $cgi->param('invoicing_list_POST');
77 #create new record object
79 $new = new FS::cust_main ( {
81 $_, scalar($cgi->param($_))
82 # } qw(custnum agentnum last first ss company address1 address2 city county
83 # state zip daytime night fax payby payinfo paydate payname tax
88 $error = $new->check_invoicing_list( \@invoicing_list );
90 #perhaps the invocing_list magic should move to cust_main.pm?
91 if ( $new->custnum eq '' ) {
92 $error ||= $new->insert;
93 } else { #create old record object
94 my $old = qsearchs( 'cust_main', { 'custnum' => $new->custnum } );
95 $error ||= "Old record not found!" unless $old;
96 $error ||= $new->replace($old);
100 $cgi->param('error', $error);
101 print $cgi->redirect(popurl(2). "cust_main.cgi?". $cgi->query_string );
103 $new->invoicing_list( \@invoicing_list );
104 $custnum = $new->custnum;
105 print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum#cust_main");