<%
-#<!-- $Id: cust_main.cgi,v 1.5 2001-09-11 00:08:18 ivan Exp $ -->
+#<!-- $Id: cust_main.cgi,v 1.9 2001-10-10 05:59:36 thalakan Exp $ -->
use strict;
#use vars qw( $conf %ncancelled_pkgs %all_pkgs $cgi @cust_main $sortby );
$conf = new FS::Conf;
-if ( $cgi->keywords ) {
- my($query)=$cgi->keywords;
+if ( $cgi->param('browse') ) {
+ my $query = $cgi->param('browse');
if ( $query eq 'custnum' ) {
$sortby=\*custnum_sort;
@cust_main=qsearch('cust_main',{});
$sortby=\*company_sort;
@cust_main=qsearch('cust_main',{});
} else {
- die "unknown query string $query";
+ die "unknown browse field $query";
}
} else {
@cust_main=();
}
@cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main
- if $conf->exists('hidecancelledcustomers');
+ if $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
+ || ( $conf->exists('hidecancelledcustomers')
+ && ! $cgi->param('showcancelledcustomers') );
if ( $conf->exists('hidecancelledpackages' ) ) {
%all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main;
} else {
my($total)=scalar(@cust_main);
print $cgi->header( '-expires' => 'now' ), header("Customer Search Results",menubar(
'Main Menu', popurl(2)
- )), "$total matching customers found";
+ )), "$total matching customers found ";
+ if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
+ || ( $conf->exists('hidecancelledcustomers')
+ && ! $cgi->param('showcancelledcustomers')
+ )
+ ) {
+ $cgi->param('showcancelledcustomers', 1);
+ print qq!( <a href="!. $cgi->self_url. qq!">show cancelled customers</a> )!;
+ } else {
+ $cgi->param('showcancelledcustomers', 0);
+ print qq!( <a href="!. $cgi->self_url. qq!">hide cancelled customers</a> )!;
+ }
if ( $cgi->param('referral_custnum') ) {
$cgi->param('referral_custnum') =~ /^(\d+)$/
or eidiot "Illegal referral_custnum\n";
$last_type{$_}++;
}
- $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/
- or eidiot "Illegal last name";
- my($last)=$1;
+ my $cust_obj = new FS::cust_main;
+ $cust_obj->setfield('last', $cgi->param('last_text'));
+ my $error = $cust_obj->ut_name('last');
+ eidiot "Illegal last name" if $error;
+ my($last) = $cust_obj->getfield('last');
if ( $last_type{'Exact'}
&& ! $last_type{'Fuzzy'}