summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/cust_main.cgi5
-rw-r--r--httemplate/edit/cust_main/billing.html54
-rwxr-xr-xhttemplate/edit/cust_pay.cgi46
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi3
-rwxr-xr-xhttemplate/search/cust_pay.cgi43
-rw-r--r--httemplate/search/report_cust_pay.html6
-rwxr-xr-xhttemplate/view/cust_bill.cgi40
-rw-r--r--httemplate/view/cust_main/payment_history.html56
8 files changed, 219 insertions, 34 deletions
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index bfd396881..e10c85f01 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -35,6 +35,7 @@ if ( $cgi->param('error') ) {
$popnum = $cgi->param('popnum');
@invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
$same = $cgi->param('same');
+ $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
} elsif ( $cgi->keywords ) { #editing
my( $query ) = $cgi->keywords;
$query =~ /^(\d+)$/;
@@ -261,7 +262,8 @@ function bottomfixup(what) {
'payinfo', 'payinfo1', 'payinfo2',
'payname', 'exp_month', 'exp_year', 'paycvv',
'paystart_month', 'paystart_year', 'payissue',
- 'payip'
+ 'payip',
+ 'paid'
);
var billing_bottomvars = new Array(
@@ -340,6 +342,7 @@ function copyelement(from, to) {
'payname', 'exp_month', 'exp_year', 'paycvv',
'paystart_month', 'paystart_year', 'payissue',
'payip',
+ 'paid',
'tax',
'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX'
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index 17b1b0cc9..caac3a956 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -4,6 +4,11 @@ my( $cust_main ) = @_;
my $conf = new FS::Conf;
my $payby_default = $conf->config('payby-default');
+my @payby = $conf->config('payby');
+#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
+@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
+ unless grep /\w/, @payby;
+
if ( $payby_default eq 'HIDE' ) {
$cust_main->payby('BILL') unless $cust_main->payby;
@@ -294,15 +299,60 @@ if ( $payby_default eq 'HIDE' ) {
'</TABLE>',
+ 'CASH' =>
+
+ '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
+
+ qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!.
+ qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'CASH' ? $cust_main->paid : '' ). qq!"></TD></TR>!.
+
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+
+ '</TABLE>',
+
+ 'WEST' =>
+
+ '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
+
+ qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!.
+ qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'WEST' ? $cust_main->paid : '' ). qq!"></TD></TR>!.
+
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+ '<TR><TD>&nbsp;</TD></TR>'.
+
+ '</TABLE>',
+
);
- tie my %options, 'Tie::IxHash',
+
+ my %allopt = (
'CARD' => 'Credit card',
'CHEK' => 'Electronic check',
'LECB' => 'Phone bill billing',
'BILL' => 'Billing',
+ 'CASH' => 'Cash', # initial payment, then billing',
+ 'WEST' => 'Western Union', # initial payment, then billing',
'COMP' => 'Complimentary',
- ;
+ );
+ if ( $cust_main->custnum ) { #don't offer CASH and WEST initial payment types
+ # when editing customer
+ delete $allopt{$_} for qw(CASH WEST);
+ }
+
+ tie my %options, 'Tie::IxHash',
+ map { $_ => $allopt{$_} }
+ grep { exists $allopt{$_} }
+ @payby;
+
my %payby2option = (
( map { $_ => $_ } keys %options ),
'DCRD' => 'CARD',
diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi
index c0a679b03..b2f3f55ff 100755
--- a/httemplate/edit/cust_pay.cgi
+++ b/httemplate/edit/cust_pay.cgi
@@ -1,8 +1,13 @@
-<!-- mason kludge -->
<%
my $conf = new FS::Conf;
+my %payby = (
+ 'BILL' => 'Check',
+ 'CASH' => 'Cash',
+ 'WEST' => 'Western Union',
+);
+
my($link, $linknum, $paid, $payby, $payinfo, $quickpay, $_date);
if ( $cgi->param('error') ) {
$link = $cgi->param('link');
@@ -12,31 +17,29 @@ if ( $cgi->param('error') ) {
$payinfo = $cgi->param('payinfo');
$quickpay = $cgi->param('quickpay');
$_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time;
-} elsif ($cgi->keywords) {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $link = 'invnum';
- $linknum = $1;
- $paid = '';
- $payby = 'BILL';
- $payinfo = "";
- $quickpay = '';
- $_date = time;
-} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
$link = 'custnum';
$linknum = $1;
$paid = '';
- $payby = 'BILL';
+ $payby = $cgi->param('payby') || 'BILL';
$payinfo = '';
$quickpay = $cgi->param('quickpay');
$_date = time;
+} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
+ $link = 'invnum';
+ $linknum = $1;
+ $paid = '';
+ $payby = $cgi->param('payby') || 'BILL';
+ $payinfo = "";
+ $quickpay = '';
+ $_date = time;
} else {
die "illegal query ". $cgi->keywords;
}
my $paybatch = "webui-$_date-$$-". rand() * 2**32;
-my $title = 'Post payment';
+my $title = 'Post '. $payby{$payby}. ' payment';
$title .= " against Invoice #$linknum" if $link eq 'invnum';
%>
@@ -97,13 +100,18 @@ Payment
<TR>
<TD ALIGN="right">Amount</TD>
<TD BGCOLOR="#ffffff" ALIGN="right"><%= $money_char %></TD>
- <TD><INPUT TYPE="text" NAME="paid" VALUE="<%= $paid %>" SIZE=8 MAXLENGTH=8></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Check #</TD>
- <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<%= $payinfo %>" SIZE=10></TD>
+ <TD><INPUT TYPE="text" NAME="paid" VALUE="<%= $paid %>" SIZE=8 MAXLENGTH=8> by <B><%= $payby{$payby} %></B></TD>
</TR>
+<% if ( $payby eq 'BILL' ) { %>
+
+ <TR>
+ <TD ALIGN="right">Check #</TD>
+ <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<%= $payinfo %>" SIZE=10></TD>
+ </TR>
+
+<% } %>
+
<TR>
<% if ( $link eq 'custnum' ) { %>
<TD ALIGN="right">Auto-apply<BR>to invoices</TD>
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index 85dbb9775..d77aa2fdd 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -55,6 +55,9 @@ if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) {
);
}
+$new->setfield('paid', $cgi->param('paid') )
+ if $cgi->param('paid');
+
#perhaps this stuff should go to cust_main.pm
my $cust_pkg = '';
my $svc_acct = '';
diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi
index 89da7426a..2106a649a 100755
--- a/httemplate/search/cust_pay.cgi
+++ b/httemplate/search/cust_pay.cgi
@@ -16,14 +16,27 @@
}
if ( $cgi->param('payby') ) {
- $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/
- or die "illegal payby ". $cgi->param('payby');
+ $cgi->param('payby') =~
+ /^(CARD|CHEK|BILL|PREP|CASH|WEST)(-(VisaMC|Amex|Discover|Maestro))?$/
+ or die "illegal payby ". $cgi->param('payby');
push @search, "cust_pay.payby = '$1'";
if ( $3 ) {
if ( $3 eq 'VisaMC' ) {
#avoid posix regexes for portability
push @search,
- " ( substring(cust_pay.payinfo from 1 for 1) = '4' ".
+ " ( ( substring(cust_pay.payinfo from 1 for 1) = '4' ".
+ " AND substring(cust_pay.payinfo from 1 for 4) != '4936' ".
+ " AND substring(cust_pay.payinfo from 1 for 6) ".
+ " NOT SIMILAR TO '49030[2-9]' ".
+ " AND substring(cust_pay.payinfo from 1 for 6) ".
+ " NOT SIMILAR TO '49033[5-9]' ".
+ " AND substring(cust_pay.payinfo from 1 for 6) ".
+ " NOT SIMILAR TO '49110[1-2]' ".
+ " AND substring(cust_pay.payinfo from 1 for 6) ".
+ " NOT SIMILAR TO '49117[4-9]' ".
+ " AND substring(cust_pay.payinfo from 1 for 6) ".
+ " NOT SIMILAR TO '49118[1-2]' ".
+ " )".
" OR substring(cust_pay.payinfo from 1 for 2) = '51' ".
" OR substring(cust_pay.payinfo from 1 for 2) = '52' ".
" OR substring(cust_pay.payinfo from 1 for 2) = '53' ".
@@ -38,7 +51,25 @@
" ) ";
} elsif ( $3 eq 'Discover' ) {
push @search,
- " substring(cust_pay.payinfo from 1 for 4 ) = '6011' ";
+ " substring(cust_pay.payinfo from 1 for 4 ) = '6011' ".
+ " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' ";
+ } elsif ( $3 eq 'Maestro' ) {
+ push @search,
+ " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ".
+ ' OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ".
+ ' OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ".
+ " OR substring(cust_pay.payinfo from 1 for 4 ) = '4936' ".
+ " OR substring(cust_pay.payinfo from 1 for 6 ) ".
+ " SIMILAR TO '49030[2-9]' ".
+ " OR substring(cust_pay.payinfo from 1 for 6 ) ".
+ " SIMILAR TO '49033[5-9]' ".
+ " OR substring(cust_pay.payinfo from 1 for 6 ) ".
+ " SIMILAR TO '49110[1-2]' ".
+ " OR substring(cust_pay.payinfo from 1 for 6 ) ".
+ " SIMILAR TO '49117[4-9]' ".
+ " OR substring(cust_pay.payinfo from 1 for 6 ) ".
+ " SIMILAR TO '49118[1-2]' ".
+ " ) ";
} else {
die "unknown card type $3";
}
@@ -134,6 +165,10 @@
'Check #'. $cust_pay->payinfo;
} elsif ( $cust_pay->payby eq 'PREP' ) {
'Prepaid card #'. $cust_pay->payinfo;
+ } elsif ( $cust_pay->payby eq 'CASH' ) {
+ 'Cash '. $cust_pay->payinfo;
+ } elsif ( $cust_pay->payby eq 'WEST' ) {
+ 'Western Union'; #. $cust_pay->payinfo;
} else {
$cust_pay->payby. ' '. $cust_pay->payinfo;
}
diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html
index 8b9e27302..18501d5b5 100644
--- a/httemplate/search/report_cust_pay.html
+++ b/httemplate/search/report_cust_pay.html
@@ -19,8 +19,12 @@
<OPTION VALUE="CARD-VisaMC">credit card (Visa/MasterCard)</OPTION>
<OPTION VALUE="CARD-Amex">credit card (American Express)</OPTION>
<OPTION VALUE="CARD-Discover">credit card (Discover)</OPTION>
+ <OPTION VALUE="CARD-Maestro">credit card (Maestro/Switch/Solo)</OPTION>
<OPTION VALUE="CHEK">electronic check / ACH</OPTION>
- <OPTION VALUE="BILL">check / cash</OPTION>
+ <OPTION VALUE="BILL">check</OPTION>
+ <OPTION VALUE="PREP">prepaid card</OPTION>
+ <OPTION VALUE="CASH">cash</OPTION>
+ <OPTION VALUE="WEST">Western Union</OPTION>
</SELECT>
</TD>
</TR>
diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi
index d149cf172..8dcbd3a35 100755
--- a/httemplate/view/cust_bill.cgi
+++ b/httemplate/view/cust_bill.cgi
@@ -8,6 +8,12 @@ my $invnum = $3;
my $conf = new FS::Conf;
+my @payby = $conf->config('payby');
+#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
+@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
+ unless grep /\w/, @payby;
+my %payby = map { $_=>1 } @payby;
+
my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
die "Invoice #$invnum not found!" unless $cust_bill;
my $custnum = $cust_bill->getfield('custnum');
@@ -22,8 +28,38 @@ my $link = $templatename ? "$templatename-$invnum" : $invnum;
"View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
)) %>
-<% if ( $cust_bill->owed > 0 ) { %>
- <A HREF="<%= $p %>edit/cust_pay.cgi?<%= $invnum %>">Enter payments (check/cash) against this invoice</A> |
+<% if ( $cust_bill->owed > 0
+ && ( $payby{'BILL'} || $payby{'CASH'} || $payby{'WEST'} )
+ )
+ {
+ my $s = 0;
+%>
+
+ Post
+
+ <% if ( $payby{'BILL'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;invnum=<%= $invnum %>">check</A>
+
+ <% } %>
+
+ <% if ( $payby{'CASH'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;invnum=<%= $invnum %>">cash</A>
+
+ <% } %>
+
+ <% if ( $payby{'WEST'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;invnum=<%= $invnum %>">Western Union</A>
+
+ <% } %>
+
+ payment against this invoice<BR>
+
<% } %>
<A HREF="<%= $p %>misc/print-invoice.cgi?<%= $link %>">Re-print this invoice</A>
diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html
index 6c475c5f2..e58b6248e 100644
--- a/httemplate/view/cust_main/payment_history.html
+++ b/httemplate/view/cust_main/payment_history.html
@@ -1,13 +1,56 @@
<%
my( $cust_main ) = @_;
- my $conf = new FS::Conf;
my $custnum = $cust_main->custnum;
+
+ my $conf = new FS::Conf;
+
+ my @payby = $conf->config('payby');
+ #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
+ @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
+ unless grep /\w/, @payby;
+ my %payby = map { $_=>1 } @payby;
+
+ my $s = 0;
+
%>
<BR><BR><A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR>
-<A HREF="<%= $p %>edit/cust_pay.cgi?custnum=<%= $custnum %>">Post cash/check payment</A>
-| <A HREF="<%= $p %>misc/payment.cgi?payby=CARD;custnum=<%= $custnum %>">Process credit card payment</A>
-| <A HREF="<%= $p %>misc/payment.cgi?payby=CHEK;custnum=<%= $custnum %>">Process electronic check (ACH) payment</A>
+
+<% if ( $payby{'BILL'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;custnum=<%= $custnum %>">Post check payment</A>
+
+<% } %>
+
+<% if ( $payby{'CASH'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;custnum=<%= $custnum %>">Post cash payment</A>
+
+<% } %>
+
+<% if ( $payby{'WEST'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;custnum=<%= $custnum %>">Post Western Union payment</A>
+
+<% } %>
+
+<% if ( $payby{'CARD'} || $payby{'DCRD'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>misc/payment.cgi?payby=CARD;custnum=<%= $custnum %>">Process credit card payment</A>
+
+<% } %>
+
+<% if ( $payby{'CHEK'} || $payby{'DCHK'} ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>misc/payment.cgi?payby=CHEK;custnum=<%= $custnum %>">Process electronic check (ACH) payment</A>
+
+<% } %>
+
<BR><A HREF="<%= $p %>edit/cust_credit.cgi?<%= $custnum %>">Post credit</A>
<BR>
@@ -51,8 +94,11 @@ foreach my $cust_pay ($cust_main->cust_pay) {
$payby =~ s/^BILL$/Check #/ if $payinfo;
$payby =~ s/^CHEK$/Electronic check /;
$payby =~ s/^PREP$/Prepaid card /;
+ $payby =~ s/^CARD$/Credit card #/;
+ $payby =~ s/^COMP$/Complimentary by /;
+ $payby =~ s/^CASH$/Cash/;
+ $payby =~ s/^WEST$/Western Union/;
$payby =~ s/^BILL$//;
- $payby =~ s/^(CARD|COMP)$/$1 /;
my $info = $payby ? " ($payby$payinfo)" : '';
my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' );