summaryrefslogtreecommitdiff
path: root/httemplate/search/cust_bill.html
diff options
context:
space:
mode:
authorivan <ivan>2004-04-23 12:19:40 +0000
committerivan <ivan>2004-04-23 12:19:40 +0000
commit87227cd405166484ca7b791b2bd3c8829ce8d969 (patch)
treeb838747ae5773879bb023b6b39ae904a3f29fefb /httemplate/search/cust_bill.html
parent5cd995865b91204f7ce9233a8ba4d5eee62f9be4 (diff)
credit report, add some links to sales/credits/receipts summary, move payment search to template
Diffstat (limited to 'httemplate/search/cust_bill.html')
-rwxr-xr-xhttemplate/search/cust_bill.html23
1 files changed, 16 insertions, 7 deletions
diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html
index 51241575c..27b147108 100755
--- a/httemplate/search/cust_bill.html
+++ b/httemplate/search/cust_bill.html
@@ -1,22 +1,30 @@
<%
my( $count_query, $sql_query );
- if ( $cgi->keywords ) {
- my($query) = $cgi->keywords;
+ if ( $cgi->param('begin') || $cgi->param('end') || $cgi->keywords ) {
+
my $owed =
"charged - ( SELECT COALESCE(SUM(amount),0) FROM cust_bill_pay
WHERE cust_bill_pay.invnum = cust_bill.invnum )
- ( SELECT COALESCE(SUM(amount),0) FROM cust_credit_bill
WHERE cust_credit_bill.invnum = cust_bill.invnum )";
+
my @where;
- my $orderby = '';
+ my $orderby = 'ORDER BY cust_bill._date';
+
+ if ( $cgi->param('begin') =~ /^(\d+)$/ ) {
+ push @where, "cust_bill._date >= $1",
+ }
+ if ( $cgi->param('end') =~ /^(\d+)$/ ) {
+ push @where, "cust_bill._date < $1",
+ }
+
+ my($query) = $cgi->keywords;
if ( $query =~ /^(OPEN(\d*)_)?(invnum|date|custnum)$/ ) {
my($open, $days, $field) = ($1, $2, $3);
$field = "_date" if $field eq 'date';
$orderby = "ORDER BY cust_bill.$field";
push @where, "0 != $owed" if $open;
push @where, "cust_bill._date < ". (time-86400*$days) if $days;
- } else {
- die "unknown query string $query";
}
my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : '';
@@ -50,12 +58,13 @@
'name' => 'invoices',
'query' => $sql_query,
'count_query' => $count_query,
- 'count_addl' => [ '$%.2f total amount',
+ 'count_addl' => [ '$%.2f total invoiced',
'$%.2f total outstanding balance',
],
'redirect' => $link,
'header' =>
- [ '', qw(Balance Amount Date ), 'Contact name', 'Company' ],
+ [ 'Invoice #', qw(Balance Amount Date), 'Contact name',
+ 'Company' ],
'fields' => [
'invnum',
sub { sprintf('$%.2f', shift->get('owed') ) },