From 8ae047bd7c16f16ace5acfa1098392b56835d24c Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 13 Jul 1998 17:52:51 +0000 Subject: [PATCH] Initial revision --- htdocs/edit/cust_main.cgi | 214 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100755 htdocs/edit/cust_main.cgi diff --git a/htdocs/edit/cust_main.cgi b/htdocs/edit/cust_main.cgi new file mode 100755 index 000000000..14556010c --- /dev/null +++ b/htdocs/edit/cust_main.cgi @@ -0,0 +1,214 @@ +#!/usr/bin/perl -Tw +# +# cust_main.cgi: Edit a customer (output form) +# +# 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 + +use strict; +use CGI::Base; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup getotaker); +use FS::Record qw(qsearch qsearchs); +use FS::cust_main; + +my($cgi) = new CGI::Base; +$cgi->get; + +cgisuidsetup($cgi); + +SendHeaders(); # one guess. + +#get record +my($custnum,$action,$cust_main); +if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing + $custnum=$1; + $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); + $action='Edit'; +} else { + $custnum=''; + $cust_main = create FS::cust_main ( {} ); + $cust_main->setfield('otaker',&getotaker); + $cust_main->setfield('country','US'); + $action='Add'; +} + +print < + + Customer $action + + +
+

Customer $action

+
+
+
+END
+
+print qq!!,
+      qq!Customer #!;
+print $custnum ? $custnum : " (NEW)" , "";
+
+#agentnum
+my($agentnum)=$cust_main->agentnum || 1; #set to first agent by default
+my(@agents) = qsearch('agent',{});
+print qq!\n\nAgent # ";
+
+#referral
+#unless ($custnum) {
+  my($refnum)=$cust_main->refnum || 0; #to avoid "arguement not numeric" error
+  my(@referrals) = qsearch('part_referral',{});
+  print qq!\nReferral ";
+#}
+
+my($last,$first,$ss,$company,$address1,$address2,$city)=(
+  $cust_main->last,
+  $cust_main->first,
+  $cust_main->ss,
+  $cust_main->company,
+  $cust_main->address1,
+  $cust_main->address2,
+  $cust_main->city,
+);
+
+print < (first)  SS# 
+Company 
+Address 
+        
+City   State (county) ";
+
+my($zip,$country,$daytime,$night,$fax)=(
+  $cust_main->zip,
+  $cust_main->country,
+  $cust_main->daytime,
+  $cust_main->night,
+  $cust_main->fax,
+);
+
+print <
+Country: $country
+
+Phone (daytime)  (night)  (fax)
+
+END
+
+my(%payby)=(
+  'CARD' => "Credit card    ",
+  'BILL' => "Billing    ",
+  'COMP' => "Complimentary",
+);
+for (qw(CARD BILL COMP)) {
+  print qq!payby eq "$_");
+  print qq!>$payby{$_}!;
+}
+
+
+my($payinfo,$payname,$otaker)=(
+  $cust_main->payinfo,
+  $cust_main->payname,
+  $cust_main->otaker,
+);
+
+my($paydate);
+if ( $cust_main->paydate =~ /^(\d{4})-(\d{2})-\d{2}$/ ) {
+  $paydate="$2/$1"
+} elsif ( $cust_main->paydate =~ /^(\d{2})-\d{2}-(\d{4}$)/ ) {
+  $paydate="$1/$2"
+}
+else {
+  $paydate='';
+}
+
+print <
+END
+
+print qq!Exp. date (MM/YY or MM/YYYY)    Billing name \ntax eq "Y";
+print qq!> Tax Exempt!;
+
+print <$otaker
+
+END + +print qq!
!; + +print < + + +END + -- 2.20.1