From 963a290ad2d9a89b45b66ac9d9ccdd612a756f11 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 25 Jan 1999 12:26:17 +0000 Subject: [PATCH] yet more mod_perl stuff --- htdocs/view/cust_bill.cgi | 9 +- htdocs/view/cust_main.cgi | 330 ++++++++++++++++++++++------------------- site_perl/CGI.pm | 40 ++++- site_perl/Record.pm | 13 +- site_perl/cust_bill.pm | 310 ++++++++++++++++++-------------------- site_perl/cust_credit.pm | 14 +- site_perl/cust_main.pm | 18 ++- site_perl/cust_main_invoice.pm | 24 ++- site_perl/cust_pay.pm | 8 +- site_perl/cust_pkg.pm | 31 ++-- site_perl/cust_refund.pm | 8 +- site_perl/svc_Common.pm | 9 +- site_perl/svc_acct.pm | 10 +- site_perl/svc_acct_sm.pm | 3 +- site_perl/svc_domain.pm | 8 +- 15 files changed, 472 insertions(+), 363 deletions(-) diff --git a/htdocs/view/cust_bill.cgi b/htdocs/view/cust_bill.cgi index 44e3a4a1b..1989726a3 100755 --- a/htdocs/view/cust_bill.cgi +++ b/htdocs/view/cust_bill.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: cust_bill.cgi,v 1.6 1999-01-19 05:14:18 ivan Exp $ +# $Id: cust_bill.cgi,v 1.7 1999-01-25 12:26:03 ivan Exp $ # # Note: Should be run setuid freeside as user nobody. # @@ -25,7 +25,10 @@ # also print 'printed' field ivan@sisd.com 98-jul-10 # # $Log: cust_bill.cgi,v $ -# Revision 1.6 1999-01-19 05:14:18 ivan +# Revision 1.7 1999-01-25 12:26:03 ivan +# yet more mod_perl stuff +# +# Revision 1.6 1999/01/19 05:14:18 ivan # for mod_perl: no more top-level my() variables; use vars instead # also the last s/create/new/; # @@ -75,7 +78,7 @@ print $cgi->header( '-expires' => 'now' ), header('Invoice View', menubar( Enter payments (check/cash) against this invoice
Reprint this invoice

(Printed $printed times) -
+    
 END
 
 print $cust_bill->print_text;
diff --git a/htdocs/view/cust_main.cgi b/htdocs/view/cust_main.cgi
index 7c5f4bead..2119b3e0c 100755
--- a/htdocs/view/cust_main.cgi
+++ b/htdocs/view/cust_main.cgi
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: cust_main.cgi,v 1.10 1999-01-19 05:14:19 ivan Exp $
+# $Id: cust_main.cgi,v 1.11 1999-01-25 12:26:04 ivan Exp $
 #
 # Usage: cust_main.cgi custnum
 #        http://server.name/path/cust_main.cgi?custnum
@@ -33,7 +33,10 @@
 # lose background, FS::CGI ivan@sisd.com 98-sep-2
 #
 # $Log: cust_main.cgi,v $
-# Revision 1.10  1999-01-19 05:14:19  ivan
+# 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/;
 #
@@ -66,13 +69,13 @@
 use strict;
 use vars qw ( $cgi $query $custnum $cust_main $hashref $agent $referral 
               @packages $package @history @bills $bill @credits $credit
-              $balance $item ); 
+              $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;
@@ -88,9 +91,7 @@ $cgi = new CGI;
 
 print $cgi->header( '-expires' => 'now' ), header("Customer View", menubar(
   'Main Menu' => popurl(2)
-)),<
-END
+));
 
 die "No customer specified (bad URL)!" unless $cgi->keywords;
 ($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
@@ -100,120 +101,133 @@ $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
 die "Customer not found!" unless $cust_main;
 $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 -$agent = qsearchs('agent',{ - 'agentnum' => $cust_main->getfield('agentnum') -} ); -die "Agent not found!" unless $agent; -print "
Agent #" , $agent->getfield('agentnum') , ": " , - $agent->getfield('agent') , ""; - -#refnum -$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 ), + '', + '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!, @@ -222,55 +236,68 @@ print qq!
!, table, "\n", qq!\n!; #get package info -@packages = qsearch('cust_pkg',{'custnum'=>$custnum}); +@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.
!, +print qq!

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

!; + qq!Post credit / refund )!; #get payment history # # major problem: this whole thing is way too sloppy. # minor problem: the description lines need better formatting. +@history = (); #needed for mod_perl :) + @bills = qsearch('cust_bill',{'custnum'=>$custnum}); foreach $bill (@bills) { my($bref)=$bill->hashref; @@ -283,7 +310,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'), @@ -316,7 +342,7 @@ foreach $credit (@credits) { } #formatting - print "
", table, < Date Description @@ -360,7 +386,7 @@ foreach $item (sort keyfield_numerically @history) { } #formatting -print "
"; +print ""; #end diff --git a/site_perl/CGI.pm b/site_perl/CGI.pm index 97dedaddf..142438e4c 100644 --- a/site_perl/CGI.pm +++ b/site_perl/CGI.pm @@ -9,7 +9,7 @@ use CGI::Carp qw(fatalsToBrowser); use FS::UID; @ISA = qw(Exporter); -@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable); +@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable); =head1 NAME @@ -53,7 +53,7 @@ sub header { - + $title

@@ -79,11 +79,14 @@ sub menubar { #$menubar=menubar('Main Menu', '../', 'Item', 'url', ... ); =item idiot ERROR +This is depriciated. Don't use it. + Sends headers and an HTML error message. =cut sub idiot { + #warn "idiot depriciated"; my($error)=@_; my($cgi)=FS::UID::cgi; if ( $cgi->isa('CGI::Base') ) { @@ -103,7 +106,6 @@ sub idiot {
Your request could not be processed because of the following error:

$error -

Hit the Back button in your web browser, correct this mistake, and try again. END @@ -112,11 +114,14 @@ END =item eidiot ERROR +This is depriciated. Don't use it. + Sends headers and an HTML error message, then exits. =cut sub eidiot { + #warn "eidiot depriciated"; idiot(@_); exit; } @@ -148,7 +153,7 @@ Returns HTML tag for beginning a table. sub table { my $col = shift; if ( $col ) { - ""; + qq!
!; } else { "
"; } @@ -162,11 +167,29 @@ Returns HTML tag for beginning an (invisible) table. sub itable { my $col = shift; + my $cellspacing = shift || 0; + if ( $col ) { + qq!
!; + } else { + qq!
!; + } +} + +=item ntable + +This is getting silly. + +=cut + +sub ntable { + my $col = shift; + my $cellspacing = shift || 0; if ( $col ) { - qq!
!; + qq!
!; } else { - "
"; + "
"; } + } =back @@ -193,7 +216,10 @@ lose the background, eidiot ivan@sisd.com 98-sep-2 pod ivan@sisd.com 98-sep-12 $Log: CGI.pm,v $ -Revision 1.15 1999-01-18 09:41:48 ivan +Revision 1.16 1999-01-25 12:26:05 ivan +yet more mod_perl stuff + +Revision 1.15 1999/01/18 09:41:48 ivan all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl (good idea anyway) diff --git a/site_perl/Record.pm b/site_perl/Record.pm index 81574131e..aa8d75b3d 100644 --- a/site_perl/Record.pm +++ b/site_perl/Record.pm @@ -353,6 +353,7 @@ sub insert { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $sth->execute or return $sth->errstr; @@ -396,6 +397,7 @@ sub delete { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; my $rc = $sth->execute or return $sth->errstr; #not portable #return "Record not found, statement:\n$statement" if $rc eq "0E0"; @@ -462,6 +464,7 @@ sub replace { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; my $rc = $sth->execute or return $sth->errstr; #not portable #return "Record not found (or records identical)." if $rc eq "0E0"; @@ -590,9 +593,10 @@ is an error, returns the error, otherwise returns false. sub ut_money { my($self,$field)=@_; + $self->setfield($field, 0) if $self->getfield($field) eq ''; $self->getfield($field) =~ /^(\-)? ?(\d*)(\.\d{2})?$/ or return "Illegal (money) $field!"; - $self->setfield($field,"$1$2$3" || 0); + $self->setfield($field, "$1$2$3" || 0); ''; } @@ -805,7 +809,7 @@ sub hfields { =head1 VERSION -$Id: Record.pm,v 1.11 1999-01-18 09:22:38 ivan Exp $ +$Id: Record.pm,v 1.12 1999-01-25 12:26:06 ivan Exp $ =head1 BUGS @@ -927,7 +931,10 @@ added pod documentation ivan@sisd.com 98-sep-6 ut_phonen got ''; at the end ivan@sisd.com 98-sep-27 $Log: Record.pm,v $ -Revision 1.11 1999-01-18 09:22:38 ivan +Revision 1.12 1999-01-25 12:26:06 ivan +yet more mod_perl stuff + +Revision 1.11 1999/01/18 09:22:38 ivan changes to track email addresses for email invoicing Revision 1.10 1998/12/29 11:59:33 ivan diff --git a/site_perl/cust_bill.pm b/site_perl/cust_bill.pm index 5de1d929b..6d87b1bb3 100644 --- a/site_perl/cust_bill.pm +++ b/site_perl/cust_bill.pm @@ -15,7 +15,7 @@ use FS::cust_pkg; #ask FS::UID to run this stuff for us later $FS::UID::callback{'FS::cust_bill'} = sub { $conf = new FS::Conf; - ( $add1, $add2, $add3, $add4 ) = $conf->config('address'); + ( $add1, $add2, $add3, $add4 ) = ( $conf->config('address'), '', '', '', '' ); }; =head1 NAME @@ -264,172 +264,156 @@ sub print_text { #printing bits here (yuck!) - local($SIG{CHLD}) = sub { wait() }; - $|=1; - my($pid)=open(CHILD,"-|"); - die "Can't fork: $!" unless defined($pid); + my @collect = (); - if ($pid) { #parent - my(@collect)=; - close CHILD; - return @collect; - } else { #child - - my($description,$amount); - my(@buf); - - #define format stuff - $%=0; - $= = 35; - local($^L) = <company if $cust_main->company; - $address[$l++]=$cust_main->address1; - $address[$l++]=$cust_main->address2 if $cust_main->address2; - $address[$l++]=$cust_main->city. ", ". $cust_main->state. " ". - $cust_main->zip; - $address[$l++]=$cust_main->country unless $cust_main->country eq 'US'; - - #previous balance - foreach ( @pr_cust_bill ) { - push @buf, ( - "Previous Balance, Invoice #". $_->invnum. - " (". time2str("%x",$_->_date). ")", - '$'. sprintf("%10.2f",$_->owed) - ); - } - if (@pr_cust_bill) { - push @buf,('','-----------'); - push @buf,('Total Previous Balance','$' . sprintf("%10.2f",$pr_total ) ); - push @buf,('',''); - } - - #new charges - foreach ( $self->cust_bill_pkg ) { - - if ( $_->pkgnum ) { - - my($cust_pkg)=qsearchs('cust_pkg', { 'pkgnum', $_->pkgnum } ); - my($part_pkg)=qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->pkgpart}); - my($pkg)=$part_pkg->pkg; - - push @buf, ( "$pkg Setup",'$' . sprintf("%10.2f",$_->setup) ) - if $_->setup != 0; - push @buf, ( - "$pkg (" . time2str("%x",$_->sdate) . " - " . - time2str("%x",$_->edate) . ")", - '$' . sprintf("%10.2f",$_->recur) - ) if $_->recur != 0; - - } else { #pkgnum Tax - push @buf,("Tax",'$' . sprintf("%10.2f",$_->setup) ) - if $_->setup != 0; - } - } + my($description,$amount); + my(@buf); + #format address + my($l,@address)=(0,'','','','','','',''); + $address[$l++] = + $cust_main->payname. + ( ( $cust_main->payby eq 'BILL' ) && $cust_main->payinfo + ? " (P.O. #". $cust_main->payinfo. ")" + : '' + ) + ; + $address[$l++]=$cust_main->company if $cust_main->company; + $address[$l++]=$cust_main->address1; + $address[$l++]=$cust_main->address2 if $cust_main->address2; + $address[$l++]=$cust_main->city. ", ". $cust_main->state. " ". + $cust_main->zip; + $address[$l++]=$cust_main->country unless $cust_main->country eq 'US'; + + #previous balance + foreach ( @pr_cust_bill ) { + push @buf, ( + "Previous Balance, Invoice #". $_->invnum. + " (". time2str("%x",$_->_date). ")", + '$'. sprintf("%10.2f",$_->owed) + ); + } + if (@pr_cust_bill) { push @buf,('','-----------'); - push @buf,('Total New Charges', - '$' . sprintf("%10.2f",$self->charged) ); + push @buf,('Total Previous Balance','$' . sprintf("%10.2f",$pr_total ) ); push @buf,('',''); + } - push @buf,('','-----------'); - push @buf,('Total Charges', - '$' . sprintf("%10.2f",$self->charged + $pr_total) ); - push @buf,('',''); + #new charges + foreach ( $self->cust_bill_pkg ) { - #credits - foreach ( @cr_cust_credit ) { - push @buf,( - "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")", - '$' . sprintf("%10.2f",$_->credited) - ); - } + if ( $_->pkgnum ) { - #get & print payments - foreach ( $self->cust_pay ) { - push @buf,( - "Payment received ". time2str("%x",$_->_date ), - '$' . sprintf("%10.2f",$_->paid ) - ); - } - - #balance due - push @buf,('','-----------'); - push @buf,('Balance Due','$' . - sprintf("%10.2f",$self->owed + $pr_total - $cr_total ) ); + my($cust_pkg)=qsearchs('cust_pkg', { 'pkgnum', $_->pkgnum } ); + my($part_pkg)=qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->pkgpart}); + my($pkg)=$part_pkg->pkg; - #now print - - my($tot_pages)=int(scalar(@buf)/30); #15 lines, 2 values per line - $tot_pages++ if scalar(@buf) % 30; - - while (@buf) { + push @buf, ( "$pkg Setup",'$' . sprintf("%10.2f",$_->setup) ) + if $_->setup != 0; + push @buf, ( + "$pkg (" . time2str("%x",$_->sdate) . " - " . + time2str("%x",$_->edate) . ")", + '$' . sprintf("%10.2f",$_->recur) + ) if $_->recur != 0; + + } else { #pkgnum Tax + push @buf,("Tax",'$' . sprintf("%10.2f",$_->setup) ) + if $_->setup != 0; + } + } + + push @buf,('','-----------'); + push @buf,('Total New Charges', + '$' . sprintf("%10.2f",$self->charged) ); + push @buf,('',''); + + push @buf,('','-----------'); + push @buf,('Total Charges', + '$' . sprintf("%10.2f",$self->charged + $pr_total) ); + push @buf,('',''); + + #credits + foreach ( @cr_cust_credit ) { + push @buf,( + "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")", + '$' . sprintf("%10.2f",$_->credited) + ); + } + + #get & print payments + foreach ( $self->cust_pay ) { + push @buf,( + "Payment received ". time2str("%x",$_->_date ), + '$' . sprintf("%10.2f",$_->paid ) + ); + } + + #balance due + push @buf,('','-----------'); + push @buf,('Balance Due','$' . + sprintf("%10.2f",$self->owed + $pr_total - $cr_total ) ); + + #now print + + my $tot_lines = 50; #should be configurable + #header is 17 lines + my $tot_pages = int( scalar(@buf) / ( 2 * ( $tot_lines - 17 ) ) ); + $tot_pages++ if scalar(@buf) % ( 2 * ( $tot_lines - 17 ) ); + + my $page = 1; + my $lines; + while (@buf) { + $lines = $tot_lines; + my @header = &header( + $page, $tot_pages, $self->_date, $self->invnum, @address + ); + push @collect, @header; + $lines -= scalar(@header); + + while ( $lines-- && @buf ) { $description=shift(@buf); $amount=shift(@buf); - write; + push @collect, myswrite($description, $amount); } - ($description,$amount)=('',''); - write while ( $- ); - print $^L; - - exit; #kid - - format STDOUT_TOP = - - @||||||||||||||||||| - "Invoice" - @||||||||||||||||||| @<<<<<<< @<<<<<<<<<<< -{ - ( $tot_pages != 1 ) ? "Page $% of $tot_pages" : '', - time2str("%x",( $self->_date )), "FS-$invnum" -} - - -@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -$add1 -@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -$add2 -@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -$add3 -@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -$add4 - - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -{ $cust_main->payname, - ( ( $cust_main->payby eq 'BILL' ) && $cust_main->payinfo ) - ? "P.O. #". $cust_main->payinfo : '' -} - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -$address[0],'' - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -$address[1],$overdue ? "* This invoice is now PAST DUE! *" : '' - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -$address[2],$overdue ? " Please forward payment promptly " : '' - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -$address[3],$overdue ? "to avoid interruption of service." : '' - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -$address[4],'' - - - -. - - format STDOUT = + $page++; + } + while ( $lines-- ) { + push @collect, myswrite('', ''); + } + + return @collect; + + sub header { #17 lines + my ( $page, $tot_pages, $date, $invnum, @address ) = @_ ; + push @address, '', '', '', ''; + + my @return = (); + my $i = ' 'x32; + push @return, + '', + $i. 'Invoice', + $i. substr("Page $page of $tot_pages".' 'x10, 0, 20). + time2str("%x", $date ). " FS-". $invnum, + '', + '', + $add1, + $add2, + $add3, + $add4, + '', + splice @address, 0, 7; + ; + return map $_. "\n", @return; + } + + sub myswrite { + my $format = <, L, L, L, @@ -470,7 +449,10 @@ charges can be negative ivan@sisd.com 98-jul-13 pod, ingegrate with FS::Invoice ivan@sisd.com 98-sep-20 $Log: cust_bill.pm,v $ -Revision 1.5 1999-01-18 21:58:03 ivan +Revision 1.6 1999-01-25 12:26:07 ivan +yet more mod_perl stuff + +Revision 1.5 1999/01/18 21:58:03 ivan esthetic: eq and ne were used in a few places instead of == and != Revision 1.4 1998/12/29 11:59:36 ivan diff --git a/site_perl/cust_credit.pm b/site_perl/cust_credit.pm index a050e3021..b9a05832b 100644 --- a/site_perl/cust_credit.pm +++ b/site_perl/cust_credit.pm @@ -77,7 +77,12 @@ automatically set to amount). sub insert { my $self = shift; - $self->credited($self->amount) if $self->credited eq ''; + my $error; + return $error if $error = $self->ut_money('credited') + || $self->ut_money('amount'); + + $self->credited($self->amount) if $self->credited == 0 + || $self->credited eq ''; return "credited != amount!" unless $self->credited == $self->amount; @@ -152,7 +157,7 @@ sub check { =head1 VERSION -$Id: cust_credit.pm,v 1.3 1999-01-18 21:58:04 ivan Exp $ +$Id: cust_credit.pm,v 1.4 1999-01-25 12:26:08 ivan Exp $ =head1 BUGS @@ -170,7 +175,10 @@ ivan@sisd.com 98-mar-17 pod, otaker from FS::UID ivan@sisd.com 98-sep-21 $Log: cust_credit.pm,v $ -Revision 1.3 1999-01-18 21:58:04 ivan +Revision 1.4 1999-01-25 12:26:08 ivan +yet more mod_perl stuff + +Revision 1.3 1999/01/18 21:58:04 ivan esthetic: eq and ne were used in a few places instead of == and != Revision 1.2 1998/12/29 11:59:38 ivan diff --git a/site_perl/cust_main.pm b/site_perl/cust_main.pm index 979b6f4d6..a89896da6 100644 --- a/site_perl/cust_main.pm +++ b/site_perl/cust_main.pm @@ -356,7 +356,7 @@ If there is an error, returns the error, otherwise returns false. sub bill { my( $self, %options ) = @_; - my $time = $options{'time'} || $^T; + my $time = $options{'time'} || time; my $error; @@ -366,6 +366,7 @@ sub bill { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; # find the packages which are due for billing, find out how much they are # & generate invoice database. @@ -543,7 +544,7 @@ return an error. By default, they don't. sub collect { my( $self, %options ) = @_; - my $invoice_time = $options{'invoice_time'} || $^T; + my $invoice_time = $options{'invoice_time'} || time; my $total_owed = $self->balance; return '' unless $total_owed > 0; #redundant????? @@ -554,6 +555,7 @@ sub collect { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; foreach my $cust_bill ( qsearch('cust_bill', { 'custnum' => $self->custnum, } ) @@ -820,7 +822,10 @@ sub check_invoicing_list { 'custnum' => $self->custnum, 'dest' => $address, } ); - my $error = $cust_main_invoice->check; + my $error = $self->custnum + ? $cust_main_invoice->check + : $cust_main_invoice->checkdest + ; return $error if $error; } ''; @@ -830,7 +835,7 @@ sub check_invoicing_list { =head1 VERSION -$Id: cust_main.pm,v 1.9 1999-01-18 09:22:41 ivan Exp $ +$Id: cust_main.pm,v 1.10 1999-01-25 12:26:09 ivan Exp $ =head1 BUGS @@ -886,7 +891,10 @@ enable cybercash, cybercash v3 support, don't need to import FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21 $Log: cust_main.pm,v $ -Revision 1.9 1999-01-18 09:22:41 ivan +Revision 1.10 1999-01-25 12:26:09 ivan +yet more mod_perl stuff + +Revision 1.9 1999/01/18 09:22:41 ivan changes to track email addresses for email invoicing Revision 1.8 1998/12/29 11:59:39 ivan diff --git a/site_perl/cust_main_invoice.pm b/site_perl/cust_main_invoice.pm index 6ae6425ef..2823294c1 100644 --- a/site_perl/cust_main_invoice.pm +++ b/site_perl/cust_main_invoice.pm @@ -105,13 +105,28 @@ sub check { my $error = $self->ut_numbern('destnum') || $self->ut_number('custnum') - || $self->ut_text('dest') + || $self->checkdest; ; return $error if $error; return "Unknown customer" unless qsearchs('cust_main',{ 'custnum' => $self->custnum }); + ''; #noerror +} + +=item checkdest + +Checks the dest field only. + +=cut + +sub checkdest { + my $self = shift; + + my $error = $self->ut_text('dest'); + return $error if $error; + if ( $self->dest eq 'POST' ) { #contemplate our navel } elsif ( $self->dest =~ /^(\d+)$/ ) { @@ -152,7 +167,7 @@ sub address { =head1 VERSION -$Id: cust_main_invoice.pm,v 1.5 1999-01-18 21:58:05 ivan Exp $ +$Id: cust_main_invoice.pm,v 1.6 1999-01-25 12:26:10 ivan Exp $ =head1 BUGS @@ -168,7 +183,10 @@ added hfields ivan@sisd.com 97-nov-13 $Log: cust_main_invoice.pm,v $ -Revision 1.5 1999-01-18 21:58:05 ivan +Revision 1.6 1999-01-25 12:26:10 ivan +yet more mod_perl stuff + +Revision 1.5 1999/01/18 21:58:05 ivan esthetic: eq and ne were used in a few places instead of == and != Revision 1.4 1999/01/18 09:22:42 ivan diff --git a/site_perl/cust_pay.pm b/site_perl/cust_pay.pm index fc9112b00..2cb256baa 100644 --- a/site_perl/cust_pay.pm +++ b/site_perl/cust_pay.pm @@ -89,6 +89,7 @@ sub insert { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error = $new_cust_bill->replace($old_cust_bill); return "Error modifying cust_bill: $error" if $error; @@ -170,7 +171,7 @@ sub check { =head1 VERSION -$Id: cust_pay.pm,v 1.2 1998-12-29 11:59:43 ivan Exp $ +$Id: cust_pay.pm,v 1.3 1999-01-25 12:26:11 ivan Exp $ =head1 BUGS @@ -189,7 +190,10 @@ new api ivan@sisd.com 98-mar-13 pod ivan@sisd.com 98-sep-21 $Log: cust_pay.pm,v $ -Revision 1.2 1998-12-29 11:59:43 ivan +Revision 1.3 1999-01-25 12:26:11 ivan +yet more mod_perl stuff + +Revision 1.2 1998/12/29 11:59:43 ivan mostly properly OO, some work still to be done with svc_ stuff diff --git a/site_perl/cust_pkg.pm b/site_perl/cust_pkg.pm index 5b119ed28..039b65451 100644 --- a/site_perl/cust_pkg.pm +++ b/site_perl/cust_pkg.pm @@ -193,6 +193,7 @@ sub cancel { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; foreach my $cust_svc ( qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } ) @@ -219,7 +220,7 @@ sub cancel { unless ( $self->getfield('cancel') ) { my %hash = $self->hash; - $hash{'cancel'} = $^T; + $hash{'cancel'} = time; my $new = new FS::cust_pkg ( \%hash ); $error = $new->replace($self); return $error if $error; @@ -246,6 +247,7 @@ sub suspend { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; foreach my $cust_svc ( qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } ) @@ -267,7 +269,7 @@ sub suspend { unless ( $self->getfield('susp') ) { my %hash = $self->hash; - $hash{'susp'} = $^T; + $hash{'susp'} = time; my $new = new FS::cust_pkg ( \%hash ); $error = $new->replace($self); return $error if $error; @@ -294,6 +296,7 @@ sub unsuspend { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; foreach my $cust_svc ( qsearch('cust_svc',{'pkgnum'=> $self->pkgnum } ) @@ -417,38 +420,39 @@ sub order { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; #first cancel old packages # my($pkgnum); foreach $pkgnum ( @{$remove_pkgnums} ) { my($old) = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - return "Package $pkgnum not found to remove!" unless $old; + die "Package $pkgnum not found to remove!" unless $old; my(%hash) = $old->hash; - $hash{'cancel'}=$^T; - my($new) = create FS::cust_pkg ( \%hash ); + $hash{'cancel'}=time; + my($new) = new FS::cust_pkg ( \%hash ); my($error)=$new->replace($old); - return $error if $error; + die "Couldn't update package $pkgnum: $error" if $error; } #now add new packages, changing cust_svc records if necessary # my($pkgpart); while ($pkgpart=shift @{$pkgparts} ) { - my($new) = create FS::cust_pkg ( { + my($new) = new FS::cust_pkg ( { 'custnum' => $custnum, 'pkgpart' => $pkgpart, } ); my($error) = $new->insert; - return $error if $error; + die "Couldn't insert new cust_pkg record: $error" if $error; my($pkgnum)=$new->getfield('pkgnum'); my($cust_svc); foreach $cust_svc ( @{ shift @cust_svc } ) { my(%hash) = $cust_svc->hash; $hash{'pkgnum'}=$pkgnum; - my($new) = create FS::cust_svc ( \%hash ); + my($new) = new FS::cust_svc ( \%hash ); my($error)=$new->replace($cust_svc); - return $error if $error; + die "Couldn't link old service to new package: $error" if $error; } } @@ -459,7 +463,7 @@ sub order { =head1 VERSION -$Id: cust_pkg.pm,v 1.5 1999-01-18 21:58:07 ivan Exp $ +$Id: cust_pkg.pm,v 1.6 1999-01-25 12:26:12 ivan Exp $ =head1 BUGS @@ -490,7 +494,10 @@ fixed for new agent->agent_type->type_pkgs in &order ivan@sisd.com 98-mar-7 pod ivan@sisd.com 98-sep-21 $Log: cust_pkg.pm,v $ -Revision 1.5 1999-01-18 21:58:07 ivan +Revision 1.6 1999-01-25 12:26:12 ivan +yet more mod_perl stuff + +Revision 1.5 1999/01/18 21:58:07 ivan esthetic: eq and ne were used in a few places instead of == and != Revision 1.4 1998/12/29 11:59:45 ivan diff --git a/site_perl/cust_refund.pm b/site_perl/cust_refund.pm index 0778473a9..4ec54907d 100644 --- a/site_perl/cust_refund.pm +++ b/site_perl/cust_refund.pm @@ -91,6 +91,7 @@ sub insert { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error = $new_cust_credit->replace($old_cust_credit); return "Error modifying cust_credit: $error" if $error; @@ -170,7 +171,7 @@ sub check { =head1 VERSION -$Id: cust_refund.pm,v 1.2 1998-12-29 11:59:46 ivan Exp $ +$Id: cust_refund.pm,v 1.3 1999-01-25 12:26:13 ivan Exp $ =head1 BUGS @@ -190,7 +191,10 @@ ivan@sisd.com 98-mar-18 pod and finish up ivan@sisd.com 98-sep-21 $Log: cust_refund.pm,v $ -Revision 1.2 1998-12-29 11:59:46 ivan +Revision 1.3 1999-01-25 12:26:13 ivan +yet more mod_perl stuff + +Revision 1.2 1998/12/29 11:59:46 ivan mostly properly OO, some work still to be done with svc_ stuff diff --git a/site_perl/svc_Common.pm b/site_perl/svc_Common.pm index e516e0065..9c0c4e69f 100644 --- a/site_perl/svc_Common.pm +++ b/site_perl/svc_Common.pm @@ -46,6 +46,7 @@ sub insert { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error = $self->check; return $error if $error; @@ -90,6 +91,7 @@ sub delete { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; my $svcnum = $self->svcnum; @@ -163,7 +165,7 @@ sub cancel { ''; } =head1 VERSION -$Id: svc_Common.pm,v 1.1 1998-12-30 00:30:45 ivan Exp $ +$Id: svc_Common.pm,v 1.2 1999-01-25 12:26:14 ivan Exp $ =head1 BUGS @@ -180,7 +182,10 @@ from the base documentation. =head1 HISTORY $Log: svc_Common.pm,v $ -Revision 1.1 1998-12-30 00:30:45 ivan +Revision 1.2 1999-01-25 12:26:14 ivan +yet more mod_perl stuff + +Revision 1.1 1998/12/30 00:30:45 ivan svc_ stuff is more properly OO - has a common superclass FS::svc_Common diff --git a/site_perl/svc_acct.pm b/site_perl/svc_acct.pm index c69f1032b..1ba92aec1 100644 --- a/site_perl/svc_acct.pm +++ b/site_perl/svc_acct.pm @@ -120,6 +120,7 @@ sub insert { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error = $self->check; return $error if $error; @@ -188,6 +189,7 @@ sub delete { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error = $self->SUPER::delete; return $error if $error; @@ -242,6 +244,7 @@ sub replace { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error = $new->SUPER::replace($old); return $error if $error; @@ -440,7 +443,7 @@ sub check { =head1 VERSION -$Id: svc_acct.pm,v 1.5 1999-01-18 21:58:09 ivan Exp $ +$Id: svc_acct.pm,v 1.6 1999-01-25 12:26:15 ivan Exp $ =head1 BUGS @@ -482,7 +485,10 @@ arbitrary radius attributes ivan@sisd.com 98-aug-13 pod and FS::conf ivan@sisd.com 98-sep-22 $Log: svc_acct.pm,v $ -Revision 1.5 1999-01-18 21:58:09 ivan +Revision 1.6 1999-01-25 12:26:15 ivan +yet more mod_perl stuff + +Revision 1.5 1999/01/18 21:58:09 ivan esthetic: eq and ne were used in a few places instead of == and != Revision 1.4 1998/12/30 00:30:45 ivan diff --git a/site_perl/svc_acct_sm.pm b/site_perl/svc_acct_sm.pm index 5c0f510e4..b0eee114c 100644 --- a/site_perl/svc_acct_sm.pm +++ b/site_perl/svc_acct_sm.pm @@ -103,6 +103,7 @@ sub insert { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error=$self->check; return $error if $error; @@ -229,7 +230,7 @@ sub check { =head1 VERSION -$Id: svc_acct_sm.pm,v 1.5 1999-01-18 21:58:10 ivan Exp $ +$Id: svc_acct_sm.pm,v 1.6 1999-01-25 12:26:16 ivan Exp $ =head1 BUGS diff --git a/site_perl/svc_domain.pm b/site_perl/svc_domain.pm index f86723f4a..76d666b86 100644 --- a/site_perl/svc_domain.pm +++ b/site_perl/svc_domain.pm @@ -121,6 +121,7 @@ sub insert { local $SIG{QUIT} = 'IGNORE'; local $SIG{TERM} = 'IGNORE'; local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; $error = $self->check; return $error if $error; @@ -386,7 +387,7 @@ sub submit_internic { =head1 VERSION -$Id: svc_domain.pm,v 1.5 1998-12-30 00:30:47 ivan Exp $ +$Id: svc_domain.pm,v 1.6 1999-01-25 12:26:17 ivan Exp $ =head1 BUGS @@ -422,7 +423,10 @@ ivan@sisd.com 98-jul-17-19 pod, some FS::Conf (not complete) ivan@sisd.com 98-sep-23 $Log: svc_domain.pm,v $ -Revision 1.5 1998-12-30 00:30:47 ivan +Revision 1.6 1999-01-25 12:26:17 ivan +yet more mod_perl stuff + +Revision 1.5 1998/12/30 00:30:47 ivan svc_ stuff is more properly OO - has a common superclass FS::svc_Common Revision 1.3 1998/11/13 09:56:57 ivan -- 2.11.0