From d0f483f47168e01eb6c28e8fc99a62050b245132 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 26 Dec 2001 04:25:04 +0000 Subject: [PATCH] auto-apply payments and credits, post credit UI overhaul --- FS/FS/CGI.pm | 64 +++++++++++++++++++++++++++++++- httemplate/edit/cust_credit.cgi | 40 ++++++++++---------- httemplate/edit/cust_pay.cgi | 66 ++++++--------------------------- httemplate/edit/process/cust_credit.cgi | 7 +++- httemplate/edit/process/cust_pay.cgi | 7 +++- 5 files changed, 105 insertions(+), 79 deletions(-) diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index f0fec434d..c66bfe3c2 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -9,7 +9,8 @@ use CGI::Carp qw(fatalsToBrowser); use FS::UID; @ISA = qw(Exporter); -@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable); +@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable + small_custview); @header = ( '-Expires' => '-1', '-Pragma' => 'no-cache', @@ -206,6 +207,65 @@ sub ntable { } +=item small_custview CUSTNUM || CUST_MAIN_OBJECT, COUNTRYDEFAULT + +Sheesh. I should just switch to Mason. + +=cut + +sub small_custview { + use FS::Record qw(qsearchs); + use FS::cust_main; + + my $arg = shift; + my $countrydefault = shift || 'US'; + + my $cust_main = ref($arg) ? $arg + : qsearchs('cust_main', { 'custnum' => $arg } ) + or die "unknown custnum $arg"; + + my $html = 'Customer #'. $cust_main->custnum. ''. + ntable('#e8e8e8'). ''. ntable("#cccccc",2). + 'Billing'. + $cust_main->getfield('last'). ', '. $cust_main->first. '
'; + + $html .= $cust_main->company. '
' if $cust_main->company; + $html .= $cust_main->address1. '
'; + $html .= $cust_main->address2. '
' if $cust_main->address2; + $html .= $cust_main->city. ', '. $cust_main->state. ' '. $cust_main->zip. '
'; + $html .= $cust_main->country. '
' + if $cust_main->country && $cust_main->country ne $countrydefault; + + $html .= ''; + + if ( defined $cust_main->dbdef_table->column('ship_last') ) { + + my $pre = $cust_main->ship_last ? 'ship_' : ''; + + $html .= ''. ntable("#cccccc",2). + 'Service'. + $cust_main->get("${pre}last"). ', '. + $cust_main->get("${pre}first"). '
'; + $html .= $cust_main->get("${pre}company"). '
' + if $cust_main->get("${pre}company"); + $html .= $cust_main->get("${pre}address1"). '
'; + $html .= $cust_main->get("${pre}address2"). '
' + if $cust_main->get("${pre}address2"); + $html .= $cust_main->get("${pre}city"). ', '. + $cust_main->get("${pre}state"). ' '. + $cust_main->get("${pre}ship_zip"). '
'; + $html .= $cust_main->get("${pre}country"). '
' + if $cust_main->get("${pre}country") + && $cust_main->get("${pre}country") ne $countrydefault; + + $html .= ''; + } + + $html .= ''; + + $html; +} + =back =head1 BUGS @@ -214,6 +274,8 @@ Not OO. Not complete. +small_custview sooooo doesn't belong here. i should just switch to Mason. + =head1 SEE ALSO L, L diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi index 5d5f5b296..63732f86c 100755 --- a/httemplate/edit/cust_credit.cgi +++ b/httemplate/edit/cust_credit.cgi @@ -1,16 +1,18 @@ <% -# +# use strict; -use vars qw( $cgi $query $custnum $otaker $p1 $crednum $_date $amount $reason ); +use vars qw( $cgi $query $custnum $otaker $p1 $_date $amount $reason ); use Date::Format; use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup getotaker); -use FS::CGI qw(header popurl); +use FS::CGI qw(header popurl small_custview); use FS::Record qw(fields); #use FS::cust_credit; +my $conf = new FS::Conf; + $cgi = new CGI; cgisuidsetup($cgi); @@ -40,35 +42,31 @@ print header("Post Credit", ''); print qq!Error: !, $cgi->param('error'), "" if $cgi->param('error'); -print <config('countrydefault'));
+ + + + + END -$crednum = ""; -print qq!Credit #!, $crednum ? $crednum : " (NEW)", qq!!; - -print qq!
Customer #$custnum!; - -print qq!!; - -print qq!
Date: !, time2str("%D",$_date), qq!!; +print '

Credit'. ntable("#cccccc", 2). + 'Date'. + time2str("%D",$_date). ''; -print qq!
Amount \$!; -print qq!!; +print qq!Amount\$!; #print qq! Also post refund!; -print qq!!; +print qq!Reason!; -print qq!
Reason !; +print qq!Auto-apply
to invoices!; print <
- -END - -print < diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index dfef3c542..7f70802c3 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi $link $linknum $p1 $_date $payby $payinfo $paid ); @@ -8,12 +8,10 @@ use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::Conf; use FS::UID qw(cgisuidsetup); -use FS::CGI qw(header popurl ntable); +use FS::CGI qw(header popurl ntable small_custview); my $conf = new FS::Conf; -my $countrydefault = $conf->config('countrydefault') || 'US'; - $cgi = new CGI; cgisuidsetup($cgi); @@ -43,10 +41,10 @@ if ( $cgi->param('error') ) { $_date = time; $p1 = popurl(1); -print header("Enter payment", ''); +print header("Post payment", ''); print qq!Error: !, $cgi->param('error'), - "" + "

" if $cgi->param('error'); print <
Customer #$custnum". ntable('#e8e8e8'); -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) - or die "unknown custnum $custnum"; - -print ''. ntable("#cccccc",2). - 'Billing'. - $cust_main->getfield('last'). ', '. $cust_main->first. '
'; -print $cust_main->company. '
' if $cust_main->company; -print $cust_main->address1. '
'; -print $cust_main->address2. '
' if $cust_main->address2; -print $cust_main->city. ', '. $cust_main->state. ' '. $cust_main->zip. '
'; -print $cust_main->country. '
' if $cust_main->country - && $cust_main->country ne $countrydefault; - -print ''. - ''; - -if ( defined $cust_main->dbdef_table->column('ship_last') ) { - - my $pre = $cust_main->ship_last ? 'ship_' : ''; - - print ''. ntable("#cccccc",2). - 'Service'. - $cust_main->get("${pre}last"). ', '. - $cust_main->get("${pre}first"). '
'; - print $cust_main->get("${pre}company"). '
' - if $cust_main->get("${pre}company"); - print $cust_main->get("${pre}address1"). '
'; - print $cust_main->get("${pre}address2"). '
' - if $cust_main->get("${pre}address2"); - print $cust_main->get("${pre}city"). ', '. - $cust_main->get("${pre}state"). ' '. - $cust_main->get("${pre}ship_zip"). '
'; - print $cust_main->get("${pre}country"). '
' - if $cust_main->get("${pre}country") - && $cust_main->get("${pre}country") ne $countrydefault; - - print ''. - ''; -} - -print ''; +print small_custview($custnum, $conf->config('countrydefault')); +print qq!!; +print qq!!; print '

Payment'. ntable("#cccccc", 2). 'Date'. - time2str("%D",$_date). ''. - qq!!; + time2str("%D",$_date). ''; print qq!Amount\$!; -print qq!Payby$payby!; +print qq!Payby$payby!; #payinfo (check # now as payby="BILL" hardcoded.. what to do later?) print qq!Check #!; +print qq!Auto-apply
to invoices!; + #paybatch print qq!!; @@ -165,10 +125,6 @@ print <
-END - -print < diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi index b52d0bd46..2eb431bcc 100755 --- a/httemplate/edit/process/cust_credit.cgi +++ b/httemplate/edit/process/cust_credit.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi $custnum $new $error ); @@ -31,6 +31,11 @@ if ( $error ) { $cgi->param('error', $error); print $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ); } else { + if ( $cgi->param('apply') eq 'yes' ) { + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum }) + or die "unknown custnum $linknum"; + $cust_main->apply_payments; + } print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); } diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index 9be96505d..b2b3602db 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi $link $linknum $new $error ); @@ -38,6 +38,11 @@ if ($error) { } elsif ( $link eq 'invnum' ) { print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum"); } elsif ( $link eq 'custnum' ) { + if ( $cgi->param('apply') eq 'yes' ) { + my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum }) + or die "unknown custnum $linknum"; + $cust_main->apply_payments; + } print $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum"); } -- 2.11.0