1 % if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) {
2 % if ( $cgi->param('quickpay') eq 'yes' ) {
3 <% $cgi->redirect(popurl(2). "edit/cust_pay.cgi?quickpay=yes;custnum=". $cust_main[0]->custnum) %>
5 <% $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum) %>
8 %} elsif ( scalar(@cust_main) == 0 ) {
9 % errorpage(emt("No matching customers found!"));
10 % } # errorpage quits, so we don't need an 'else' below
12 <& /elements/header.html, mt("Customer Search Results"), '' &>
13 % $total ||= scalar(@cust_main);
15 <% mt("[_1] matching customers found",$total) |h %>
17 % my $pager = include( '/elements/pager.html',
18 % 'offset' => $offset,
19 % 'num_rows' => scalar(@cust_main),
21 % 'maxrecords' => $maxrecords,
24 % unless ( $cgi->param('cancelled') ) {
26 % if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
27 % || ( $conf->exists('hidecancelledcustomers')
28 % && ! $cgi->param('showcancelledcustomers')
31 % $cgi->param('showcancelledcustomers', 1);
32 % $linklabel = 'show';
34 % $cgi->param('showcancelledcustomers', 0);
35 % $linklabel = 'hide';
37 % $cgi->param('offset', 0);
38 ( <a href="<% $cgi->self_url %>"><% mt("$linklabel canceled customers") |h %></a> )
41 % if ( $cgi->param('referral_custnum') ) {
42 % $cgi->param('referral_custnum') =~ /^(\d+)$/
43 % or errorpage(emt("Illegal referral_custnum"));
44 % my $referral_custnum = $1;
45 % my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } );
47 function changed(what) {
52 % # XXX: translate this section...hard due to "referrals of CUST SELECT levels deep" construction
54 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $referral_custnum %>">
55 % my $refcustlabel = "$referral_custnum: " .
56 % ( $cust_main->company || $cust_main->last. ', '. $cust_main->first );
58 <A HREF="<% popurl(2)."view/cust_main.cgi?$referral_custnum" %>"><% $refcustlabel |h %></A>
59 <SELECT NAME="referral_depth" SIZE="1" onChange="changed(this)">';
62 % $cgi->param('referral_depth') =~ /^(\d*)$/
63 % or errorpage(emt("Illegal referral_depth"));
64 % my $referral_depth = $1;
66 % foreach my $depth ( 1 .. $max ) {
67 % my $selected = ($depth == $referral_depth) ? 'SELECTED' : '';
68 <OPTION <% $selected %>><% $depth %>
74 % my @custom_priorities = ();
75 % if ( $conf->config('ticket_system-custom_priority_field')
76 % && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) {
77 % @custom_priorities =
78 % $conf->config('ticket_system-custom_priority_field-values');
81 <BR><BR><% $pager.include('/elements/table-grid.html') %>
83 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('#') |h %></TH>
84 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
85 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Name') |h %></TH>
86 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Company') |h %></TH>
88 %foreach my $addl_header ( @addl_headers ) {
89 <TH CLASS="grid" BGCOLOR="#cccccc"><% $addl_header %></TH>
92 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Packages') |h %></TH>
93 <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN="2"><% mt('Services') |h %></TH>
96 % my $bgcolor1 = '#eeeeee';
97 % my $bgcolor2 = '#ffffff';
100 % my(%saw,$cust_main);
101 % foreach $cust_main (
102 % sort $sortby grep(!$saw{$_->custnum}++, @cust_main)
105 % if ( $bgcolor eq $bgcolor1 ) {
106 % $bgcolor = $bgcolor2;
108 % $bgcolor = $bgcolor1;
111 % my($custnum,$last,$first,$company)=(
112 % $cust_main->custnum,
113 % $cust_main->getfield('last'),
114 % $cust_main->getfield('first'),
115 % $cust_main->company,
120 % foreach my $cust_pkg ( @{$all_pkgs{$custnum}} ) {
121 % my %cust_svc_by_svcpart;
123 % #local($FS::part_pkg::cache_enabled) = 1; #for $cust_pkg->part_svc
124 % local($FS::cust_svc::cache_enabled) = 1; #for $cust_svc->part_svc
125 % #local($FS::pkg_svc::cache_enabled) = 1; #for $pkg_svc->part_svc
126 % foreach my $part_svc (
127 % #$cust_pkg->part_svc( summarize_size=>$large_pkg_size )
129 % 'select' => 'part_svc.*, COUNT(*) AS num_cust_svc',
130 % 'table' => 'part_svc',
131 % 'addl_from' => 'LEFT JOIN cust_svc USING ( svcpart )',
132 % 'extra_sql' => 'WHERE pkgnum = ? '.
133 % ' GROUP BY '. join(', ',
134 % map "part_svc.$_", fields('part_svc')
136 % 'extra_param' => [ [$cust_pkg->pkgnum,'int'] ],
139 % my $svcpart = $part_svc->svcpart;
140 % my $num_cust_svc = $part_svc->num_cust_svc;
141 % if ( $large_pkg_size > 0 and $num_cust_svc >= $large_pkg_size ) {
142 % # don't retrieve the cust_svc records, just stash the
143 % # part_svc and num_cust_svc for later
144 % $cust_svc_by_svcpart{$svcpart} =
145 % [ 'summarize', $part_svc, $num_cust_svc ];
148 % elsif ( $num_cust_svc ) {
149 % #$cust_svc_by_svcpart{$svcpart} = $part_svc->cust_pkg_svc;
150 % #further optimization opportunities: don't need to re-pull in another $part_svc object, sorting this is expensive, etc.
151 % $cust_svc_by_svcpart{$svcpart} = [ $cust_pkg->cust_svc($part_svc->svcpart) ];
152 % $rows += $num_cust_svc;
154 % } #foreach $part_svc
155 % $rows ||= 1; # in case the package has no services
156 % push @all_cust_svc, \%cust_svc_by_svcpart;
157 % push @pkg_rowspans, $rows;
158 % } #foreach $cust_pkg
159 % my $rowspan = List::Util::sum(@pkg_rowspans) || 1;
162 % if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) {
163 % $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum;
165 % $view = $p. 'view/cust_main.cgi?'. $custnum;
167 % my $pcompany = $company
168 % ? qq!<A HREF="$view"><FONT SIZE=-1>!. encode_entities($company). '</FONT></A>'
169 % : '<FONT SIZE=-1> </FONT>';
171 % my $status_label = $cust_main->status_label;
172 % my $statuscolor = $cust_main->statuscolor;
175 <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
176 <A HREF="<% $view %>"><FONT SIZE=-1><% $cust_main->display_custnum %></FONT></A>
178 <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
179 <FONT SIZE="-1" COLOR="#<% $statuscolor %>"><B><% $status_label %></B></FONT>
181 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
182 <A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" |h %></FONT></A>
184 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
188 % foreach my $addl_col ( @addl_cols ) {
189 % if ( $addl_col eq 'tickets' ) {
190 % if ( @custom_priorities ) {
192 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right>
194 <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
195 % foreach my $priority ( @custom_priorities, '' ) {
197 % FS::TicketSystem->num_customer_tickets($custnum,$priority);
199 % $ahref= '<A HREF="'.
200 % FS::TicketSystem->href_customer_tickets($custnum,$priority).
206 <FONT SIZE=-1><% $ahref.$num %></A></FONT>
209 <FONT SIZE=-1><% $ahref %><% $priority || '<i>('.emt('none').')</i>' %></A></FONT>
215 <TH ALIGN=right STYLE="border-top: dashed 1px black">
218 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right>
222 % $ahref = '<A HREF="'.
223 % FS::TicketSystem->href_customer_tickets($custnum).
225 % if $cust_main->get($addl_col);
228 <% $ahref %><% $cust_main->get($addl_col) %></A>
229 % if ( @custom_priorities ) {
232 <TH ALIGN=left STYLE="border-top: dashed 1px black">
233 <FONT SIZE=-1><% ${ahref} %>Total</A><FONT>
242 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right><FONT SIZE=-1>
243 <% $cust_main->get($addl_col) %>
250 % foreach ( @{$all_pkgs{$custnum}} ) {
251 % local($FS::cust_svc::cache_enabled) = 1; #for $cust_svc->part_svc
252 % my $pkgnum = $_->pkgnum;
253 % my $part_pkg = $_->part_pkg;
255 % my $pkg_comment = $part_pkg->pkg_comment( cust_pkg=>$_, nopkgpart=>1 );
256 % my $show = $default_customer_view =~ /^(jumbo|packages)$/
258 % : ';show=packages';
259 % my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
260 % my $pkgview = "${p}view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag";
261 % # cust_svc stuff, built earlier
262 % my %cust_svc_by_svcpart = %{ shift @all_cust_svc };
263 % my $pkg_rowspan = shift @pkg_rowspans;
265 <% $n1 %><TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN="<% $pkg_rowspan%>">
266 <A HREF="<% $pkgview %>"><FONT SIZE=-1><% $pkg_comment |h %></FONT></A>
270 % my $td = '<TD CLASS="grid" BGCOLOR="'.$bgcolor.'">';
272 % foreach my $svcpart ( sort keys %cust_svc_by_svcpart ) { #sort order?
273 % my $these = $cust_svc_by_svcpart{$svcpart};
274 % if ( $these->[0] eq 'summarize' ) {
275 % my $part_svc = $these->[1];
276 % my $num_cust_svc = $these->[2];
279 % # link opens a new search for this pkgnum/svcpart combo
280 % my $href = $p.'search/cust_pkg_svc.html?svcpart='.$svcpart.
281 % ';pkgnum='.$pkgnum;
283 <A HREF="<% $href %>"><% $part_svc->svc %></A>
286 <A HREF="<% $href %>"><B>(<% mt("view all [_1]", $num_cust_svc) |h %>)</B></A>
290 <% $td %><& /elements/search-cust_svc.html,
291 'svcpart' => $svcpart,
293 'svcdb' => $part_svc->svcdb,
297 % elsif ( scalar @$these ) { # do not summarize
298 % foreach my $cust_svc ( @$these ) {
299 % my $part_svc = $cust_svc->part_svc;
302 <% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %>
305 <% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %>
308 % } #foreach $cust_svc
310 % } # foreach $svcpart
312 % unless ( %cust_svc_by_svcpart ) {
313 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=2> </TD>
319 % unless ( @{$all_pkgs{$custnum}} ) {
320 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=3> </TD>
328 <& /elements/footer.html &>
330 my $curuser = $FS::CurrentUser::CurrentUser;
333 unless $curuser->access_right('List all customers');
335 my $conf = new FS::Conf;
336 my $maxrecords = $conf->config('maxsearchrecordsperpage');
337 # summarize more than this many services of the same svcpart
338 my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size') || 0;
340 my $default_customer_view = $curuser->default_customer_view;
343 $limit .= "LIMIT $maxrecords" if $maxrecords;
345 my $offset = $cgi->param('offset') || 0;
346 $limit .= " OFFSET $offset" if $offset;
350 my(@cust_main, $sortby, $orderby);
352 my @addl_headers = ();
354 if ( $cgi->param('browse')
355 || $cgi->param('otaker_on')
356 || $cgi->param('agentnum_on')
361 if ( $cgi->param('browse') ) {
362 my $query = $cgi->param('browse');
363 if ( $query eq 'custnum' ) {
364 if ( $conf->exists('cust_main-default_agent_custid') ) {
365 $sortby=\*display_custnum_sort;
366 $orderby = "ORDER BY CASE WHEN agent_custid IS NOT NULL
367 AND agent_custid != ''
368 AND agent_custid ". regexp_sql. " '^[0-9]+\$'
369 THEN CAST(agent_custid AS BIGINT)
373 $sortby=\*custnum_sort;
374 $orderby = "ORDER BY custnum";
376 } elsif ( $query eq 'last' ) {
378 $orderby = "ORDER BY LOWER(last || ' ' || first)";
379 } elsif ( $query eq 'company' ) {
380 $sortby=\*company_sort;
381 $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )";
382 } elsif ( $query eq 'tickets' ) {
383 $sortby = \*tickets_sort;
384 $orderby = "ORDER BY tickets DESC";
385 push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets";
386 push @addl_headers, 'Tickets';
387 push @addl_cols, 'tickets';
388 } elsif ( $query eq 'uspsunvalid' ) {
389 $search{'country'} = 'US';
390 $sortby=\*custnum_sort;
391 $orderby = "ORDER BY custnum";
393 die "unknown browse field $query";
396 $sortby = \*last_sort; #??
397 $orderby = "ORDER BY LOWER(last || ' ' || first)"; #??
400 if ( $cgi->param('otaker_on') ) {
402 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
403 $cgi->param('otaker') =~ /^(\w{1,32})$/ or errorpage("Illegal otaker");
404 $search{otaker} = $1;
405 } elsif ( $cgi->param('agentnum_on') ) {
406 $cgi->param('agentnum') =~ /^(\d+)$/ or errorpage("Illegal agentnum");
407 $search{agentnum} = $1;
414 if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
415 || ( $conf->exists('hidecancelledcustomers')
416 && ! $cgi->param('showcancelledcustomers') )
418 push @qual, FS::cust_main->uncancel_sql;
421 push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled');
422 push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect');
423 push @qual, FS::cust_main->ordered_sql if $cgi->param('ordered');
424 push @qual, FS::cust_main->active_sql if $cgi->param('active');
425 push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive');
426 push @qual, FS::cust_main->susp_sql if $cgi->param('suspended');
429 my $qual = join(' AND ',
430 map { "$_ = ". dbh->quote($search{$_}) } keys %search );
432 my $addl_qual = join(' AND ', @qual);
434 #here is the agent virtualization
435 $addl_qual .= ( $addl_qual ? ' AND ' : '' ).
436 $FS::CurrentUser::CurrentUser->agentnums_sql;
438 if ( $cgi->param('browse') && $cgi->param('browse') eq 'uspsunvalid' ) {
439 $addl_qual .= ' AND ( length(zip) < 9 OR upper(address1) != address1 OR upper(city) != city ) ';
443 $qual .= ' AND ' if $qual;
447 $qual = " WHERE $qual" if $qual;
448 my $statement = "SELECT COUNT(*) FROM cust_main $qual";
449 my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement";
450 $sth->execute or die "Error executing \"$statement\": ". $sth->errstr;
452 $total = $sth->fetchrow_arrayref->[0];
456 $addl_qual = " AND $addl_qual";
458 $addl_qual = " WHERE $addl_qual";
464 $select = 'cust_main.*, '. join (', ', @select);
469 @cust_main = qsearch('cust_main', \%search, $select,
470 "$addl_qual $orderby $limit" );
474 $sortby = \*last_sort;
476 push @cust_main, @{&custnumsearch}
477 if $cgi->param('custnum_on') && $cgi->param('custnum_text');
478 push @cust_main, @{&cardsearch}
479 if $cgi->param('card_on') && $cgi->param('card');
480 push @cust_main, @{&lastsearch}
481 if $cgi->param('last_on') && $cgi->param('last_text');
482 push @cust_main, @{&companysearch}
483 if $cgi->param('company_on') && $cgi->param('company_text');
484 push @cust_main, @{&address2search}
485 if $cgi->param('address2_on') && $cgi->param('address2_text');
486 push @cust_main, @{&phonesearch}
487 if $cgi->param('phone_on') && $cgi->param('phone_text');
488 push @cust_main, @{&referralsearch}
489 if $cgi->param('referral_custnum');
491 if ( $cgi->param('company_on') && $cgi->param('company_text') ) {
492 $sortby = \*company_sort;
493 push @cust_main, @{&companysearch};
496 if ( $cgi->param('search_cust') ) {
497 $sortby = \*company_sort;
498 $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )";
499 push @cust_main, smart_search(
500 'search' => scalar($cgi->param('search_cust')),
504 @cust_main = grep { $_->status ne 'cancelled' } @cust_main
505 if ! $cgi->param('cancelled')
507 $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
508 || ( $conf->exists('hidecancelledcustomers')
509 && ! $cgi->param('showcancelledcustomers') )
513 @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
517 if ( scalar(@cust_main) > 1 || $cgi->param('referral_custnum') ) {
519 my $pkgs_method = $conf->exists('hidecancelledpackages')
523 #false laziness w/httemplate/view/cust_main/packages.html
524 my $select = join(',',
527 'setup_option.optionvalue AS _opt_setup_fee',
528 'recur_option.optionvalue AS _opt_recur_fee',
531 my $addl_from = ' LEFT JOIN part_pkg USING ( pkgpart ) '.
532 FS::part_pkg->join_options_sql;
534 local($FS::cust_pkg::cache_enabled) = 1; #for $cust_pkg->part_pkg
535 %all_pkgs = map { $_->custnum =>
536 [ $_->$pkgs_method({ select => $select,
537 addl_from => $addl_from,
538 skip_label_sort => 1,
547 lc($a->getfield('last')) cmp lc($b->getfield('last'))
548 || lc($a->first) cmp lc($b->first);
552 return -1 if $a->company && ! $b->company;
553 return 1 if ! $a->company && $b->company;
554 lc($a->company) cmp lc($b->company)
555 || lc($a->getfield('last')) cmp lc($b->getfield('last'))
556 || lc($a->first) cmp lc($b->first);;
559 sub display_custnum_sort {
560 $a->display_custnum <=> $b->display_custnum;
564 $a->getfield('custnum') <=> $b->getfield('custnum');
568 $b->getfield('tickets') <=> $a->getfield('tickets');
573 my $custnum = $cgi->param('custnum_text');
575 $custnum =~ /^(\d{1,23})$/ or errorpage(emt("Illegal customer number"));
578 [ qsearchs('cust_main', { 'custnum' => $custnum } ) ];
583 my($card)=$cgi->param('card');
585 $card =~ /^(\d{13,16}|\d{8,9})$/ or errorpage(emt("Illegal card number"));
588 [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}),
589 qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'})
594 $cgi->param('referral_custnum') =~ /^(\d+)$/
595 or errorpage("Illegal referral_custnum");
596 my $cust_main = qsearchs('cust_main', { 'custnum' => $1 } )
597 or errorpage(emt("Customer [_1] not found",$1));
599 if ( $cgi->param('referral_depth') ) {
600 $cgi->param('referral_depth') =~ /^(\d+)$/
601 or errorpage(emt("Illegal referral_depth"));
606 [ $cust_main->referral_cust_main($depth) ];
612 foreach ( $cgi->param('last_type') ) {
616 $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/
617 or errorpage(emt("Illegal last name"));
620 if ( $last_type{'Exact'} || $last_type{'Fuzzy'} ) {
621 push @cust_main, qsearch( 'cust_main',
622 { 'last' => { 'op' => 'ILIKE',
623 'value' => $last } } );
625 push @cust_main, qsearch( 'cust_main',
626 { 'ship_last' => { 'op' => 'ILIKE',
627 'value' => $last } } )
628 if defined dbdef->table('cust_main')->column('ship_last');
631 if ( $last_type{'Substring'} || $last_type{'All'} ) {
633 push @cust_main, qsearch( 'cust_main',
634 { 'last' => { 'op' => 'ILIKE',
635 'value' => "%$last%" } } );
637 push @cust_main, qsearch( 'cust_main',
638 { 'ship_last' => { 'op' => 'ILIKE',
639 'value' => "%$last%" } } )
640 if defined dbdef->table('cust_main')->column('ship_last');
644 if ( $last_type{'Fuzzy'} || $last_type{'All'} ) {
645 push @cust_main, FS::cust_main::Search->fuzzy_search( { 'last' => $last } );
655 foreach ( $cgi->param('company_type') ) {
659 $cgi->param('company_text') =~
660 /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
661 or errorpage(emt("Illegal company"));
664 if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) {
665 push @cust_main, qsearch( 'cust_main',
666 { 'company' => { 'op' => 'ILIKE',
667 'value' => $company } } );
669 push @cust_main, qsearch( 'cust_main',
670 { 'ship_company' => { 'op' => 'ILIKE',
671 'value' => $company } } )
672 if defined dbdef->table('cust_main')->column('ship_last');
675 if ( $company_type{'Substring'} || $company_type{'All'} ) {
677 push @cust_main, qsearch( 'cust_main',
678 { 'company' => { 'op' => 'ILIKE',
679 'value' => "%$company%" } } );
681 push @cust_main, qsearch( 'cust_main',
682 { 'ship_company' => { 'op' => 'ILIKE',
683 'value' => "%$company%" } })
684 if defined dbdef->table('cust_main')->column('ship_last');
688 if ( $company_type{'Fuzzy'} || $company_type{'All'} ) {
689 push @cust_main, FS::cust_main::Search->fuzzy_search( { 'company' => $company } );
692 if ($company_type{'Sound-alike'}) {
701 $cgi->param('address2_text') =~
702 /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
703 or errorpage(emt("Illegal address2"));
706 # matching at the start or end of an address, but not in the middle
708 foreach my $toggle (0,1) {
709 push @where, 'LOWER(cust_location.address2) LIKE LOWER('
710 . dbh->quote($toggle ? $address2 . '%' : '%' . $address2)
714 push @cust_main, qsearch({
716 'table' => 'cust_main',
717 'addl_from' => 'JOIN cust_location ON (cust_location.locationnum IN (cust_main.bill_locationnum, cust_main.ship_locationnum))',
718 'extra_sql' => 'WHERE ' . join(' OR ',@where),
727 my $phone = $cgi->param('phone_text');
730 if ( $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ ) {
732 $phone .= " x$4" if $4;
733 } elsif ( $phone =~ /^(\d{3})(\d{4})$/ ) {
735 } elsif ( $phone =~ /^(\d{3,4})$/ ) {
738 errorpage(gettext('illegal_phone'). ": $phone");
741 my @fields = qw(daytime night fax);
742 push @fields, qw(ship_daytime ship_night ship_fax)
743 if defined dbdef->table('cust_main')->column('ship_last');
745 for my $field ( @fields ) {
746 push @cust_main, qsearch ( 'cust_main',
747 { $field => { 'op' => 'LIKE',
748 'value' => "%$phone%" } } );