RT# 77532 - can search cust main phone numbers in advanced customer search
authorChristopher Burger <burgerc@freeside.biz>
Fri, 24 May 2019 14:51:08 +0000 (10:51 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Tue, 28 May 2019 16:24:28 +0000 (12:24 -0400)
Conflicts:
httemplate/search/cust_main.html
httemplate/search/report_cust_main.html

FS/FS/cust_main/Search.pm
httemplate/search/cust_main.html
httemplate/search/elements/cust_main_phones.html [new file with mode: 0644]
httemplate/search/report_cust_main.html

index fcb3efc..8073ce1 100644 (file)
@@ -791,6 +791,21 @@ sub search {
     )";
   }
 
+  ##
+  # phones
+  ##
+
+  foreach my $phonet (qw(daytime night mobile)) {
+    if ($params->{$phonet}) {
+      $params->{$phonet} =~ s/\D//g;
+      $params->{$phonet} =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/
+        or next;
+      my $phonen = "$1-$2-$3";
+      if ($4) { push @where, "cust_main.".$phonet." = '".$phonen." x$4'"; }
+      else { push @where, "cust_main.".$phonet." like '".$phonen."%'"; }
+    }
+  }
+
   ###
   # refnum
   ###
index 62e4a27..4d5d18f 100755 (executable)
@@ -51,6 +51,7 @@ my %search_hash = ();
 my @scalars = qw (
   agentnum salesnum status
   address city county state zip country location_history
+  daytime night mobile
   paydate_year paydate_month invoice_terms
   no_censustract with_geocode with_email tax no_tax POST no_POST
   custbatch usernum
diff --git a/httemplate/search/elements/cust_main_phones.html b/httemplate/search/elements/cust_main_phones.html
new file mode 100644 (file)
index 0000000..de62119
--- /dev/null
@@ -0,0 +1,27 @@
+<TR>
+  <TD VALIGN="top" ALIGN="right"><% mt('Phones') |h %></TD>
+  <TD COLSPAN=6>
+    <TABLE CELLSPACING=0 CELLPADDING=0>
+      <TR>
+% foreach my $phone (qw(daytime night mobile)) {
+        <TD>
+          <INPUT TYPE="text"
+                 NAME="<% $phone %>"
+                 VALUE=""
+                 SIZE=18
+          >
+          <BR><FONT SIZE=-1 COLOR="#333333"><% mt($phone_label{$phone}) |h %></FONT>
+        </TD>
+        <TD>&nbsp;</TD>
+% }
+      </TR>
+    </TABLE>
+  </TD>
+</TR>
+<%init>
+my %phone_label = (
+  daytime => 'Day Phone',
+  night   => 'Night Phone',
+  mobile  => 'Mobile Phone',
+);
+</%init>
\ No newline at end of file
index 47d46e1..18b0fd1 100755 (executable)
       </TD>
     </TR>
 
+    <& elements/cust_main_phones.html &>
+
     <TR>
       <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
     </TR>