From: ivan Date: Thu, 13 Jun 2002 23:28:14 +0000 (+0000) Subject: phone number search (Bug#422) X-Git-Tag: freeside_1_4_0_pre14~10 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=141003fc6cab41daf1a4a697a610c953ec42906e phone number search (Bug#422) --- diff --git a/httemplate/index.html b/httemplate/index.html index 5e47b9464..c3e9ae45c 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -31,8 +31,9 @@
Customer # or all customers by customer number
Last name or all customers by last name
Company or all customers by company
-
Username or all accounts by username
-
Domain or all domains
+
Phone #
+
Username or all accounts by username
+
Domain or all domains

diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 247cf8fd6..1bd5fb60a 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -200,6 +200,8 @@ if ( $cgi->param('browse') if $cgi->param('last_on') && $cgi->param('last_text'); push @cust_main, @{&companysearch} if $cgi->param('company_on') && $cgi->param('company_text'); + push @cust_main, @{&phonesearch} + if $cgi->param('phone_on') && $cgi->param('phone_text'); push @cust_main, @{&referralsearch} if $cgi->param('referral_custnum'); @@ -606,4 +608,30 @@ sub companysearch { \@cust_main; } + +sub phonesearch { + my @cust_main; + + my $phone = $cgi->param('phone_text'); + + #false laziness with Record::ut_phonen, only works with US/CA numbers... + $phone =~ s/\D//g; + $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ + or eidiot gettext('illegal_phone'). ": $phone"; + $phone = "$1-$2-$3"; + $phone .= " x$4" if $4; + + my @fields = qw(daytime night fax); + push @fields, qw(ship_daytime ship_night ship_fax) + if defined dbdef->table('cust_main')->column('ship_last'); + + for my $field ( @fields ) { + push @cust_main, qsearch ( 'cust_main', + { $field => { 'op' => 'LIKE', + 'value' => "$phone%" } } ); + } + + \@cust_main; +} + %>