1 %my $curuser = $FS::CurrentUser::CurrentUser;
4 % unless $curuser->access_right('List customers');
6 %my $conf = new FS::Conf;
7 %my $maxrecords = $conf->config('maxsearchrecordsperpage');
11 %#my $monsterjoin = <<END;
12 %#cust_main left outer join (
13 %# ( cust_pkg left outer join part_pkg using(pkgpart)
14 %# ) left outer join (
17 %# ( cust_svc left outer join part_svc using (svcpart)
18 %# ) left outer join svc_acct using (svcnum)
19 %# ) left outer join svc_domain using(svcnum)
20 %# ) left outer join svc_forward using(svcnum)
25 %#my $monsterjoin = <<END;
26 %#cust_main left outer join (
27 %# ( cust_pkg left outer join part_pkg using(pkgpart)
28 %# ) left outer join (
31 %# ( cust_svc left outer join part_svc using (svcpart)
32 %# ) left outer join (
33 %# svc_acct left outer join (
34 %# select svcnum, domain, catchall from svc_domain
35 %# ) as svc_acct_domsvc (
36 %# svc_acct_svcnum, svc_acct_domain, svc_acct_catchall
37 %# ) on svc_acct.domsvc = svc_acct_domsvc.svc_acct_svcnum
39 %# ) left outer join svc_domain using(svcnum)
40 %# ) left outer join svc_forward using(svcnum)
46 %$limit .= "LIMIT $maxrecords" if $maxrecords;
48 %my $offset = $cgi->param('offset') || 0;
49 %$limit .= " OFFSET $offset" if $offset;
53 %my(@cust_main, $sortby, $orderby);
55 %my @addl_headers = ();
57 %if ( $cgi->param('browse')
58 % || $cgi->param('otaker_on')
59 % || $cgi->param('agentnum_on')
64 % if ( $cgi->param('browse') ) {
65 % my $query = $cgi->param('browse');
66 % if ( $query eq 'custnum' ) {
67 % if ( $conf->exists('cust_main-default_agent_custid') ) {
68 % $sortby=\*display_custnum_sort;
69 % $orderby = "ORDER BY CASE WHEN agent_custid IS NOT NULL AND agent_custid != '' THEN CAST(agent_custid AS BIGINT) ELSE custnum END";
71 % $sortby=\*custnum_sort;
72 % $orderby = "ORDER BY custnum";
74 % } elsif ( $query eq 'last' ) {
75 % $sortby=\*last_sort;
76 % $orderby = "ORDER BY LOWER(last || ' ' || first)";
77 % } elsif ( $query eq 'company' ) {
78 % $sortby=\*company_sort;
79 % $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )";
80 % } elsif ( $query eq 'tickets' ) {
81 % $sortby = \*tickets_sort;
82 % $orderby = "ORDER BY tickets DESC";
83 % push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets";
84 % push @addl_headers, 'Tickets';
85 % push @addl_cols, 'tickets';
87 % die "unknown browse field $query";
90 % $sortby = \*last_sort; #??
91 % $orderby = "ORDER BY LOWER(last || ' ' || first)"; #??
94 % if ( $cgi->param('otaker_on') ) {
96 % unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
97 % $cgi->param('otaker') =~ /^(\w{1,32})$/ or errorpage("Illegal otaker");
98 % $search{otaker} = $1;
99 % } elsif ( $cgi->param('agentnum_on') ) {
100 % $cgi->param('agentnum') =~ /^(\d+)$/ or errorpage("Illegal agentnum");
101 % $search{agentnum} = $1;
103 %# die "unknown query...";
108 % my $ncancelled = '';
110 % if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
111 % || ( $conf->exists('hidecancelledcustomers')
112 % && ! $cgi->param('showcancelledcustomers') )
114 % #grep { $_->ncancelled_pkgs || ! $_->all_pkgs }
115 % push @qual, FS::cust_main->uncancel_sql;
119 % push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled');
120 % push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect');
121 % push @qual, FS::cust_main->active_sql if $cgi->param('active');
122 % push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive');
123 % push @qual, FS::cust_main->susp_sql if $cgi->param('suspended');
126 % my $qual = join(' AND ',
127 % map { "$_ = ". dbh->quote($search{$_}) } keys %search );
129 % my $addl_qual = join(' AND ', @qual);
131 % #here is the agent virtualization
132 % $addl_qual .= ( $addl_qual ? ' AND ' : '' ).
133 % $FS::CurrentUser::CurrentUser->agentnums_sql;
135 % if ( $addl_qual ) {
136 % $qual .= ' AND ' if $qual;
137 % $qual .= $addl_qual;
140 % $qual = " WHERE $qual" if $qual;
141 % my $statement = "SELECT COUNT(*) FROM cust_main $qual";
142 % my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement";
143 % $sth->execute or die "Error executing \"$statement\": ". $sth->errstr;
145 % $total = $sth->fetchrow_arrayref->[0];
147 % if ( $addl_qual ) {
149 % $addl_qual = " AND $addl_qual";
151 % $addl_qual = " WHERE $addl_qual";
157 % $select = 'cust_main.*, '. join (', ', @select);
162 % @cust_main = qsearch('cust_main', \%search, $select,
163 % "$addl_qual $orderby $limit" );
165 %# foreach my $cust_main ( @just_cust_main ) {
167 %# my @one_cust_main;
168 %# $FS::Record::DEBUG=1;
169 %# ( $cache, @one_cust_main ) = jsearch(
171 %# { 'custnum' => $cust_main->custnum },
177 %# push @cust_main, @one_cust_main;
182 % $sortby = \*last_sort;
184 % push @cust_main, @{&custnumsearch}
185 % if $cgi->param('custnum_on') && $cgi->param('custnum_text');
186 % push @cust_main, @{&cardsearch}
187 % if $cgi->param('card_on') && $cgi->param('card');
188 % push @cust_main, @{&lastsearch}
189 % if $cgi->param('last_on') && $cgi->param('last_text');
190 % push @cust_main, @{&companysearch}
191 % if $cgi->param('company_on') && $cgi->param('company_text');
192 % push @cust_main, @{&address2search}
193 % if $cgi->param('address2_on') && $cgi->param('address2_text');
194 % push @cust_main, @{&phonesearch}
195 % if $cgi->param('phone_on') && $cgi->param('phone_text');
196 % push @cust_main, @{&referralsearch}
197 % if $cgi->param('referral_custnum');
199 % if ( $cgi->param('company_on') && $cgi->param('company_text') ) {
200 % $sortby = \*company_sort;
201 % push @cust_main, @{&companysearch};
204 % if ( $cgi->param('search_cust') ) {
205 % $sortby = \*company_sort;
206 % $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )";
207 % push @cust_main, smart_search( 'search' => $cgi->param('search_cust'),
208 % 'no_fuzzy_on_exact' => 1, #pref?
212 % @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main
213 % if ! $cgi->param('cancelled')
215 % $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
216 % || ( $conf->exists('hidecancelledcustomers')
217 % && ! $cgi->param('showcancelledcustomers') )
221 % @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
225 %if ( $conf->exists('hidecancelledpackages' ) ) {
226 % %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main;
228 % %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main;
232 %if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) {
233 % if ( $cgi->param('quickpay') eq 'yes' ) {
234 % print $cgi->redirect(popurl(2). "edit/cust_pay.cgi?quickpay=yes;custnum=". $cust_main[0]->custnum);
236 % print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum);
239 %} elsif ( scalar(@cust_main) == 0 ) {
242 <!-- mason kludge -->
244 % errorpage("No matching customers found!");
248 <% include('/elements/header.html', "Customer Search Results", '' ) %>
249 % $total ||= scalar(@cust_main);
252 <% $total %> matching customers found
254 % my $pager = include( '/elements/pager.html',
255 % 'offset' => $offset,
256 % 'num_rows' => scalar(@cust_main),
258 % 'maxrecords' => $maxrecords,
261 % unless ( $cgi->param('cancelled') ) {
262 % if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
263 % || ( $conf->exists('hidecancelledcustomers')
264 % && ! $cgi->param('showcancelledcustomers')
267 % $cgi->param('showcancelledcustomers', 1);
268 % $cgi->param('offset', 0);
269 % print qq!( <a href="!. $cgi->self_url. qq!">show!;
271 % $cgi->param('showcancelledcustomers', 0);
272 % $cgi->param('offset', 0);
273 % print qq!( <a href="!. $cgi->self_url. qq!">hide!;
275 % print ' canceled customers</a> )';
278 % if ( $cgi->param('referral_custnum') ) {
279 % $cgi->param('referral_custnum') =~ /^(\d+)$/
280 % or errorpage("Illegal referral_custnum");
281 % my $referral_custnum = $1;
282 % my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } );
283 % print '<FORM METHOD="GET">'.
284 % qq!<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="$referral_custnum">!.
285 % 'referrals of <A HREF="'. popurl(2).
286 % "view/cust_main.cgi?$referral_custnum\">$referral_custnum: ".
287 % ( $cust_main->company
288 % || $cust_main->last. ', '. $cust_main->first ).
292 % function changed(what) {
293 % what.form.submit();
297 % print ' <SELECT NAME="referral_depth" SIZE="1" onChange="changed(this)">';
298 % my $max = 8; #config file
299 % $cgi->param('referral_depth') =~ /^(\d*)$/
300 % or errorpage("Illegal referral_depth");
301 % my $referral_depth = $1;
303 % foreach my $depth ( 1 .. $max ) {
305 % ' SELECTED'x($depth == $referral_depth),
308 % print "</SELECT> levels deep".
309 % '<NOSCRIPT> <INPUT TYPE="submit" VALUE="change"></NOSCRIPT>'.
313 % my @custom_priorities = ();
314 % if ( $conf->config('ticket_system-custom_priority_field')
315 % && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) {
316 % @custom_priorities =
317 % $conf->config('ticket_system-custom_priority_field-values');
320 % print "<BR><BR>". $pager. include('/elements/table-grid.html'). <<END;
322 % <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
323 % <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
324 % <TH CLASS="grid" BGCOLOR="#cccccc">(bill) name</TH>
325 % <TH CLASS="grid" BGCOLOR="#cccccc">company</TH>
328 %if ( defined dbdef->table('cust_main')->column('ship_last') ) {
330 % <TH CLASS="grid" BGCOLOR="#cccccc">(service) name</TH>
331 % <TH CLASS="grid" BGCOLOR="#cccccc">company</TH>
335 %foreach my $addl_header ( @addl_headers ) {
336 % print '<TH CLASS="grid" BGCOLOR="#cccccc">'. "$addl_header</TH>";
340 % <TH CLASS="grid" BGCOLOR="#cccccc">Packages</TH>
341 % <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Services</TH>
345 % my $bgcolor1 = '#eeeeee';
346 % my $bgcolor2 = '#ffffff';
349 % my(%saw,$cust_main);
350 % foreach $cust_main (
351 % sort $sortby grep(!$saw{$_->custnum}++, @cust_main)
354 % if ( $bgcolor eq $bgcolor1 ) {
355 % $bgcolor = $bgcolor2;
357 % $bgcolor = $bgcolor1;
360 % my($custnum,$last,$first,$company)=(
361 % $cust_main->custnum,
362 % $cust_main->getfield('last'),
363 % $cust_main->getfield('first'),
364 % $cust_main->company,
368 % my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} );
369 % foreach ( @{$all_pkgs{$custnum}} ) {
370 % #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
371 % my @cust_svc = $_->cust_svc;
372 % push @lol_cust_svc, \@cust_svc;
373 % $rowspan += scalar(@cust_svc) || 1;
376 % #my($rowspan) = scalar(@{$all_pkgs{$custnum}});
378 % if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) {
379 % $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum;
381 % $view = $p. 'view/cust_main.cgi?'. $custnum;
383 % my $pcompany = $company
384 % ? qq!<A HREF="$view"><FONT SIZE=-1>$company</FONT></A>!
385 % : '<FONT SIZE=-1> </FONT>';
387 % my $status = $cust_main->status;
388 % my $statuscol = $cust_main->statuscolor;
391 <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% $cust_main->display_custnum %></FONT></A></TD>
392 <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><FONT SIZE="-1" COLOR="#<% $statuscol %>"><B><% ucfirst($status) %></B></FONT></TD>
393 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A></TD>
394 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pcompany %></TD>
396 % if ( defined dbdef->table('cust_main')->column('ship_last') ) {
397 % my($ship_last,$ship_first,$ship_company)=(
398 % $cust_main->ship_last || $cust_main->getfield('last'),
399 % $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first,
400 % $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company,
402 % my $pship_company = $ship_company
403 % ? qq!<A HREF="$view"><FONT SIZE=-1>$ship_company</FONT></A>!
404 % : '<FONT SIZE=-1> </FONT>';
408 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$ship_last, $ship_first" %></FONT></A></TD>
409 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pship_company %></A></TD>
412 % foreach my $addl_col ( @addl_cols ) {
413 % if ( $addl_col eq 'tickets' ) {
414 % if ( @custom_priorities ) {
417 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
419 <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
420 % foreach my $priority ( @custom_priorities, '' ) {
423 % FS::TicketSystem->num_customer_tickets($custnum,$priority);
425 % $ahref= '<A HREF="'.
426 % FS::TicketSystem->href_customer_tickets($custnum,$priority).
434 <FONT SIZE=-1><% $ahref.$num %></A></FONT>
437 <FONT SIZE=-1><% $ahref %><% $priority || '<i>(none)</i>' %></A></FONT>
444 <TH ALIGN=right STYLE="border-top: dashed 1px black">
449 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
453 % $ahref = '<A HREF="'.
454 % FS::TicketSystem->href_customer_tickets($custnum).
456 % if $cust_main->get($addl_col);
460 <% $ahref %><% $cust_main->get($addl_col) %></A>
461 % if ( @custom_priorities ) {
465 <TH ALIGN=left STYLE="border-top: dashed 1px black">
466 <FONT SIZE=-1><% ${ahref} %>Total</A><FONT>
477 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
478 <% $cust_main->get($addl_col) %>
485 % foreach ( @{$all_pkgs{$custnum}} ) {
486 % my $pkgnum = $_->pkgnum;
487 %# my $part_pkg = qsearchs( 'part_pkg', { pkgpart => $_->pkgpart } );
488 % my $part_pkg = $_->part_pkg;
490 % my $pkg_comment = $part_pkg->pkg_comment(nopkgpart => 1);
491 % my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
493 % : ';show=packages';
494 % my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
495 % my $pkgview = "${p}view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag";
496 % my @cust_svc = @{shift @lol_cust_svc};
497 % #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
498 % my $rowspan = scalar(@cust_svc) || 1;
500 % print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg_comment</FONT></A></TD>!;
503 % foreach my $cust_svc ( @cust_svc ) {
504 % my($label, $value, $svcdb) = $cust_svc->label;
505 % my($svcnum) = $cust_svc->svcnum;
506 % my($sview) = $p.'view';
508 % qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !.
509 % qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !;
513 % unless ( @cust_svc ) {
514 % print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=2> </TD>!;
517 % #print qq!</TR><TR>\n!;
521 % unless ( @{$all_pkgs{$custnum}} ) {
522 % print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=3> </TD>!;
533 <% include('/elements/footer.html') %>
536 %#undef $cache; #does this help?
541 % lc($a->getfield('last')) cmp lc($b->getfield('last'))
542 % || lc($a->first) cmp lc($b->first);
546 % return -1 if $a->company && ! $b->company;
547 % return 1 if ! $a->company && $b->company;
548 % lc($a->company) cmp lc($b->company)
549 % || lc($a->getfield('last')) cmp lc($b->getfield('last'))
550 % || lc($a->first) cmp lc($b->first);;
553 %sub display_custnum_sort {
554 % $a->display_custnum <=> $b->display_custnum;
558 % $a->getfield('custnum') <=> $b->getfield('custnum');
562 % $b->getfield('tickets') <=> $a->getfield('tickets');
567 % my $custnum = $cgi->param('custnum_text');
568 % $custnum =~ s/\D//g;
569 % $custnum =~ /^(\d{1,23})$/ or errorpage("Illegal customer number");
572 % [ qsearchs('cust_main', { 'custnum' => $custnum } ) ];
577 % my($card)=$cgi->param('card');
579 % $card =~ /^(\d{13,16})$/ or errorpage("Illegal card number");
582 % [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}),
583 % qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'})
587 %sub referralsearch {
588 % $cgi->param('referral_custnum') =~ /^(\d+)$/
589 % or errorpage("Illegal referral_custnum");
590 % my $cust_main = qsearchs('cust_main', { 'custnum' => $1 } )
591 % or errorpage("Customer $1 not found");
593 % if ( $cgi->param('referral_depth') ) {
594 % $cgi->param('referral_depth') =~ /^(\d+)$/
595 % or errorpage("Illegal referral_depth");
600 % [ $cust_main->referral_cust_main($depth) ];
606 % foreach ( $cgi->param('last_type') ) {
610 % $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/
611 % or errorpage("Illegal last name");
614 % if ( $last_type{'Exact'} || $last_type{'Fuzzy'} ) {
615 % push @cust_main, qsearch( 'cust_main',
616 % { 'last' => { 'op' => 'ILIKE',
617 % 'value' => $last } } );
619 % push @cust_main, qsearch( 'cust_main',
620 % { 'ship_last' => { 'op' => 'ILIKE',
621 % 'value' => $last } } )
622 % if defined dbdef->table('cust_main')->column('ship_last');
625 % if ( $last_type{'Substring'} || $last_type{'All'} ) {
627 % push @cust_main, qsearch( 'cust_main',
628 % { 'last' => { 'op' => 'ILIKE',
629 % 'value' => "%$last%" } } );
631 % push @cust_main, qsearch( 'cust_main',
632 % { 'ship_last' => { 'op' => 'ILIKE',
633 % 'value' => "%$last%" } } )
634 % if defined dbdef->table('cust_main')->column('ship_last');
638 % if ( $last_type{'Fuzzy'} || $last_type{'All'} ) {
639 % push @cust_main, FS::cust_main::Search->fuzzy_search( { 'last' => $last } );
642 % #if ($last_type{'Sound-alike'}) {
652 % foreach ( $cgi->param('company_type') ) {
653 % $company_type{$_}++
656 % $cgi->param('company_text') =~
657 % /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
658 % or errorpage("Illegal company");
661 % if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) {
662 % push @cust_main, qsearch( 'cust_main',
663 % { 'company' => { 'op' => 'ILIKE',
664 % 'value' => $company } } );
666 % push @cust_main, qsearch( 'cust_main',
667 % { 'ship_company' => { 'op' => 'ILIKE',
668 % 'value' => $company } } )
669 % if defined dbdef->table('cust_main')->column('ship_last');
672 % if ( $company_type{'Substring'} || $company_type{'All'} ) {
674 % push @cust_main, qsearch( 'cust_main',
675 % { 'company' => { 'op' => 'ILIKE',
676 % 'value' => "%$company%" } } );
678 % push @cust_main, qsearch( 'cust_main',
679 % { 'ship_company' => { 'op' => 'ILIKE',
680 % 'value' => "%$company%" } })
681 % if defined dbdef->table('cust_main')->column('ship_last');
685 % if ( $company_type{'Fuzzy'} || $company_type{'All'} ) {
686 % push @cust_main, FS::cust_main::Search->fuzzy_search( { 'company' => $company } );
689 % if ($company_type{'Sound-alike'}) {
695 %sub address2search {
698 % $cgi->param('address2_text') =~
699 % /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
700 % or errorpage("Illegal address2");
703 % push @cust_main, qsearch( 'cust_main',
704 % { 'address2' => { 'op' => 'ILIKE',
705 % 'value' => $address2 } } );
706 % push @cust_main, qsearch( 'cust_main',
707 % { 'ship_address2' => { 'op' => 'ILIKE',
708 % 'value' => $address2 } } );
716 % my $phone = $cgi->param('phone_text');
718 % #(no longer really) false laziness with Record::ut_phonen
719 % #only works with US/CA numbers...
721 % if ( $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ ) {
722 % $phone = "$1-$2-$3";
723 % $phone .= " x$4" if $4;
724 % } elsif ( $phone =~ /^(\d{3})(\d{4})$/ ) {
726 % } elsif ( $phone =~ /^(\d{3,4})$/ ) {
729 % errorpage(gettext('illegal_phone'). ": $phone");
732 % my @fields = qw(daytime night fax);
733 % push @fields, qw(ship_daytime ship_night ship_fax)
734 % if defined dbdef->table('cust_main')->column('ship_last');
736 % for my $field ( @fields ) {
737 % push @cust_main, qsearch ( 'cust_main',
738 % { $field => { 'op' => 'LIKE',
739 % 'value' => "%$phone%" } } );