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') );
210 % @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main
211 % if ! $cgi->param('cancelled')
213 % $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
214 % || ( $conf->exists('hidecancelledcustomers')
215 % && ! $cgi->param('showcancelledcustomers') )
219 % @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
223 %if ( $conf->exists('hidecancelledpackages' ) ) {
224 % %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main;
226 % %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main;
230 %if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) {
231 % if ( $cgi->param('quickpay') eq 'yes' ) {
232 % print $cgi->redirect(popurl(2). "edit/cust_pay.cgi?quickpay=yes;custnum=". $cust_main[0]->custnum);
234 % print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum);
237 %} elsif ( scalar(@cust_main) == 0 ) {
240 <!-- mason kludge -->
242 % errorpage("No matching customers found!");
246 <% include('/elements/header.html', "Customer Search Results", '' ) %>
247 % $total ||= scalar(@cust_main);
250 <% $total %> matching customers found
252 % my $pager = include( '/elements/pager.html',
253 % 'offset' => $offset,
254 % 'num_rows' => scalar(@cust_main),
256 % 'maxrecords' => $maxrecords,
259 % unless ( $cgi->param('cancelled') ) {
260 % if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
261 % || ( $conf->exists('hidecancelledcustomers')
262 % && ! $cgi->param('showcancelledcustomers')
265 % $cgi->param('showcancelledcustomers', 1);
266 % $cgi->param('offset', 0);
267 % print qq!( <a href="!. $cgi->self_url. qq!">show!;
269 % $cgi->param('showcancelledcustomers', 0);
270 % $cgi->param('offset', 0);
271 % print qq!( <a href="!. $cgi->self_url. qq!">hide!;
273 % print ' canceled customers</a> )';
276 % if ( $cgi->param('referral_custnum') ) {
277 % $cgi->param('referral_custnum') =~ /^(\d+)$/
278 % or errorpage("Illegal referral_custnum");
279 % my $referral_custnum = $1;
280 % my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } );
281 % print '<FORM METHOD="GET">'.
282 % qq!<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="$referral_custnum">!.
283 % 'referrals of <A HREF="'. popurl(2).
284 % "view/cust_main.cgi?$referral_custnum\">$referral_custnum: ".
285 % ( $cust_main->company
286 % || $cust_main->last. ', '. $cust_main->first ).
290 % function changed(what) {
291 % what.form.submit();
295 % print ' <SELECT NAME="referral_depth" SIZE="1" onChange="changed(this)">';
296 % my $max = 8; #config file
297 % $cgi->param('referral_depth') =~ /^(\d*)$/
298 % or errorpage("Illegal referral_depth");
299 % my $referral_depth = $1;
301 % foreach my $depth ( 1 .. $max ) {
303 % ' SELECTED'x($depth == $referral_depth),
306 % print "</SELECT> levels deep".
307 % '<NOSCRIPT> <INPUT TYPE="submit" VALUE="change"></NOSCRIPT>'.
311 % my @custom_priorities = ();
312 % if ( $conf->config('ticket_system-custom_priority_field')
313 % && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) {
314 % @custom_priorities =
315 % $conf->config('ticket_system-custom_priority_field-values');
318 % print "<BR><BR>". $pager. include('/elements/table-grid.html'). <<END;
320 % <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
321 % <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
322 % <TH CLASS="grid" BGCOLOR="#cccccc">(bill) name</TH>
323 % <TH CLASS="grid" BGCOLOR="#cccccc">company</TH>
326 %if ( defined dbdef->table('cust_main')->column('ship_last') ) {
328 % <TH CLASS="grid" BGCOLOR="#cccccc">(service) name</TH>
329 % <TH CLASS="grid" BGCOLOR="#cccccc">company</TH>
333 %foreach my $addl_header ( @addl_headers ) {
334 % print '<TH CLASS="grid" BGCOLOR="#cccccc">'. "$addl_header</TH>";
338 % <TH CLASS="grid" BGCOLOR="#cccccc">Packages</TH>
339 % <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Services</TH>
343 % my $bgcolor1 = '#eeeeee';
344 % my $bgcolor2 = '#ffffff';
347 % my(%saw,$cust_main);
348 % foreach $cust_main (
349 % sort $sortby grep(!$saw{$_->custnum}++, @cust_main)
352 % if ( $bgcolor eq $bgcolor1 ) {
353 % $bgcolor = $bgcolor2;
355 % $bgcolor = $bgcolor1;
358 % my($custnum,$last,$first,$company)=(
359 % $cust_main->custnum,
360 % $cust_main->getfield('last'),
361 % $cust_main->getfield('first'),
362 % $cust_main->company,
366 % my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} );
367 % foreach ( @{$all_pkgs{$custnum}} ) {
368 % #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
369 % my @cust_svc = $_->cust_svc;
370 % push @lol_cust_svc, \@cust_svc;
371 % $rowspan += scalar(@cust_svc) || 1;
374 % #my($rowspan) = scalar(@{$all_pkgs{$custnum}});
376 % if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) {
377 % $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum;
379 % $view = $p. 'view/cust_main.cgi?'. $custnum;
381 % my $pcompany = $company
382 % ? qq!<A HREF="$view"><FONT SIZE=-1>$company</FONT></A>!
383 % : '<FONT SIZE=-1> </FONT>';
385 % my $status = $cust_main->status;
386 % my $statuscol = $cust_main->statuscolor;
389 <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% $cust_main->display_custnum %></FONT></A></TD>
390 <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><FONT SIZE="-1" COLOR="#<% $statuscol %>"><B><% ucfirst($status) %></B></FONT></TD>
391 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A></TD>
392 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pcompany %></TD>
394 % if ( defined dbdef->table('cust_main')->column('ship_last') ) {
395 % my($ship_last,$ship_first,$ship_company)=(
396 % $cust_main->ship_last || $cust_main->getfield('last'),
397 % $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first,
398 % $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company,
400 % my $pship_company = $ship_company
401 % ? qq!<A HREF="$view"><FONT SIZE=-1>$ship_company</FONT></A>!
402 % : '<FONT SIZE=-1> </FONT>';
406 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$ship_last, $ship_first" %></FONT></A></TD>
407 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pship_company %></A></TD>
410 % foreach my $addl_col ( @addl_cols ) {
411 % if ( $addl_col eq 'tickets' ) {
412 % if ( @custom_priorities ) {
415 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
417 <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
418 % foreach my $priority ( @custom_priorities, '' ) {
421 % FS::TicketSystem->num_customer_tickets($custnum,$priority);
423 % $ahref= '<A HREF="'.
424 % FS::TicketSystem->href_customer_tickets($custnum,$priority).
432 <FONT SIZE=-1><% $ahref.$num %></A></FONT>
435 <FONT SIZE=-1><% $ahref %><% $priority || '<i>(none)</i>' %></A></FONT>
442 <TH ALIGN=right STYLE="border-top: dashed 1px black">
447 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
451 % $ahref = '<A HREF="'.
452 % FS::TicketSystem->href_customer_tickets($custnum).
454 % if $cust_main->get($addl_col);
458 <% $ahref %><% $cust_main->get($addl_col) %></A>
459 % if ( @custom_priorities ) {
463 <TH ALIGN=left STYLE="border-top: dashed 1px black">
464 <FONT SIZE=-1><% ${ahref} %>Total</A><FONT>
475 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
476 <% $cust_main->get($addl_col) %>
483 % foreach ( @{$all_pkgs{$custnum}} ) {
484 % my $pkgnum = $_->pkgnum;
485 %# my $part_pkg = qsearchs( 'part_pkg', { pkgpart => $_->pkgpart } );
486 % my $part_pkg = $_->part_pkg;
488 % my $pkg_comment = $part_pkg->pkg_comment(nopkgpart => 1);
489 % my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
491 % : ';show=packages';
492 % my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
493 % my $pkgview = "${p}view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag";
494 % my @cust_svc = @{shift @lol_cust_svc};
495 % #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
496 % my $rowspan = scalar(@cust_svc) || 1;
498 % print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg_comment</FONT></A></TD>!;
501 % foreach my $cust_svc ( @cust_svc ) {
502 % my($label, $value, $svcdb) = $cust_svc->label;
503 % my($svcnum) = $cust_svc->svcnum;
504 % my($sview) = $p.'view';
506 % qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !.
507 % qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !;
511 % unless ( @cust_svc ) {
512 % print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=2> </TD>!;
515 % #print qq!</TR><TR>\n!;
519 % unless ( @{$all_pkgs{$custnum}} ) {
520 % print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=3> </TD>!;
531 <% include('/elements/footer.html') %>
534 %#undef $cache; #does this help?
539 % lc($a->getfield('last')) cmp lc($b->getfield('last'))
540 % || lc($a->first) cmp lc($b->first);
544 % return -1 if $a->company && ! $b->company;
545 % return 1 if ! $a->company && $b->company;
546 % lc($a->company) cmp lc($b->company)
547 % || lc($a->getfield('last')) cmp lc($b->getfield('last'))
548 % || lc($a->first) cmp lc($b->first);;
551 %sub display_custnum_sort {
552 % $a->display_custnum <=> $b->display_custnum;
556 % $a->getfield('custnum') <=> $b->getfield('custnum');
560 % $b->getfield('tickets') <=> $a->getfield('tickets');
565 % my $custnum = $cgi->param('custnum_text');
566 % $custnum =~ s/\D//g;
567 % $custnum =~ /^(\d{1,23})$/ or errorpage("Illegal customer number");
570 % [ qsearchs('cust_main', { 'custnum' => $custnum } ) ];
575 % my($card)=$cgi->param('card');
577 % $card =~ /^(\d{13,16})$/ or errorpage("Illegal card number");
580 % [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}),
581 % qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'})
585 %sub referralsearch {
586 % $cgi->param('referral_custnum') =~ /^(\d+)$/
587 % or errorpage("Illegal referral_custnum");
588 % my $cust_main = qsearchs('cust_main', { 'custnum' => $1 } )
589 % or errorpage("Customer $1 not found");
591 % if ( $cgi->param('referral_depth') ) {
592 % $cgi->param('referral_depth') =~ /^(\d+)$/
593 % or errorpage("Illegal referral_depth");
598 % [ $cust_main->referral_cust_main($depth) ];
604 % foreach ( $cgi->param('last_type') ) {
608 % $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/
609 % or errorpage("Illegal last name");
612 % if ( $last_type{'Exact'} || $last_type{'Fuzzy'} ) {
613 % push @cust_main, qsearch( 'cust_main',
614 % { 'last' => { 'op' => 'ILIKE',
615 % 'value' => $last } } );
617 % push @cust_main, qsearch( 'cust_main',
618 % { 'ship_last' => { 'op' => 'ILIKE',
619 % 'value' => $last } } )
620 % if defined dbdef->table('cust_main')->column('ship_last');
623 % if ( $last_type{'Substring'} || $last_type{'All'} ) {
625 % push @cust_main, qsearch( 'cust_main',
626 % { 'last' => { 'op' => 'ILIKE',
627 % 'value' => "%$last%" } } );
629 % push @cust_main, qsearch( 'cust_main',
630 % { 'ship_last' => { 'op' => 'ILIKE',
631 % 'value' => "%$last%" } } )
632 % if defined dbdef->table('cust_main')->column('ship_last');
636 % if ( $last_type{'Fuzzy'} || $last_type{'All'} ) {
637 % push @cust_main, FS::cust_main->fuzzy_search( { 'last' => $last } );
640 % #if ($last_type{'Sound-alike'}) {
650 % foreach ( $cgi->param('company_type') ) {
651 % $company_type{$_}++
654 % $cgi->param('company_text') =~
655 % /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
656 % or errorpage("Illegal company");
659 % if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) {
660 % push @cust_main, qsearch( 'cust_main',
661 % { 'company' => { 'op' => 'ILIKE',
662 % 'value' => $company } } );
664 % push @cust_main, qsearch( 'cust_main',
665 % { 'ship_company' => { 'op' => 'ILIKE',
666 % 'value' => $company } } )
667 % if defined dbdef->table('cust_main')->column('ship_last');
670 % if ( $company_type{'Substring'} || $company_type{'All'} ) {
672 % push @cust_main, qsearch( 'cust_main',
673 % { 'company' => { 'op' => 'ILIKE',
674 % 'value' => "%$company%" } } );
676 % push @cust_main, qsearch( 'cust_main',
677 % { 'ship_company' => { 'op' => 'ILIKE',
678 % 'value' => "%$company%" } })
679 % if defined dbdef->table('cust_main')->column('ship_last');
683 % if ( $company_type{'Fuzzy'} || $company_type{'All'} ) {
684 % push @cust_main, FS::cust_main->fuzzy_search( { 'company' => $company } );
687 % if ($company_type{'Sound-alike'}) {
693 %sub address2search {
696 % $cgi->param('address2_text') =~
697 % /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
698 % or errorpage("Illegal address2");
701 % push @cust_main, qsearch( 'cust_main',
702 % { 'address2' => { 'op' => 'ILIKE',
703 % 'value' => $address2 } } );
704 % push @cust_main, qsearch( 'cust_main',
705 % { 'ship_address2' => { 'op' => 'ILIKE',
706 % 'value' => $address2 } } );
714 % my $phone = $cgi->param('phone_text');
716 % #(no longer really) false laziness with Record::ut_phonen
717 % #only works with US/CA numbers...
719 % if ( $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ ) {
720 % $phone = "$1-$2-$3";
721 % $phone .= " x$4" if $4;
722 % } elsif ( $phone =~ /^(\d{3})(\d{4})$/ ) {
724 % } elsif ( $phone =~ /^(\d{3,4})$/ ) {
727 % errorpage(gettext('illegal_phone'). ": $phone");
730 % my @fields = qw(daytime night fax);
731 % push @fields, qw(ship_daytime ship_night ship_fax)
732 % if defined dbdef->table('cust_main')->column('ship_last');
734 % for my $field ( @fields ) {
735 % push @cust_main, qsearch ( 'cust_main',
736 % { $field => { 'op' => 'LIKE',
737 % 'value' => "%$phone%" } } );