#!/usr/bin/perl -Tw # # $Id: cust_main.cgi,v 1.6 1999-01-18 09:41:24 ivan Exp $ # # Usage: cust_main.cgi custnum # http://server.name/path/cust_main.cgi?custnum # # Note: Should be run setuid freeside as user nobody. # # ivan@voicenet.com 96-nov-29 -> 96-dec-04 # # Blank custnum for new customer. # ivan@voicenet.com 96-dec-16 # # referral defaults to blank, to force people to pick something # ivan@voicenet.com 97-jun-4 # # rewrote for new API # ivan@voicenet.com 97-jul-28 # # new customer is null, not '#' # otaker gotten from &getotaker instead of $ENV{REMOTE_USER} # ivan@sisd.com 97-nov-12 # # cgisuidsetup($cgi); # no need for old_ fields. # now state+county is a select field (took out PA hack) # used autoloaded $cust_main->field methods # ivan@sisd.com 97-dec-17 # # fixed quoting problems ivan@sisd.com 98-feb-23 # # paydate sql update ivan@sisd.com 98-mar-5 # # Changes to allow page to work at a relative position in server # Changed 'day' to 'daytime' because Pg6.3 reserves the day word # Added test for paydate in mm-dd-yyyy format for Pg6.3 default format # bmccane@maxbaud.net 98-apr-3 # # fixed one missed day->daytime ivan@sisd.com 98-jul-13 # # $Log: cust_main.cgi,v $ # Revision 1.6 1999-01-18 09:41:24 ivan # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl # (good idea anyway) # # Revision 1.5 1999/01/18 09:22:30 ivan # changes to track email addresses for email invoicing # # Revision 1.4 1998/12/23 08:08:15 ivan # fix typo # # Revision 1.3 1998/12/17 06:17:00 ivan # fix double // in relative URLs, s/CGI::Base/CGI/; # use strict; use CGI::Switch; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup getotaker); use FS::Record qw(qsearch qsearchs); use FS::CGI qw(header popurl itable table); use FS::cust_main; my $cgi = new CGI; cgisuidsetup($cgi); #get record my ( $custnum, $action, $cust_main ); if ( $cgi->keywords ) { #editing my( $query ) = $cgi->keywords; $query =~ /^(\d+)$/; $custnum=$1; $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); $action='Edit'; } else { $custnum=''; $cust_main = new FS::cust_main ( {} ); $cust_main->setfield('otaker',&getotaker); $action='Add'; } # top my $p1 = popurl(1); print $cgi->header( '-expires' => 'now' ), header("Customer $action", ''), qq!
!, qq!!, qq!Customer # !, ( $custnum ? $custnum : " (NEW)" ), ; # agent my @agents = qsearch( 'agent', {} ); my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first if ( scalar(@agents) == 1 ) { print qq!!; } else { print qq!

Agent "; } # contact info my($last,$first,$ss,$company,$address1,$address2,$city,$zip)=( $cust_main->last, $cust_main->first, $cust_main->ss, $cust_main->company, $cust_main->address1, $cust_main->address2, $cust_main->city, $cust_main->zip, ); print "

Contact information", itable("#c0c0c0"), <Contact name
(last, first), SS# Company Address   CityState/CountryZip!; my($daytime,$night,$fax)=( $cust_main->daytime, $cust_main->night, $cust_main->fax, ); print <Day Phone Night Phone Fax END print ""; # billing info sub expselect { my $prefix = shift; my $date = shift || ''; my( $m, $y ) = ( 0, 0 ); if ( $date =~ /^(\d{4})-(\d{2})-\d{2}$/ ) { #PostgreSQL date format ( $m, $y ) = ( $2, $1 ); } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { ( $m, $y ) = ( $1, $3 ); } my $return = qq!!; for ( 1999 .. 2037 ) { $return .= "Billing information", itable("#c0c0c0"), qq!tax eq "Y"; print qq!>Tax Exempt!; print qq!invoicing_list; print qq! CHECKED! if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list; print qq!> Postal mail invoice!; my $invoicing_list = join(', ', grep { $_ ne 'POST' } @invoicing_list ); print qq!Email invoice !; print ""; print table("#c0c0c0"), ""; my($payinfo, $payname)=( $cust_main->payinfo, $cust_main->payname, ); my %payby = ( 'CARD' => qq!Credit card

Exp !. expselect("CARD"). qq!
Name on card
!, 'BILL' => qq!Billing
P.O.
Exp !. expselect("BILL", "12-2037"). qq!
Attention
!, 'COMP' => qq!Complimentary
Approved by
Exp !. expselect("COMP"), ); my %paybychecked = ( 'CARD' => qq!Credit card

Exp !. expselect("CARD", $cust_main->paydate). qq!
Name on card
!, 'BILL' => qq!Billing
P.O.
Exp !. expselect("BILL", $cust_main->paydate). qq!
Attention
!, 'COMP' => qq!Complimentary
Approved by
Exp !. expselect("COMP", $cust_main->paydate), ); for (qw(CARD BILL COMP)) { print qq!payby eq "$_") { print qq! CHECKED> $paybychecked{$_}!; } else { print qq!> $payby{$_}!; } } print ""; #referral my $refnum = $cust_main->refnum || 0; if ( $custnum ) { print qq!!; } else { my(@referrals) = qsearch('part_referral',{}); print qq!
Referral "; } my $otaker = $cust_main->otaker; print qq!!, qq!

!, "", ;