X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=htdocs%2Fview%2Fcust_main.cgi;h=7d51e288adfdc6e6fa832aa708e2ab442ac5c30e;hp=c39643d7009febb8c37b82eddad78b8d8520f532;hb=e0da34d97b1463b55a334e8dae10cd55796e2312;hpb=2a7d9b79f305a57d84c49ee556242777bd739f74 diff --git a/htdocs/view/cust_main.cgi b/htdocs/view/cust_main.cgi index c39643d70..7d51e288a 100755 --- a/htdocs/view/cust_main.cgi +++ b/htdocs/view/cust_main.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# cust_main.cgi: View a customer +# $Id: cust_main.cgi,v 1.12 1999-02-07 09:59:40 ivan Exp $ # # Usage: cust_main.cgi custnum # http://server.name/path/cust_main.cgi?custnum @@ -33,7 +33,36 @@ # lose background, FS::CGI ivan@sisd.com 98-sep-2 # # $Log: cust_main.cgi,v $ -# Revision 1.3 1998-11-15 13:14:20 ivan +# Revision 1.12 1999-02-07 09:59:40 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.11 1999/01/25 12:26:04 ivan +# yet more mod_perl stuff +# +# Revision 1.10 1999/01/19 05:14:19 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.9 1999/01/18 09:41:43 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.8 1999/01/18 09:22:35 ivan +# changes to track email addresses for email invoicing +# +# Revision 1.7 1998/12/30 23:03:34 ivan +# bugfixes; fields isn't exported by derived classes +# +# Revision 1.6 1998/12/23 02:42:33 ivan +# remove double '/' in link urls +# +# Revision 1.5 1998/12/23 02:36:28 ivan +# use FS::cust_refund; to eliminate warning +# +# Revision 1.4 1998/12/17 09:57:21 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# +# Revision 1.3 1998/11/15 13:14:20 ivan # first pass as per-customer custom pricing # # Revision 1.2 1998/11/13 11:28:08 ivan @@ -41,12 +70,15 @@ # use strict; +use vars qw ( $cgi $query $custnum $cust_main $hashref $agent $referral + @packages $package @history @bills $bill @credits $credit + $balance $item @agents @referrals @invoicing_list $n1 ); use CGI; use CGI::Carp qw(fatalsToBrowser); use Date::Format; use FS::UID qw(cgisuidsetup); use FS::Record qw(qsearchs qsearch); -use FS::CGI qw(header menubar popurl table); +use FS::CGI qw(header menubar popurl table itable ntable); use FS::cust_credit; use FS::cust_pay; use FS::cust_bill; @@ -55,138 +87,150 @@ use FS::cust_pkg; use FS::part_referral; use FS::agent; use FS::cust_main; +use FS::cust_refund; -my($cgi) = new CGI; +$cgi = new CGI; &cgisuidsetup($cgi); -print $cgi->header, header("Customer View", menubar( +print $cgi->header( '-expires' => 'now' ), header("Customer View", menubar( 'Main Menu' => popurl(2) -)),< -END +)); die "No customer specified (bad URL)!" unless $cgi->keywords; -my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array +($query) = $cgi->keywords; # needs parens with my, ->keywords returns array $query =~ /^(\d+)$/; -my($custnum)=$1; -my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum}); +$custnum = $1; +$cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); die "Customer not found!" unless $cust_main; -my($hashref)=$cust_main->hashref; +$hashref = $cust_main->hashref; -#custnum -print "
Customer #$custnum
", - qq!
Customer Information | !, - qq!Comments | !, - qq!Packages | !, - qq!Payment History
!; +print itable(), ''; -#bill now linke -print qq!
!, - qq!Bill this customer now
!; +print qq!Edit this customer!, + ntable("#c0c0c0"), "", ntable("#c0c0c0",2), + 'Customer number', + $custnum, '', +; -#formatting -print qq!
Customer Information!, - qq!!, - qq!
Edit this information
!; - -#agentnum -my($agent)=qsearchs('agent',{ - 'agentnum' => $cust_main->getfield('agentnum') -} ); -die "Agent not found!" unless $agent; -print "
Agent #" , $agent->getfield('agentnum') , ": " , - $agent->getfield('agent') , ""; - -#refnum -my($referral)=qsearchs('part_referral',{'refnum' => $cust_main->refnum}); -die "Referral not found!" unless $referral; -print "
Referral #", $referral->refnum, ": ", - $referral->referral, "<\B>"; - -#last, first -print "

", $hashref->{'last'}, ", ", $hashref->{first}, ""; - -#ss -print " (SS# ", $hashref->{ss}, ")" if $hashref->{ss}; - -#company -print "
", $hashref->{company}, "" if $hashref->{company}; - -#address1 -print "
", $hashref->{address1}, ""; - -#address2 -print "
", $hashref->{address2}, "" if $hashref->{address2}; - -#city -print "
", $hashref->{city}, ""; - -#county -print " (", $hashref->{county}, " county)" if $hashref->{county}; - -#state -print ",", $hashref->{state}, ""; - -#zip -print " ", $hashref->{zip}, ""; - -#country -print "
", $hashref->{country}, "" - unless $hashref->{country} eq "US"; - -#daytime -print "

", $hashref->{daytime}, "" if $hashref->{daytime}; -print " (Day)" if $hashref->{daytime} && $hashref->{night}; - -#night -print "
", $hashref->{night}, "" if $hashref->{night}; -print " (Night)" if $hashref->{daytime} && $hashref->{night}; - -#fax -print "
", $hashref->{fax}, " (Fax)" if $hashref->{fax}; - -#payby/payinfo/paydate/payname -if ($hashref->{payby} eq "CARD") { - print "

Card #", $hashref->{payinfo}, " Exp. ", - $hashref->{paydate}, ""; - print " (", $hashref->{payname}, ")" if $hashref->{payname}; -} elsif ($hashref->{payby} eq "BILL") { - print "

Bill"; - print " on P.O. #", $hashref->{payinfo}, "" - if $hashref->{payinfo}; - print " until ", $hashref->{paydate}, "" - if $hashref->{paydate}; - print " to ", $hashref->{payname}, " at above address" - if $hashref->{payname}; -} elsif ($hashref->{payby} eq "COMP") { - print "

Access complimentary"; - print " courtesy of ", $hashref->{payinfo}, "" - if $hashref->{payinfo}; - print " until ", $hashref->{paydate}, "" - if $hashref->{paydate}; -} else { - print "Unknown payment type ", $hashref->{payby}, "!"; +@agents = qsearch( 'agent', {} ); +unless ( scalar(@agents) == 1 ) { + $agent = qsearchs('agent',{ + 'agentnum' => $cust_main->agentnum + } ); + print 'Agent', + $agent->agentnum, ": ", $agent->agent, ''; +} +@referrals = qsearch( 'part_referral', {} ); +unless ( scalar(@referrals) == 1 ) { + my $referral = qsearchs('part_referral', { + 'refnum' => $cust_main->refnum + } ); + print 'Referral', + $referral->refnum, ": ", $referral->referral, ''; +} +print 'Order taker', + $cust_main->otaker, ''; + +print ''; + +print ''; + +print "Contact information", ntable("#c0c0c0"), "", + ntable("#c0c0c0",2), + 'Contact name
(last, first)', + '', + $cust_main->last, ', ', $cust_main->first, + 'SS#', + $cust_main->ss || ' ', '', + 'Company', + $cust_main->company, + '', + 'Address', + $cust_main->address1, + '', +; +print ' ', + $cust_main->address2, '' + if $cust_main->address2; +print 'City', + $cust_main->city, + 'State', + $cust_main->state, + 'Zip', + $cust_main->zip, '', + 'Country', + $cust_main->country, + '', +; +print 'Day Phone', + $cust_main->daytime || ' ', '', + 'Night Phone', + $cust_main->night || ' ', '', + 'Fax', + $cust_main->fax || ' ', '', + '', "" +; + +print ''; + +@invoicing_list = $cust_main->invoicing_list; +print "Billing information (", + qq!!, "Bill now)", + ntable("#c0c0c0"), "", ntable("#c0c0c0",2), + 'Tax exempt', + $cust_main->tax ? 'yes' : 'no', + '', + 'Postal invoices', + ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no', + '', + 'Email invoices', + join(', ', grep { $_ ne 'POST' } @invoicing_list ) || 'no', + '', + 'Billing type', +; + +if ( $cust_main->payby eq 'CARD' ) { + print 'Credit card', + 'Card number', + $cust_main->payinfo, '', + 'Expiration', + $cust_main->paydate, '', + 'Name on card', + $cust_main->payname, '' + ; +} elsif ( $cust_main->payby eq 'BILL' ) { + print 'Billing'; + print 'P.O. ', + $cust_main->payinfo, '', + if $cust_main->payinfo; + print 'Expiration', + $cust_main->paydate, '', + 'Attention', + $cust_main->payname, '', + ; +} elsif ( $cust_main->payby eq 'COMP' ) { + print 'Complimentary', + 'Authorized by', + $cust_main->payinfo, '', + 'Expiration', + $cust_main->paydate, '', + ; } -#tax -print "
(Tax exempt)" if $hashref->{tax}; - -#otaker -print "

Order taken by ", $hashref->{otaker}, ""; +print ""; -#formatting -print qq!


Packages!, - qq!
Click on package number to view/edit package.!, - qq!
Add/Edit packages!, - qq!

!; +print qq!

Packages !, +# qq!
Click on package number to view/edit package.!, + qq!( Order and cancel packages )!, +; #display packages #formatting -print qq!
!, table, "\n", - qq!#Package!, - qq!Dates\n!, +print qq!!, table, "\n", + qq!Package!, + qq!DatesServices\n!, qq!Setup!, qq!Next bill!, qq!Susp.Expire!, @@ -195,64 +239,73 @@ print qq!
!, table, "\n", qq!\n!; #get package info -my(@packages)=qsearch('cust_pkg',{'custnum'=>$custnum}); -my($package); +@packages = $cust_main->all_pkgs; +#@packages = $cust_main->ncancelled_pkgs; + +$n1 = ''; foreach $package (@packages) { - my($pref)=$package->hashref; - my($part_pkg)=qsearchs('part_pkg',{ - 'pkgpart' => $pref->{pkgpart} - } ); - print qq!!, - $pref->{pkgnum}, qq!!, - "", $part_pkg->getfield('pkg'), " - ", - $part_pkg->getfield('comment'), - qq!
!, - qq!!, - qq!!, - qq!!, - "
", - "", - $pref->{setup} ? time2str("%D",$pref->{setup} ) : "" , - "", - "", - $pref->{bill} ? time2str("%D",$pref->{bill} ) : "" , - "", - "", - $pref->{susp} ? time2str("%D",$pref->{susp} ) : "" , - "", - "", - $pref->{expire} ? time2str("%D",$pref->{expire} ) : "" , - "", - "", - $pref->{cancel} ? time2str("%D",$pref->{cancel} ) : "" , - "", - ""; -} + my $pkgnum = $package->pkgnum; + my $pkg = $package->part_pkg->pkg; + my $comment = $package->part_pkg->comment; + my $pkgview = popurl(2). "view/cust_pkg.cgi?$pkgnum"; + my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); + my $rowspan = scalar(@cust_svc) || 1; + + my $button_cgi = new CGI; + $button_cgi->param('clone', $package->part_pkg->pkgpart); + $button_cgi->param('pkgnum', $package->pkgnum); + my $button_url = popurl(2). "edit/part_pkg.cgi?". $button_cgi->query_string; + + #print $n1, qq!$pkgnum!, + print $n1, qq!$pkgnum!, + qq!!, + #qq!$pkg - $comment!, + qq!$pkg - $comment!, + qq! ( Edit | Customize pricing )!, + ; + for ( qw( setup bill susp expire cancel ) ) { + print "", ( $package->getfield($_) + ? time2str("%D", $package->getfield($_) ) + : ' ' + ), '', + ; + } + + my $n2 = ''; + foreach my $cust_svc ( @cust_svc ) { + my($label, $value, $svcdb) = $cust_svc->label; + my($svcnum) = $cust_svc->svcnum; + my($sview) = popurl(2). "/view"; + print $n2,qq!$label!, + qq!$value!; + $n2=""; + } + $n1=""; +} +print ""; #formatting -print "
"; +print ""; #formatting -print qq!

Payment History!, - qq!
!, - qq!Click on invoice to view invoice/enter payment.
!, - qq!!, - qq!Post Credit / Refund

!; +print qq!

Payment History!, + qq!!, + qq! ( Click on invoice to view invoice/enter payment. | !, + qq!!, + qq!Post credit / refund )!; #get payment history # # major problem: this whole thing is way too sloppy. # minor problem: the description lines need better formatting. -my(@history); +@history = (); #needed for mod_perl :) -my(@bills)=qsearch('cust_bill',{'custnum'=>$custnum}); -my($bill); +@bills = qsearch('cust_bill',{'custnum'=>$custnum}); foreach $bill (@bills) { my($bref)=$bill->hashref; push @history, - $bref->{_date} . qq!\t{invnum} . qq!">Invoice #! . $bref->{invnum} . qq! (Balance \$! . $bref->{owed} . qq!)\t! . $bref->{charged} . qq!\t\t\t!; @@ -260,7 +313,6 @@ foreach $bill (@bills) { my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } ); my($payment); foreach $payment (@payments) { -# my($pref)=$payment->hashref; my($date,$invnum,$payby,$payinfo,$paid)=($payment->getfield('_date'), $payment->getfield('invnum'), $payment->getfield('payby'), @@ -272,8 +324,7 @@ foreach $bill (@bills) { } } -my(@credits)=qsearch('cust_credit',{'custnum'=>$custnum}); -my($credit); +@credits = qsearch('cust_credit',{'custnum'=>$custnum}); foreach $credit (@credits) { my($cref)=$credit->hashref; push @history, @@ -294,7 +345,7 @@ foreach $credit (@credits) { } #formatting - print "
", table, < Date Description @@ -308,8 +359,7 @@ END #display payment history -my($balance)=0; -my($item); +$balance = 0; foreach $item (sort keyfield_numerically @history) { my($date,$desc,$charge,$payment,$credit,$refund)=split(/\t/,$item); $charge ||= 0; @@ -339,7 +389,7 @@ foreach $item (sort keyfield_numerically @history) { } #formatting -print "
"; +print ""; #end