summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/ConfDefaults.pm2
-rw-r--r--FS/FS/UI/Web.pm13
-rwxr-xr-xhttemplate/search/cust_main.html15
-rwxr-xr-xhttemplate/search/report_cust_main.html6
4 files changed, 32 insertions, 4 deletions
diff --git a/FS/FS/ConfDefaults.pm b/FS/FS/ConfDefaults.pm
index e3257e2..7978259 100644
--- a/FS/FS/ConfDefaults.pm
+++ b/FS/FS/ConfDefaults.pm
@@ -53,6 +53,8 @@ sub cust_fields_avail { (
'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Fax number | Invoicing email(s) | Payment Type' =>
'custnum | Status | Last, First | Company | (all address fields ) | ( all phones ) | Invoicing email(s) | Payment Type',
+ 'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Fax number | Invoicing email(s) | Payment Type | Current Balance' =>
+ 'custnum | Status | Last, First | Company | (all address fields ) | ( all phones ) | Invoicing email(s) | Payment Type | Current Balance',
); }
diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm
index 3f786dd..6a97f96 100644
--- a/FS/FS/UI/Web.pm
+++ b/FS/FS/UI/Web.pm
@@ -5,6 +5,7 @@ use vars qw($DEBUG @ISA @EXPORT_OK $me);
use Exporter;
use FS::Conf;
use FS::Record qw(dbdef);
+use FS::cust_main; # are sql_balance and sql_date_balance in the right module?
#use vars qw(@ISA);
#use FS::UI
@@ -163,7 +164,7 @@ sub parse_lt_gt {
warn "checking for ${field}_$op field\n"
if $DEBUG;
- if ( $cgi->param($field."_$op") =~ /^\s*\$?\s*([\d\,\s]+(\.\d\d)?)\s*$/ ) {
+ if ( $cgi->param($field."_$op") =~ /^\s*\$?\s*(-?[\d\,\s]+(\.\d\d)?)\s*$/ ) {
my $num = $1;
$num =~ s/[\,\s]+//g;
@@ -223,6 +224,7 @@ sub cust_header {
'Fax number' => 'fax',
'Invoicing email(s)' => 'invoicing_list_emailonly_scalar',
'Payment Type' => 'payby',
+ 'Current Balance' => 'current_balance',
);
my %header2colormethod = (
@@ -298,9 +300,14 @@ sub cust_sql_fields {
#inefficientish, but tiny lists and only run once per page
push @fields,
grep { my $field = $_; grep { $_ eq $field } @cust_fields }
- qw( address1 address2 city state zip daytime night );
+ qw( address1 address2 city state zip daytime night fax payby );
- map "cust_main.$_", @fields;
+ my @extra_fields = ();
+ if (grep { $_ eq 'current_balance' } @cust_fields) {
+ push @extra_fields, FS::cust_main->balance_sql . " AS current_balance";
+ }
+
+ map("cust_main.$_", @fields), @extra_fields;
}
=item cust_fields OBJECT [ CUST_FIELDS_VALUE ]
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index 1889b6c..00fd153 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -69,6 +69,15 @@ foreach my $field (qw( signupdate )) {
}
##
+# amounts
+##
+
+my $balance_sql = FS::cust_main->balance_sql();
+
+push @where, map { s/current_balance/$balance_sql/; $_ }
+ FS::UI::Web::parse_lt_gt($cgi, 'current_balance');
+
+##
# setup queries, subs, etc. for the search
##
@@ -83,7 +92,11 @@ my $addl_from = 'LEFT JOIN cust_pkg USING ( custnum ) ';
my $count_query = "SELECT COUNT(*) FROM cust_main $extra_sql";
-my $select = '*';
+my $select = join(', ',
+ 'cust_main.custnum',
+ FS::UI::Web::cust_sql_fields($cgi->param('cust_fields')),
+ );
+
my (@extra_headers) = ();
my (@extra_fields) = ();
diff --git a/httemplate/search/report_cust_main.html b/httemplate/search/report_cust_main.html
index 9e8cc81..50bc67b 100755
--- a/httemplate/search/report_cust_main.html
+++ b/httemplate/search/report_cust_main.html
@@ -30,6 +30,12 @@
% }
+ <% include( '/elements/tr-input-lessthan_greaterthan.html',
+ label => 'Current Balance',
+ field => 'current_balance',
+ )
+ %>
+
<TR>
<TD ALIGN="right" VALIGN="center">Include cancelled packages</TD>
<TD><INPUT TYPE="checkbox" NAME="cancelled_pkgs"></TD>