2 % unless $FS::CurrentUser::CurrentUser->access_right('List customers');
4 %my $conf = new FS::Conf;
5 %my $maxrecords = $conf->config('maxsearchrecordsperpage');
9 %#my $monsterjoin = <<END;
10 %#cust_main left outer join (
11 %# ( cust_pkg left outer join part_pkg using(pkgpart)
12 %# ) left outer join (
15 %# ( cust_svc left outer join part_svc using (svcpart)
16 %# ) left outer join svc_acct using (svcnum)
17 %# ) left outer join svc_domain using(svcnum)
18 %# ) left outer join svc_forward using(svcnum)
23 %#my $monsterjoin = <<END;
24 %#cust_main left outer join (
25 %# ( cust_pkg left outer join part_pkg using(pkgpart)
26 %# ) left outer join (
29 %# ( cust_svc left outer join part_svc using (svcpart)
30 %# ) left outer join (
31 %# svc_acct left outer join (
32 %# select svcnum, domain, catchall from svc_domain
33 %# ) as svc_acct_domsvc (
34 %# svc_acct_svcnum, svc_acct_domain, svc_acct_catchall
35 %# ) on svc_acct.domsvc = svc_acct_domsvc.svc_acct_svcnum
37 %# ) left outer join svc_domain using(svcnum)
38 %# ) left outer join svc_forward using(svcnum)
44 %$limit .= "LIMIT $maxrecords" if $maxrecords;
46 %my $offset = $cgi->param('offset') || 0;
47 %$limit .= " OFFSET $offset" if $offset;
51 %my(@cust_main, $sortby, $orderby);
53 %my @addl_headers = ();
55 %if ( $cgi->param('browse')
56 % || $cgi->param('otaker_on')
57 % || $cgi->param('agentnum_on')
62 % if ( $cgi->param('browse') ) {
63 % my $query = $cgi->param('browse');
64 % if ( $query eq 'custnum' ) {
65 % $sortby=\*custnum_sort;
66 % $orderby = "ORDER BY custnum";
67 % } elsif ( $query eq 'last' ) {
68 % $sortby=\*last_sort;
69 % $orderby = "ORDER BY LOWER(last || ' ' || first)";
70 % } elsif ( $query eq 'company' ) {
71 % $sortby=\*company_sort;
72 % $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )";
73 % } elsif ( $query eq 'tickets' ) {
74 % $sortby = \*tickets_sort;
75 % $orderby = "ORDER BY tickets DESC";
76 % push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets";
77 % push @addl_headers, 'Tickets';
78 % push @addl_cols, 'tickets';
80 % die "unknown browse field $query";
83 % $sortby = \*last_sort; #??
84 % $orderby = "ORDER BY LOWER(last || ' ' || first)"; #??
87 % if ( $cgi->param('otaker_on') ) {
89 % unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
90 % $cgi->param('otaker') =~ /^(\w{1,32})$/ or errorpage("Illegal otaker");
91 % $search{otaker} = $1;
92 % } elsif ( $cgi->param('agentnum_on') ) {
93 % $cgi->param('agentnum') =~ /^(\d+)$/ or errorpage("Illegal agentnum");
94 % $search{agentnum} = $1;
96 %# die "unknown query...";
101 % my $ncancelled = '';
103 % if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
104 % || ( $conf->exists('hidecancelledcustomers')
105 % && ! $cgi->param('showcancelledcustomers') )
107 % #grep { $_->ncancelled_pkgs || ! $_->all_pkgs }
108 % push @qual, FS::cust_main->uncancel_sql;
112 % push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled');
113 % push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect');
114 % push @qual, FS::cust_main->active_sql if $cgi->param('active');
115 % push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive');
116 % push @qual, FS::cust_main->susp_sql if $cgi->param('suspended');
119 % my $qual = join(' AND ',
120 % map { "$_ = ". dbh->quote($search{$_}) } keys %search );
122 % my $addl_qual = join(' AND ', @qual);
124 % #here is the agent virtualization
125 % $addl_qual .= ( $addl_qual ? ' AND ' : '' ).
126 % $FS::CurrentUser::CurrentUser->agentnums_sql;
128 % if ( $addl_qual ) {
129 % $qual .= ' AND ' if $qual;
130 % $qual .= $addl_qual;
133 % $qual = " WHERE $qual" if $qual;
134 % my $statement = "SELECT COUNT(*) FROM cust_main $qual";
135 % my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement";
136 % $sth->execute or die "Error executing \"$statement\": ". $sth->errstr;
138 % $total = $sth->fetchrow_arrayref->[0];
140 % if ( $addl_qual ) {
142 % $addl_qual = " AND $addl_qual";
144 % $addl_qual = " WHERE $addl_qual";
150 % $select = 'cust_main.*, '. join (', ', @select);
155 % @cust_main = qsearch('cust_main', \%search, $select,
156 % "$addl_qual $orderby $limit" );
158 %# foreach my $cust_main ( @just_cust_main ) {
160 %# my @one_cust_main;
161 %# $FS::Record::DEBUG=1;
162 %# ( $cache, @one_cust_main ) = jsearch(
164 %# { 'custnum' => $cust_main->custnum },
170 %# push @cust_main, @one_cust_main;
175 % $sortby = \*last_sort;
177 % push @cust_main, @{&custnumsearch}
178 % if $cgi->param('custnum_on') && $cgi->param('custnum_text');
179 % push @cust_main, @{&cardsearch}
180 % if $cgi->param('card_on') && $cgi->param('card');
181 % push @cust_main, @{&lastsearch}
182 % if $cgi->param('last_on') && $cgi->param('last_text');
183 % push @cust_main, @{&companysearch}
184 % if $cgi->param('company_on') && $cgi->param('company_text');
185 % push @cust_main, @{&address2search}
186 % if $cgi->param('address2_on') && $cgi->param('address2_text');
187 % push @cust_main, @{&phonesearch}
188 % if $cgi->param('phone_on') && $cgi->param('phone_text');
189 % push @cust_main, @{&referralsearch}
190 % if $cgi->param('referral_custnum');
192 % if ( $cgi->param('company_on') && $cgi->param('company_text') ) {
193 % $sortby = \*company_sort;
194 % push @cust_main, @{&companysearch};
197 % if ( $cgi->param('search_cust') ) {
198 % $sortby = \*company_sort;
199 % $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )";
200 % push @cust_main, smart_search( 'search' => $cgi->param('search_cust') );
203 % @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main
204 % if ! $cgi->param('cancelled')
206 % $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
207 % || ( $conf->exists('hidecancelledcustomers')
208 % && ! $cgi->param('showcancelledcustomers') )
212 % @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
216 %if ( $conf->exists('hidecancelledpackages' ) ) {
217 % %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main;
219 % %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main;
223 %if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) {
224 % if ( $cgi->param('quickpay') eq 'yes' ) {
225 % print $cgi->redirect(popurl(2). "edit/cust_pay.cgi?quickpay=yes;custnum=". $cust_main[0]->custnum);
227 % print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum);
230 %} elsif ( scalar(@cust_main) == 0 ) {
233 <!-- mason kludge -->
235 % errorpage("No matching customers found!");
239 <% include('/elements/header.html', "Customer Search Results", '' ) %>
240 % $total ||= scalar(@cust_main);
243 <% $total %> matching customers found
245 % my $pager = include( '/elements/pager.html',
246 % 'offset' => $offset,
247 % 'num_rows' => scalar(@cust_main),
249 % 'maxrecords' => $maxrecords,
252 % unless ( $cgi->param('cancelled') ) {
253 % if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
254 % || ( $conf->exists('hidecancelledcustomers')
255 % && ! $cgi->param('showcancelledcustomers')
258 % $cgi->param('showcancelledcustomers', 1);
259 % $cgi->param('offset', 0);
260 % print qq!( <a href="!. $cgi->self_url. qq!">show!;
262 % $cgi->param('showcancelledcustomers', 0);
263 % $cgi->param('offset', 0);
264 % print qq!( <a href="!. $cgi->self_url. qq!">hide!;
266 % print ' cancelled customers</a> )';
269 % if ( $cgi->param('referral_custnum') ) {
270 % $cgi->param('referral_custnum') =~ /^(\d+)$/
271 % or errorpage("Illegal referral_custnum");
272 % my $referral_custnum = $1;
273 % my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } );
274 % print '<FORM METHOD="GET">'.
275 % qq!<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="$referral_custnum">!.
276 % 'referrals of <A HREF="'. popurl(2).
277 % "view/cust_main.cgi?$referral_custnum\">$referral_custnum: ".
278 % ( $cust_main->company
279 % || $cust_main->last. ', '. $cust_main->first ).
283 % function changed(what) {
284 % what.form.submit();
288 % print ' <SELECT NAME="referral_depth" SIZE="1" onChange="changed(this)">';
289 % my $max = 8; #config file
290 % $cgi->param('referral_depth') =~ /^(\d*)$/
291 % or errorpage("Illegal referral_depth");
292 % my $referral_depth = $1;
294 % foreach my $depth ( 1 .. $max ) {
296 % ' SELECTED'x($depth == $referral_depth),
299 % print "</SELECT> levels deep".
300 % '<NOSCRIPT> <INPUT TYPE="submit" VALUE="change"></NOSCRIPT>'.
304 % my @custom_priorities = ();
305 % if ( $conf->config('ticket_system-custom_priority_field')
306 % && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) {
307 % @custom_priorities =
308 % $conf->config('ticket_system-custom_priority_field-values');
311 % print "<BR><BR>". $pager. include('/elements/table-grid.html'). <<END;
313 % <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
314 % <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
315 % <TH CLASS="grid" BGCOLOR="#cccccc">(bill) name</TH>
316 % <TH CLASS="grid" BGCOLOR="#cccccc">company</TH>
319 %if ( defined dbdef->table('cust_main')->column('ship_last') ) {
321 % <TH CLASS="grid" BGCOLOR="#cccccc">(service) name</TH>
322 % <TH CLASS="grid" BGCOLOR="#cccccc">company</TH>
326 %foreach my $addl_header ( @addl_headers ) {
327 % print '<TH CLASS="grid" BGCOLOR="#cccccc">'. "$addl_header</TH>";
331 % <TH CLASS="grid" BGCOLOR="#cccccc">Packages</TH>
332 % <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Services</TH>
336 % my $bgcolor1 = '#eeeeee';
337 % my $bgcolor2 = '#ffffff';
340 % my(%saw,$cust_main);
341 % foreach $cust_main (
342 % sort $sortby grep(!$saw{$_->custnum}++, @cust_main)
345 % if ( $bgcolor eq $bgcolor1 ) {
346 % $bgcolor = $bgcolor2;
348 % $bgcolor = $bgcolor1;
351 % my($custnum,$last,$first,$company)=(
352 % $cust_main->custnum,
353 % $cust_main->getfield('last'),
354 % $cust_main->getfield('first'),
355 % $cust_main->company,
359 % my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} );
360 % foreach ( @{$all_pkgs{$custnum}} ) {
361 % #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
362 % my @cust_svc = $_->cust_svc;
363 % push @lol_cust_svc, \@cust_svc;
364 % $rowspan += scalar(@cust_svc) || 1;
367 % #my($rowspan) = scalar(@{$all_pkgs{$custnum}});
369 % if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) {
370 % $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum;
372 % $view = $p. 'view/cust_main.cgi?'. $custnum;
374 % my $pcompany = $company
375 % ? qq!<A HREF="$view"><FONT SIZE=-1>$company</FONT></A>!
376 % : '<FONT SIZE=-1> </FONT>';
378 % my $status = $cust_main->status;
379 % my $statuscol = $cust_main->statuscolor;
382 <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% $custnum %></FONT></A></TD>
383 <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><FONT SIZE="-1" COLOR="#<% $statuscol %>"><B><% ucfirst($status) %></B></FONT></TD>
384 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A></TD>
385 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pcompany %></TD>
387 % if ( defined dbdef->table('cust_main')->column('ship_last') ) {
388 % my($ship_last,$ship_first,$ship_company)=(
389 % $cust_main->ship_last || $cust_main->getfield('last'),
390 % $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first,
391 % $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company,
393 % my $pship_company = $ship_company
394 % ? qq!<A HREF="$view"><FONT SIZE=-1>$ship_company</FONT></A>!
395 % : '<FONT SIZE=-1> </FONT>';
399 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$ship_last, $ship_first" %></FONT></A></TD>
400 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pship_company %></A></TD>
403 % foreach my $addl_col ( @addl_cols ) {
404 % if ( $addl_col eq 'tickets' ) {
405 % if ( @custom_priorities ) {
408 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
410 <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
411 % foreach my $priority ( @custom_priorities, '' ) {
414 % FS::TicketSystem->num_customer_tickets($custnum,$priority);
416 % $ahref= '<A HREF="'.
417 % FS::TicketSystem->href_customer_tickets($custnum,$priority).
425 <FONT SIZE=-1><% $ahref.$num %></A></FONT>
428 <FONT SIZE=-1><% $ahref %><% $priority || '<i>(none)</i>' %></A></FONT>
435 <TH ALIGN=right STYLE="border-top: dashed 1px black">
440 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
444 % $ahref = '<A HREF="'.
445 % FS::TicketSystem->href_customer_tickets($custnum).
447 % if $cust_main->get($addl_col);
451 <% $ahref %><% $cust_main->get($addl_col) %></A>
452 % if ( @custom_priorities ) {
456 <TH ALIGN=left STYLE="border-top: dashed 1px black">
457 <FONT SIZE=-1><% ${ahref} %>Total</A><FONT>
468 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
469 <% $cust_main->get($addl_col) %>
476 % foreach ( @{$all_pkgs{$custnum}} ) {
477 % my $pkgnum = $_->pkgnum;
478 %# my $part_pkg = qsearchs( 'part_pkg', { pkgpart => $_->pkgpart } );
479 % my $part_pkg = $_->part_pkg;
481 % my $pkg = $part_pkg->pkg;
482 % my $comment = $part_pkg->comment;
483 % my $pkgview = "${p}view/cust_main.cgi?$custnum#cust_pkg$pkgnum";
484 % my @cust_svc = @{shift @lol_cust_svc};
485 % #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
486 % my $rowspan = scalar(@cust_svc) || 1;
488 % print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg - $comment</FONT></A></TD>!;
491 % foreach my $cust_svc ( @cust_svc ) {
492 % my($label, $value, $svcdb) = $cust_svc->label;
493 % my($svcnum) = $cust_svc->svcnum;
494 % my($sview) = $p.'view';
496 % qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !.
497 % qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !;
501 % unless ( @cust_svc ) {
502 % print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=2> </TD>!;
505 % #print qq!</TR><TR>\n!;
509 % unless ( @{$all_pkgs{$custnum}} ) {
510 % print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=3> </TD>!;
521 <% include('/elements/footer.html') %>
524 %#undef $cache; #does this help?
529 % lc($a->getfield('last')) cmp lc($b->getfield('last'))
530 % || lc($a->first) cmp lc($b->first);
534 % return -1 if $a->company && ! $b->company;
535 % return 1 if ! $a->company && $b->company;
536 % lc($a->company) cmp lc($b->company)
537 % || lc($a->getfield('last')) cmp lc($b->getfield('last'))
538 % || lc($a->first) cmp lc($b->first);;
542 % $a->getfield('custnum') <=> $b->getfield('custnum');
546 % $b->getfield('tickets') <=> $a->getfield('tickets');
551 % my $custnum = $cgi->param('custnum_text');
552 % $custnum =~ s/\D//g;
553 % $custnum =~ /^(\d{1,23})$/ or errorpage("Illegal customer number");
556 % [ qsearchs('cust_main', { 'custnum' => $custnum } ) ];
561 % my($card)=$cgi->param('card');
563 % $card =~ /^(\d{13,16})$/ or errorpage("Illegal card number");
566 % [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}),
567 % qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'})
571 %sub referralsearch {
572 % $cgi->param('referral_custnum') =~ /^(\d+)$/
573 % or errorpage("Illegal referral_custnum");
574 % my $cust_main = qsearchs('cust_main', { 'custnum' => $1 } )
575 % or errorpage("Customer $1 not found");
577 % if ( $cgi->param('referral_depth') ) {
578 % $cgi->param('referral_depth') =~ /^(\d+)$/
579 % or errorpage("Illegal referral_depth");
584 % [ $cust_main->referral_cust_main($depth) ];
590 % foreach ( $cgi->param('last_type') ) {
594 % $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/
595 % or errorpage("Illegal last name");
598 % if ( $last_type{'Exact'} || $last_type{'Fuzzy'} ) {
599 % push @cust_main, qsearch( 'cust_main',
600 % { 'last' => { 'op' => 'ILIKE',
601 % 'value' => $last } } );
603 % push @cust_main, qsearch( 'cust_main',
604 % { 'ship_last' => { 'op' => 'ILIKE',
605 % 'value' => $last } } )
606 % if defined dbdef->table('cust_main')->column('ship_last');
609 % if ( $last_type{'Substring'} || $last_type{'All'} ) {
611 % push @cust_main, qsearch( 'cust_main',
612 % { 'last' => { 'op' => 'ILIKE',
613 % 'value' => "%$last%" } } );
615 % push @cust_main, qsearch( 'cust_main',
616 % { 'ship_last' => { 'op' => 'ILIKE',
617 % 'value' => "%$last%" } } )
618 % if defined dbdef->table('cust_main')->column('ship_last');
622 % if ( $last_type{'Fuzzy'} || $last_type{'All'} ) {
623 % push @cust_main, FS::cust_main->fuzzy_search( { 'last' => $last } );
626 % #if ($last_type{'Sound-alike'}) {
636 % foreach ( $cgi->param('company_type') ) {
637 % $company_type{$_}++
640 % $cgi->param('company_text') =~
641 % /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
642 % or errorpage("Illegal company");
645 % if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) {
646 % push @cust_main, qsearch( 'cust_main',
647 % { 'company' => { 'op' => 'ILIKE',
648 % 'value' => $company } } );
650 % push @cust_main, qsearch( 'cust_main',
651 % { 'ship_company' => { 'op' => 'ILIKE',
652 % 'value' => $company } } )
653 % if defined dbdef->table('cust_main')->column('ship_last');
656 % if ( $company_type{'Substring'} || $company_type{'All'} ) {
658 % push @cust_main, qsearch( 'cust_main',
659 % { 'company' => { 'op' => 'ILIKE',
660 % 'value' => "%$company%" } } );
662 % push @cust_main, qsearch( 'cust_main',
663 % { 'ship_company' => { 'op' => 'ILIKE',
664 % 'value' => "%$company%" } })
665 % if defined dbdef->table('cust_main')->column('ship_last');
669 % if ( $company_type{'Fuzzy'} || $company_type{'All'} ) {
670 % push @cust_main, FS::cust_main->fuzzy_search( { 'company' => $company } );
673 % if ($company_type{'Sound-alike'}) {
679 %sub address2search {
682 % $cgi->param('address2_text') =~
683 % /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
684 % or errorpage("Illegal address2");
687 % push @cust_main, qsearch( 'cust_main',
688 % { 'address2' => { 'op' => 'ILIKE',
689 % 'value' => $address2 } } );
690 % push @cust_main, qsearch( 'cust_main',
691 % { 'address2' => { 'op' => 'ILIKE',
692 % 'value' => $address2 } } )
693 % if defined dbdef->table('cust_main')->column('ship_last');
701 % my $phone = $cgi->param('phone_text');
703 % #(no longer really) false laziness with Record::ut_phonen
704 % #only works with US/CA numbers...
706 % if ( $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ ) {
707 % $phone = "$1-$2-$3";
708 % $phone .= " x$4" if $4;
709 % } elsif ( $phone =~ /^(\d{3})(\d{4})$/ ) {
711 % } elsif ( $phone =~ /^(\d{3,4})$/ ) {
714 % errorpage(gettext('illegal_phone'). ": $phone");
717 % my @fields = qw(daytime night fax);
718 % push @fields, qw(ship_daytime ship_night ship_fax)
719 % if defined dbdef->table('cust_main')->column('ship_last');
721 % for my $field ( @fields ) {
722 % push @cust_main, qsearch ( 'cust_main',
723 % { $field => { 'op' => 'LIKE',
724 % 'value' => "%$phone%" } } );