add payby selection to adv. customer search
[freeside.git] / httemplate / search / cust_main.html
index 1889b6c..5fb5dda 100755 (executable)
@@ -68,6 +68,26 @@ foreach my $field (qw( signupdate )) {
 
 }
 
+###
+# payby
+###
+
+my @payby = grep /^([A-Z]{4})$/, $cgi->param('payby');
+if ( @payby ) {
+  push @where, '( '. join(' OR ', map "cust_main.payby = '$_'", @payby). ' )';
+}
+
+###
+
+##
+# 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 +103,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) = ();