X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=a52321de3ce01d87b8eb21edd1e88a936c9eab8d;hb=50c494e839fc0dd73ff986d04c54a8d508f5ede0;hp=5defaf4aff774b511f71d65b2a39f51884f52ff0;hpb=5e99168da38e7616fc726242ce7d85e140f22c6f;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 5defaf4af..a52321de3 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; #use vars qw( $conf %ncancelled_pkgs %all_pkgs $cgi @cust_main $sortby ); @@ -19,8 +19,8 @@ cgisuidsetup($cgi); $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',{}); @@ -31,7 +31,7 @@ if ( $cgi->keywords ) { $sortby=\*company_sort; @cust_main=qsearch('cust_main',{}); } else { - die "unknown query string $query"; + die "unknown browse field $query"; } } else { @cust_main=(); @@ -42,7 +42,9 @@ if ( $cgi->keywords ) { } @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 { @@ -57,9 +59,20 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { } else { my($total)=scalar(@cust_main); - print $cgi->header( '-expires' => 'now' ), header("Customer Search Results",menubar( + print 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!( show cancelled customers )!; + } else { + $cgi->param('showcancelledcustomers', 0); + print qq!( hide cancelled customers )!; + } if ( $cgi->param('referral_custnum') ) { $cgi->param('referral_custnum') =~ /^(\d+)$/ or eidiot "Illegal referral_custnum\n"; @@ -159,9 +172,9 @@ END my($pkg) = $_->part_pkg->pkg; my $comment = $_->part_pkg->comment; my($pkgview) = popurl(2). "/view/cust_pkg.cgi?$pkgnum"; - #my(@cust_svc) = shift @lol_cust_svc; - my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); - my($rowspan) = scalar(@cust_svc) || 1; + my @cust_svc = @{shift @lol_cust_svc}; + #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); + my $rowspan = scalar(@cust_svc) || 1; print $n1, qq!$pkg - $comment!; my($n2)=''; @@ -253,13 +266,12 @@ sub lastsearch { } else { - my(%last); + &FS::cust_main::check_and_rebuild_fuzzyfiles; + my $all_last = &FS::cust_main::all_last; - my(@all_last)=map $_->getfield('last'), qsearch('cust_main',{}); - push @all_last, grep $_, map $_->getfield('ship_last'), qsearch('cust_main',{}) - if defined dbdef->table('cust_main')->column('ship_last'); + my %last; if ($last_type{'Fuzzy'}) { - foreach ( amatch($last, [ qw(i) ], @all_last) ) { + foreach ( amatch($last, [ qw(i) ], @$all_last) ) { $last{$_}++; } } @@ -300,13 +312,12 @@ sub companysearch { } else { - my(%company); - my(@all_company)=map $_->company, qsearch('cust_main',{}); - push @all_company, grep $_, map $_->getfield('ship_company'), qsearch('cust_main',{}) - if defined dbdef->table('cust_main')->column('ship_last'); + &FS::cust_main::check_and_rebuild_fuzzyfiles; + my $all_company = &FS::cust_main::all_company; + my %company; if ($company_type{'Fuzzy'}) { - foreach ( amatch($company, [ qw(i) ], @all_company ) ) { + foreach ( amatch($company, [ qw(i) ], @$all_company ) ) { $company{$_}++; } }