From 51984ac3d3da3006809c6866fdecd4ad83610731 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Jul 2001 07:36:04 +0000 Subject: templates!!! --- httemplate/search/cust_main.cgi | 315 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 315 insertions(+) create mode 100755 httemplate/search/cust_main.cgi (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi new file mode 100755 index 000000000..844bb98b8 --- /dev/null +++ b/httemplate/search/cust_main.cgi @@ -0,0 +1,315 @@ +<% +# +# $Id: cust_main.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: post form to: +# http://server.name/path/cust_main.cgi +# +# ivan@voicenet.com 96-dec-12 +# +# rewrite ivan@sisd.com 98-mar-4 +# +# now does browsing too ivan@sisd.com 98-mar-6 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# display total, use FS::CGI ivan@sisd.com 98-jul-17 +# +# $Log: cust_main.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.17 2001/04/23 16:07:54 ivan +# fix +# Insecure dependency in eval while running with -T switch at /usr/local/lib/site_perl/FS/Record.pm line 202. +# +# Revision 1.16 2001/02/07 19:45:45 ivan +# tyop +# +# Revision 1.15 2000/07/17 16:45:41 ivan +# first shot at invoice browsing and some other cleanups +# +# Revision 1.14 1999/08/12 04:45:21 ivan +# typo - missed a paren +# +# Revision 1.13 1999/08/12 04:32:21 ivan +# hidecancelledcustomers +# +# Revision 1.12 1999/07/17 10:38:52 ivan +# scott nelson noticed this mod_perl-triggered bug and +# gave me a great bugreport at the last rhythmethod +# +# Revision 1.11 1999/04/09 04:22:34 ivan +# also table() +# +# Revision 1.10 1999/04/09 03:52:55 ivan +# explicit & for table/itable/ntable +# +# Revision 1.9 1999/02/28 00:03:55 ivan +# removed misleading comments +# +# Revision 1.8 1999/02/07 09:59:36 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.7 1999/01/25 12:19:11 ivan +# yet more mod_perl stuff +# +# Revision 1.6 1999/01/19 05:14:12 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.5 1999/01/18 09:41:37 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.4 1998/12/30 00:57:50 ivan +# bug +# +# Revision 1.3 1998/12/17 09:41:08 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# +# Revision 1.2 1998/11/12 08:10:22 ivan +# CGI.pm instead of CGI-modules +# relative URLs using popurl +# got rid of lots of little tables +# s/agrep/String::Approx/; +# bubble up packages and services and link (slow) +# + +use strict; +#use vars qw( $conf %ncancelled_pkgs %all_pkgs $cgi @cust_main $sortby ); +use vars qw( $conf %all_pkgs $cgi @cust_main $sortby ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use IO::Handle; +use String::Approx qw(amatch); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar eidiot popurl table); +use FS::cust_main; +use FS::cust_svc; + +$cgi = new CGI; +cgisuidsetup($cgi); + +$conf = new FS::Conf; + +if ( $cgi->keywords ) { + my($query)=$cgi->keywords; + if ( $query eq 'custnum' ) { + $sortby=\*custnum_sort; + @cust_main=qsearch('cust_main',{}); + } elsif ( $query eq 'last' ) { + $sortby=\*last_sort; + @cust_main=qsearch('cust_main',{}); + } elsif ( $query eq 'company' ) { + $sortby=\*company_sort; + @cust_main=qsearch('cust_main',{}); + } else { + die "unknown query string $query"; + } +} else { + @cust_main=(); + &cardsearch if ( $cgi->param('card_on') && $cgi->param('card') ); + &lastsearch if ( $cgi->param('last_on') && $cgi->param('last_text') ); + &companysearch if ( $cgi->param('company_on') && $cgi->param('company_text') ); +} + +@cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main + if $conf->exists('hidecancelledcustomers'); +if ( $conf->exists('hidecancelledpackages' ) ) { + %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main; +} else { + %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main; +} + +if ( scalar(@cust_main) == 1 ) { + print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); + exit; +} elsif ( scalar(@cust_main) == 0 ) { + eidiot "No matching customers found!\n"; +} else { + + my($total)=scalar(@cust_main); + print $cgi->header( '-expires' => 'now' ), header("Customer Search Results",menubar( + 'Main Menu', popurl(2) + )), "$total matching customers found
", &table(), < + + Contact name + Company + Packages + Services + +END + + my(%saw,$cust_main); + foreach $cust_main ( + sort $sortby grep(!$saw{$_->custnum}++, @cust_main) + ) { + my($custnum,$last,$first,$company)=( + $cust_main->custnum, + $cust_main->getfield('last'), + $cust_main->getfield('first'), + $cust_main->company, + ); + + my(@lol_cust_svc); + my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} ); + foreach ( @{$all_pkgs{$custnum}} ) { + my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); + push @lol_cust_svc, \@cust_svc; + $rowspan += scalar(@cust_svc) || 1; + } + + #my($rowspan) = scalar(@{$all_pkgs{$custnum}}); + my($view) = popurl(2). "view/cust_main.cgi?$custnum"; + print < + $custnum + $last, $first + $company +END + + my($n1)=''; + foreach ( @{$all_pkgs{$custnum}} ) { + my($pkgnum) = ($_->pkgnum); + 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; + + print $n1, qq!$pkg - $comment!; + my($n2)=''; + foreach my $cust_svc ( @cust_svc ) { + my($label, $value, $svcdb) = $cust_svc->label; + my($svcnum) = $cust_svc->svcnum; + my($sview) = popurl(2). "/view"; + print $n2,qq!$label!, + qq!$value!; + $n2=""; + } + #print qq!\n!; + $n1=""; + } + print ""; + } + + print < + + +END + +} + +# + +sub last_sort { + $a->getfield('last') cmp $b->getfield('last'); +} + +sub company_sort { + return -1 if $a->company && ! $b->company; + return 1 if ! $a->company && $b->company; + $a->getfield('company') cmp $b->getfield('company'); +} + +sub custnum_sort { + $a->getfield('custnum') <=> $b->getfield('custnum'); +} + +sub cardsearch { + + my($card)=$cgi->param('card'); + $card =~ s/\D//g; + $card =~ /^(\d{13,16})$/ or eidiot "Illegal card number\n"; + my($payinfo)=$1; + + push @cust_main, qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}); + +} + +sub lastsearch { + my(%last_type); + foreach ( $cgi->param('last_type') ) { + $last_type{$_}++; + } + + $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/ + or eidiot "Illegal last name"; + my($last)=$1; + + if ( $last_type{'Exact'} + && ! $last_type{'Fuzzy'} + # && ! $last_type{'Sound-alike'} + ) { + + push @cust_main, qsearch('cust_main',{'last'=>$last}); + + } else { + + my(%last); + + my(@all_last)=map $_->getfield('last'), qsearch('cust_main',{}); + if ($last_type{'Fuzzy'}) { + foreach ( amatch($last, [ qw(i) ], @all_last) ) { + $last{$_}++; + } + } + + #if ($last_type{'Sound-alike'}) { + #} + + foreach ( keys %last ) { + push @cust_main, qsearch('cust_main',{'last'=>$_}); + } + + } + $sortby=\*last_sort; +} + +sub companysearch { + + my(%company_type); + foreach ( $cgi->param('company_type') ) { + $company_type{$_}++ + }; + + $cgi->param('company_text') =~ /^([\w \,\.\-\']*)$/ + or eidiot "Illegal company"; + my($company)=$1; + + if ( $company_type{'Exact'} + && ! $company_type{'Fuzzy'} + # && ! $company_type{'Sound-alike'} + ) { + + push @cust_main, qsearch('cust_main',{'company'=>$company}); + + } else { + + my(%company); + my(@all_company)=map $_->company, qsearch('cust_main',{}); + + if ($company_type{'Fuzzy'}) { + foreach ( amatch($company, [ qw(i) ], @all_company ) ) { + $company{$_}++; + } + } + + #if ($company_type{'Sound-alike'}) { + #} + + foreach ( keys %company ) { + push @cust_main, qsearch('cust_main',{'company'=>$_}); + } + + } + $sortby=\*company_sort; + +} +%> -- cgit v1.2.1 From 2066bf9d3ebb4e53c49ab8b4b447c4eb88e425a4 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Jul 2001 10:41:44 +0000 Subject: shipping address additions --- httemplate/search/cust_main.cgi | 119 +++++++++++++--------------------------- 1 file changed, 39 insertions(+), 80 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 844bb98b8..86bca1fcf 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -1,81 +1,5 @@ <% -# -# $Id: cust_main.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# Usage: post form to: -# http://server.name/path/cust_main.cgi -# -# ivan@voicenet.com 96-dec-12 -# -# rewrite ivan@sisd.com 98-mar-4 -# -# now does browsing too ivan@sisd.com 98-mar-6 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# display total, use FS::CGI ivan@sisd.com 98-jul-17 -# -# $Log: cust_main.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.17 2001/04/23 16:07:54 ivan -# fix -# Insecure dependency in eval while running with -T switch at /usr/local/lib/site_perl/FS/Record.pm line 202. -# -# Revision 1.16 2001/02/07 19:45:45 ivan -# tyop -# -# Revision 1.15 2000/07/17 16:45:41 ivan -# first shot at invoice browsing and some other cleanups -# -# Revision 1.14 1999/08/12 04:45:21 ivan -# typo - missed a paren -# -# Revision 1.13 1999/08/12 04:32:21 ivan -# hidecancelledcustomers -# -# Revision 1.12 1999/07/17 10:38:52 ivan -# scott nelson noticed this mod_perl-triggered bug and -# gave me a great bugreport at the last rhythmethod -# -# Revision 1.11 1999/04/09 04:22:34 ivan -# also table() -# -# Revision 1.10 1999/04/09 03:52:55 ivan -# explicit & for table/itable/ntable -# -# Revision 1.9 1999/02/28 00:03:55 ivan -# removed misleading comments -# -# Revision 1.8 1999/02/07 09:59:36 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.7 1999/01/25 12:19:11 ivan -# yet more mod_perl stuff -# -# Revision 1.6 1999/01/19 05:14:12 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.5 1999/01/18 09:41:37 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.4 1998/12/30 00:57:50 ivan -# bug -# -# Revision 1.3 1998/12/17 09:41:08 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# -# Revision 1.2 1998/11/12 08:10:22 ivan -# CGI.pm instead of CGI-modules -# relative URLs using popurl -# got rid of lots of little tables -# s/agrep/String::Approx/; -# bubble up packages and services and link (slow) -# +# use strict; #use vars qw( $conf %ncancelled_pkgs %all_pkgs $cgi @cust_main $sortby ); @@ -85,7 +9,7 @@ use CGI::Carp qw(fatalsToBrowser); use IO::Handle; use String::Approx qw(amatch); use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs); +use FS::Record qw(qsearch qsearchs dbdef); use FS::CGI qw(header menubar eidiot popurl table); use FS::cust_main; use FS::cust_svc; @@ -137,8 +61,18 @@ if ( scalar(@cust_main) == 1 ) { )), "$total matching customers found
", &table(), < - Contact name - Company + (bill) name + company +END + +if ( defined dbdef->table('cust_main')->column('ship_last') ) { + print <(service) name + company +END +} + +print <Packages Services @@ -171,6 +105,17 @@ END $last, $first $company END + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + my($ship_last,$ship_first,$ship_company)=( + $cust_main->ship_last || $cust_main->getfield('last'), + $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first, + $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company, + ); +print <$ship_last, $ship_first + $ship_company +END + } my($n1)=''; foreach ( @{$all_pkgs{$custnum}} ) { @@ -250,11 +195,16 @@ sub lastsearch { push @cust_main, qsearch('cust_main',{'last'=>$last}); + push @cust_main, qsearch('cust_main',{'ship_last'=>$last}) + if defined dbdef->table('cust_main')->column('ship_last'); + } else { my(%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'); if ($last_type{'Fuzzy'}) { foreach ( amatch($last, [ qw(i) ], @all_last) ) { $last{$_}++; @@ -266,6 +216,8 @@ sub lastsearch { foreach ( keys %last ) { push @cust_main, qsearch('cust_main',{'last'=>$_}); + push @cust_main, qsearch('cust_main',{'ship_last'=>$_}) + if defined dbdef->table('cust_main')->column('ship_last'); } } @@ -290,10 +242,15 @@ sub companysearch { push @cust_main, qsearch('cust_main',{'company'=>$company}); + push @cust_main, qsearch('cust_main',{'ship_company'=>$company}) + if defined dbdef->table('cust_main')->column('ship_last'); + } 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'); if ($company_type{'Fuzzy'}) { foreach ( amatch($company, [ qw(i) ], @all_company ) ) { @@ -306,6 +263,8 @@ sub companysearch { foreach ( keys %company ) { push @cust_main, qsearch('cust_main',{'company'=>$_}); + push @cust_main, qsearch('cust_main',{'ship_company'=>$_}) + if defined dbdef->table('cust_main')->column('ship_last'); } } -- cgit v1.2.1 From aa7b51c0794f6a61e522fbba978f6c64446d8696 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 28 Aug 2001 14:34:14 +0000 Subject: customer-to-customer referrals! --- httemplate/search/cust_main.cgi | 65 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 6 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 86bca1fcf..d038896f6 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 ); @@ -35,9 +35,10 @@ if ( $cgi->keywords ) { } } else { @cust_main=(); - &cardsearch if ( $cgi->param('card_on') && $cgi->param('card') ); - &lastsearch if ( $cgi->param('last_on') && $cgi->param('last_text') ); - &companysearch if ( $cgi->param('company_on') && $cgi->param('company_text') ); + &cardsearch if $cgi->param('card_on') && $cgi->param('card'); + &lastsearch if $cgi->param('last_on') && $cgi->param('last_text'); + &companysearch if $cgi->param('company_on') && $cgi->param('company_text'); + &referralsearch if $cgi->param('referral_custnum'); } @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main @@ -48,7 +49,7 @@ if ( $conf->exists('hidecancelledpackages' ) ) { %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main; } -if ( scalar(@cust_main) == 1 ) { +if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); exit; } elsif ( scalar(@cust_main) == 0 ) { @@ -58,7 +59,42 @@ if ( scalar(@cust_main) == 1 ) { my($total)=scalar(@cust_main); print $cgi->header( '-expires' => 'now' ), header("Customer Search Results",menubar( 'Main Menu', popurl(2) - )), "$total matching customers found
", &table(), <param('referral_custnum') ) { + $cgi->param('referral_custnum') =~ /^(\d+)$/ + or eidiot "Illegal referral_custnum\n"; + my $referral_custnum = $1; + my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); + print '
'. + qq!!. + 'referrals of $referral_custnum: ". + ( $cust_main->company + || $cust_main->last. ', '. $cust_main->first ). + ''; + print "\n",< + function changed(what) { + what.form.submit(); + } + +END + print ' levels deep". + ''. + ''; + } + print "
", &table(), < (bill) name @@ -175,7 +211,24 @@ sub cardsearch { my($payinfo)=$1; push @cust_main, qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}); + $sortby=\*last_sort; +} +sub referralsearch { + $cgi->param('referral_custnum') =~ /^(\d+)$/ + or eidiot "Illegal referral_custnum"; + my $cust_main = qsearchs('cust_main', { 'custnum' => $1 } ) + or eidiot "Customer $1 not found"; + my $depth; + if ( $cgi->param('referral_depth') ) { + $cgi->param('referral_depth') =~ /^(\d+)$/ + or eidiot "Illegal referral_depth"; + $depth = $1; + } else { + $depth = 1; + } + push @cust_main, $cust_main->referral_cust_main($depth); + $sortby=\*last_sort; } sub lastsearch { -- cgit v1.2.1 From 5e99168da38e7616fc726242ce7d85e140f22c6f Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 28 Aug 2001 16:58:08 +0000 Subject: customer-to-customer referrals in singup server --- httemplate/search/cust_main.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index d038896f6..5defaf4af 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 ); @@ -81,7 +81,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { END print ' '. ''; } - print "
", &table(), <
". $pager. &table(). < (bill) name @@ -240,14 +346,12 @@ END print ""; } - print < - - -END + print "$pager"; } +undef $cache; #does this help? + # sub last_sort { -- cgit v1.2.1 From 9bb09778b787ed8a69436c8da34616e80a9addf2 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Dec 2001 08:43:46 +0000 Subject: paged customer browse! --- httemplate/search/cust_main.cgi | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index a139f0eed..b26889d0b 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 ); @@ -21,7 +21,7 @@ cgisuidsetup($cgi); $conf = new FS::Conf; $maxrecords = $conf->config('maxsearchrecordsperpage'); -my $cache; +#my $cache; #my $monsterjoin = < Date: Mon, 3 Dec 2001 10:59:25 +0000 Subject: paged package browse --- httemplate/search/cust_main.cgi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index b26889d0b..d5bc17aec 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -1,15 +1,17 @@ <% -# +# use strict; #use vars qw( $conf %ncancelled_pkgs %all_pkgs $cgi @cust_main $sortby ); #use vars qw( $conf %all_pkgs $cgi @cust_main $sortby ); -use vars qw( $conf %all_pkgs $cgi @cust_main $sortby $orderby $maxrecords $limit $offset ); +use vars qw( $conf %all_pkgs $cgi @cust_main $sortby + $orderby $maxrecords $limit $offset ); use CGI; use CGI::Carp qw(fatalsToBrowser); use IO::Handle; use String::Approx qw(amatch); use FS::UID qw(dbh cgisuidsetup); +use FS::Conf; use FS::Record qw(qsearch qsearchs dbdef jsearch); use FS::CGI qw(header menubar eidiot popurl table); use FS::cust_main; @@ -163,6 +165,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { 'Main Menu', popurl(2) )), "$total matching customers found "; + #begin pager my $pager = ''; if ( $total != scalar(@cust_main) && $maxrecords ) { unless ( $offset == 0 ) { @@ -187,6 +190,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { '">Next '; } } + #end pager if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me || ( $conf->exists('hidecancelledcustomers') -- cgit v1.2.1 From 301ef098a56e1fc011d26d1f108a48e99ad701f4 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Dec 2001 11:33:19 +0000 Subject: paged service browse!! --- httemplate/search/cust_main.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index d5bc17aec..b9b1d1fb2 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 ); @@ -110,7 +110,7 @@ if ( $cgi->param('browse') ) { or die dbh->errstr. " doing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; - $total = @{$sth->fetchrow_arrayref}[0]; + $total = $sth->fetchrow_arrayref->[0]; my @just_cust_main = qsearch('cust_main',{}, '', "$ncancelled $orderby $limit" -- cgit v1.2.1 From f91771606ce8a2bb4f2fa44e7bf54c9b7c945db6 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 26 Dec 2001 05:19:01 +0000 Subject: expedited check entry --- httemplate/search/cust_main.cgi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index b9b1d1fb2..4d3ec3564 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 ); @@ -154,7 +154,11 @@ if ( $conf->exists('hidecancelledpackages' ) ) { #%all_pkgs = (); if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { - print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); + if ( $cgi->param('quickpay') eq 'yes' ) { + print $cgi->redirect(popurl(2). "edit/cust_pay.cgi?quickpay=yes;custnum=". $cust_main[0]->custnum); + } else { + print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); + } exit; } elsif ( scalar(@cust_main) == 0 ) { eidiot "No matching customers found!\n"; @@ -282,7 +286,12 @@ END } #my($rowspan) = scalar(@{$all_pkgs{$custnum}}); - my $view = $p. 'view/cust_main.cgi?'. $custnum; + my $view; + if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) { + $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum; + } else { + $view = $p. 'view/cust_main.cgi?'. $custnum; + } print < $custnum -- cgit v1.2.1 From d73c1796de9df0ed14469f745d985cd706137d6d Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 9 Jan 2002 13:29:34 +0000 Subject: update fuzzy cache files on customer replace. do an exact search along with the fuzzy search (webui) --- httemplate/search/cust_main.cgi | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 4d3ec3564..65db0a815 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 ); @@ -399,17 +399,18 @@ sub lastsearch { or eidiot "Illegal last name"; my($last)=$1; - if ( $last_type{'Exact'} - && ! $last_type{'Fuzzy'} - # && ! $last_type{'Sound-alike'} - ) { +# if ( $last_type{'Exact'} +# && ! $last_type{'Fuzzy'} +# # && ! $last_type{'Sound-alike'} +# ) { push @cust_main, qsearch('cust_main',{'last'=>$last}); push @cust_main, qsearch('cust_main',{'ship_last'=>$last}) if defined dbdef->table('cust_main')->column('ship_last'); - } else { +# } else { + if ( $last_type{'Fuzzy'} ) { &FS::cust_main::check_and_rebuild_fuzzyfiles; my $all_last = &FS::cust_main::all_last; @@ -445,17 +446,18 @@ sub companysearch { or eidiot "Illegal company"; my($company)=$1; - if ( $company_type{'Exact'} - && ! $company_type{'Fuzzy'} - # && ! $company_type{'Sound-alike'} - ) { +# if ( $company_type{'Exact'} +# && ! $company_type{'Fuzzy'} +# # && ! $company_type{'Sound-alike'} +# ) { push @cust_main, qsearch('cust_main',{'company'=>$company}); push @cust_main, qsearch('cust_main',{'ship_company'=>$company}) if defined dbdef->table('cust_main')->column('ship_last'); - } else { +# } else { + if ( $company_type{'Fuzzy'} ) { &FS::cust_main::check_and_rebuild_fuzzyfiles; my $all_company = &FS::cust_main::all_company; -- cgit v1.2.1 From 1fd6d8cf5d7854860ef4fd10ed89828e0c04ec39 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 30 Jan 2002 14:18:09 +0000 Subject: remove use Module; and $cgi = new CGI; &cgisuidsetup(); from all templates. should work better under Mason. --- httemplate/search/cust_main.cgi | 65 ++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 37 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 65db0a815..f21dd7ed1 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -1,27 +1,7 @@ <% -# - -use strict; -#use vars qw( $conf %ncancelled_pkgs %all_pkgs $cgi @cust_main $sortby ); -#use vars qw( $conf %all_pkgs $cgi @cust_main $sortby ); -use vars qw( $conf %all_pkgs $cgi @cust_main $sortby - $orderby $maxrecords $limit $offset ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use IO::Handle; -use String::Approx qw(amatch); -use FS::UID qw(dbh cgisuidsetup); -use FS::Conf; -use FS::Record qw(qsearch qsearchs dbdef jsearch); -use FS::CGI qw(header menubar eidiot popurl table); -use FS::cust_main; -use FS::cust_svc; - -$cgi = new CGI; -cgisuidsetup($cgi); - -$conf = new FS::Conf; -$maxrecords = $conf->config('maxsearchrecordsperpage'); + +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); #my $cache; @@ -59,16 +39,15 @@ $maxrecords = $conf->config('maxsearchrecordsperpage'); #) using (custnum) #END -$orderby = ''; #removeme - -$limit = ''; +my $limit = ''; $limit .= "LIMIT $maxrecords" if $maxrecords; -$offset = $cgi->param('offset') || 0; +my $offset = $cgi->param('offset') || 0; $limit .= " OFFSET $offset" if $offset; my $total; +my(@cust_main, $sortby, $orderby); if ( $cgi->param('browse') ) { my $query = $cgi->param('browse'); if ( $query eq 'custnum' ) { @@ -135,10 +114,21 @@ if ( $cgi->param('browse') ) { } else { @cust_main=(); - &cardsearch if $cgi->param('card_on') && $cgi->param('card'); - &lastsearch if $cgi->param('last_on') && $cgi->param('last_text'); - &companysearch if $cgi->param('company_on') && $cgi->param('company_text'); - &referralsearch if $cgi->param('referral_custnum'); + $sortby = \*last_sort; + + push @cust_main, @{&cardsearch} + if $cgi->param('card_on') && $cgi->param('card'); + push @cust_main, @{&lastsearch} + if $cgi->param('last_on') && $cgi->param('last_text'); + push @cust_main, @{&companysearch} + if $cgi->param('company_on') && $cgi->param('company_text'); + push @cust_main, @{&referralsearch} + if $cgi->param('referral_custnum'); + + if ( $cgi->param('company_on') && $cgi->param('company_text') ) { + $sortby = \*company_sort; + push @cust_main, @{&companysearch}; + } @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main if $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me @@ -146,6 +136,7 @@ if ( $cgi->param('browse') ) { && ! $cgi->param('showcancelledcustomers') ); } +my %all_pkgs; if ( $conf->exists('hidecancelledpackages' ) ) { %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main; } else { @@ -368,8 +359,7 @@ sub cardsearch { $card =~ /^(\d{13,16})$/ or eidiot "Illegal card number\n"; my($payinfo)=$1; - push @cust_main, qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}); - $sortby=\*last_sort; + [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}) ]; } sub referralsearch { @@ -385,12 +375,12 @@ sub referralsearch { } else { $depth = 1; } - push @cust_main, $cust_main->referral_cust_main($depth); - $sortby=\*last_sort; + [ $cust_main->referral_cust_main($depth) ]; } sub lastsearch { my(%last_type); + my @cust_main; foreach ( $cgi->param('last_type') ) { $last_type{$_}++; } @@ -432,12 +422,13 @@ sub lastsearch { } } - $sortby=\*last_sort; + \@cust_main; } sub companysearch { my(%company_type); + my @cust_main; foreach ( $cgi->param('company_type') ) { $company_type{$_}++ }; @@ -479,7 +470,7 @@ sub companysearch { } } - $sortby=\*company_sort; + \@cust_main; } %> -- cgit v1.2.1 From 0bdec843e4a9bb7f947c9ba980a40f7bf37020fb Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 9 Feb 2002 18:24:02 +0000 Subject: no more exit() in templates --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index f21dd7ed1..89e325d09 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -150,7 +150,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { } else { print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); } - exit; + #exit; } elsif ( scalar(@cust_main) == 0 ) { eidiot "No matching customers found!\n"; } else { -- cgit v1.2.1 From a4c96748eb6eab29a70f3a944c6520283a635c78 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Feb 2002 16:05:22 +0000 Subject: *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. --- httemplate/search/cust_main.cgi | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 89e325d09..b962c7c42 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -152,8 +152,14 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { } #exit; } elsif ( scalar(@cust_main) == 0 ) { +%> + +<% eidiot "No matching customers found!\n"; } else { +%> + +<% $total ||= scalar(@cust_main); print header("Customer Search Results",menubar( -- cgit v1.2.1 From b05f4d252a27eab0a6fa8212abf920c0fa24a509 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Feb 2002 17:30:33 +0000 Subject: eliminate duplicate cusomters before figuring to display a list or redirect. eliiminates "2 matching found" displayed but only one in list. --- httemplate/search/cust_main.cgi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index b962c7c42..1e28ad57d 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -45,7 +45,7 @@ $limit .= "LIMIT $maxrecords" if $maxrecords; my $offset = $cgi->param('offset') || 0; $limit .= " OFFSET $offset" if $offset; -my $total; +my $total = 0; my(@cust_main, $sortby, $orderby); if ( $cgi->param('browse') ) { @@ -134,6 +134,9 @@ if ( $cgi->param('browse') ) { if $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me || ( $conf->exists('hidecancelledcustomers') && ! $cgi->param('showcancelledcustomers') ); + + my %saw = (); + @cust_main = grep { !$saw{$_->custnum}++ } @cust_main; } my %all_pkgs; -- cgit v1.2.1 From 903b22b3da3e3ee493bb322854c6bc0b0085e0dd Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 23 Feb 2002 11:56:55 +0000 Subject: case-insensitive and substring searching --- httemplate/search/cust_main.cgi | 63 +++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 18 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 1e28ad57d..f153f02d4 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -398,24 +398,37 @@ sub lastsearch { or eidiot "Illegal last name"; my($last)=$1; -# if ( $last_type{'Exact'} -# && ! $last_type{'Fuzzy'} -# # && ! $last_type{'Sound-alike'} -# ) { + if ( $last_type{'Exact'} || $last_type{'Fuzzy'} ) { + push @cust_main, qsearch( 'cust_main', + { 'last' => { 'op' => 'ILIKE', + 'value' => $last } } ); + + push @cust_main, qsearch( 'cust_main', + { 'ship_last' => { 'op' => 'ILIKE', + 'value' => $last } } ) + if defined dbdef->table('cust_main')->column('ship_last'); + } + + if ( $last_type{'Substring'} || $last_type{'All'} ) { - push @cust_main, qsearch('cust_main',{'last'=>$last}); + push @cust_main, qsearch( 'cust_main', + { 'last' => { 'op' => 'ILIKE', + 'value' => "%$last%" } } ); - push @cust_main, qsearch('cust_main',{'ship_last'=>$last}) + push @cust_main, qsearch( 'cust_main', + { 'ship_last' => { 'op' => 'ILIKE', + 'value' => "%$last%" } } ) if defined dbdef->table('cust_main')->column('ship_last'); -# } else { - if ( $last_type{'Fuzzy'} ) { + } + + if ( $last_type{'Fuzzy'} || $last_type{'All'} ) { &FS::cust_main::check_and_rebuild_fuzzyfiles; my $all_last = &FS::cust_main::all_last; my %last; - if ($last_type{'Fuzzy'}) { + if ( $last_type{'Fuzzy'} || $last_type{'All'} ) { foreach ( amatch($last, [ qw(i) ], @$all_last) ) { $last{$_}++; } @@ -431,6 +444,7 @@ sub lastsearch { } } + \@cust_main; } @@ -446,24 +460,37 @@ sub companysearch { or eidiot "Illegal company"; my($company)=$1; -# if ( $company_type{'Exact'} -# && ! $company_type{'Fuzzy'} -# # && ! $company_type{'Sound-alike'} -# ) { + if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) { + push @cust_main, qsearch( 'cust_main', + { 'company' => { 'op' => 'ILIKE', + 'value' => $company } } ); - push @cust_main, qsearch('cust_main',{'company'=>$company}); + push @cust_main, qsearch( 'cust_main', + { 'ship_company' => { 'op' => 'ILIKE', + 'value' => $company } } ) + if defined dbdef->table('cust_main')->column('ship_last'); + } + + if ( $company_type{'Substring'} || $company_type{'All'} ) { - push @cust_main, qsearch('cust_main',{'ship_company'=>$company}) + push @cust_main, qsearch( 'cust_main', + { 'company' => { 'op' => 'ILIKE', + 'value' => "%$company%" } } ); + + push @cust_main, qsearch( 'cust_main', + { 'ship_company' => { 'op' => 'ILIKE', + 'value' => "%$company%" } }) if defined dbdef->table('cust_main')->column('ship_last'); -# } else { - if ( $company_type{'Fuzzy'} ) { + } + + if ( $company_type{'Fuzzy'} || $company_type{'All'} ) { &FS::cust_main::check_and_rebuild_fuzzyfiles; my $all_company = &FS::cust_main::all_company; my %company; - if ($company_type{'Fuzzy'}) { + if ( $company_type{'Fuzzy'} || $company_type{'All'} ) { foreach ( amatch($company, [ qw(i) ], @$all_company ) ) { $company{$_}++; } -- cgit v1.2.1 From 4ea362bfa2d2ea984996439e0c32cb4ea6dda7ee Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 25 Mar 2002 14:59:06 +0000 Subject: customers by otaker report (ugly search/cust_main.cgi mods; revert if they cause problems) --- httemplate/search/cust_main.cgi | 63 +++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 15 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index f153f02d4..799569898 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -48,19 +48,34 @@ $limit .= " OFFSET $offset" if $offset; my $total = 0; my(@cust_main, $sortby, $orderby); -if ( $cgi->param('browse') ) { - my $query = $cgi->param('browse'); - if ( $query eq 'custnum' ) { - $sortby=\*custnum_sort; - $orderby = 'ORDER BY custnum'; - } elsif ( $query eq 'last' ) { - $sortby=\*last_sort; - $orderby = 'ORDER BY last'; - } elsif ( $query eq 'company' ) { - $sortby=\*company_sort; - $orderby = 'ORDER BY company'; +if ( $cgi->param('browse') + || $cgi->param('otaker_on') +) { + + my %search = (); + if ( $cgi->param('browse') ) { + my $query = $cgi->param('browse'); + if ( $query eq 'custnum' ) { + $sortby=\*custnum_sort; + $orderby = 'ORDER BY custnum'; + } elsif ( $query eq 'last' ) { + $sortby=\*last_sort; + $orderby = 'ORDER BY last'; + } elsif ( $query eq 'company' ) { + $sortby=\*company_sort; + $orderby = 'ORDER BY company'; + } else { + die "unknown browse field $query"; + } } else { - die "unknown browse field $query"; + $sortby = \*last_sort; #?? + $orderby = 'ORDER BY last'; #?? + if ( $cgi->param('otaker_on') ) { + $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; + $search{otaker} = $1; + } else { + die "unknown query..."; + } } my $ncancelled = ''; @@ -72,7 +87,7 @@ if ( $cgi->param('browse') ) { #grep { $_->ncancelled_pkgs || ! $_->all_pkgs } #needed for MySQL??? OR cust_pkg.cancel = \"\" $ncancelled = " - WHERE 0 < ( SELECT COUNT(*) FROM cust_pkg + 0 < ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.custnum = cust_main.custnum AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 @@ -84,14 +99,32 @@ if ( $cgi->param('browse') ) { "; } - my $statement = "SELECT COUNT(*) FROM cust_main $ncancelled"; + #EWWWWWW + my $qual = join(' AND ', + map { "$_ = ". dbh->quote($search{$_}) } keys %search ); + + if ( $ncancelled ) { + $qual .= ' AND ' if $qual; + $qual .= $ncancelled; + } + + $qual = " WHERE $qual" if $qual; + + my $statement = "SELECT COUNT(*) FROM cust_main $qual"; my $sth = dbh->prepare($statement) or die dbh->errstr. " doing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; $total = $sth->fetchrow_arrayref->[0]; - my @just_cust_main = qsearch('cust_main',{}, '', + if ( $ncancelled ) { + if ( %search ) { + $ncancelled = " AND $ncancelled"; + } else { + $ncancelled = " WHERE $ncancelled"; + } + } + my @just_cust_main = qsearch('cust_main', \%search, '', "$ncancelled $orderby $limit" ); -- cgit v1.2.1 From 081fd913aa0383c06425ca1a832d30f7f79e7a06 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Mar 2002 16:24:26 +0000 Subject: simple visual fix:   for blank company column --- httemplate/search/cust_main.cgi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 799569898..03997ee35 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -325,11 +325,14 @@ END } else { $view = $p. 'view/cust_main.cgi?'. $custnum; } + my $pcompany = $company + ? qq!$company! + : ' '; print < $custnum $last, $first - $company + $pcompany END if ( defined dbdef->table('cust_main')->column('ship_last') ) { my($ship_last,$ship_first,$ship_company)=( @@ -337,9 +340,14 @@ END $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first, $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company, ); + my $pship_company = $ship_company + ? qq!$ship_company! + : ' '; + print <$ship_last, $ship_first - $ship_company + $pship_company END } -- cgit v1.2.1 From 336d87dc8c7c105d3d9cd41c3590acc09964281d Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 6 Apr 2002 21:32:03 +0000 Subject: fix visual glitch --- httemplate/search/cust_main.cgi | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 03997ee35..63aa924b1 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -340,12 +340,10 @@ END $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first, $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company, ); - my $pship_company = $ship_company - ? qq!$ship_company! - : ' '; - print <$ship_company! + : ' '; + print <$ship_last, $ship_first $pship_company END -- cgit v1.2.1 From 644260c472b6aaf40ab4cea714bed5e6bfe708c1 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 17 Apr 2002 00:25:58 +0000 Subject: better ordering in search results --- httemplate/search/cust_main.cgi | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 63aa924b1..2e255cfa2 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -57,19 +57,19 @@ if ( $cgi->param('browse') my $query = $cgi->param('browse'); if ( $query eq 'custnum' ) { $sortby=\*custnum_sort; - $orderby = 'ORDER BY custnum'; + $orderby = "ORDER BY custnum"; } elsif ( $query eq 'last' ) { $sortby=\*last_sort; - $orderby = 'ORDER BY last'; + $orderby = "ORDER BY LOWER(last || ' ' || first)"; } elsif ( $query eq 'company' ) { $sortby=\*company_sort; - $orderby = 'ORDER BY company'; + $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; } else { die "unknown browse field $query"; } } else { $sortby = \*last_sort; #?? - $orderby = 'ORDER BY last'; #?? + $orderby = "ORDER BY LOWER(last || ' ' || first)"; #?? if ( $cgi->param('otaker_on') ) { $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; $search{otaker} = $1; @@ -387,13 +387,16 @@ END # sub last_sort { - $a->getfield('last') cmp $b->getfield('last'); + lc($a->getfield('last')) cmp lc($b->getfield('last')) + || lc($a->first) cmp lc($b->first); } sub company_sort { return -1 if $a->company && ! $b->company; return 1 if ! $a->company && $b->company; - $a->getfield('company') cmp $b->getfield('company'); + lc($a->company) cmp lc($b->company) + || lc($a->getfield('last')) cmp lc($b->getfield('last')) + || lc($a->first) cmp lc($b->first);; } sub custnum_sort { -- cgit v1.2.1 From 7fc18b419e3cec20eb7c898017673b40a7424cde Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 4 Jun 2002 14:02:18 +0000 Subject: mysql support! thanks to Donald Greer for the SQL and Dale Hege for the patches --- httemplate/search/cust_main.cgi | 81 +++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 19 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 2e255cfa2..b4565601b 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -80,23 +80,52 @@ if ( $cgi->param('browse') my $ncancelled = ''; + if ( driver_name eq 'mysql' ) { + + my $query = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM + SELECT cust_pkg.custnum,COUNT(*) as count + FROM cust_pkg,cust_main + WHERE cust_pkg.custnum = cust_main.custnum + AND ( cust_pkg.cancel IS NULL + OR cust_pkg.cancel = 0 ) + GROUP BY cust_pkg.custnum"; + my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + $query = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM + SELECT cust_pkg.custnum,COUNT(*) as count + FROM cust_pkg,cust_main + WHERE cust_pkg.custnum = cust_main.custnum + GROUP BY cust_pkg.custnum"; + my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + } + if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me || ( $conf->exists('hidecancelledcustomers') && ! $cgi->param('showcancelledcustomers') ) ) { #grep { $_->ncancelled_pkgs || ! $_->all_pkgs } - #needed for MySQL??? OR cust_pkg.cancel = \"\" - $ncancelled = " - 0 < ( SELECT COUNT(*) FROM cust_pkg - WHERE cust_pkg.custnum = cust_main.custnum - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 - ) - ) - OR 0 = ( SELECT COUNT(*) FROM cust_pkg - WHERE cust_pkg.custnum = cust_main.custnum - ) - "; + if ( driver_name eq 'mysql' ) { + $ncancelled = " + temp1_$$.custnum = cust_main.custnum + AND temp2_$$.custnum = cust_main.custnum + AND (temp1_$$.count > 0 + OR temp2_$$.count = 0 ) + "; + } else { + $ncancelled = " + 0 < ( SELECT COUNT(*) FROM cust_pkg + WHERE cust_pkg.custnum = cust_main.custnum + AND ( cust_pkg.cancel IS NULL + OR cust_pkg.cancel = 0 + ) + ) + OR 0 = ( SELECT COUNT(*) FROM cust_pkg + WHERE cust_pkg.custnum = cust_main.custnum + ) + "; + } + } #EWWWWWW @@ -109,10 +138,14 @@ if ( $cgi->param('browse') } $qual = " WHERE $qual" if $qual; - - my $statement = "SELECT COUNT(*) FROM cust_main $qual"; - my $sth = dbh->prepare($statement) - or die dbh->errstr. " doing $statement"; + my $statement; + if ( driver_name eq 'mysql' ) { + $statement = "SELECT COUNT(*) FROM cust_main"; + $statement .= ", temp1_$$, temp2_$$ $qual" if $qual; + } else { + $statement = "SELECT COUNT(*) FROM cust_main $qual"; + } + my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; $total = $sth->fetchrow_arrayref->[0]; @@ -124,10 +157,20 @@ if ( $cgi->param('browse') $ncancelled = " WHERE $ncancelled"; } } - my @just_cust_main = qsearch('cust_main', \%search, '', - "$ncancelled $orderby $limit" - ); + my @just_cust_main; + if ( driver_name eq /mysql/ ) { + @just_cust_main = qsearch('cust_main', \%search, 'cust_main.*', + ",temp1_$$,temp2_$$ $ncancelled $orderby $limit"); + } else { + @just_cust_main = qsearch('cust_main', \%search, '', + "$ncancelled $orderby $limit" ); + } + if ( driver_name eq 'mysql' ) { + $query = "DROP TABLE temp1_$$,temp2_$$;"; + my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + } @cust_main = @just_cust_main; # foreach my $cust_main ( @just_cust_main ) { -- cgit v1.2.1 From c9b608b9c0df8921d30055f18c23fd2d030afb25 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 5 Jun 2002 22:46:26 +0000 Subject: more mysql goodness, thanks dale --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index b4565601b..d9d4e657c 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -159,7 +159,7 @@ if ( $cgi->param('browse') } my @just_cust_main; - if ( driver_name eq /mysql/ ) { + if ( driver_name eq 'mysql' ) { @just_cust_main = qsearch('cust_main', \%search, 'cust_main.*', ",temp1_$$,temp2_$$ $ncancelled $orderby $limit"); } else { -- cgit v1.2.1 From afe61aa1e4158a49ba67740d947a991e285d5fb1 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 13 Jun 2002 00:53:26 +0000 Subject: search on customer number (Bug#422) --- httemplate/search/cust_main.cgi | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index d9d4e657c..247cf8fd6 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -192,6 +192,8 @@ if ( $cgi->param('browse') @cust_main=(); $sortby = \*last_sort; + push @cust_main, @{&custnumsearch} + if $cgi->param('custnum_on') && $cgi->param('custnum_text'); push @cust_main, @{&cardsearch} if $cgi->param('card_on') && $cgi->param('card'); push @cust_main, @{&lastsearch} @@ -446,6 +448,16 @@ sub custnum_sort { $a->getfield('custnum') <=> $b->getfield('custnum'); } +sub custnumsearch { + + my $custnum = $cgi->param('custnum_text'); + $custnum =~ s/\D//g; + $custnum =~ /^(\d{1,23})$/ or eidiot "Illegal customer number\n"; + my $custnum = $1; + + [ qsearchs('cust_main', { 'custnum' => $custnum } ) ]; +} + sub cardsearch { my($card)=$cgi->param('card'); -- cgit v1.2.1 From 141003fc6cab41daf1a4a697a610c953ec42906e Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 13 Jun 2002 23:28:14 +0000 Subject: phone number search (Bug#422) --- httemplate/search/cust_main.cgi | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 247cf8fd6..1bd5fb60a 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -200,6 +200,8 @@ if ( $cgi->param('browse') if $cgi->param('last_on') && $cgi->param('last_text'); push @cust_main, @{&companysearch} if $cgi->param('company_on') && $cgi->param('company_text'); + push @cust_main, @{&phonesearch} + if $cgi->param('phone_on') && $cgi->param('phone_text'); push @cust_main, @{&referralsearch} if $cgi->param('referral_custnum'); @@ -606,4 +608,30 @@ sub companysearch { \@cust_main; } + +sub phonesearch { + my @cust_main; + + my $phone = $cgi->param('phone_text'); + + #false laziness with Record::ut_phonen, only works with US/CA numbers... + $phone =~ s/\D//g; + $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ + or eidiot gettext('illegal_phone'). ": $phone"; + $phone = "$1-$2-$3"; + $phone .= " x$4" if $4; + + my @fields = qw(daytime night fax); + push @fields, qw(ship_daytime ship_night ship_fax) + if defined dbdef->table('cust_main')->column('ship_last'); + + for my $field ( @fields ) { + push @cust_main, qsearch ( 'cust_main', + { $field => { 'op' => 'LIKE', + 'value' => "$phone%" } } ); + } + + \@cust_main; +} + %> -- cgit v1.2.1 From 18f51a14e90cf1548326419120cdba1c33d99c63 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 14 Jun 2002 00:12:49 +0000 Subject: search by for address2 (unit) - commented out in default index.html --- httemplate/search/cust_main.cgi | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 1bd5fb60a..586f8d991 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -200,6 +200,8 @@ if ( $cgi->param('browse') if $cgi->param('last_on') && $cgi->param('last_text'); push @cust_main, @{&companysearch} if $cgi->param('company_on') && $cgi->param('company_text'); + push @cust_main, @{&address2search} + if $cgi->param('address2_on') && $cgi->param('address2_text'); push @cust_main, @{&phonesearch} if $cgi->param('phone_on') && $cgi->param('phone_text'); push @cust_main, @{&referralsearch} @@ -555,9 +557,10 @@ sub companysearch { $company_type{$_}++ }; - $cgi->param('company_text') =~ /^([\w \,\.\-\']*)$/ - or eidiot "Illegal company"; - my($company)=$1; + $cgi->param('company_text') =~ + /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ + or eidiot "Illegal company"; + my $company = $1; if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) { push @cust_main, qsearch( 'cust_main', @@ -609,6 +612,25 @@ sub companysearch { \@cust_main; } +sub address2search { + my @cust_main; + + $cgi->param('address2_text') =~ + /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ + or eidiot "Illegal address2"; + my $address2 = $1; + + push @cust_main, qsearch( 'cust_main', + { 'address2' => { 'op' => 'ILIKE', + 'value' => $address2 } } ); + push @cust_main, qsearch( 'cust_main', + { 'address2' => { 'op' => 'ILIKE', + 'value' => $address2 } } ) + if defined dbdef->table('cust_main')->column('ship_last'); + + \@cust_main; +} + sub phonesearch { my @cust_main; -- cgit v1.2.1 From 93773ff8f4e002cb70a07cb4f7956279eb630acf Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 11 Sep 2002 09:09:23 +0000 Subject: mason warnings --- httemplate/search/cust_main.cgi | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 586f8d991..0a98b1891 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -82,22 +82,22 @@ if ( $cgi->param('browse') if ( driver_name eq 'mysql' ) { - my $query = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM - SELECT cust_pkg.custnum,COUNT(*) as count - FROM cust_pkg,cust_main - WHERE cust_pkg.custnum = cust_main.custnum - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 ) - GROUP BY cust_pkg.custnum"; - my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; - $query = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM - SELECT cust_pkg.custnum,COUNT(*) as count - FROM cust_pkg,cust_main - WHERE cust_pkg.custnum = cust_main.custnum - GROUP BY cust_pkg.custnum"; - my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + my $sql = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM + SELECT cust_pkg.custnum,COUNT(*) as count + FROM cust_pkg,cust_main + WHERE cust_pkg.custnum = cust_main.custnum + AND ( cust_pkg.cancel IS NULL + OR cust_pkg.cancel = 0 ) + GROUP BY cust_pkg.custnum"; + my $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; + $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; + $sql = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM + SELECT cust_pkg.custnum,COUNT(*) as count + FROM cust_pkg,cust_main + WHERE cust_pkg.custnum = cust_main.custnum + GROUP BY cust_pkg.custnum"; + $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; + $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; } if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me @@ -167,9 +167,9 @@ if ( $cgi->param('browse') "$ncancelled $orderby $limit" ); } if ( driver_name eq 'mysql' ) { - $query = "DROP TABLE temp1_$$,temp2_$$;"; - my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + my $sql = "DROP TABLE temp1_$$,temp2_$$;"; + my $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; + $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; } @cust_main = @just_cust_main; @@ -457,7 +457,7 @@ sub custnumsearch { my $custnum = $cgi->param('custnum_text'); $custnum =~ s/\D//g; $custnum =~ /^(\d{1,23})$/ or eidiot "Illegal customer number\n"; - my $custnum = $1; + $custnum = $1; [ qsearchs('cust_main', { 'custnum' => $custnum } ) ]; } -- cgit v1.2.1 From c4d2226e0cc4bdd6d9f689b061b5f4f5b9609b0b Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 4 Oct 2002 12:57:06 +0000 Subject: working on the road: - easier "change package" link for changing one package to another - sqlradius export now compatible with Pg - indices on phone numbers - install instructions specify Pg 7.1 (at least until ILIKE thing is changed) - searching on phone number fragments --- httemplate/search/cust_main.cgi | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 0a98b1891..ac238b63e 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -636,12 +636,19 @@ sub phonesearch { my $phone = $cgi->param('phone_text'); - #false laziness with Record::ut_phonen, only works with US/CA numbers... + #(no longer really) false laziness with Record::ut_phonen + #only works with US/CA numbers... $phone =~ s/\D//g; - $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ - or eidiot gettext('illegal_phone'). ": $phone"; - $phone = "$1-$2-$3"; - $phone .= " x$4" if $4; + if ( $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ ) { + $phone = "$1-$2-$3"; + $phone .= " x$4" if $4; + } elsif ( $phone =~ /^(\d{3})(\d{4})$/ ) { + $phone = "$1-$2"; + } elsif ( $phone =~ /^(\d{3,4})$/ ) { + $phone = $1; + } else { + eidiot gettext('illegal_phone'). ": $phone"; + } my @fields = qw(daytime night fax); push @fields, qw(ship_daytime ship_night ship_fax) @@ -650,7 +657,7 @@ sub phonesearch { for my $field ( @fields ) { push @cust_main, qsearch ( 'cust_main', { $field => { 'op' => 'LIKE', - 'value' => "$phone%" } } ); + 'value' => "%$phone%" } } ); } \@cust_main; -- cgit v1.2.1 From 030bef17868168b05a67d9f5866b55da1bb9439c Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 21 Apr 2003 20:53:57 +0000 Subject: on-demand vs. automatic cards & checks: added DCRD and DCHK payment types --- httemplate/search/cust_main.cgi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index ac238b63e..fe4ec5d05 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -469,7 +469,9 @@ sub cardsearch { $card =~ /^(\d{13,16})$/ or eidiot "Illegal card number\n"; my($payinfo)=$1; - [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}) ]; + [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}) + qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'}) + ]; } sub referralsearch { -- cgit v1.2.1 From f3b99e9676baf155c46d37d56a5da4db57536072 Mon Sep 17 00:00:00 2001 From: khoff Date: Wed, 23 Apr 2003 05:36:24 +0000 Subject: Missing comma. --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index fe4ec5d05..5b39a09f2 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -469,7 +469,7 @@ sub cardsearch { $card =~ /^(\d{13,16})$/ or eidiot "Illegal card number\n"; my($payinfo)=$1; - [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}) + [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}), qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'}) ]; } -- cgit v1.2.1 From c3e5b694f98b424f9fe68b76450d1464ba7a0fec Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 29 Sep 2003 10:10:47 +0000 Subject: agent browse now links to active/cancelled customers --- httemplate/search/cust_main.cgi | 77 ++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 24 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 5b39a09f2..50d367e1e 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -50,6 +50,7 @@ my $total = 0; my(@cust_main, $sortby, $orderby); if ( $cgi->param('browse') || $cgi->param('otaker_on') + || $cgi->param('agentnum_on') ) { my %search = (); @@ -73,6 +74,9 @@ if ( $cgi->param('browse') if ( $cgi->param('otaker_on') ) { $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; $search{otaker} = $1; + } elsif ( $cgi->param('agentnum_on') ) { + $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; + $search{agentnum} = $1; } else { die "unknown query..."; } @@ -112,6 +116,7 @@ if ( $cgi->param('browse') AND (temp1_$$.count > 0 OR temp2_$$.count = 0 ) "; + } else { $ncancelled = " 0 < ( SELECT COUNT(*) FROM cust_pkg @@ -124,15 +129,32 @@ if ( $cgi->param('browse') WHERE cust_pkg.custnum = cust_main.custnum ) "; - } - + } + } + + my $cancelled = ''; + if ( $cgi->param('cancelled') ) { + $cancelled = " + 0 = ( SELECT COUNT(*) FROM cust_pkg + WHERE cust_pkg.custnum = cust_main.custnum + AND ( cust_pkg.cancel IS NULL + OR cust_pkg.cancel = 0 + ) + ) + AND 0 < ( SELECT COUNT(*) FROM cust_pkg + WHERE cust_pkg.custnum = cust_main.custnum + ) + "; } #EWWWWWW my $qual = join(' AND ', map { "$_ = ". dbh->quote($search{$_}) } keys %search ); - if ( $ncancelled ) { + if ( $cancelled ) { + $qual .= ' AND ' if $qual; + $qual .= $cancelled; + } elsif ( $ncancelled ) { $qual .= ' AND ' if $qual; $qual .= $ncancelled; } @@ -150,21 +172,22 @@ if ( $cgi->param('browse') $total = $sth->fetchrow_arrayref->[0]; - if ( $ncancelled ) { + my $rqual = $cancelled || $ncancelled; + if ( $rqual ) { if ( %search ) { - $ncancelled = " AND $ncancelled"; + $rqual = " AND $rqual"; } else { - $ncancelled = " WHERE $ncancelled"; + $rqual = " WHERE $rqual"; } } my @just_cust_main; if ( driver_name eq 'mysql' ) { @just_cust_main = qsearch('cust_main', \%search, 'cust_main.*', - ",temp1_$$,temp2_$$ $ncancelled $orderby $limit"); + ",temp1_$$,temp2_$$ $rqual $orderby $limit"); } else { @just_cust_main = qsearch('cust_main', \%search, '', - "$ncancelled $orderby $limit" ); + "$rqual $orderby $limit" ); } if ( driver_name eq 'mysql' ) { my $sql = "DROP TABLE temp1_$$,temp2_$$;"; @@ -213,9 +236,12 @@ if ( $cgi->param('browse') } @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main - if $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me - || ( $conf->exists('hidecancelledcustomers') - && ! $cgi->param('showcancelledcustomers') ); + if ! $cgi->param('cancelled') + && ( + $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me + || ( $conf->exists('hidecancelledcustomers') + && ! $cgi->param('showcancelledcustomers') ) + ); my %saw = (); @cust_main = grep { !$saw{$_->custnum}++ } @cust_main; @@ -277,19 +303,22 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { } } #end pager - - if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me - || ( $conf->exists('hidecancelledcustomers') - && ! $cgi->param('showcancelledcustomers') - ) - ) { - $cgi->param('showcancelledcustomers', 1); - $cgi->param('offset', 0); - print qq!( show cancelled customers )!; - } else { - $cgi->param('showcancelledcustomers', 0); - $cgi->param('offset', 0); - print qq!( hide cancelled customers )!; + + unless ( $cgi->param('cancelled') ) { + if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me + || ( $conf->exists('hidecancelledcustomers') + && ! $cgi->param('showcancelledcustomers') + ) + ) { + $cgi->param('showcancelledcustomers', 1); + $cgi->param('offset', 0); + print qq!( show!; + } else { + $cgi->param('showcancelledcustomers', 0); + $cgi->param('offset', 0); + print qq!( hide!; + } + print ' cancelled customers )'; } if ( $cgi->param('referral_custnum') ) { $cgi->param('referral_custnum') =~ /^(\d+)$/ -- cgit v1.2.1 From e3f327b2af9e6a591bae41d315fda731ec7f5128 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Mar 2004 11:05:58 +0000 Subject: remove everything that links to package view also, closes: Bug#569 --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 50d367e1e..69a78d6fe 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -435,7 +435,7 @@ END my $pkg = $part_pkg->pkg; my $comment = $part_pkg->comment; - my $pkgview = $p. 'view/cust_pkg.cgi?'. $pkgnum; + my $pkgview = "${p}view/cust_main.cgi?$custnum#cust_pkg$pkgnum"; my @cust_svc = @{shift @lol_cust_svc}; #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); my $rowspan = scalar(@cust_svc) || 1; -- cgit v1.2.1 From 3913f6d159b5b8110061690b7c97642c27abf7eb Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 10 Jun 2004 12:31:32 +0000 Subject: agent interface --- httemplate/search/cust_main.cgi | 111 ++++++++++------------------------------ 1 file changed, 27 insertions(+), 84 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 69a78d6fe..632d68df9 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -82,119 +82,62 @@ if ( $cgi->param('browse') } } - my $ncancelled = ''; + my @qual = (); - if ( driver_name eq 'mysql' ) { - - my $sql = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM - SELECT cust_pkg.custnum,COUNT(*) as count - FROM cust_pkg,cust_main - WHERE cust_pkg.custnum = cust_main.custnum - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 ) - GROUP BY cust_pkg.custnum"; - my $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; - $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; - $sql = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM - SELECT cust_pkg.custnum,COUNT(*) as count - FROM cust_pkg,cust_main - WHERE cust_pkg.custnum = cust_main.custnum - GROUP BY cust_pkg.custnum"; - $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; - $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; - } + my $ncancelled = ''; if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me || ( $conf->exists('hidecancelledcustomers') && ! $cgi->param('showcancelledcustomers') ) ) { #grep { $_->ncancelled_pkgs || ! $_->all_pkgs } - if ( driver_name eq 'mysql' ) { - $ncancelled = " - temp1_$$.custnum = cust_main.custnum - AND temp2_$$.custnum = cust_main.custnum - AND (temp1_$$.count > 0 - OR temp2_$$.count = 0 ) - "; - - } else { - $ncancelled = " - 0 < ( SELECT COUNT(*) FROM cust_pkg - WHERE cust_pkg.custnum = cust_main.custnum - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 - ) - ) - OR 0 = ( SELECT COUNT(*) FROM cust_pkg - WHERE cust_pkg.custnum = cust_main.custnum - ) - "; - } - } - - my $cancelled = ''; - if ( $cgi->param('cancelled') ) { - $cancelled = " - 0 = ( SELECT COUNT(*) FROM cust_pkg - WHERE cust_pkg.custnum = cust_main.custnum - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 - ) - ) - AND 0 < ( SELECT COUNT(*) FROM cust_pkg + push @qual, " + ( 0 < ( SELECT COUNT(*) FROM cust_pkg + WHERE cust_pkg.custnum = cust_main.custnum + AND ( cust_pkg.cancel IS NULL + OR cust_pkg.cancel = 0 + ) + ) + OR 0 = ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.custnum = cust_main.custnum ) + ) "; - } + } + + push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled'); + push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect'); + push @qual, FS::cust_main->active_sql if $cgi->param('active'); + push @qual, FS::cust_main->susp_sql if $cgi->param('suspended'); #EWWWWWW my $qual = join(' AND ', map { "$_ = ". dbh->quote($search{$_}) } keys %search ); - if ( $cancelled ) { - $qual .= ' AND ' if $qual; - $qual .= $cancelled; - } elsif ( $ncancelled ) { + my $addl_qual = join(' AND ', @qual); + + if ( $addl_qual ) { $qual .= ' AND ' if $qual; - $qual .= $ncancelled; + $qual .= $addl_qual; } $qual = " WHERE $qual" if $qual; - my $statement; - if ( driver_name eq 'mysql' ) { - $statement = "SELECT COUNT(*) FROM cust_main"; - $statement .= ", temp1_$$, temp2_$$ $qual" if $qual; - } else { - $statement = "SELECT COUNT(*) FROM cust_main $qual"; - } + my $statement = "SELECT COUNT(*) FROM cust_main $qual"; my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; $total = $sth->fetchrow_arrayref->[0]; - my $rqual = $cancelled || $ncancelled; - if ( $rqual ) { + if ( $addl_qual ) { if ( %search ) { - $rqual = " AND $rqual"; + $addl_qual = " AND $addl_qual"; } else { - $rqual = " WHERE $rqual"; + $addl_qual = " WHERE $addl_qual"; } } - my @just_cust_main; - if ( driver_name eq 'mysql' ) { - @just_cust_main = qsearch('cust_main', \%search, 'cust_main.*', - ",temp1_$$,temp2_$$ $rqual $orderby $limit"); - } else { - @just_cust_main = qsearch('cust_main', \%search, '', - "$rqual $orderby $limit" ); - } - if ( driver_name eq 'mysql' ) { - my $sql = "DROP TABLE temp1_$$,temp2_$$;"; - my $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; - $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; - } - @cust_main = @just_cust_main; + @cust_main = qsearch('cust_main', \%search, '', + "$addl_qual $orderby $limit" ); # foreach my $cust_main ( @just_cust_main ) { # -- cgit v1.2.1 From 0cbeb01df08457b056a7ae775b4924c266b4228b Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 24 Aug 2004 11:16:57 +0000 Subject: big update for reseller interface --- httemplate/search/cust_main.cgi | 46 +++++++---------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 632d68df9..27f23de36 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -498,28 +498,12 @@ sub lastsearch { } if ( $last_type{'Fuzzy'} || $last_type{'All'} ) { - - &FS::cust_main::check_and_rebuild_fuzzyfiles; - my $all_last = &FS::cust_main::all_last; - - my %last; - if ( $last_type{'Fuzzy'} || $last_type{'All'} ) { - foreach ( amatch($last, [ qw(i) ], @$all_last) ) { - $last{$_}++; - } - } - - #if ($last_type{'Sound-alike'}) { - #} - - foreach ( keys %last ) { - push @cust_main, qsearch('cust_main',{'last'=>$_}); - push @cust_main, qsearch('cust_main',{'ship_last'=>$_}) - if defined dbdef->table('cust_main')->column('ship_last'); - } - + push @cust_main, FS::cust_main->fuzzy_search( { 'last' => $last } ); } + #if ($last_type{'Sound-alike'}) { + #} + \@cust_main; } @@ -561,26 +545,10 @@ sub companysearch { } if ( $company_type{'Fuzzy'} || $company_type{'All'} ) { + push @cust_main, FS::cust_main->fuzzy_search( { 'company' => $company } ); + } - &FS::cust_main::check_and_rebuild_fuzzyfiles; - my $all_company = &FS::cust_main::all_company; - - my %company; - if ( $company_type{'Fuzzy'} || $company_type{'All'} ) { - foreach ( amatch($company, [ qw(i) ], @$all_company ) ) { - $company{$_}++; - } - } - - #if ($company_type{'Sound-alike'}) { - #} - - foreach ( keys %company ) { - push @cust_main, qsearch('cust_main',{'company'=>$_}); - push @cust_main, qsearch('cust_main',{'ship_company'=>$_}) - if defined dbdef->table('cust_main')->column('ship_last'); - } - + if ($company_type{'Sound-alike'}) { } \@cust_main; -- cgit v1.2.1 From 0d1d2630e726ab4ce32bab9c3e4a889eee43fcb4 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Dec 2004 09:59:48 +0000 Subject: second big RT integration checkin, customer linking/delinking interface --- httemplate/search/cust_main.cgi | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 27f23de36..c4b0ce0cd 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -48,6 +48,9 @@ $limit .= " OFFSET $offset" if $offset; my $total = 0; my(@cust_main, $sortby, $orderby); +my @select = (); +my @addl_headers = (); +my @addl_cols = (); if ( $cgi->param('browse') || $cgi->param('otaker_on') || $cgi->param('agentnum_on') @@ -65,6 +68,12 @@ if ( $cgi->param('browse') } elsif ( $query eq 'company' ) { $sortby=\*company_sort; $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; + } elsif ( $query eq 'tickets' ) { + $sortby = \*tickets_sort; + $orderby = "ORDER BY tickets DESC"; + push @select, FS::TicketSystem->sql_customer_tickets. " as tickets"; + push @addl_headers, 'Tickets'; + push @addl_cols, 'tickets'; } else { die "unknown browse field $query"; } @@ -136,7 +145,14 @@ if ( $cgi->param('browse') } } - @cust_main = qsearch('cust_main', \%search, '', + my $select; + if ( @select ) { + $select = 'cust_main.*, '. join (', ', @select); + } else { + $select = '*'; + } + + @cust_main = qsearch('cust_main', \%search, $select, "$addl_qual $orderby $limit" ); # foreach my $cust_main ( @just_cust_main ) { @@ -312,6 +328,10 @@ if ( defined dbdef->table('cust_main')->column('ship_last') ) { END } +foreach my $addl_header ( @addl_headers ) { + print "$addl_header"; +} + print <Packages Services @@ -370,6 +390,12 @@ END END } + foreach my $addl_col ( @addl_cols ) { + print qq!!. + $cust_main->get($addl_col). + ""; + } + my($n1)=''; foreach ( @{$all_pkgs{$custnum}} ) { my $pkgnum = $_->pkgnum; @@ -424,6 +450,10 @@ sub custnum_sort { $a->getfield('custnum') <=> $b->getfield('custnum'); } +sub tickets_sort { + $a->getfield('tickets') <=> $b->getfield('tickets'); +} + sub custnumsearch { my $custnum = $cgi->param('custnum_text'); -- cgit v1.2.1 From 2e01e767e3ec53eca7193e4498a449d9d92b4f89 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Dec 2004 10:18:35 +0000 Subject: fix license boilerplate and search sorting --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index c4b0ce0cd..b2f8befe7 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -451,7 +451,7 @@ sub custnum_sort { } sub tickets_sort { - $a->getfield('tickets') <=> $b->getfield('tickets'); + $b->getfield('tickets') <=> $a->getfield('tickets'); } sub custnumsearch { -- cgit v1.2.1 From cce36d549b8d8cb7612f3b9a85927801de756e7e Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Dec 2004 06:56:56 +0000 Subject: link customers back to tickets! --- httemplate/search/cust_main.cgi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index b2f8befe7..48fbf41bb 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -339,7 +339,6 @@ print <custnum}++, @cust_main) ) { @@ -391,7 +390,10 @@ END } foreach my $addl_col ( @addl_cols ) { - print qq!!. + print "". + qq!!. $cust_main->get($addl_col). ""; } -- cgit v1.2.1 From dda497584a2e12907bba7cf07051fe34ede63b32 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Dec 2004 14:00:43 +0000 Subject: 1st try at adding custom field handling --- httemplate/search/cust_main.cgi | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 48fbf41bb..7d15d1cfc 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -279,6 +279,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { } print ' cancelled customers )'; } + if ( $cgi->param('referral_custnum') ) { $cgi->param('referral_custnum') =~ /^(\d+)$/ or eidiot "Illegal referral_custnum\n"; @@ -314,6 +315,13 @@ END ''; } + my @custom_priorities = (); + if ( $conf->config('ticket_system-custom_priority_field') + && @{ $conf->config('ticket_system-custom_priority_field-values') } ) { + @custom_priorities = + $conf->config('ticket_system-custom_priority_field-values'); + } + print "

". $pager. &table(). < @@ -390,12 +398,28 @@ END } foreach my $addl_col ( @addl_cols ) { - print "". - qq!!. - $cust_main->get($addl_col). - ""; + print ""; + if ( $addl_col eq 'tickets' ) { + if ( @custom_priorities ) { + foreach my $priority ( @custom_priorities ) { + print ''. + FS::TicketSystem->num_customer_tickets($custnum,$priority). + " $priority
"; + } + } + print ''. + $cust_main->get($addl_col); + print ' total' + if @custom_priorities; + print ""; + } else { + print $cust_main->get($addl_col); + } + print ""; } my($n1)=''; -- cgit v1.2.1 From 083686ba493552355f8665b362917b70e181a859 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Dec 2004 14:09:29 +0000 Subject: fix reading custome field values --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 7d15d1cfc..916ccf24e 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -317,7 +317,7 @@ END my @custom_priorities = (); if ( $conf->config('ticket_system-custom_priority_field') - && @{ $conf->config('ticket_system-custom_priority_field-values') } ) { + && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) { @custom_priorities = $conf->config('ticket_system-custom_priority_field-values'); } -- cgit v1.2.1 From a6595fa854b75f109450bf1af3cc9333ba9dc723 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Dec 2004 14:36:47 +0000 Subject: fix total links and line up custom field columns --- httemplate/search/cust_main.cgi | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 916ccf24e..56b4f27d4 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -401,21 +401,26 @@ END print ""; if ( $addl_col eq 'tickets' ) { if ( @custom_priorities ) { + print ''; foreach my $priority ( @custom_priorities ) { - print ''. - FS::TicketSystem->num_customer_tickets($custnum,$priority). - " $priority
"; + my $ahref = + ''; + print "". + ""; } + print "
$ahref". + FS::TicketSystem->num_customer_tickets($custnum,$priority). + "$ahref$priority
"; } - print ''. - $cust_main->get($addl_col); - print ' total' + my $ahref = + ''; + print $ahref. $cust_main->get($addl_col). ''; + print '${ahref}total
' if @custom_priorities; - print ""; } else { print $cust_main->get($addl_col); } -- cgit v1.2.1 From 8127468dc459a8257ab7c15cca10801b9b2a3551 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Dec 2004 14:42:08 +0000 Subject: fix total link --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 56b4f27d4..a12c180a5 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -419,7 +419,7 @@ END FS::TicketSystem->href_customer_tickets($custnum). '">'; print $ahref. $cust_main->get($addl_col). ''; - print '${ahref}total' + print "${ahref}total" if @custom_priorities; } else { print $cust_main->get($addl_col); -- cgit v1.2.1 From 8d4abaa99403699aa5b5f02e899d2ea33980f913 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 09:21:43 +0000 Subject: more RT integration --- httemplate/search/cust_main.cgi | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index a12c180a5..ca9df87a6 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -71,7 +71,7 @@ if ( $cgi->param('browse') } elsif ( $query eq 'tickets' ) { $sortby = \*tickets_sort; $orderby = "ORDER BY tickets DESC"; - push @select, FS::TicketSystem->sql_customer_tickets. " as tickets"; + push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets"; push @addl_headers, 'Tickets'; push @addl_cols, 'tickets'; } else { @@ -402,7 +402,7 @@ END if ( $addl_col eq 'tickets' ) { if ( @custom_priorities ) { print ''; - foreach my $priority ( @custom_priorities ) { + foreach my $priority ( @custom_priorities, '' ) { my $ahref = '". - ""; + ""; } - print "'. + '
$ahref". FS::TicketSystem->num_customer_tickets($custnum,$priority). "$ahref$priority
$ahref". + ( $priority || '(none)' ). +
"; + print '
 
'; } my $ahref = ''; print $ahref. $cust_main->get($addl_col). ''; - print "${ahref}total
" + print "${ahref}Total" if @custom_priorities; } else { print $cust_main->get($addl_col); -- cgit v1.2.1 From d32a4d7f7855e245caa546c41819bcf01d4cccf1 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 09:57:43 +0000 Subject: fix typo --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index ca9df87a6..209c50848 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -412,7 +412,7 @@ END "". "$ahref". ( $priority || '(none)' ). - "; + ""; } print ' '. ''; -- cgit v1.2.1 From d5f33566675ef84accc14877733e243eec95ff01 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 10:07:50 +0000 Subject: deuglify --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 209c50848..9ef384740 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -414,7 +414,7 @@ END ( $priority || '(none)' ). ""; } - print ' '. + print ''. ''; } my $ahref = -- cgit v1.2.1 From 22edb078bfa5aebdef81f7048a81f8336449cdbf Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 22:02:39 +0000 Subject: UI: condense ticket subtable a little --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 9ef384740..778cdf2b0 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -401,7 +401,7 @@ END print ""; if ( $addl_col eq 'tickets' ) { if ( @custom_priorities ) { - print ''; + print &itable('', 0); foreach my $priority ( @custom_priorities, '' ) { my $ahref = 'href_customer_tickets($custnum,$priority). '">'; - print "". - "". + ""; + ""; } print ''. '
$ahref". + print "
$ahref". FS::TicketSystem->num_customer_tickets($custnum,$priority). - "$ahref". + "$ahref". ( $priority || '(none)' ). - "
'; @@ -425,7 +425,7 @@ END print "${ahref}Total
" if @custom_priorities; } else { - print $cust_main->get($addl_col); + print ''. $cust_main->get($addl_col). ''; } print ""; } -- cgit v1.2.1 From 0857cba67d87cdbfac318f8912b9e8147600a2a2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 22:20:42 +0000 Subject: UI: dont link to empty lists --- httemplate/search/cust_main.cgi | 43 ++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 32ce10d94..8dd38991f 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -398,36 +398,47 @@ END } foreach my $addl_col ( @addl_cols ) { - print ""; + print ""; if ( $addl_col eq 'tickets' ) { if ( @custom_priorities ) { print &itable('', 0); foreach my $priority ( @custom_priorities, '' ) { - my $ahref = - ''; - print "$ahref". - FS::TicketSystem->num_customer_tickets($custnum,$priority). - "". + + my $num = + FS::TicketSystem->num_customer_tickets($custnum,$priority); + my $ahref = ''; + $aref = ''; + if $num; + + print ''. + " $ahref$num". "$ahref". ( $priority || '(none)' ). ""; + } print ''. - ''; + ''; } - my $ahref = - ''; + + my $ahref = ''; + my $ahref = ''; + if $cust_main->get($addl_col); + print $ahref. $cust_main->get($addl_col). ''; - print "${ahref}Total" + print "". + "${ahref}Total". + "" if @custom_priorities; + } else { - print ''. $cust_main->get($addl_col). ''; + print $cust_main->get($addl_col); } - print ""; + print ""; } my($n1)=''; -- cgit v1.2.1 From 6a953c149c5f4423cafc510e34c60b41bd7d0ef9 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 22:26:45 +0000 Subject: UI: dont link to empty lists --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 8dd38991f..5e30249e6 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -407,7 +407,7 @@ END my $num = FS::TicketSystem->num_customer_tickets($custnum,$priority); my $ahref = ''; - $aref = 'href_customer_tickets($custnum,$priority). '">'; if $num; -- cgit v1.2.1 From 2bb260ad6df6a86dc24d0678cf42181fe25e07e7 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 23:05:53 +0000 Subject: typo --- httemplate/search/cust_main.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 5e30249e6..10746e7e3 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -409,7 +409,7 @@ END my $ahref = ''; $ahref= ''; + '">' if $num; print ''. @@ -426,7 +426,7 @@ END my $ahref = ''; my $ahref = ''; + '">' if $cust_main->get($addl_col); print $ahref. $cust_main->get($addl_col). ''; -- cgit v1.2.1 From 4493f7285eba8e90c795e5cae680f986fdc3372f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 9 Dec 2004 23:14:56 +0000 Subject: typo --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 10746e7e3..ecff4bf3b 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -424,7 +424,7 @@ END } my $ahref = ''; - my $ahref = 'href_customer_tickets($custnum). '">' if $cust_main->get($addl_col); -- cgit v1.2.1 From 34647c32b50ce3b8ee1b6d3d7aef4ba9d0297bdb Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 6 Mar 2005 03:04:29 +0000 Subject: add Excel and CSV download of templated reports and clean up their HTML formatting, closes; Bug#520, Bug#1107 --- httemplate/search/cust_main.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index ecff4bf3b..a3256674b 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -285,7 +285,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { or eidiot "Illegal referral_custnum\n"; my $referral_custnum = $1; my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); - print '
'. + print ''. qq!!. 'referrals of $referral_custnum: ". -- cgit v1.2.1 From 65886f8e35ddd4a618760d7771c6163521cb43b5 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 21 May 2005 17:26:01 +0000 Subject: hehe, allow changing the browse order of any sort --- httemplate/search/cust_main.cgi | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'httemplate/search/cust_main.cgi') diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index a3256674b..665f5637d 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -57,6 +57,7 @@ if ( $cgi->param('browse') ) { my %search = (); + if ( $cgi->param('browse') ) { my $query = $cgi->param('browse'); if ( $query eq 'custnum' ) { @@ -80,15 +81,16 @@ if ( $cgi->param('browse') } else { $sortby = \*last_sort; #?? $orderby = "ORDER BY LOWER(last || ' ' || first)"; #?? - if ( $cgi->param('otaker_on') ) { - $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; - $search{otaker} = $1; - } elsif ( $cgi->param('agentnum_on') ) { - $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; - $search{agentnum} = $1; - } else { - die "unknown query..."; - } + } + + if ( $cgi->param('otaker_on') ) { + $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; + $search{otaker} = $1; + } elsif ( $cgi->param('agentnum_on') ) { + $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; + $search{agentnum} = $1; +# } else { +# die "unknown query..."; } my @qual = (); -- cgit v1.2.1