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_bill.cgi | 180 ++++++++++++++++++ httemplate/search/cust_bill.html | 21 +++ httemplate/search/cust_main-payinfo.html | 20 ++ httemplate/search/cust_main.cgi | 315 +++++++++++++++++++++++++++++++ httemplate/search/cust_main.html | 36 ++++ httemplate/search/cust_pkg.cgi | 155 +++++++++++++++ httemplate/search/svc_acct.cgi | 211 +++++++++++++++++++++ httemplate/search/svc_acct.html | 21 +++ httemplate/search/svc_acct_sm.cgi | 144 ++++++++++++++ httemplate/search/svc_acct_sm.html | 23 +++ httemplate/search/svc_domain.cgi | 214 +++++++++++++++++++++ httemplate/search/svc_domain.html | 22 +++ 12 files changed, 1362 insertions(+) create mode 100755 httemplate/search/cust_bill.cgi create mode 100755 httemplate/search/cust_bill.html create mode 100755 httemplate/search/cust_main-payinfo.html create mode 100755 httemplate/search/cust_main.cgi create mode 100755 httemplate/search/cust_main.html create mode 100755 httemplate/search/cust_pkg.cgi create mode 100755 httemplate/search/svc_acct.cgi create mode 100755 httemplate/search/svc_acct.html create mode 100755 httemplate/search/svc_acct_sm.cgi create mode 100755 httemplate/search/svc_acct_sm.html create mode 100755 httemplate/search/svc_domain.cgi create mode 100755 httemplate/search/svc_domain.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi new file mode 100755 index 000000000..5550b5513 --- /dev/null +++ b/httemplate/search/cust_bill.cgi @@ -0,0 +1,180 @@ +<% +# +# $Id: cust_bill.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: post form to: +# http://server.name/path/cust_bill.cgi +# +# ivan@voicenet.com 97-apr-4 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# $Log: cust_bill.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.6 2001/04/22 01:38:39 ivan +# svc_domain needs to import dbh sub from Record +# view/cust_main.cgi needs to use ->owed method, not check (depriciated) owed field +# search/cust_bill.cgi redirect error when there's only one invoice +# +# Revision 1.5 2000/07/17 16:45:41 ivan +# first shot at invoice browsing and some other cleanups +# +# Revision 1.4 1999/02/28 00:03:54 ivan +# removed misleading comments +# +# Revision 1.3 1999/01/19 05:14:11 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.2 1998/12/17 09:41:07 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw ( $cgi $invnum $query $sortby @cust_bill ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use Date::Format; +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(popurl header menubar eidiot table ); +use FS::Record qw(qsearch qsearchs); +use FS::cust_bill; +use FS::cust_main; + +$cgi = new CGI; +cgisuidsetup($cgi); + +if ( $cgi->keywords ) { + my($query) = $cgi->keywords; + if ( $query eq 'invnum' ) { + $sortby = \*invnum_sort; + @cust_bill = qsearch('cust_bill', {} ); + } elsif ( $query eq 'date' ) { + $sortby = \*date_sort; + @cust_bill = qsearch('cust_bill', {} ); + } elsif ( $query eq 'custnum' ) { + $sortby = \*custnum_sort; + @cust_bill = qsearch('cust_bill', {} ); + } elsif ( $query eq 'OPEN_invnum' ) { + $sortby = \*invnum_sort; + @cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + } elsif ( $query eq 'OPEN_date' ) { + $sortby = \*date_sort; + @cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + } elsif ( $query eq 'OPEN_custnum' ) { + $sortby = \*custnum_sort; + @cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { + my $open = $1 * 86400; + $sortby = \*invnum_sort; + @cust_bill = + grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { + my $open = $1 * 86400; + $sortby = \*date_sort; + @cust_bill = + grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { + my $open = $1 * 86400; + $sortby = \*custnum_sort; + @cust_bill = + grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + } else { + die "unknown query string $query"; + } +} else { + $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; + $invnum = $2; + @cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum } ); + $sortby = \*invnum_sort; +} + +if ( scalar(@cust_bill) == 1 ) { + my $invnum = $cust_bill[0]->invnum; + print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect +} elsif ( scalar(@cust_bill) == 0 ) { + eidiot("Invoice not found."); +} else { + my $total = scalar(@cust_bill); + print $cgi->header( '-expires' => 'now' ), + &header("Invoice Search Results", menubar( + 'Main Menu', popurl(2) + )), "$total matching invoices found
", &table(), < + + Balance + Amount + Date + Contact name + Company + +END + + my(%saw, $cust_bill); + foreach $cust_bill ( + sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) + ) { + my($invnum, $owed, $charged, $date ) = ( + $cust_bill->invnum, + $cust_bill->owed, + $cust_bill->charged, + $cust_bill->_date, + ); + my $pdate = time2str("%b %d %Y", $date); + + my $rowspan = 1; + + my $view = popurl(2). "view/cust_bill.cgi?$invnum"; + print < + $invnum + \$$owed + \$$charged + $pdate +END + my $custnum = $cust_bill->custnum; + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); + if ( $cust_main ) { + my $cview = popurl(2). "view/cust_main.cgi?". $cust_main->custnum; + my ( $name, $company ) = ( + $cust_main->last. ', '. $cust_main->first, + $cust_main->company, + ); + print <$name + $company +END + } else { + print <WARNING: couldn't find cust_main.custnum $custnum (cust_bill.invnum $invnum) +END + } + + print ""; + } + + print < + + +END + +} + +# + +sub invnum_sort { + $a->invnum <=> $b->invnum; +} + +sub custnum_sort { + $a->custnum <=> $b->custnum || $a->invnum <=> $b->invnum; +} + +sub date_sort { + $a->_date <=> $b->_date || $a->invnum <=> $b->invnum; +} +%> diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html new file mode 100755 index 000000000..4adb40e4a --- /dev/null +++ b/httemplate/search/cust_bill.html @@ -0,0 +1,21 @@ + + + Invoice Search + + +
+

Invoice Search

+
+
+
+ Search for invoice #: + + +

+ +

+ +
+ + + diff --git a/httemplate/search/cust_main-payinfo.html b/httemplate/search/cust_main-payinfo.html new file mode 100755 index 000000000..47bb83cbd --- /dev/null +++ b/httemplate/search/cust_main-payinfo.html @@ -0,0 +1,20 @@ + + + Customer Search + + + + Customer Search + +
+
+ Search for Credit card #: + + + +

+ +

+ + + 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; + +} +%> diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html new file mode 100755 index 000000000..3184698b4 --- /dev/null +++ b/httemplate/search/cust_main.html @@ -0,0 +1,36 @@ + + + Customer Search + + + + Customer Search + +
+
+ Search for last name: + + using search method: + +

Search for company: + + using search methods: + +

Note: Fuzzy searching can take a while. Please be patient. + +

+ +
Explanation of search methods: +
    +
  • Fuzzy - Searches for matches that are close to your text. +
  • Exact - Finds exact matches only, but much faster than the other search methods. +
+ + + diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi new file mode 100755 index 000000000..d63d2d188 --- /dev/null +++ b/httemplate/search/cust_pkg.cgi @@ -0,0 +1,155 @@ +<% +# +# $Id: cust_pkg.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# based on search/svc_acct.cgi ivan@sisd.com 98-jul-17 +# +# $Log: cust_pkg.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.11 2000/07/17 16:45:41 ivan +# first shot at invoice browsing and some other cleanups +# +# Revision 1.10 2000/07/17 12:49:29 ivan +# better error message if a package isn't linked to a customer (that shouldn't happen) +# +# Revision 1.9 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.8 1999/02/09 09:22:57 ivan +# visual and bugfixes +# +# Revision 1.7 1999/02/07 09:59:37 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.6 1999/01/19 05:14:13 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:38 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.4 1999/01/18 09:22:33 ivan +# changes to track email addresses for email invoicing +# +# Revision 1.3 1998/12/23 03:05:59 ivan +# $cgi->keywords instead of $cgi->query_string +# +# Revision 1.2 1998/12/17 09:41:09 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw ( $cgi @cust_pkg $sortby $query ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header eidiot popurl); +use FS::cust_pkg; +use FS::pkg_svc; +use FS::cust_svc; +use FS::cust_main; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +($query) = $cgi->keywords; +#this tree is a little bit redundant +if ( $query eq 'pkgnum' ) { + $sortby=\*pkgnum_sort; + @cust_pkg=qsearch('cust_pkg',{}); +} elsif ( $query eq 'APKG_pkgnum' ) { + $sortby=\*pkgnum_sort; + @cust_pkg=(); + #perhaps this should go in cust_pkg as a qsearch-like constructor? + my($cust_pkg); + foreach $cust_pkg (qsearch('cust_pkg',{})) { + my($flag)=0; + my($pkg_svc); + PKG_SVC: + foreach $pkg_svc (qsearch('pkg_svc',{ 'pkgpart' => $cust_pkg->pkgpart })) { + if ( $pkg_svc->quantity + > scalar(qsearch('cust_svc',{ + 'pkgnum' => $cust_pkg->pkgnum, + 'svcpart' => $pkg_svc->svcpart, + })) + ) + { + $flag=1; + last PKG_SVC; + } + } + push @cust_pkg, $cust_pkg if $flag; + } +} else { + die "Empty QUERY_STRING!"; +} + +if ( scalar(@cust_pkg) == 1 ) { + my($pkgnum)=$cust_pkg[0]->pkgnum; + print $cgi->redirect(popurl(2). "view/cust_pkg.cgi?$pkgnum"); + exit; +} elsif ( scalar(@cust_pkg) == 0 ) { #error + eidiot("No packages found"); +} else { + my($total)=scalar(@cust_pkg); + print $cgi->header( '-expires' => 'now' ), header('Package Search Results',''), < + + Package # + Customer # + Contact name + Company + +END + + my(%saw,$cust_pkg); + foreach $cust_pkg ( + sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg) + ) { + my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); + my($pkgnum,$custnum,$name,$company)=( + $cust_pkg->pkgnum, + $cust_pkg->custnum, + $cust_main ? $cust_main->last. ', '. $cust_main->first : '', + $cust_main ? $cust_main->company : '', + ); + my $p = popurl(2); + print < + $pkgnum +END + if ( $cust_main ) { + print <$custnum + $name + $company + +END + } else { + print <WARNING: couldn't find cust_main.custnum $custnum (cust_pkg.pkgnum $pkgnum) + +END + } + } + + print < + + +END + exit; + +} + +sub pkgnum_sort { + $a->getfield('pkgnum') <=> $b->getfield('pkgnum'); +} + +%> diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi new file mode 100755 index 000000000..15f74ac20 --- /dev/null +++ b/httemplate/search/svc_acct.cgi @@ -0,0 +1,211 @@ +<% +# +# $Id: svc_acct.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: post form to: +# http://server.name/path/svc_acct.cgi +# +# Note: Should be run setuid freeside as user nobody. +# +# loosely (sp?) based on search/cust_main.cgi +# +# ivan@voicenet.com 96-jan-3 -> 96-jan-4 +# +# rewrite (now does browsing too) ivan@sisd.com 98-mar-9 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# show unlinked accounts ivan@sisd.com 98-jun-22 +# +# use FS::CGI, show total ivan@sisd.com 98-jul-17 +# +# give service and customer info too ivan@sisd.com 98-aug-16 +# +# $Log: svc_acct.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.11 1999/04/14 11:25:33 ivan +# *** empty log message *** +# +# Revision 1.10 1999/04/14 11:20:21 ivan +# visual fix +# +# Revision 1.9 1999/04/10 01:53:18 ivan +# oops, search usernames limited to 8 chars +# +# Revision 1.8 1999/04/09 23:43:29 ivan +# just in case +# +# Revision 1.7 1999/02/07 09:59:38 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.6 1999/01/19 05:14:14 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:39 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.4 1999/01/18 09:22:34 ivan +# changes to track email addresses for email invoicing +# +# Revision 1.3 1998/12/23 03:06:28 ivan +# $cgi->keywords instead of $cgi->query_string +# +# Revision 1.2 1998/12/17 09:41:10 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw( $cgi @svc_acct $sortby $query ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header eidiot popurl table); +use FS::svc_acct; +use FS::cust_main; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors +#this tree is a little bit redundant +if ( $query eq 'svcnum' ) { + $sortby=\*svcnum_sort; + @svc_acct=qsearch('svc_acct',{}); +} elsif ( $query eq 'username' ) { + $sortby=\*username_sort; + @svc_acct=qsearch('svc_acct',{}); +} elsif ( $query eq 'uid' ) { + $sortby=\*uid_sort; + @svc_acct=grep $_->uid ne '', qsearch('svc_acct',{}); +} elsif ( $query eq 'UN_svcnum' ) { + $sortby=\*svcnum_sort; + @svc_acct = grep qsearchs('cust_svc',{ + 'svcnum' => $_->svcnum, + 'pkgnum' => '', + }), qsearch('svc_acct',{}); +} elsif ( $query eq 'UN_username' ) { + $sortby=\*username_sort; + @svc_acct = grep qsearchs('cust_svc',{ + 'svcnum' => $_->svcnum, + 'pkgnum' => '', + }), qsearch('svc_acct',{}); +} elsif ( $query eq 'UN_uid' ) { + $sortby=\*uid_sort; + @svc_acct = grep qsearchs('cust_svc',{ + 'svcnum' => $_->svcnum, + 'pkgnum' => '', + }), qsearch('svc_acct',{}); +} else { + $sortby=\*uid_sort; + &usernamesearch; +} + +if ( scalar(@svc_acct) == 1 ) { + my($svcnum)=$svc_acct[0]->svcnum; + print $cgi->redirect(popurl(2). "view/svc_acct.cgi?$svcnum"); #redirect + exit; +} elsif ( scalar(@svc_acct) == 0 ) { #error + eidiot("Account not found"); +} else { + my($total)=scalar(@svc_acct); + print $cgi->header( '-expires' => 'now' ), + header("Account Search Results",''), + "$total matching accounts found", + &table(), < + Service # + Username + UID + Service + Customer # + Contact name + Company + +END + + my(%saw,$svc_acct); + my $p = popurl(2); + foreach $svc_acct ( + sort $sortby grep(!$saw{$_->svcnum}++, @svc_acct) + ) { + my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svc_acct->svcnum }) + or die "No cust_svc record for svcnum ". $svc_acct->svcnum; + my $part_svc = qsearchs('part_svc', { 'svcpart' => $cust_svc->svcpart }) + or die "No part_svc record for svcpart ". $cust_svc->svcpart; + my($cust_pkg,$cust_main); + if ( $cust_svc->pkgnum ) { + $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc->pkgnum }) + or die "No cust_pkg record for pkgnum ". $cust_svc->pkgnum; + $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pkg->custnum }) + or die "No cust_main record for custnum ". $cust_pkg->custnum; + } + my($svcnum,$username,$uid,$svc,$custnum,$last,$first,$company)=( + $svc_acct->svcnum, + $svc_acct->getfield('username'), + $svc_acct->getfield('uid'), + $part_svc->svc, + $cust_svc->pkgnum ? $cust_main->custnum : '', + $cust_svc->pkgnum ? $cust_main->getfield('last') : '', + $cust_svc->pkgnum ? $cust_main->getfield('first') : '', + $cust_svc->pkgnum ? $cust_main->company : '', + ); + my($pcustnum) = $custnum + ? "$custnum" + : "(unlinked)" + ; + my($pname) = $custnum ? "$last, $first" : ''; + my $pcompany = $custnum ? "$company" : ''; + print < + $svcnum + $username + $uid + $svc + $pcustnum + $pname + $pcompany + +END + + } + + print < + + + +END + exit; + +} + +sub svcnum_sort { + $a->getfield('svcnum') <=> $b->getfield('svcnum'); +} + +sub username_sort { + $a->getfield('username') cmp $b->getfield('username'); +} + +sub uid_sort { + $a->getfield('uid') <=> $b->getfield('uid'); +} + +sub usernamesearch { + + $cgi->param('username') =~ /^([\w\d\-]+)$/; #untaint username_text + my($username)=$1; + + @svc_acct=qsearch('svc_acct',{'username'=>$username}); + +} + + +%> diff --git a/httemplate/search/svc_acct.html b/httemplate/search/svc_acct.html new file mode 100755 index 000000000..91291be99 --- /dev/null +++ b/httemplate/search/svc_acct.html @@ -0,0 +1,21 @@ + + + Account Search + + +
+

Account Search

+
+
+
+ Search for username: + + +

+ +

+ +
+ + + diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi new file mode 100755 index 000000000..451e1fd3d --- /dev/null +++ b/httemplate/search/svc_acct_sm.cgi @@ -0,0 +1,144 @@ +<% +# +# $Id: svc_acct_sm.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: post form to: +# http://server.name/path/svc_domain.cgi +# +# ivan@voicenet.com 96-mar-5 +# +# need to look at table in results to make it more readable +# +# ivan@voicenet.com +# +# rewrite ivan@sisd.com 98-mar-15 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# $Log: svc_acct_sm.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.10 1999/07/20 06:03:36 ivan +# s/CGI::Request/CGI/; (how'd i miss that before?) +# +# Revision 1.9 1999/04/09 04:22:34 ivan +# also table() +# +# Revision 1.8 1999/04/09 03:52:55 ivan +# explicit & for table/itable/ntable +# +# Revision 1.7 1999/02/28 00:03:56 ivan +# removed misleading comments +# +# Revision 1.6 1999/02/09 09:22:58 ivan +# visual and bugfixes +# +# Revision 1.5 1999/01/19 05:14:16 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.4 1999/01/18 09:41:40 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.3 1998/12/17 09:41:11 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw( $conf $cgi $mydomain $domuser $svc_domain $domsvc @svc_acct_sm ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(popurl idiot header table); +use FS::Record qw(qsearch qsearchs); +use FS::Conf; +use FS::svc_domain; +use FS::svc_acct_sm; +use FS::svc_acct; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +$conf = new FS::Conf; +$mydomain = $conf->config('domain'); + +$cgi->param('domuser') =~ /^([a-z0-9_\-]{0,32})$/; +$domuser = $1; + +$cgi->param('domain') =~ /^([\w\-\.]+)$/ or die "Illegal domain"; +$svc_domain = qsearchs('svc_domain',{'domain'=>$1}) + or die "Unknown domain"; +$domsvc = $svc_domain->svcnum; + +if ($domuser) { + @svc_acct_sm=qsearch('svc_acct_sm',{ + 'domuser' => $domuser, + 'domsvc' => $domsvc, + }); +} else { + @svc_acct_sm=qsearch('svc_acct_sm',{'domsvc' => $domsvc}); +} + +if ( scalar(@svc_acct_sm) == 1 ) { + my($svcnum)=$svc_acct_sm[0]->svcnum; + print $cgi->redirect(popurl(2). "view/svc_acct_sm.cgi?$svcnum"); +} elsif ( scalar(@svc_acct_sm) > 1 ) { + print $cgi->header( '-expires' => 'now' ), + header('Mail Alias Search Results'), + &table(), < + Mail to
(click to view mail alias) + Forwards to
(click to view account) + +END + + my($svc_acct_sm); + foreach $svc_acct_sm (@svc_acct_sm) { + my($svcnum,$domuser,$domuid,$domsvc)=( + $svc_acct_sm->svcnum, + $svc_acct_sm->domuser, + $svc_acct_sm->domuid, + $svc_acct_sm->domsvc, + ); + + my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $domsvc } ); + if ( $svc_domain ) { + my $domain = $svc_domain->domain; + + print qq!!, + #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); + ( ($domuser eq '*') ? "(anything)" : $domuser ), + qq!\@$domain !, + ; + } else { + my $warning = "couldn't find svc_domain.svcnum $svcnum ( svc_acct_sm.svcnum $svcnum"; + warn $warning; + print "WARNING: $warning"; + } + + my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $domuid } ); + if ( $svc_acct ) { + my $username = $svc_acct->username; + my $svc_acct_svcnum =$svc_acct->svcnum; + print qq!$username\@$mydomain!, + qq!! + ; + } else { + my $warning = "couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum $svcnum)!"; + warn $warning; + print "WARNING: $warning"; + } + + } + + print ''; + +} else { #error + idiot("Mail Alias not found"); +} + +%> diff --git a/httemplate/search/svc_acct_sm.html b/httemplate/search/svc_acct_sm.html new file mode 100755 index 000000000..0719856db --- /dev/null +++ b/httemplate/search/svc_acct_sm.html @@ -0,0 +1,23 @@ + + + Mail Alias Search + + +
+

Mail Alias Search

+
+
+
+ Search for mail alias: + (opt.) @ + (req.) + +

+ +

+ +
+ + + + diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi new file mode 100755 index 000000000..8bcf4a694 --- /dev/null +++ b/httemplate/search/svc_domain.cgi @@ -0,0 +1,214 @@ +<% +# +# $Id: svc_domain.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: post form to: +# http://server.name/path/svc_domain.cgi +# +# ivan@voicenet.com 97-mar-5 +# +# rewrite ivan@sisd.com 98-mar-14 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# display total, use FS::CGI now does browsing too ivan@sisd.com 98-jul-17 +# +# $Log: svc_domain.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.11 2000/03/03 18:22:44 ivan +# changes from 1.2.3 release, fixes from webdemo +# +# Revision 1.10 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.9 1999/04/15 13:39:16 ivan +# $cgi->header( '-expires' => 'now' ) +# +# Revision 1.8 1999/02/28 00:03:57 ivan +# removed misleading comments +# +# Revision 1.7 1999/02/23 08:09:24 ivan +# beginnings of one-screen new customer entry and some other miscellania +# +# Revision 1.6 1999/02/09 09:22:59 ivan +# visual and bugfixes +# +# Revision 1.5 1999/02/07 09:59:39 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.4 1999/01/19 05:14:17 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.3 1998/12/23 03:06:50 ivan +# $cgi->keywords instead of $cgi->query_string +# +# Revision 1.2 1998/12/17 09:41:12 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw ( $cgi @svc_domain $sortby $query $conf $mydomain ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header eidiot popurl); +use FS::svc_domain; +use FS::cust_svc; +use FS::svc_acct_sm; +use FS::svc_acct; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +$conf = new FS::Conf; +$mydomain = $conf->config('domain'); + +($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors +if ( $query eq 'svcnum' ) { + $sortby=\*svcnum_sort; + @svc_domain=qsearch('svc_domain',{}); +} elsif ( $query eq 'domain' ) { + $sortby=\*domain_sort; + @svc_domain=qsearch('svc_domain',{}); +} elsif ( $query eq 'UN_svcnum' ) { + $sortby=\*svcnum_sort; + @svc_domain = grep qsearchs('cust_svc',{ + 'svcnum' => $_->svcnum, + 'pkgnum' => '', + }), qsearch('svc_domain',{}); +} elsif ( $query eq 'UN_domain' ) { + $sortby=\*domain_sort; + @svc_domain = grep qsearchs('cust_svc',{ + 'svcnum' => $_->svcnum, + 'pkgnum' => '', + }), qsearch('svc_domain',{}); +} else { + $cgi->param('domain') =~ /^([\w\-\.]+)$/; + my($domain)=$1; + #push @svc_domain, qsearchs('svc_domain',{'domain'=>$domain}); + @svc_domain = qsearchs('svc_domain',{'domain'=>$domain}); +} + +if ( scalar(@svc_domain) == 1 ) { + print $cgi->redirect(popurl(2). "view/svc_domain.cgi?". $svc_domain[0]->svcnum); + exit; +} elsif ( scalar(@svc_domain) == 0 ) { + eidiot "No matching domains found!\n"; +} else { + + my($total)=scalar(@svc_domain); + print $cgi->header( '-expires' => 'now' ), + header("Domain Search Results",''), < + + Service # + Domain + Mail to
(click to view mail alias) + Forwards to
(click to view account) + +END + + my(%saw,$svc_domain); + my $p = popurl(2); + foreach $svc_domain ( + sort $sortby grep(!$saw{$_->svcnum}++, @svc_domain) + ) { + my($svcnum,$domain)=( + $svc_domain->svcnum, + $svc_domain->domain, + ); + #my($malias); + #if ( qsearch('svc_acct_sm',{'domsvc'=>$svcnum}) ) { + # $malias=( + # qq|
|. + # qq||. + # qq||. + # qq||. + # qq|
| + # ); + #} else { + # $malias=''; + #} + + my @svc_acct_sm=qsearch('svc_acct_sm',{'domsvc' => $svcnum}); + my $rowspan = scalar(@svc_acct_sm) || 1; + + print < + $svcnum + $domain +END + + my $n1 = ''; + # false laziness: this was stolen from search/svc_acct_sm.cgi. but the + # web interface in general needs to be rewritten in a mucho cleaner way + my($svc_acct_sm); + foreach $svc_acct_sm (@svc_acct_sm) { + my($svcnum,$domuser,$domuid,$domsvc)=( + $svc_acct_sm->svcnum, + $svc_acct_sm->domuser, + $svc_acct_sm->domuid, + $svc_acct_sm->domsvc, + ); + #my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $domsvc } ); + #if ( $svc_domain ) { + # my $domain = $svc_domain->domain; + + print qq!$n1!, + #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); + ( ($domuser eq '*') ? "(anything)" : $domuser ), + qq!\@$domain !, + ; + #} else { + # my $warning = "couldn't find svc_domain.svcnum $svcnum ( svc_acct_sm.svcnum $svcnum"; + # warn $warning; + # print "$n1WARNING: $warning"; + #} + + my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $domuid } ); + if ( $svc_acct ) { + my $username = $svc_acct->username; + my $svc_acct_svcnum =$svc_acct->svcnum; + print qq!$username\@$mydomain!, + qq!! + ; + } else { + my $warning = "couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum $svcnum)!"; + warn $warning; + print "WARNING: $warning"; + } + $n1 = ""; + } + #end of false laziness + print ""; + + } + + print < + + +END + +} + +sub svcnum_sort { + $a->getfield('svcnum') <=> $b->getfield('svcnum'); +} + +sub domain_sort { + $a->getfield('domain') cmp $b->getfield('doimain'); +} + + +%> diff --git a/httemplate/search/svc_domain.html b/httemplate/search/svc_domain.html new file mode 100755 index 000000000..533743ba2 --- /dev/null +++ b/httemplate/search/svc_domain.html @@ -0,0 +1,22 @@ + + + Domain Search + + +
+

Domain Search

+
+
+
+ Search for domain: + + +

+ +

+ +
+ + + + -- 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') 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 926e9ed1c29c929e0f8c1b4dc57e02b21cf14598 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 15 Aug 2001 10:04:53 +0000 Subject: remove (some of the) bad direct exit; calls --- httemplate/search/cust_pkg.cgi | 44 +----------------------------- httemplate/search/svc_acct.cgi | 61 +----------------------------------------- 2 files changed, 2 insertions(+), 103 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index d63d2d188..50028e3e3 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,46 +1,5 @@ <% -# -# $Id: cust_pkg.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# based on search/svc_acct.cgi ivan@sisd.com 98-jul-17 -# -# $Log: cust_pkg.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.11 2000/07/17 16:45:41 ivan -# first shot at invoice browsing and some other cleanups -# -# Revision 1.10 2000/07/17 12:49:29 ivan -# better error message if a package isn't linked to a customer (that shouldn't happen) -# -# Revision 1.9 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.8 1999/02/09 09:22:57 ivan -# visual and bugfixes -# -# Revision 1.7 1999/02/07 09:59:37 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.6 1999/01/19 05:14:13 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:38 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.4 1999/01/18 09:22:33 ivan -# changes to track email addresses for email invoicing -# -# Revision 1.3 1998/12/23 03:05:59 ivan -# $cgi->keywords instead of $cgi->query_string -# -# Revision 1.2 1998/12/17 09:41:09 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# +# use strict; use vars qw ( $cgi @cust_pkg $sortby $query ); @@ -144,7 +103,6 @@ END END - exit; } diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 15f74ac20..bd89d768f 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,63 +1,5 @@ <% -# -# $Id: svc_acct.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# Usage: post form to: -# http://server.name/path/svc_acct.cgi -# -# Note: Should be run setuid freeside as user nobody. -# -# loosely (sp?) based on search/cust_main.cgi -# -# ivan@voicenet.com 96-jan-3 -> 96-jan-4 -# -# rewrite (now does browsing too) ivan@sisd.com 98-mar-9 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# show unlinked accounts ivan@sisd.com 98-jun-22 -# -# use FS::CGI, show total ivan@sisd.com 98-jul-17 -# -# give service and customer info too ivan@sisd.com 98-aug-16 -# -# $Log: svc_acct.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.11 1999/04/14 11:25:33 ivan -# *** empty log message *** -# -# Revision 1.10 1999/04/14 11:20:21 ivan -# visual fix -# -# Revision 1.9 1999/04/10 01:53:18 ivan -# oops, search usernames limited to 8 chars -# -# Revision 1.8 1999/04/09 23:43:29 ivan -# just in case -# -# Revision 1.7 1999/02/07 09:59:38 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.6 1999/01/19 05:14:14 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:39 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.4 1999/01/18 09:22:34 ivan -# changes to track email addresses for email invoicing -# -# Revision 1.3 1998/12/23 03:06:28 ivan -# $cgi->keywords instead of $cgi->query_string -# -# Revision 1.2 1998/12/17 09:41:10 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# +# use strict; use vars qw( $cgi @svc_acct $sortby $query ); @@ -182,7 +124,6 @@ END END - exit; } -- cgit v1.2.1 From cb85608dc292b4693ccb80913fc5a1959d6e9afc Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 19 Aug 2001 08:32:43 +0000 Subject: display bill and service name/company, and services --- httemplate/search/cust_pkg.cgi | 96 ++++++++++++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 22 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 50028e3e3..2ab6e2b57 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,13 +1,13 @@ <% -# +# use strict; -use vars qw ( $cgi @cust_pkg $sortby $query ); +use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg ); use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs); -use FS::CGI qw(header eidiot popurl); +use FS::Record qw(qsearch qsearchs dbdef); +use FS::CGI qw(header eidiot popurl table); use FS::cust_pkg; use FS::pkg_svc; use FS::cust_svc; @@ -16,6 +16,8 @@ use FS::cust_main; $cgi = new CGI; &cgisuidsetup($cgi); +my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {}); + ($query) = $cgi->keywords; #this tree is a little bit redundant if ( $query eq 'pkgnum' ) { @@ -56,47 +58,97 @@ if ( scalar(@cust_pkg) == 1 ) { eidiot("No packages found"); } else { my($total)=scalar(@cust_pkg); - print $cgi->header( '-expires' => 'now' ), header('Package Search Results',''), < + print $cgi->header( '-expires' => 'now' ), + header('Package Search Results',''), + "$total matching packages found
", &table(), < - Package # - Customer # - Contact name - Company + Package + Cust# + (bill) name + company +END + +if ( defined dbdef->table('cust_main')->column('ship_last') ) { + print <(service) name + company +END +} + +print <Services END + my $n1 = ''; my(%saw,$cust_pkg); foreach $cust_pkg ( sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg) ) { my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); - my($pkgnum,$custnum,$name,$company)=( + my($pkgnum, $custnum, $last, $first, $company, + $ship_last, $ship_first, $ship_company)=( $cust_pkg->pkgnum, $cust_pkg->custnum, - $cust_main ? $cust_main->last. ', '. $cust_main->first : '', + $cust_main ? $cust_main->last : '', + $cust_main ? $cust_main->first : '', $cust_main ? $cust_main->company : '', + $cust_main + ? ( $cust_main->ship_last || $cust_main->getfield('last') ) + : '', + $cust_main + ? ( $cust_main->ship_last + ? $cust_main->ship_first + : $cust_main->first ) + : '', + $cust_main + ? ( $cust_main->ship_last + ? $cust_main->ship_company + : $cust_main->company ) + : '', ); + my $pkg = $part_pkg{$cust_pkg->pkgpart}->pkg; + #$pkg .= ' - '. $part_pkg{$cust_pkg->pkgpart}->comment; + my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); + my $rowspan = scalar(@cust_svc) || 1; my $p = popurl(2); - print < - $pkgnum + print $n1, <$pkgnum - $pkg END if ( $cust_main ) { print <$custnum - $name - $company - + $custnum + $last, $first + $company END + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + print <$ship_last, $ship_first + $ship_company +END + } } else { + my $colspan = defined dbdef->table('cust_main')->column('ship_last') + ? 5 : 3; print <WARNING: couldn't find cust_main.custnum $custnum (cust_pkg.pkgnum $pkgnum) - + WARNING: couldn't find cust_main.custnum $custnum (cust_pkg.pkgnum $pkgnum) END } + + my $n2 = ''; + foreach my $cust_svc ( @cust_svc ) { + my($label, $value, $svcdb) = $cust_svc->label; + my $svcnum = $cust_svc->svcnum; + my $sview = $p. "view"; + print $n2,qq!$label!, + qq!$value!; + $n2=""; + } + + $n1 = ""; + } + print ''; print < -- cgit v1.2.1 From 8a8c9386cbd3383b0134aae8e32b5995f8886fb2 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 19 Aug 2001 15:53:36 +0000 Subject: added user interface for svc_forward and vpopmail support --- httemplate/search/svc_acct.cgi | 9 ++- httemplate/search/svc_domain.cgi | 117 ++++++++++++++++++++++----------------- 2 files changed, 73 insertions(+), 53 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index bd89d768f..dba5ac302 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi @svc_acct $sortby $query ); @@ -64,6 +64,7 @@ if ( scalar(@svc_acct) == 1 ) { Service # Username + Domain UID Service Customer # @@ -81,6 +82,8 @@ END or die "No cust_svc record for svcnum ". $svc_acct->svcnum; my $part_svc = qsearchs('part_svc', { 'svcpart' => $cust_svc->svcpart }) or die "No part_svc record for svcpart ". $cust_svc->svcpart; + my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc }) + or die "No svc_domain record for domsvc ". $cust_svc->domsvc; my($cust_pkg,$cust_main); if ( $cust_svc->pkgnum ) { $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc->pkgnum }) @@ -88,9 +91,10 @@ END $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pkg->custnum }) or die "No cust_main record for custnum ". $cust_pkg->custnum; } - my($svcnum,$username,$uid,$svc,$custnum,$last,$first,$company)=( + my($svcnum,$username,$domain,$uid,$svc,$custnum,$last,$first,$company)=( $svc_acct->svcnum, $svc_acct->getfield('username'), + $svc_domain->getfield('domain'), $svc_acct->getfield('uid'), $part_svc->svc, $cust_svc->pkgnum ? $cust_main->custnum : '', @@ -108,6 +112,7 @@ END $svcnum $username + $domain $uid $svc $pcustnum diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 8bcf4a694..4276976a1 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,6 +1,6 @@ <% # -# $Id: svc_domain.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# $Id: svc_domain.cgi,v 1.2 2001-08-19 15:53:36 jeff Exp $ # # Usage: post form to: # http://server.name/path/svc_domain.cgi @@ -15,7 +15,10 @@ # display total, use FS::CGI now does browsing too ivan@sisd.com 98-jul-17 # # $Log: svc_domain.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan +# Revision 1.2 2001-08-19 15:53:36 jeff +# added user interface for svc_forward and vpopmail support +# +# Revision 1.1 2001/07/30 07:36:04 ivan # templates!!! # # Revision 1.11 2000/03/03 18:22:44 ivan @@ -60,8 +63,8 @@ use FS::Record qw(qsearch qsearchs); use FS::CGI qw(header eidiot popurl); use FS::svc_domain; use FS::cust_svc; -use FS::svc_acct_sm; use FS::svc_acct; +use FS::svc_forward; $cgi = new CGI; &cgisuidsetup($cgi); @@ -112,15 +115,19 @@ if ( scalar(@svc_domain) == 1 ) { Service # Domain - Mail to
(click to view mail alias) + Mail to
(click to view account) Forwards to
(click to view account) END - my(%saw,$svc_domain); +# my(%saw); # if we've multiple domains with the same + # svcnum, then we've a corrupt database + + my($svc_domain); my $p = popurl(2); foreach $svc_domain ( - sort $sortby grep(!$saw{$_->svcnum}++, @svc_domain) +# sort $sortby grep(!$saw{$_->svcnum}++, @svc_domain) + sort $sortby (@svc_domain) ) { my($svcnum,$domain)=( $svc_domain->svcnum, @@ -139,57 +146,65 @@ END # $malias=''; #} - my @svc_acct_sm=qsearch('svc_acct_sm',{'domsvc' => $svcnum}); - my $rowspan = scalar(@svc_acct_sm) || 1; - - print < - $svcnum - $domain -END + my @svc_acct=qsearch('svc_acct',{'domsvc' => $svcnum}); + my $rowspan = 0; my $n1 = ''; - # false laziness: this was stolen from search/svc_acct_sm.cgi. but the - # web interface in general needs to be rewritten in a mucho cleaner way - my($svc_acct_sm); - foreach $svc_acct_sm (@svc_acct_sm) { - my($svcnum,$domuser,$domuid,$domsvc)=( - $svc_acct_sm->svcnum, - $svc_acct_sm->domuser, - $svc_acct_sm->domuid, - $svc_acct_sm->domsvc, + my($svc_acct, @rows); + foreach $svc_acct ( + sort {$b->getfield('username') cmp $a->getfield('username')} (@svc_acct) + ) { + + my (@forwards) = (); + + my($svcnum,$username)=( + $svc_acct->svcnum, + $svc_acct->username, ); - #my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $domsvc } ); - #if ( $svc_domain ) { - # my $domain = $svc_domain->domain; - - print qq!$n1!, - #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); - ( ($domuser eq '*') ? "(anything)" : $domuser ), - qq!\@$domain !, - ; - #} else { - # my $warning = "couldn't find svc_domain.svcnum $svcnum ( svc_acct_sm.svcnum $svcnum"; - # warn $warning; - # print "$n1WARNING: $warning"; - #} - - my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $domuid } ); - if ( $svc_acct ) { - my $username = $svc_acct->username; - my $svc_acct_svcnum =$svc_acct->svcnum; - print qq!$username\@$mydomain!, - qq!! - ; - } else { - my $warning = "couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum $svcnum)!"; - warn $warning; - print "WARNING: $warning"; + + my @svc_forward = qsearch( 'svc_forward', { 'srcsvc' => $svcnum } ); + my $svc_forward; + foreach $svc_forward (@svc_forward) { + my($dstsvc,$dst) = ( + $svc_forward->dstsvc, + $svc_forward->dst, + ); + if ($dstsvc) { + my $dst_svc_acct=qsearchs( 'svc_acct', { 'svcnum' => $dstsvc } ); + my $destination=$dst_svc_acct->email; + push @forwards, qq!$destination!, + qq!! + ; + }else{ + push @forwards, qq!$dst! + ; + } } + + push @rows, qq!$n1!, + #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); + ( ($username eq '*') ? "(anything)" : $username ), + qq!\@$domain !, + ; + + push @rows, @forwards; + + $rowspan += (scalar(@svc_forward) || 1); $n1 = ""; } #end of false laziness + + + + print < + $svcnum + $domain +END + + print @rows; print ""; } @@ -207,7 +222,7 @@ sub svcnum_sort { } sub domain_sort { - $a->getfield('domain') cmp $b->getfield('doimain'); + $a->getfield('domain') cmp $b->getfield('domain'); } -- cgit v1.2.1 From 75cbdf6ab6af5539382a63d21c8f4042d53ba6c1 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 21 Aug 2001 02:03:32 +0000 Subject: deal with databases w/o separate shipping address --- httemplate/search/cust_pkg.cgi | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 2ab6e2b57..8a0dfd132 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg ); @@ -86,27 +86,31 @@ END sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg) ) { my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); - my($pkgnum, $custnum, $last, $first, $company, - $ship_last, $ship_first, $ship_company)=( + my($pkgnum, $custnum, $last, $first, $company) = ( $cust_pkg->pkgnum, $cust_pkg->custnum, $cust_main ? $cust_main->last : '', $cust_main ? $cust_main->first : '', $cust_main ? $cust_main->company : '', - $cust_main - ? ( $cust_main->ship_last || $cust_main->getfield('last') ) - : '', - $cust_main - ? ( $cust_main->ship_last - ? $cust_main->ship_first - : $cust_main->first ) - : '', - $cust_main - ? ( $cust_main->ship_last - ? $cust_main->ship_company - : $cust_main->company ) - : '', ); + my($ship_last, $ship_first, $ship_company); + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + ($ship_last, $ship_first, $ship_company) = ( + $cust_main + ? ( $cust_main->ship_last || $cust_main->getfield('last') ) + : '', + $cust_main + ? ( $cust_main->ship_last + ? $cust_main->ship_first + : $cust_main->first ) + : '', + $cust_main + ? ( $cust_main->ship_last + ? $cust_main->ship_company + : $cust_main->company ) + : '', + ); + } my $pkg = $part_pkg{$cust_pkg->pkgpart}->pkg; #$pkg .= ' - '. $part_pkg{$cust_pkg->pkgpart}->comment; my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); -- cgit v1.2.1 From 7d66bf30114486f1463b2899399364e780147b49 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 21 Aug 2001 02:16:36 +0000 Subject: fix to work against 1.3.x databases, with a warning --- httemplate/search/svc_acct.cgi | 86 ++++++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 20 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index dba5ac302..dc4c4fdaa 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,12 +1,12 @@ <% -# +# use strict; -use vars qw( $cgi @svc_acct $sortby $query ); +use vars qw( $cgi @svc_acct $sortby $query $mydomain ); use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs); +use FS::Record qw(qsearch qsearchs dbdef); use FS::CGI qw(header eidiot popurl table); use FS::svc_acct; use FS::cust_main; @@ -62,16 +62,22 @@ if ( scalar(@svc_acct) == 1 ) { "$total matching accounts found", &table(), < - Service # + # Username Domain UID Service - Customer # - Contact name - Company - + Cust# + (bill) name + company END + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + print <(service) name + company +END + } + print ""; my(%saw,$svc_acct); my $p = popurl(2); @@ -82,8 +88,22 @@ END or die "No cust_svc record for svcnum ". $svc_acct->svcnum; my $part_svc = qsearchs('part_svc', { 'svcpart' => $cust_svc->svcpart }) or die "No part_svc record for svcpart ". $cust_svc->svcpart; - my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc }) - or die "No svc_domain record for domsvc ". $cust_svc->domsvc; + + my $domain; + my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc }); + if ( $svc_domain ) { + $domain = "svcnum. + "\">". $svc_domain->domain. ""; + } else { + unless ( $mydomain ) { + my $conf = new FS::Conf; + unless ( $mydomain = $conf->config('domain') ) { + die "No legacy domain config file and no svc_domain.svcnum record ". + "for svc_acct.domsvc: ". $cust_svc->domsvc; + } + } + $domain = "$mydomain*"; + } my($cust_pkg,$cust_main); if ( $cust_svc->pkgnum ) { $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc->pkgnum }) @@ -91,10 +111,9 @@ END $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pkg->custnum }) or die "No cust_main record for custnum ". $cust_pkg->custnum; } - my($svcnum,$username,$domain,$uid,$svc,$custnum,$last,$first,$company)=( + my($svcnum, $username, $uid, $svc, $custnum, $last, $first, $company) = ( $svc_acct->svcnum, $svc_acct->getfield('username'), - $svc_domain->getfield('domain'), $svc_acct->getfield('uid'), $part_svc->svc, $cust_svc->pkgnum ? $cust_main->custnum : '', @@ -106,8 +125,24 @@ END ? "$custnum" : "(unlinked)" ; - my($pname) = $custnum ? "$last, $first" : ''; + my $pname = $custnum ? "$last, $first" : ''; my $pcompany = $custnum ? "$company" : ''; + my($pship_name, $pship_company); + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + my($ship_last, $ship_first, $ship_company) = ( + $cust_svc->pkgnum ? ( $cust_main->ship_last || $last ) : '', + $cust_svc->pkgnum ? ( $cust_main->ship_last + ? $cust_main->ship_first + : $first + ) : '', + $cust_svc->pkgnum ? ( $cust_main->ship_last + ? $cust_main->ship_company + : $company + ) : '', + ); + $pship_name = $custnum ? "$ship_last, $ship_first" : ''; + $pship_company = $custnum ? "$ship_company" : ''; + } print < $svcnum @@ -118,17 +153,28 @@ END $pcustnum $pname $pcompany - END + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + print <$pship_name + $pship_company +END + } + print ""; } - print < - - - -END + print ''; + + if ( $mydomain ) { + print "
* The $mydomain domain ". + "is contained in your legacy domain ". + "configuration file. ". + "You should run the bin/fs-migrate-svc_acct_sm script ". + "to create a proper svc_domain record for this domain." + } + + print ''; } -- cgit v1.2.1 From 3d671921441ba8422650b54435a1959ad1d4c71d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 21 Aug 2001 02:31:57 +0000 Subject: remove $Log$ messages. whew. --- httemplate/search/cust_bill.cgi | 34 +----------------------- httemplate/search/svc_acct_sm.cgi | 48 +--------------------------------- httemplate/search/svc_domain.cgi | 55 +-------------------------------------- 3 files changed, 3 insertions(+), 134 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 5550b5513..a961455be 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -1,37 +1,5 @@ <% -# -# $Id: cust_bill.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# Usage: post form to: -# http://server.name/path/cust_bill.cgi -# -# ivan@voicenet.com 97-apr-4 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# $Log: cust_bill.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.6 2001/04/22 01:38:39 ivan -# svc_domain needs to import dbh sub from Record -# view/cust_main.cgi needs to use ->owed method, not check (depriciated) owed field -# search/cust_bill.cgi redirect error when there's only one invoice -# -# Revision 1.5 2000/07/17 16:45:41 ivan -# first shot at invoice browsing and some other cleanups -# -# Revision 1.4 1999/02/28 00:03:54 ivan -# removed misleading comments -# -# Revision 1.3 1999/01/19 05:14:11 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.2 1998/12/17 09:41:07 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# +# use strict; use vars qw ( $cgi $invnum $query $sortby @cust_bill ); diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi index 451e1fd3d..4350c320c 100755 --- a/httemplate/search/svc_acct_sm.cgi +++ b/httemplate/search/svc_acct_sm.cgi @@ -1,51 +1,5 @@ <% -# -# $Id: svc_acct_sm.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# Usage: post form to: -# http://server.name/path/svc_domain.cgi -# -# ivan@voicenet.com 96-mar-5 -# -# need to look at table in results to make it more readable -# -# ivan@voicenet.com -# -# rewrite ivan@sisd.com 98-mar-15 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# $Log: svc_acct_sm.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.10 1999/07/20 06:03:36 ivan -# s/CGI::Request/CGI/; (how'd i miss that before?) -# -# Revision 1.9 1999/04/09 04:22:34 ivan -# also table() -# -# Revision 1.8 1999/04/09 03:52:55 ivan -# explicit & for table/itable/ntable -# -# Revision 1.7 1999/02/28 00:03:56 ivan -# removed misleading comments -# -# Revision 1.6 1999/02/09 09:22:58 ivan -# visual and bugfixes -# -# Revision 1.5 1999/01/19 05:14:16 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.4 1999/01/18 09:41:40 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.3 1998/12/17 09:41:11 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# +# use strict; use vars qw( $conf $cgi $mydomain $domuser $svc_domain $domsvc @svc_acct_sm ); diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 4276976a1..fb386e2cf 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,58 +1,5 @@ <% -# -# $Id: svc_domain.cgi,v 1.2 2001-08-19 15:53:36 jeff Exp $ -# -# Usage: post form to: -# http://server.name/path/svc_domain.cgi -# -# ivan@voicenet.com 97-mar-5 -# -# rewrite ivan@sisd.com 98-mar-14 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# display total, use FS::CGI now does browsing too ivan@sisd.com 98-jul-17 -# -# $Log: svc_domain.cgi,v $ -# Revision 1.2 2001-08-19 15:53:36 jeff -# added user interface for svc_forward and vpopmail support -# -# Revision 1.1 2001/07/30 07:36:04 ivan -# templates!!! -# -# Revision 1.11 2000/03/03 18:22:44 ivan -# changes from 1.2.3 release, fixes from webdemo -# -# Revision 1.10 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.9 1999/04/15 13:39:16 ivan -# $cgi->header( '-expires' => 'now' ) -# -# Revision 1.8 1999/02/28 00:03:57 ivan -# removed misleading comments -# -# Revision 1.7 1999/02/23 08:09:24 ivan -# beginnings of one-screen new customer entry and some other miscellania -# -# Revision 1.6 1999/02/09 09:22:59 ivan -# visual and bugfixes -# -# Revision 1.5 1999/02/07 09:59:39 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.4 1999/01/19 05:14:17 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.3 1998/12/23 03:06:50 ivan -# $cgi->keywords instead of $cgi->query_string -# -# Revision 1.2 1998/12/17 09:41:12 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# +# use strict; use vars qw ( $cgi @svc_domain $sortby $query $conf $mydomain ); -- 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') 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') 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') 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 ++- httemplate/search/cust_pkg.cgi | 127 ++++++++++++++++++++++++++++++---------- 2 files changed, 101 insertions(+), 34 deletions(-) (limited to 'httemplate/search') 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') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 93ce7ae29..e862cefab 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,11 +1,13 @@ <% -# +# use strict; -use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg ); +use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg + $conf $maxrecords $limit $offset ); use CGI; use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); +use FS::UID qw(dbh cgisuidsetup); +use FS::Conf; use FS::Record qw(qsearch qsearchs dbdef); use FS::CGI qw(header eidiot popurl table); use FS::cust_pkg; @@ -16,40 +18,79 @@ use FS::cust_main; $cgi = new CGI; &cgisuidsetup($cgi); +$conf = new FS::Conf; +$maxrecords = $conf->config('maxsearchrecordsperpage'); + my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {}); +$limit = ''; +$limit .= "LIMIT $maxrecords" if $maxrecords; + +$offset = $cgi->param('offset') || 0; +$limit .= " OFFSET $offset" if $offset; + +my $total; + ($query) = $cgi->keywords; +my $unconf = ''; #this tree is a little bit redundant if ( $query eq 'pkgnum' ) { $sortby=\*pkgnum_sort; - @cust_pkg=qsearch('cust_pkg',{}); + + } elsif ( $query eq 'APKG_pkgnum' ) { + $sortby=\*pkgnum_sort; - @cust_pkg=(); - #perhaps this should go in cust_pkg as a qsearch-like constructor? - my($cust_pkg); - foreach $cust_pkg (qsearch('cust_pkg',{})) { - my($flag)=0; - my($pkg_svc); - PKG_SVC: - foreach $pkg_svc (qsearch('pkg_svc',{ 'pkgpart' => $cust_pkg->pkgpart })) { - if ( $pkg_svc->quantity - > scalar(qsearch('cust_svc',{ - 'pkgnum' => $cust_pkg->pkgnum, - 'svcpart' => $pkg_svc->svcpart, - })) - ) - { - $flag=1; - last PKG_SVC; - } - } - push @cust_pkg, $cust_pkg if $flag; - } + + $unconf = " + WHERE 0 < + ( SELECT count(*) FROM pkg_svc + WHERE pkg_svc.pkgpart = cust_pkg.pkgpart + AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc + WHERE cust_svc.pkgnum = cust_pkg.pkgnum + AND cust_svc.svcpart = pkg_svc.svcpart + ) + ) + "; + + #@cust_pkg=(); + ##perhaps this should go in cust_pkg as a qsearch-like constructor? + #my($cust_pkg); + #foreach $cust_pkg ( + # qsearch('cust_pkg',{}, '', "ORDER BY pkgnum $limit" ) + #) { + # my($flag)=0; + # my($pkg_svc); + # PKG_SVC: + # foreach $pkg_svc (qsearch('pkg_svc',{ 'pkgpart' => $cust_pkg->pkgpart })) { + # if ( $pkg_svc->quantity + # > scalar(qsearch('cust_svc',{ + # 'pkgnum' => $cust_pkg->pkgnum, + # 'svcpart' => $pkg_svc->svcpart, + # })) + # ) + # { + # $flag=1; + # last PKG_SVC; + # } + # } + # push @cust_pkg, $cust_pkg if $flag; + #} + } else { die "Empty QUERY_STRING!"; } +my $statement = "SELECT COUNT(*) FROM cust_pkg $unconf"; +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]; + +@cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); + + if ( scalar(@cust_pkg) == 1 ) { my($pkgnum)=$cust_pkg[0]->pkgnum; print $cgi->redirect(popurl(2). "view/cust_pkg.cgi?$pkgnum"); @@ -57,9 +98,35 @@ if ( scalar(@cust_pkg) == 1 ) { } elsif ( scalar(@cust_pkg) == 0 ) { #error eidiot("No packages found"); } else { - my($total)=scalar(@cust_pkg); + $total ||= scalar(@cust_pkg); + + my $pager = ''; + if ( $total != scalar(@cust_pkg) && $maxrecords ) { + unless ( $offset == 0 ) { + $cgi->param('offset', $offset - $maxrecords); + $pager .= 'Previous '; + } + my $poff; + my $page; + for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { + $page++; + if ( $offset == $poff ) { + $pager .= qq!$page !; + } else { + $cgi->param('offset', $poff); + $pager .= qq!$page !; + } + } + unless ( $offset + $maxrecords > $total ) { + $cgi->param('offset', $offset + $maxrecords); + $pager .= 'Next '; + } + } + print header('Package Search Results',''), - "$total matching packages found
", &table(), <
$pager", &table(), < Package Cust# @@ -153,11 +220,7 @@ END } print ''; - print < - - -END + print "$pager"; } -- 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 +- httemplate/search/cust_pkg.cgi | 10 ++-- httemplate/search/svc_acct.cgi | 103 +++++++++++++++++++++++++++++----------- 3 files changed, 83 insertions(+), 34 deletions(-) (limited to 'httemplate/search') 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" diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index e862cefab..9f13dbb33 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg @@ -31,13 +31,11 @@ $limit .= " OFFSET $offset" if $offset; my $total; -($query) = $cgi->keywords; my $unconf = ''; -#this tree is a little bit redundant +($query) = $cgi->keywords; if ( $query eq 'pkgnum' ) { $sortby=\*pkgnum_sort; - } elsif ( $query eq 'APKG_pkgnum' ) { $sortby=\*pkgnum_sort; @@ -86,7 +84,7 @@ 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]; +$total = $sth->fetchrow_arrayref->[0]; @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); @@ -100,6 +98,7 @@ if ( scalar(@cust_pkg) == 1 ) { } else { $total ||= scalar(@cust_pkg); + #begin pager my $pager = ''; if ( $total != scalar(@cust_pkg) && $maxrecords ) { unless ( $offset == 0 ) { @@ -124,6 +123,7 @@ if ( scalar(@cust_pkg) == 1 ) { '">Next '; } } + #end pager print header('Package Search Results',''), "$total matching packages found

$pager", &table(), < +# use strict; -use vars qw( $cgi @svc_acct $sortby $query $mydomain ); +use vars qw( $cgi @svc_acct $sortby $query $mydomain + $conf $maxrecords $limit $offset ); use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); @@ -16,41 +17,61 @@ $mydomain = ''; $cgi = new CGI; &cgisuidsetup($cgi); +$conf = new FS::Conf; +$maxrecords = $conf->config('maxsearchrecordsperpage'); + +my $orderby = ''; #removeme + +$limit = ''; +$limit .= "LIMIT $maxrecords" if $maxrecords; + +$offset = $cgi->param('offset') || 0; +$limit .= " OFFSET $offset" if $offset; + +my $total; + ($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors -#this tree is a little bit redundant + +my $unlinked = ''; +if ( $query =~ /^UN_(.*)$/ ) { + $query = $1; + $unlinked = ' + WHERE 0 < + ( SELECT count(*) FROM cust_svc + WHERE cust_svc.svcnum = svc_acct.svcnum + AND pkgnum IS NULL + ) + '; +} + if ( $query eq 'svcnum' ) { $sortby=\*svcnum_sort; - @svc_acct=qsearch('svc_acct',{}); + $orderby = 'ORDER BY svcnum'; } elsif ( $query eq 'username' ) { $sortby=\*username_sort; - @svc_acct=qsearch('svc_acct',{}); + $orderby = 'ORDER BY username'; } elsif ( $query eq 'uid' ) { $sortby=\*uid_sort; - @svc_acct=grep $_->uid ne '', qsearch('svc_acct',{}); -} elsif ( $query eq 'UN_svcnum' ) { - $sortby=\*svcnum_sort; - @svc_acct = grep qsearchs('cust_svc',{ - 'svcnum' => $_->svcnum, - 'pkgnum' => '', - }), qsearch('svc_acct',{}); -} elsif ( $query eq 'UN_username' ) { - $sortby=\*username_sort; - @svc_acct = grep qsearchs('cust_svc',{ - 'svcnum' => $_->svcnum, - 'pkgnum' => '', - }), qsearch('svc_acct',{}); -} elsif ( $query eq 'UN_uid' ) { - $sortby=\*uid_sort; - @svc_acct = grep qsearchs('cust_svc',{ - 'svcnum' => $_->svcnum, - 'pkgnum' => '', - }), qsearch('svc_acct',{}); + $orderby = ( $unlinked ? 'AND' : 'WHERE' ). 'uid IS NOT NULL ORDER BY uid'; } else { $sortby=\*uid_sort; &usernamesearch; } +if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' ) { + + my $statement = "SELECT COUNT(*) FROM svc_acct $unlinked"; + 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]; + + @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $orderby $limit"); + +} + if ( scalar(@svc_acct) == 1 ) { my($svcnum)=$svc_acct[0]->svcnum; print $cgi->redirect(popurl(2). "view/svc_acct.cgi?$svcnum"); #redirect @@ -58,9 +79,37 @@ if ( scalar(@svc_acct) == 1 ) { } elsif ( scalar(@svc_acct) == 0 ) { #error idiot("Account not found"); } else { - my($total)=scalar(@svc_acct); + $total ||= scalar(@svc_acct); + + #begin pager + my $pager = ''; + if ( $total != scalar(@svc_acct) && $maxrecords ) { + unless ( $offset == 0 ) { + $cgi->param('offset', $offset - $maxrecords); + $pager .= 'Previous '; + } + my $poff; + my $page; + for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { + $page++; + if ( $offset == $poff ) { + $pager .= qq!$page !; + } else { + $cgi->param('offset', $poff); + $pager .= qq!$page !; + } + } + unless ( $offset + $maxrecords > $total ) { + $cgi->param('offset', $offset + $maxrecords); + $pager .= 'Next '; + } + } + #end pager + print header("Account Search Results",''), - "$total matching accounts found", + "$total matching accounts found

$pager", &table(), < # @@ -165,7 +214,7 @@ END } - print ''; + print '$pager
'; if ( $mydomain ) { print "
* The $mydomain domain ". -- cgit v1.2.1 From d402957b601504e9f47fc2f4e6aebe80e015e3ef Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 9 Dec 2001 23:31:55 +0000 Subject: harmless? missing ; --- httemplate/search/svc_acct.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 8f7126ea8..f86794517 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi @svc_acct $sortby $query $mydomain @@ -221,7 +221,7 @@ END "is contained in your legacy domain ". "configuration file. ". "You should run the bin/fs-migrate-svc_acct_sm script ". - "to create a proper svc_domain record for this domain." + "to create a proper svc_domain record for this domain."; } print ''; -- cgit v1.2.1 From 4ad85201c2e6af983cb986d542cff18f9ce4fe9d Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 10 Dec 2001 00:44:56 +0000 Subject: visual glitch: oops, $pager wasn't getting substitued. --- httemplate/search/svc_acct.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index f86794517..1cb503103 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi @svc_acct $sortby $query $mydomain @@ -214,7 +214,7 @@ END } - print '$pager
'; + print "$pager
"; if ( $mydomain ) { print "
* The $mydomain domain ". -- cgit v1.2.1 From b5690431335934990ca157a885d5762f66728203 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Dec 2001 21:26:58 +0000 Subject: missing space in SQL, oops --- httemplate/search/svc_acct.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 1cb503103..c9d1eb6ca 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi @svc_acct $sortby $query $mydomain @@ -53,7 +53,7 @@ if ( $query eq 'svcnum' ) { $orderby = 'ORDER BY username'; } elsif ( $query eq 'uid' ) { $sortby=\*uid_sort; - $orderby = ( $unlinked ? 'AND' : 'WHERE' ). 'uid IS NOT NULL ORDER BY uid'; + $orderby = ( $unlinked ? 'AND' : 'WHERE' ). ' uid IS NOT NULL ORDER BY uid'; } else { $sortby=\*uid_sort; &usernamesearch; -- cgit v1.2.1 From 133be4f603b60052cb45a6e54104eed357df25df Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 18 Dec 2001 06:38:25 +0000 Subject: show dates on package browse --- httemplate/search/cust_pkg.cgi | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 9f13dbb33..7426276bd 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg @@ -129,6 +129,11 @@ if ( scalar(@cust_pkg) == 1 ) { "$total matching packages found

$pager", &table(), < Package + Setup + Next
bill
+ Susp. + Expire + Cancel Cust# (bill) name company @@ -154,6 +159,11 @@ END my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); my($pkgnum, $custnum, $last, $first, $company) = ( $cust_pkg->pkgnum, + time2str("%D", $cust_pkg->setup ), + time2str("%D", $cust_pkg->bill ), + time2str("%D", $cust_pkg->susp ), + time2str("%D", $cust_pkg->expire ), + time2str("%D", $cust_pkg->cancel ), $cust_pkg->custnum, $cust_main ? $cust_main->last : '', $cust_main ? $cust_main->first : '', -- cgit v1.2.1 From 428301a8083e09832ac414d2b89db26ba6ee5f4e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 18 Dec 2001 06:45:32 +0000 Subject: oops. *sigh* --- httemplate/search/cust_pkg.cgi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 7426276bd..070871e02 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg @@ -159,11 +159,11 @@ END my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); my($pkgnum, $custnum, $last, $first, $company) = ( $cust_pkg->pkgnum, - time2str("%D", $cust_pkg->setup ), - time2str("%D", $cust_pkg->bill ), - time2str("%D", $cust_pkg->susp ), - time2str("%D", $cust_pkg->expire ), - time2str("%D", $cust_pkg->cancel ), + time2str("%D", $cust_pkg->getfield('setup') ), + time2str("%D", $cust_pkg->getfield('bill') ), + time2str("%D", $cust_pkg->getfield('susp') ), + time2str("%D", $cust_pkg->getfield('expire') ), + time2str("%D", $cust_pkg->getfield('cancel') ), $cust_pkg->custnum, $cust_main ? $cust_main->last : '', $cust_main ? $cust_main->first : '', -- cgit v1.2.1 From a44aaabe9b21f0e474f7317852235600afcc5733 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 18 Dec 2001 07:08:16 +0000 Subject: working dates on package browse --- httemplate/search/cust_pkg.cgi | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 070871e02..137dc5f19 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg @@ -157,13 +157,25 @@ END sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg) ) { my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); - my($pkgnum, $custnum, $last, $first, $company) = ( + my($pkgnum, $setup, $bill, $susp, $expire, $cancel, + $custnum, $last, $first, $company + ) = ( $cust_pkg->pkgnum, - time2str("%D", $cust_pkg->getfield('setup') ), - time2str("%D", $cust_pkg->getfield('bill') ), - time2str("%D", $cust_pkg->getfield('susp') ), - time2str("%D", $cust_pkg->getfield('expire') ), - time2str("%D", $cust_pkg->getfield('cancel') ), + $cust_pkg->getfield('setup') + ? time2str("%D", $cust_pkg->getfield('setup') ) + : '', + $cust_pkg->getfield('bill') + ? time2str("%D", $cust_pkg->getfield('bill') ), + : '', + $cust_pkg->getfield('susp') + ? time2str("%D", $cust_pkg->getfield('susp') ), + : '', + $cust_pkg->getfield('expire') + ? time2str("%D", $cust_pkg->getfield('expire') ), + : '', + $cust_pkg->getfield('cancel') + ? time2str("%D", $cust_pkg->getfield('cancel') ), + : '', $cust_pkg->custnum, $cust_main ? $cust_main->last : '', $cust_main ? $cust_main->first : '', @@ -194,6 +206,11 @@ END my $p = popurl(2); print $n1, <$pkgnum - $pkg + $setup + $bill + $susp + $expire + $cancel END if ( $cust_main ) { print < Date: Tue, 18 Dec 2001 07:12:00 +0000 Subject: really working dates on package browse. ouch. --- httemplate/search/cust_pkg.cgi | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 137dc5f19..dabcf46fb 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg @@ -158,23 +158,22 @@ END ) { my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); my($pkgnum, $setup, $bill, $susp, $expire, $cancel, - $custnum, $last, $first, $company - ) = ( + $custnum, $last, $first, $company ) = ( $cust_pkg->pkgnum, $cust_pkg->getfield('setup') ? time2str("%D", $cust_pkg->getfield('setup') ) : '', $cust_pkg->getfield('bill') - ? time2str("%D", $cust_pkg->getfield('bill') ), + ? time2str("%D", $cust_pkg->getfield('bill') ) : '', $cust_pkg->getfield('susp') - ? time2str("%D", $cust_pkg->getfield('susp') ), + ? time2str("%D", $cust_pkg->getfield('susp') ) : '', $cust_pkg->getfield('expire') - ? time2str("%D", $cust_pkg->getfield('expire') ), + ? time2str("%D", $cust_pkg->getfield('expire') ) : '', $cust_pkg->getfield('cancel') - ? time2str("%D", $cust_pkg->getfield('cancel') ), + ? time2str("%D", $cust_pkg->getfield('cancel') ) : '', $cust_pkg->custnum, $cust_main ? $cust_main->last : '', -- cgit v1.2.1 From 37f9312b22a0bef8cd9f3a295ef2bffc3ca10364 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 26 Dec 2001 04:52:59 +0000 Subject: same look as rest of search pages --- httemplate/search/cust_bill.html | 12 +++++------- httemplate/search/cust_main.html | 4 ++-- httemplate/search/svc_acct.html | 12 +++++------- httemplate/search/svc_domain.html | 13 +++++-------- 4 files changed, 17 insertions(+), 24 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 4adb40e4a..36e8bc91b 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -2,11 +2,11 @@ Invoice Search - -
-

Invoice Search

-
-
+ + + Invoice Search + +

Search for invoice #: @@ -14,8 +14,6 @@

- -
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html index 3184698b4..12796c7b2 100755 --- a/httemplate/search/cust_main.html +++ b/httemplate/search/cust_main.html @@ -2,8 +2,8 @@ Customer Search - - + + Customer Search
diff --git a/httemplate/search/svc_acct.html b/httemplate/search/svc_acct.html index 91291be99..742360596 100755 --- a/httemplate/search/svc_acct.html +++ b/httemplate/search/svc_acct.html @@ -2,11 +2,11 @@ Account Search - -
-

Account Search

-
-
+ + + Account Search + +

Search for username: @@ -14,8 +14,6 @@

- -
diff --git a/httemplate/search/svc_domain.html b/httemplate/search/svc_domain.html index 533743ba2..94bb9a66d 100755 --- a/httemplate/search/svc_domain.html +++ b/httemplate/search/svc_domain.html @@ -2,11 +2,11 @@ Domain Search - -
-

Domain Search

-
-
+ + + Domain Search + +

Search for domain: @@ -14,9 +14,6 @@

- -
- -- 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-payinfo.html | 4 ++-- httemplate/search/cust_main-quickpay.html | 37 +++++++++++++++++++++++++++++++ httemplate/search/cust_main.cgi | 15 ++++++++++--- httemplate/search/cust_main.html | 2 +- 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100755 httemplate/search/cust_main-quickpay.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_main-payinfo.html b/httemplate/search/cust_main-payinfo.html index 47bb83cbd..671b5ef08 100755 --- a/httemplate/search/cust_main-payinfo.html +++ b/httemplate/search/cust_main-payinfo.html @@ -2,8 +2,8 @@ Customer Search - - + + Customer Search
diff --git a/httemplate/search/cust_main-quickpay.html b/httemplate/search/cust_main-quickpay.html new file mode 100755 index 000000000..3f0ba0412 --- /dev/null +++ b/httemplate/search/cust_main-quickpay.html @@ -0,0 +1,37 @@ + + + Quick payment entry + + + + Quick payment entry + +

+
+ + Search for last name: + + using search method: + +

Search for company: + + using search methods: + +

Note: Fuzzy searching can take a while. Please be patient. + +

+ +
Explanation of search methods: +
    +
  • Fuzzy - Searches for matches that are close to your text. +
  • Exact - Finds exact matches only, but much faster than the other search methods. +
+ + + 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 diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html index 12796c7b2..1e91adee9 100755 --- a/httemplate/search/cust_main.html +++ b/httemplate/search/cust_main.html @@ -6,7 +6,7 @@ Customer Search -
+

Search for last name: -- cgit v1.2.1 From 92c43e05cdc7dc5c5a4f8d6b0017f7d699cda90d Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 26 Dec 2001 09:18:18 +0000 Subject: search by check # --- httemplate/search/cust_pay.cgi | 112 ++++++++++++++++++++++++++++++++++++++++ httemplate/search/cust_pay.html | 18 +++++++ 2 files changed, 130 insertions(+) create mode 100755 httemplate/search/cust_pay.cgi create mode 100755 httemplate/search/cust_pay.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi new file mode 100755 index 000000000..68a17e7dc --- /dev/null +++ b/httemplate/search/cust_pay.cgi @@ -0,0 +1,112 @@ +<% +# + +use strict; +use vars qw( $cgi $sortby @cust_pay ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use Date::Format; +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(popurl header menubar idiot table ); +use FS::Record qw(qsearch ); +use FS::cust_pay; +use FS::cust_main; + +$cgi = new CGI; +cgisuidsetup($cgi); + +$cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; +my $payinfo = $1; +$cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; +my $payby = $1; +@cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo, + 'payby' => $payby } ); +$sortby = \*date_sort; + +if (0) { +#if ( scalar(@cust_pay) == 1 ) { +# my $invnum = $cust_bill[0]->invnum; +# print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect +} elsif ( scalar(@cust_pay) == 0 ) { + idiot("Check # not found."); + #exit; +} else { + my $total = scalar(@cust_pay); + my $s = $total > 1 ? 's' : ''; + print header("Check # Search Results", menubar( + 'Main Menu', popurl(2) + )), "$total matching check$s found
", &table(), < + + Amount + Date + Contact name + Company + +END + + my(%saw, $cust_pay); + foreach my $cust_pay ( + sort $sortby grep(!$saw{$_->paynum}++, @cust_pay) + ) { + my($paynum, $custnum, $payinfo, $amount, $date ) = ( + $cust_pay->paynum, + $cust_pay->custnum, + $cust_pay->payinfo, + sprintf("%.2f", $cust_pay->paid), + $cust_pay->_date, + ); + my $pdate = time2str("%b %d %Y", $date); + + my $rowspan = 1; + + my $view = popurl(2). "view/cust_main.cgi?". $custnum. + "#". $payby. $payinfo; + + print < + $payinfo + \$$amount + $pdate +END + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); + if ( $cust_main ) { + #my $cview = popurl(2). "view/cust_main.cgi?". $cust_main->custnum; + my ( $name, $company ) = ( + $cust_main->last. ', '. $cust_main->first, + $cust_main->company, + ); + print <$name + $company +END + } else { + print <WARNING: couldn't find cust_main.custnum $custnum (cust_pay.paynum $paynum) +END + } + + print ""; + } + print < + + +END + +} + +# + +#sub invnum_sort { +# $a->invnum <=> $b->invnum; +#} +# +#sub custnum_sort { +# $a->custnum <=> $b->custnum || $a->invnum <=> $b->invnum; +#} + +sub date_sort { + $a->_date <=> $b->_date || $a->invnum <=> $b->invnum; +} +%> diff --git a/httemplate/search/cust_pay.html b/httemplate/search/cust_pay.html new file mode 100755 index 000000000..3848d66f7 --- /dev/null +++ b/httemplate/search/cust_pay.html @@ -0,0 +1,18 @@ + + + Check # Search + + + + Check # Search + +

+ + Search for check #: + + +

+ + + + -- 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') 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_bill.cgi | 19 ++---------- httemplate/search/cust_main.cgi | 65 +++++++++++++++++---------------------- httemplate/search/cust_pay.cgi | 22 +++---------- httemplate/search/cust_pkg.cgi | 32 +++++-------------- httemplate/search/svc_acct.cgi | 34 ++++++-------------- httemplate/search/svc_acct_sm.cgi | 28 +++++------------ httemplate/search/svc_domain.cgi | 32 +++++-------------- 7 files changed, 68 insertions(+), 164 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 41a4a546e..755745fde 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -1,20 +1,7 @@ + <% -# - -use strict; -use vars qw ( $cgi $invnum $query $sortby @cust_bill ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use Date::Format; -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(popurl header menubar eidiot table ); -use FS::Record qw(qsearch qsearchs); -use FS::cust_bill; -use FS::cust_main; - -$cgi = new CGI; -cgisuidsetup($cgi); +my(@cust_bill, $sortby); if ( $cgi->keywords ) { my($query) = $cgi->keywords; if ( $query eq 'invnum' ) { @@ -55,7 +42,7 @@ if ( $cgi->keywords ) { } } else { $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; - $invnum = $2; + my $invnum = $2; @cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum } ); $sortby = \*invnum_sort; } 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; } %> diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 68a17e7dc..715e63e24 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,27 +1,13 @@ + <% -# - -use strict; -use vars qw( $cgi $sortby @cust_pay ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use Date::Format; -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(popurl header menubar idiot table ); -use FS::Record qw(qsearch ); -use FS::cust_pay; -use FS::cust_main; - -$cgi = new CGI; -cgisuidsetup($cgi); $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; my $payinfo = $1; $cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; my $payby = $1; -@cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo, - 'payby' => $payby } ); -$sortby = \*date_sort; +my @cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo, + 'payby' => $payby } ); +my $sortby = \*date_sort; if (0) { #if ( scalar(@cust_pay) == 1 ) { diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index dabcf46fb..9705bd658 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,38 +1,22 @@ + <% -# -use strict; -use vars qw ( $cgi @cust_pkg $sortby $query %part_pkg - $conf $maxrecords $limit $offset ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(dbh cgisuidsetup); -use FS::Conf; -use FS::Record qw(qsearch qsearchs dbdef); -use FS::CGI qw(header eidiot popurl table); -use FS::cust_pkg; -use FS::pkg_svc; -use FS::cust_svc; -use FS::cust_main; - -$cgi = new CGI; -&cgisuidsetup($cgi); - -$conf = new FS::Conf; -$maxrecords = $conf->config('maxsearchrecordsperpage'); +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {}); -$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 $unconf = ''; -($query) = $cgi->keywords; +my($query) = $cgi->keywords; +my $sortby; if ( $query eq 'pkgnum' ) { $sortby=\*pkgnum_sort; @@ -86,7 +70,7 @@ $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; $total = $sth->fetchrow_arrayref->[0]; -@cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); +my @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); if ( scalar(@cust_pkg) == 1 ) { diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index c9d1eb6ca..8d5329618 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,36 +1,22 @@ + <% -# -use strict; -use vars qw( $cgi @svc_acct $sortby $query $mydomain - $conf $maxrecords $limit $offset ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs dbdef); -use FS::CGI qw(header idiot popurl table); -use FS::svc_acct; -use FS::cust_main; +my $mydomain = ''; -$mydomain = ''; - -$cgi = new CGI; -&cgisuidsetup($cgi); - -$conf = new FS::Conf; -$maxrecords = $conf->config('maxsearchrecordsperpage'); +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); my $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; -($query)=$cgi->keywords; +my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors my $unlinked = ''; @@ -45,6 +31,7 @@ if ( $query =~ /^UN_(.*)$/ ) { '; } +my(@svc_acct, $sortby); if ( $query eq 'svcnum' ) { $sortby=\*svcnum_sort; $orderby = 'ORDER BY svcnum'; @@ -56,7 +43,7 @@ if ( $query eq 'svcnum' ) { $orderby = ( $unlinked ? 'AND' : 'WHERE' ). ' uid IS NOT NULL ORDER BY uid'; } else { $sortby=\*uid_sort; - &usernamesearch; + @svc_acct = @{&usernamesearch}; } if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' ) { @@ -245,9 +232,8 @@ sub usernamesearch { $cgi->param('username') =~ /^([\w\d\-]+)$/; #untaint username_text my($username)=$1; - @svc_acct=qsearch('svc_acct',{'username'=>$username}); + [ qsearch('svc_acct',{'username'=>$username}) ]; } - %> diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi index 5250b5ca1..1f1f770be 100755 --- a/httemplate/search/svc_acct_sm.cgi +++ b/httemplate/search/svc_acct_sm.cgi @@ -1,32 +1,18 @@ + <% -# -use strict; -use vars qw( $conf $cgi $mydomain $domuser $svc_domain $domsvc @svc_acct_sm ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(popurl idiot header table); -use FS::Record qw(qsearch qsearchs); -use FS::Conf; -use FS::svc_domain; -use FS::svc_acct_sm; -use FS::svc_acct; - -$cgi = new CGI; -&cgisuidsetup($cgi); - -$conf = new FS::Conf; -$mydomain = $conf->config('domain'); +my $conf = new FS::Conf; +my $mydomain = $conf->config('domain'); $cgi->param('domuser') =~ /^([a-z0-9_\-]{0,32})$/; -$domuser = $1; +my $domuser = $1; $cgi->param('domain') =~ /^([\w\-\.]+)$/ or die "Illegal domain"; -$svc_domain = qsearchs('svc_domain',{'domain'=>$1}) +my $svc_domain = qsearchs('svc_domain',{'domain'=>$1}) or die "Unknown domain"; -$domsvc = $svc_domain->svcnum; +my $domsvc = $svc_domain->svcnum; +my @svc_acct_sm; if ($domuser) { @svc_acct_sm=qsearch('svc_acct_sm',{ 'domuser' => $domuser, diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index b09c65a0b..4ec5eb053 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,26 +1,12 @@ + <% -# - -use strict; -use vars qw ( $cgi @svc_domain $sortby $query $conf $mydomain ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs); -use FS::CGI qw(header eidiot popurl); -use FS::svc_domain; -use FS::cust_svc; -use FS::svc_acct; -use FS::svc_forward; - -$cgi = new CGI; -&cgisuidsetup($cgi); - -$conf = new FS::Conf; -$mydomain = $conf->config('domain'); - -($query)=$cgi->keywords; + +my $conf = new FS::Conf; +my $mydomain = $conf->config('domain'); + +my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors +my(@svc_domain,$sortby); if ( $query eq 'svcnum' ) { $sortby=\*svcnum_sort; @svc_domain=qsearch('svc_domain',{}); @@ -69,9 +55,7 @@ END # my(%saw); # if we've multiple domains with the same # svcnum, then we've a corrupt database - my($svc_domain); - my $p = popurl(2); - foreach $svc_domain ( + foreach my $svc_domain ( # sort $sortby grep(!$saw{$_->svcnum}++, @svc_domain) sort $sortby (@svc_domain) ) { -- 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 +- httemplate/search/cust_pkg.cgi | 4 ++-- httemplate/search/svc_domain.cgi | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'httemplate/search') 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 { diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 9705bd658..b2199e9dc 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,4 +1,4 @@ - + <% my $conf = new FS::Conf; @@ -76,7 +76,7 @@ my @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); if ( scalar(@cust_pkg) == 1 ) { my($pkgnum)=$cust_pkg[0]->pkgnum; print $cgi->redirect(popurl(2). "view/cust_pkg.cgi?$pkgnum"); - exit; + #exit; } elsif ( scalar(@cust_pkg) == 0 ) { #error eidiot("No packages found"); } else { diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 4ec5eb053..c274750aa 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,4 +1,4 @@ - + <% my $conf = new FS::Conf; @@ -34,7 +34,7 @@ if ( $query eq 'svcnum' ) { if ( scalar(@svc_domain) == 1 ) { print $cgi->redirect(popurl(2). "view/svc_domain.cgi?". $svc_domain[0]->svcnum); - exit; + #exit; } elsif ( scalar(@svc_domain) == 0 ) { eidiot "No matching domains found!\n"; } else { -- cgit v1.2.1 From 22a35047ecdffff80110e06cc08fc84f9ddba9b0 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Feb 2002 13:21:31 +0000 Subject: removed from all files to fix any redirects, whew Mason handler.pl overrides CGI::redirect fixed strict; problems in edit/part_pkg.cgi & edit/process/part_pkg.cgi --- httemplate/search/cust_bill.cgi | 1 - httemplate/search/cust_pay.cgi | 1 - httemplate/search/cust_pkg.cgi | 1 - httemplate/search/svc_acct.cgi | 1 - httemplate/search/svc_acct_sm.cgi | 1 - httemplate/search/svc_domain.cgi | 1 - 6 files changed, 6 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 755745fde..0c9f27f42 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -1,4 +1,3 @@ - <% my(@cust_bill, $sortby); diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 715e63e24..8ebd65413 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,4 +1,3 @@ - <% $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index b2199e9dc..6b25fec03 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,4 +1,3 @@ - <% my $conf = new FS::Conf; diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 8d5329618..a3fed8384 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,4 +1,3 @@ - <% my $mydomain = ''; diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi index 1f1f770be..bcfe44cfc 100755 --- a/httemplate/search/svc_acct_sm.cgi +++ b/httemplate/search/svc_acct_sm.cgi @@ -1,4 +1,3 @@ - <% my $conf = new FS::Conf; diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index c274750aa..334b6c0b7 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,4 +1,3 @@ - <% my $conf = new FS::Conf; -- 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_bill.cgi | 6 ++++++ httemplate/search/cust_main.cgi | 6 ++++++ httemplate/search/cust_pay.cgi | 6 ++++++ httemplate/search/cust_pkg.cgi | 6 ++++++ httemplate/search/svc_acct.cgi | 6 ++++++ httemplate/search/svc_acct_sm.cgi | 3 +++ httemplate/search/svc_domain.cgi | 7 ++++++- 7 files changed, 39 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 0c9f27f42..d83851804 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -50,8 +50,14 @@ if ( scalar(@cust_bill) == 1 ) { my $invnum = $cust_bill[0]->invnum; print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect } elsif ( scalar(@cust_bill) == 0 ) { +%> + +<% eidiot("Invoice not found."); } else { +%> + +<% my $total = scalar(@cust_bill); print header("Invoice Search Results", menubar( 'Main Menu', popurl(2) 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( diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 8ebd65413..b5bdf8296 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -13,11 +13,17 @@ if (0) { # my $invnum = $cust_bill[0]->invnum; # print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect } elsif ( scalar(@cust_pay) == 0 ) { +%> + +<% idiot("Check # not found."); #exit; } else { my $total = scalar(@cust_pay); my $s = $total > 1 ? 's' : ''; +%> + +<% print header("Check # Search Results", menubar( 'Main Menu', popurl(2) )), "$total matching check$s found
", &table(), <redirect(popurl(2). "view/cust_pkg.cgi?$pkgnum"); #exit; } elsif ( scalar(@cust_pkg) == 0 ) { #error +%> + +<% eidiot("No packages found"); } else { +%> + +<% $total ||= scalar(@cust_pkg); #begin pager diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index a3fed8384..0918275d7 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -63,8 +63,14 @@ if ( scalar(@svc_acct) == 1 ) { print $cgi->redirect(popurl(2). "view/svc_acct.cgi?$svcnum"); #redirect #exit; } elsif ( scalar(@svc_acct) == 0 ) { #error +%> + +<% idiot("Account not found"); } else { +%> + +<% $total ||= scalar(@svc_acct); #begin pager diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi index bcfe44cfc..4ee300612 100755 --- a/httemplate/search/svc_acct_sm.cgi +++ b/httemplate/search/svc_acct_sm.cgi @@ -25,6 +25,9 @@ if ( scalar(@svc_acct_sm) == 1 ) { my($svcnum)=$svc_acct_sm[0]->svcnum; print $cgi->redirect(popurl(2). "view/svc_acct_sm.cgi?$svcnum"); } elsif ( scalar(@svc_acct_sm) > 1 ) { +%> + +<% print header('Mail Alias Search Results'), &table(), < Mail to
(click to view mail alias) diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 334b6c0b7..fb372db14 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -35,9 +35,14 @@ if ( scalar(@svc_domain) == 1 ) { print $cgi->redirect(popurl(2). "view/svc_domain.cgi?". $svc_domain[0]->svcnum); #exit; } elsif ( scalar(@svc_domain) == 0 ) { +%> + +<% eidiot "No matching domains found!\n"; } else { - +%> + +<% my($total)=scalar(@svc_domain); print header("Domain Search Results",''), < 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') 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 b50b2e5f94774268c271484f9c07bfe316f95527 Mon Sep 17 00:00:00 2001 From: jeff Date: Fri, 22 Feb 2002 23:18:34 +0000 Subject: add some reporting features --- httemplate/search/report_cc.cgi | 94 +++++++++++++++++++++++++++++++ httemplate/search/report_cc.html | 23 ++++++++ httemplate/search/report_credit.cgi | 97 ++++++++++++++++++++++++++++++++ httemplate/search/report_credit.html | 23 ++++++++ httemplate/search/report_receivables.cgi | 26 +++++++++ httemplate/search/report_tax.cgi | 94 +++++++++++++++++++++++++++++++ httemplate/search/report_tax.html | 23 ++++++++ 7 files changed, 380 insertions(+) create mode 100755 httemplate/search/report_cc.cgi create mode 100755 httemplate/search/report_cc.html create mode 100755 httemplate/search/report_credit.cgi create mode 100755 httemplate/search/report_credit.html create mode 100755 httemplate/search/report_receivables.cgi create mode 100755 httemplate/search/report_tax.cgi create mode 100755 httemplate/search/report_tax.html (limited to 'httemplate/search') diff --git a/httemplate/search/report_cc.cgi b/httemplate/search/report_cc.cgi new file mode 100755 index 000000000..908ad35cd --- /dev/null +++ b/httemplate/search/report_cc.cgi @@ -0,0 +1,94 @@ +<% +#!/usr/bin/perl -Tw +# +# $Id: report_cc.cgi,v 1.1 2002-02-22 23:18:33 jeff Exp $ +# +# Usage: post form to: +# http://server.name/path/svc_domain.cgi +# +# ivan@voicenet.com 96-mar-5 +# +# need to look at table in results to make it more readable +# +# ivan@voicenet.com +# +# rewrite ivan@sisd.com 98-mar-15 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# $Log: report_cc.cgi,v $ +# Revision 1.1 2002-02-22 23:18:33 jeff +# add some reporting features +# +# Revision 1.1 2002/02/05 15:22:00 jeff +# preserving state prior to 1.4.0pre7 upgrade +# +# Revision 1.2 2000/09/20 19:25:19 jeff +# local modifications +# +# Revision 1.1.1.1 2000/09/18 06:26:58 jeff +# Import of Freeside 1.2.3 +# +# Revision 1.10 1999/07/20 06:03:36 ivan +# s/CGI::Request/CGI/; (how'd i miss that before?) +# +# Revision 1.9 1999/04/09 04:22:34 ivan +# also table() +# +# Revision 1.8 1999/04/09 03:52:55 ivan +# explicit & for table/itable/ntable +# +# Revision 1.7 1999/02/28 00:03:56 ivan +# removed misleading comments +# +# Revision 1.6 1999/02/09 09:22:58 ivan +# visual and bugfixes +# +# Revision 1.5 1999/01/19 05:14:16 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.4 1999/01/18 09:41:40 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.3 1998/12/17 09:41:11 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw( $conf $cgi $beginning $ending ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(popurl idiot header table); +use FS::Record qw(qsearch qsearchs); +use FS::Conf; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +$conf = new FS::Conf; + +$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; +$beginning = $1; + +$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; +$ending = $1; + + print $cgi->header( '-expires' => '-2m' ), + header('Credit Card Recipt Report Results'); + + open (REPORT, "/usr/bin/freeside-cc-receipts-report -v -s $beginning -d $ending freeside |"); + + print '
';
+  while() {
+    print $_;
+  }
+  print '
'; + + print ''; + +%> + diff --git a/httemplate/search/report_cc.html b/httemplate/search/report_cc.html new file mode 100755 index 000000000..a028a87df --- /dev/null +++ b/httemplate/search/report_cc.html @@ -0,0 +1,23 @@ + + + Credit Card Receipt Report Criteria + + +
+

Credit Card Receipt Report Criteria

+
+
+
+ Return credit card receipt report for period: + from + to + +

+ +

+ +
+ + + + diff --git a/httemplate/search/report_credit.cgi b/httemplate/search/report_credit.cgi new file mode 100755 index 000000000..8535e29cc --- /dev/null +++ b/httemplate/search/report_credit.cgi @@ -0,0 +1,97 @@ +<% +#!/usr/bin/perl -Tw +# +# $Id: report_credit.cgi,v 1.1 2002-02-22 23:18:33 jeff Exp $ +# +# Usage: post form to: +# http://server.name/path/svc_domain.cgi +# +# ivan@voicenet.com 96-mar-5 +# +# need to look at table in results to make it more readable +# +# ivan@voicenet.com +# +# rewrite ivan@sisd.com 98-mar-15 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# $Log: report_credit.cgi,v $ +# Revision 1.1 2002-02-22 23:18:33 jeff +# add some reporting features +# +# Revision 1.2 2002/02/19 14:24:53 jeff +# might be functional now +# +# Revision 1.1 2002/02/05 15:22:00 jeff +# preserving state prior to 1.4.0pre7 upgrade +# +# Revision 1.2 2000/09/20 19:25:19 jeff +# local modifications +# +# Revision 1.1.1.1 2000/09/18 06:26:58 jeff +# Import of Freeside 1.2.3 +# +# Revision 1.10 1999/07/20 06:03:36 ivan +# s/CGI::Request/CGI/; (how'd i miss that before?) +# +# Revision 1.9 1999/04/09 04:22:34 ivan +# also table() +# +# Revision 1.8 1999/04/09 03:52:55 ivan +# explicit & for table/itable/ntable +# +# Revision 1.7 1999/02/28 00:03:56 ivan +# removed misleading comments +# +# Revision 1.6 1999/02/09 09:22:58 ivan +# visual and bugfixes +# +# Revision 1.5 1999/01/19 05:14:16 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.4 1999/01/18 09:41:40 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.3 1998/12/17 09:41:11 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw( $conf $cgi $beginning $ending ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(popurl idiot header table); +use FS::Record qw(qsearch qsearchs); +use FS::Conf; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +$conf = new FS::Conf; + +$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; +$beginning = $1; + +$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; +$ending = $1; + + print $cgi->header( '-expires' => '-2m' ), + header('In House Credit Report Results'); + + open (REPORT, "/usr/bin/freeside-credit-report -v -s $beginning -d $ending freeside |"); + + print '
';
+  while() {
+    print $_;
+  }
+  print '
'; + + print ''; + +%> + diff --git a/httemplate/search/report_credit.html b/httemplate/search/report_credit.html new file mode 100755 index 000000000..bda08e31d --- /dev/null +++ b/httemplate/search/report_credit.html @@ -0,0 +1,23 @@ + + + In House Credit Report Criteria + + +
+

In House Credit Report Criteria

+
+
+
+ Return in house credit report for period: + from + to + +

+ +

+ +
+ + + + diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi new file mode 100755 index 000000000..7113ad5a7 --- /dev/null +++ b/httemplate/search/report_receivables.cgi @@ -0,0 +1,26 @@ +<% + +use strict; +use vars qw( $cgi ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); + +$cgi = new CGI; +&cgisuidsetup($cgi); + +print $cgi->header( '-expires' => '-2m' ), + header('Current Receivables Report Results'); + +open (REPORT, "/usr/bin/freeside-receivables-report -v freeside |"); + +print '
';
+while() {
+  print $_;
+}
+print '
'; + +print ''; + +%> + diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi new file mode 100755 index 000000000..8062479b5 --- /dev/null +++ b/httemplate/search/report_tax.cgi @@ -0,0 +1,94 @@ +<% +#!/usr/bin/perl -Tw +# +# $Id: report_tax.cgi,v 1.1 2002-02-22 23:18:34 jeff Exp $ +# +# Usage: post form to: +# http://server.name/path/svc_domain.cgi +# +# ivan@voicenet.com 96-mar-5 +# +# need to look at table in results to make it more readable +# +# ivan@voicenet.com +# +# rewrite ivan@sisd.com 98-mar-15 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# $Log: report_tax.cgi,v $ +# Revision 1.1 2002-02-22 23:18:34 jeff +# add some reporting features +# +# Revision 1.1 2002/02/05 15:22:00 jeff +# preserving state prior to 1.4.0pre7 upgrade +# +# Revision 1.2 2000/09/20 19:25:19 jeff +# local modifications +# +# Revision 1.1.1.1 2000/09/18 06:26:58 jeff +# Import of Freeside 1.2.3 +# +# Revision 1.10 1999/07/20 06:03:36 ivan +# s/CGI::Request/CGI/; (how'd i miss that before?) +# +# Revision 1.9 1999/04/09 04:22:34 ivan +# also table() +# +# Revision 1.8 1999/04/09 03:52:55 ivan +# explicit & for table/itable/ntable +# +# Revision 1.7 1999/02/28 00:03:56 ivan +# removed misleading comments +# +# Revision 1.6 1999/02/09 09:22:58 ivan +# visual and bugfixes +# +# Revision 1.5 1999/01/19 05:14:16 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.4 1999/01/18 09:41:40 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.3 1998/12/17 09:41:11 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw( $conf $cgi $beginning $ending ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(popurl idiot header table); +use FS::Record qw(qsearch qsearchs); +use FS::Conf; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +$conf = new FS::Conf; + +$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; +$beginning = $1; + +$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; +$ending = $1; + + print $cgi->header( '-expires' => '-2m' ), + header('Tax Report Results'); + + open (REPORT, "/usr/bin/freeside-tax-report -v -s $beginning -d $ending freeside |"); + + print '
';
+  while() {
+    print $_;
+  }
+  print '
'; + + print ''; + +%> + diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html new file mode 100755 index 000000000..a7beb2471 --- /dev/null +++ b/httemplate/search/report_tax.html @@ -0,0 +1,23 @@ + + + Tax Report Criteria + + +
+

Tax Report Criteria

+
+
+
+ Return tax report for period: + from + to + +

+ +

+ +
+ + + + -- cgit v1.2.1 From cefb9727ed4cdfacf3b967485d58b25fbea98c6b Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 23 Feb 2002 02:14:26 +0000 Subject: report fixes and cruft removal --- httemplate/search/report_cc.cgi | 87 +++++------------------------- httemplate/search/report_credit.cgi | 90 +++++--------------------------- httemplate/search/report_receivables.cgi | 12 +++-- httemplate/search/report_tax.cgi | 87 +++++------------------------- 4 files changed, 49 insertions(+), 227 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_cc.cgi b/httemplate/search/report_cc.cgi index 908ad35cd..991c00831 100755 --- a/httemplate/search/report_cc.cgi +++ b/httemplate/search/report_cc.cgi @@ -1,75 +1,16 @@ <% -#!/usr/bin/perl -Tw -# -# $Id: report_cc.cgi,v 1.1 2002-02-22 23:18:33 jeff Exp $ -# -# Usage: post form to: -# http://server.name/path/svc_domain.cgi -# -# ivan@voicenet.com 96-mar-5 -# -# need to look at table in results to make it more readable -# -# ivan@voicenet.com -# -# rewrite ivan@sisd.com 98-mar-15 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# $Log: report_cc.cgi,v $ -# Revision 1.1 2002-02-22 23:18:33 jeff -# add some reporting features -# -# Revision 1.1 2002/02/05 15:22:00 jeff -# preserving state prior to 1.4.0pre7 upgrade -# -# Revision 1.2 2000/09/20 19:25:19 jeff -# local modifications -# -# Revision 1.1.1.1 2000/09/18 06:26:58 jeff -# Import of Freeside 1.2.3 -# -# Revision 1.10 1999/07/20 06:03:36 ivan -# s/CGI::Request/CGI/; (how'd i miss that before?) -# -# Revision 1.9 1999/04/09 04:22:34 ivan -# also table() -# -# Revision 1.8 1999/04/09 03:52:55 ivan -# explicit & for table/itable/ntable -# -# Revision 1.7 1999/02/28 00:03:56 ivan -# removed misleading comments -# -# Revision 1.6 1999/02/09 09:22:58 ivan -# visual and bugfixes -# -# Revision 1.5 1999/01/19 05:14:16 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.4 1999/01/18 09:41:40 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.3 1998/12/17 09:41:11 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# use strict; -use vars qw( $conf $cgi $beginning $ending ); +use vars qw( $cgi $user $beginning $ending ); use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(popurl idiot header table); -use FS::Record qw(qsearch qsearchs); -use FS::Conf; +use CGI::Carp qw( fatalsToBrowser ); +use FS::UID qw( cgisuidsetup getotaker ); +use FS::CGI qw( header ); $cgi = new CGI; &cgisuidsetup($cgi); -$conf = new FS::Conf; +$user = getotaker; $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; $beginning = $1; @@ -77,18 +18,18 @@ $beginning = $1; $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; $ending = $1; - print $cgi->header( '-expires' => '-2m' ), - header('Credit Card Recipt Report Results'); +print $cgi->header( '-expires' => '-2m' ), + header('Credit Card Recipt Report Results'); - open (REPORT, "/usr/bin/freeside-cc-receipts-report -v -s $beginning -d $ending freeside |"); +open (REPORT, "/usr/bin/freeside-cc-receipts-report -v -s $beginning -d $ending $user |"); - print '
';
-  while() {
-    print $_;
-  }
-  print '
'; +print '
';
+while() {
+  print $_;
+}
+print '
'; - print ''; +print ''; %> diff --git a/httemplate/search/report_credit.cgi b/httemplate/search/report_credit.cgi index 8535e29cc..f4430c13f 100755 --- a/httemplate/search/report_credit.cgi +++ b/httemplate/search/report_credit.cgi @@ -1,78 +1,16 @@ <% -#!/usr/bin/perl -Tw -# -# $Id: report_credit.cgi,v 1.1 2002-02-22 23:18:33 jeff Exp $ -# -# Usage: post form to: -# http://server.name/path/svc_domain.cgi -# -# ivan@voicenet.com 96-mar-5 -# -# need to look at table in results to make it more readable -# -# ivan@voicenet.com -# -# rewrite ivan@sisd.com 98-mar-15 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# $Log: report_credit.cgi,v $ -# Revision 1.1 2002-02-22 23:18:33 jeff -# add some reporting features -# -# Revision 1.2 2002/02/19 14:24:53 jeff -# might be functional now -# -# Revision 1.1 2002/02/05 15:22:00 jeff -# preserving state prior to 1.4.0pre7 upgrade -# -# Revision 1.2 2000/09/20 19:25:19 jeff -# local modifications -# -# Revision 1.1.1.1 2000/09/18 06:26:58 jeff -# Import of Freeside 1.2.3 -# -# Revision 1.10 1999/07/20 06:03:36 ivan -# s/CGI::Request/CGI/; (how'd i miss that before?) -# -# Revision 1.9 1999/04/09 04:22:34 ivan -# also table() -# -# Revision 1.8 1999/04/09 03:52:55 ivan -# explicit & for table/itable/ntable -# -# Revision 1.7 1999/02/28 00:03:56 ivan -# removed misleading comments -# -# Revision 1.6 1999/02/09 09:22:58 ivan -# visual and bugfixes -# -# Revision 1.5 1999/01/19 05:14:16 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.4 1999/01/18 09:41:40 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.3 1998/12/17 09:41:11 ivan -# s/CGI::(Base|Request)/CGI.pm/; -# use strict; -use vars qw( $conf $cgi $beginning $ending ); +use vars qw( $cgi $user $beginning $ending ); use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(popurl idiot header table); -use FS::Record qw(qsearch qsearchs); -use FS::Conf; +use CGI::Carp qw( fatalsToBrowser ); +use FS::UID qw( cgisuidsetup getotaker ); +use FS::CGI qw( header ); $cgi = new CGI; &cgisuidsetup($cgi); -$conf = new FS::Conf; +$user = getotaker; $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; $beginning = $1; @@ -80,18 +18,18 @@ $beginning = $1; $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; $ending = $1; - print $cgi->header( '-expires' => '-2m' ), - header('In House Credit Report Results'); +print $cgi->header( '-expires' => '-2m' ), + header('In House Credit Report Results'); - open (REPORT, "/usr/bin/freeside-credit-report -v -s $beginning -d $ending freeside |"); +open (REPORT, "/usr/bin/freeside-credit-report -v -s $beginning -d $ending $user |"); - print '
';
-  while() {
-    print $_;
-  }
-  print '
'; +print '
';
+while() {
+  print $_;
+}
+print '
'; - print ''; +print ''; %> diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 7113ad5a7..6b96ba7a5 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -1,18 +1,20 @@ <% use strict; -use vars qw( $cgi ); +use vars qw( $cgi $user ); use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); +use CGI::Carp qw( fatalsToBrowser ); +use FS::UID qw( cgisuidsetup getotaker ); $cgi = new CGI; &cgisuidsetup($cgi); +$user = getotaker; + print $cgi->header( '-expires' => '-2m' ), - header('Current Receivables Report Results'); + header('Current Receivables Report Results'); -open (REPORT, "/usr/bin/freeside-receivables-report -v freeside |"); +open (REPORT, "/usr/bin/freeside-receivables-report -v $user |"); print '
';
 while() {
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index 8062479b5..bedfdac5f 100755
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -1,75 +1,16 @@
 <%
-#!/usr/bin/perl -Tw
-#
-# $Id: report_tax.cgi,v 1.1 2002-02-22 23:18:34 jeff Exp $
-#
-# Usage: post form to:
-#        http://server.name/path/svc_domain.cgi
-#
-# ivan@voicenet.com 96-mar-5
-#
-# need to look at table in results to make it more readable
-#
-# ivan@voicenet.com
-#
-# rewrite ivan@sisd.com 98-mar-15
-#
-# Changes to allow page to work at a relative position in server
-#       bmccane@maxbaud.net     98-apr-3
-#
-# $Log: report_tax.cgi,v $
-# Revision 1.1  2002-02-22 23:18:34  jeff
-# add some reporting features
-#
-# Revision 1.1  2002/02/05 15:22:00  jeff
-# preserving state prior to 1.4.0pre7 upgrade
-#
-# Revision 1.2  2000/09/20 19:25:19  jeff
-# local modifications
-#
-# Revision 1.1.1.1  2000/09/18 06:26:58  jeff
-# Import of Freeside 1.2.3
-#
-# Revision 1.10  1999/07/20 06:03:36  ivan
-# s/CGI::Request/CGI/; (how'd i miss that before?)
-#
-# Revision 1.9  1999/04/09 04:22:34  ivan
-# also table()
-#
-# Revision 1.8  1999/04/09 03:52:55  ivan
-# explicit & for table/itable/ntable
-#
-# Revision 1.7  1999/02/28 00:03:56  ivan
-# removed misleading comments
-#
-# Revision 1.6  1999/02/09 09:22:58  ivan
-# visual and bugfixes
-#
-# Revision 1.5  1999/01/19 05:14:16  ivan
-# for mod_perl: no more top-level my() variables; use vars instead
-# also the last s/create/new/;
-#
-# Revision 1.4  1999/01/18 09:41:40  ivan
-# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
-# (good idea anyway)
-#
-# Revision 1.3  1998/12/17 09:41:11  ivan
-# s/CGI::(Base|Request)/CGI.pm/;
-#
 
 use strict;
-use vars qw( $conf $cgi $beginning $ending );
+use vars qw( $cgi $user $beginning $ending );
 use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup);
-use FS::CGI qw(popurl idiot header table);
-use FS::Record qw(qsearch qsearchs);
-use FS::Conf;
+use CGI::Carp qw( fatalsToBrowser );
+use FS::UID qw( cgisuidsetup getotaker );
+use FS::CGI qw( header );
 
 $cgi = new CGI;
 &cgisuidsetup($cgi);
 
-$conf = new FS::Conf;
+$user = getotaker;
 
 $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
 $beginning = $1;
@@ -77,18 +18,18 @@ $beginning = $1;
 $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
 $ending = $1;
 
-  print $cgi->header( '-expires' => '-2m' ),
-        header('Tax Report Results');
+print $cgi->header( '-expires' => '-2m' ),
+  header('Tax Report Results');
 
-  open (REPORT, "/usr/bin/freeside-tax-report -v -s $beginning -d $ending freeside |");
+open (REPORT, "/usr/bin/freeside-tax-report -v -s $beginning -d $ending $user |");
 
-  print '
';
-  while() {
-    print $_;
-  }
-  print '
'; +print '
';
+while() {
+  print $_;
+}
+print '
'; - print ''; +print ''; %> -- 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 ++++++++++++++++++++++++++++------------ httemplate/search/cust_main.html | 10 +++++-- 2 files changed, 53 insertions(+), 20 deletions(-) (limited to 'httemplate/search') 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{$_}++; } diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html index 1e91adee9..5a066e453 100755 --- a/httemplate/search/cust_main.html +++ b/httemplate/search/cust_main.html @@ -11,14 +11,18 @@ Search for last name: using search method:

Search for company: using search methods: @@ -28,7 +32,9 @@


Explanation of search methods:
    +
  • All - Try all search methods.
  • Fuzzy - Searches for matches that are close to your text. +
  • Substring - Searches for matches that contain your text.
  • Exact - Finds exact matches only, but much faster than the other search methods.
-- cgit v1.2.1 From 00f2fdb5c3c9edfe446cf453ee33b9ebc7802925 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 23 Feb 2002 22:36:55 +0000 Subject: take hardcoded paths out of report cgis --- httemplate/search/report_cc.cgi | 2 +- httemplate/search/report_credit.cgi | 2 +- httemplate/search/report_receivables.cgi | 2 +- httemplate/search/report_tax.cgi | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_cc.cgi b/httemplate/search/report_cc.cgi index 991c00831..f1c3c962c 100755 --- a/httemplate/search/report_cc.cgi +++ b/httemplate/search/report_cc.cgi @@ -21,7 +21,7 @@ $ending = $1; print $cgi->header( '-expires' => '-2m' ), header('Credit Card Recipt Report Results'); -open (REPORT, "/usr/bin/freeside-cc-receipts-report -v -s $beginning -d $ending $user |"); +open (REPORT, "freeside-cc-receipts-report -v -s $beginning -d $ending $user |"); print '
';
 while() {
diff --git a/httemplate/search/report_credit.cgi b/httemplate/search/report_credit.cgi
index f4430c13f..e4a9bf241 100755
--- a/httemplate/search/report_credit.cgi
+++ b/httemplate/search/report_credit.cgi
@@ -21,7 +21,7 @@ $ending = $1;
 print $cgi->header( '-expires' => '-2m' ),
   header('In House Credit Report Results');
 
-open (REPORT, "/usr/bin/freeside-credit-report -v -s $beginning -d $ending $user |");
+open (REPORT, "freeside-credit-report -v -s $beginning -d $ending $user |");
 
 print '
';
 while() {
diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi
index 6b96ba7a5..ba02eb720 100755
--- a/httemplate/search/report_receivables.cgi
+++ b/httemplate/search/report_receivables.cgi
@@ -14,7 +14,7 @@ $user = getotaker;
 print $cgi->header( '-expires' => '-2m' ),
   header('Current Receivables Report Results');
 
-open (REPORT, "/usr/bin/freeside-receivables-report -v $user |");
+open (REPORT, "freeside-receivables-report -v $user |");
 
 print '
';
 while() {
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index bedfdac5f..bc683f8b7 100755
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -21,7 +21,7 @@ $ending = $1;
 print $cgi->header( '-expires' => '-2m' ),
   header('Tax Report Results');
 
-open (REPORT, "/usr/bin/freeside-tax-report -v -s $beginning -d $ending $user |");
+open (REPORT, "freeside-tax-report -v -s $beginning -d $ending $user |");
 
 print '
';
 while() {
-- 
cgit v1.2.1


From bc8ce86aaf207f2fb89054020873bbff79489642 Mon Sep 17 00:00:00 2001
From: ivan 
Date: Mon, 25 Feb 2002 19:09:43 +0000
Subject: keith@landel:     We have users that have the character "." in their
 username     we can't search these customers by Username, can you please fix.

---
 httemplate/search/svc_acct.cgi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'httemplate/search')

diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi
index 0918275d7..dd0221d9a 100755
--- a/httemplate/search/svc_acct.cgi
+++ b/httemplate/search/svc_acct.cgi
@@ -234,7 +234,7 @@ sub uid_sort {
 
 sub usernamesearch {
 
-  $cgi->param('username') =~ /^([\w\d\-]+)$/; #untaint username_text
+  $cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text
   my($username)=$1;
 
   [ qsearch('svc_acct',{'username'=>$username}) ];
-- 
cgit v1.2.1


From b717ff208f1593bc7d2021f17fbb63006e66e6ef Mon Sep 17 00:00:00 2001
From: ivan 
Date: Tue, 26 Feb 2002 22:09:44 +0000
Subject: fixup reports for templated webUI

---
 httemplate/search/report_cc.cgi          | 20 +++++---------------
 httemplate/search/report_credit.cgi      | 20 +++++---------------
 httemplate/search/report_receivables.cgi | 15 +++------------
 httemplate/search/report_tax.cgi         | 20 +++++---------------
 4 files changed, 18 insertions(+), 57 deletions(-)

(limited to 'httemplate/search')

diff --git a/httemplate/search/report_cc.cgi b/httemplate/search/report_cc.cgi
index f1c3c962c..128565fce 100755
--- a/httemplate/search/report_cc.cgi
+++ b/httemplate/search/report_cc.cgi
@@ -1,25 +1,15 @@
+
 <%
 
-use strict;
-use vars qw( $cgi $user $beginning $ending );
-use CGI;
-use CGI::Carp qw( fatalsToBrowser );
-use FS::UID qw( cgisuidsetup getotaker );
-use FS::CGI qw( header );
-
-$cgi = new CGI;
-&cgisuidsetup($cgi);
-
-$user = getotaker;
+my $user = getotaker;
 
 $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
-$beginning = $1;
+my $beginning = $1;
 
 $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
-$ending = $1;
+my $ending = $1;
 
-print $cgi->header( '-expires' => '-2m' ),
-  header('Credit Card Recipt Report Results');
+print header('Credit Card Recipt Report Results');
 
 open (REPORT, "freeside-cc-receipts-report -v -s $beginning -d $ending $user |");
 
diff --git a/httemplate/search/report_credit.cgi b/httemplate/search/report_credit.cgi
index e4a9bf241..fac6c8d0f 100755
--- a/httemplate/search/report_credit.cgi
+++ b/httemplate/search/report_credit.cgi
@@ -1,25 +1,15 @@
+
 <%
 
-use strict;
-use vars qw( $cgi $user $beginning $ending );
-use CGI;
-use CGI::Carp qw( fatalsToBrowser );
-use FS::UID qw( cgisuidsetup getotaker );
-use FS::CGI qw( header );
-
-$cgi = new CGI;
-&cgisuidsetup($cgi);
-
-$user = getotaker;
+my $user = getotaker;
 
 $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
-$beginning = $1;
+my $beginning = $1;
 
 $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
-$ending = $1;
+my $ending = $1;
 
-print $cgi->header( '-expires' => '-2m' ),
-  header('In House Credit Report Results');
+print header('In House Credit Report Results');
 
 open (REPORT, "freeside-credit-report -v -s $beginning -d $ending $user |");
 
diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi
index ba02eb720..fdd3779a9 100755
--- a/httemplate/search/report_receivables.cgi
+++ b/httemplate/search/report_receivables.cgi
@@ -1,18 +1,9 @@
+
 <%
 
-use strict;
-use vars qw( $cgi $user );
-use CGI;
-use CGI::Carp qw( fatalsToBrowser );
-use FS::UID qw( cgisuidsetup getotaker );
+my $user = getotaker;
 
-$cgi = new CGI;
-&cgisuidsetup($cgi);
-
-$user = getotaker;
-
-print $cgi->header( '-expires' => '-2m' ),
-  header('Current Receivables Report Results');
+print header('Current Receivables Report Results');
 
 open (REPORT, "freeside-receivables-report -v $user |");
 
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index bc683f8b7..79aa65c9a 100755
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -1,25 +1,15 @@
+
 <%
 
-use strict;
-use vars qw( $cgi $user $beginning $ending );
-use CGI;
-use CGI::Carp qw( fatalsToBrowser );
-use FS::UID qw( cgisuidsetup getotaker );
-use FS::CGI qw( header );
-
-$cgi = new CGI;
-&cgisuidsetup($cgi);
-
-$user = getotaker;
+my $user = getotaker;
 
 $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
-$beginning = $1;
+my $beginning = $1;
 
 $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
-$ending = $1;
+my $ending = $1;
 
-print $cgi->header( '-expires' => '-2m' ),
-  header('Tax Report Results');
+print header('Tax Report Results');
 
 open (REPORT, "freeside-tax-report -v -s $beginning -d $ending $user |");
 
-- 
cgit v1.2.1


From 7d6600bc5fe5703979f1e15682fe185aa65c4a4e Mon Sep 17 00:00:00 2001
From: ivan 
Date: Thu, 28 Feb 2002 23:08:53 +0000
Subject: add main menu link

---
 httemplate/search/svc_acct.cgi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'httemplate/search')

diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi
index dd0221d9a..3a0e922ce 100755
--- a/httemplate/search/svc_acct.cgi
+++ b/httemplate/search/svc_acct.cgi
@@ -100,7 +100,7 @@ if ( scalar(@svc_acct) == 1 ) {
   }
   #end pager
 
-  print header("Account Search Results",''),
+  print header("Account Search Results",menubar('Main Menu'=>popurl(2)),
         "$total matching accounts found

$pager", &table(), < -- cgit v1.2.1 From 5b64b45f66ca639c0ff98f6903722022c30f5cc2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 28 Feb 2002 23:30:21 +0000 Subject: tyop --- httemplate/search/svc_acct.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 3a0e922ce..2666ef621 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -100,7 +100,7 @@ if ( scalar(@svc_acct) == 1 ) { } #end pager - print header("Account Search Results",menubar('Main Menu'=>popurl(2)), + print header("Account Search Results",menubar('Main Menu'=>popurl(2))), "$total matching accounts found

$pager", &table(), < -- cgit v1.2.1 From 6c2f4c44fc083bde9dd055bd4db51e65fa377379 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 5 Mar 2002 23:13:24 +0000 Subject: consistency is nice --- httemplate/search/report_cc.cgi | 2 +- httemplate/search/report_credit.cgi | 2 +- httemplate/search/report_tax.cgi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_cc.cgi b/httemplate/search/report_cc.cgi index 128565fce..c2ab726b6 100755 --- a/httemplate/search/report_cc.cgi +++ b/httemplate/search/report_cc.cgi @@ -11,7 +11,7 @@ my $ending = $1; print header('Credit Card Recipt Report Results'); -open (REPORT, "freeside-cc-receipts-report -v -s $beginning -d $ending $user |"); +open (REPORT, "freeside-cc-receipts-report -v -s $beginning -f $ending $user |"); print '
';
 while() {
diff --git a/httemplate/search/report_credit.cgi b/httemplate/search/report_credit.cgi
index fac6c8d0f..2adafc06e 100755
--- a/httemplate/search/report_credit.cgi
+++ b/httemplate/search/report_credit.cgi
@@ -11,7 +11,7 @@ my $ending = $1;
 
 print header('In House Credit Report Results');
 
-open (REPORT, "freeside-credit-report -v -s $beginning -d $ending $user |");
+open (REPORT, "freeside-credit-report -v -s $beginning -f $ending $user |");
 
 print '
';
 while() {
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index 79aa65c9a..ac76fad6e 100755
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -11,7 +11,7 @@ my $ending = $1;
 
 print header('Tax Report Results');
 
-open (REPORT, "freeside-tax-report -v -s $beginning -d $ending $user |");
+open (REPORT, "freeside-tax-report -v -s $beginning -f $ending $user |");
 
 print '
';
 while() {
-- 
cgit v1.2.1


From d6b3ef73dad849de63c61472f00732e301482d13 Mon Sep 17 00:00:00 2001
From: ivan 
Date: Mon, 18 Mar 2002 19:40:53 +0000
Subject: update quickpay for current search capabilities

---
 httemplate/search/cust_main-quickpay.html | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'httemplate/search')

diff --git a/httemplate/search/cust_main-quickpay.html b/httemplate/search/cust_main-quickpay.html
index 3f0ba0412..9f39db914 100755
--- a/httemplate/search/cust_main-quickpay.html
+++ b/httemplate/search/cust_main-quickpay.html
@@ -12,14 +12,18 @@
        Search for last name: 
       
       using search method: 
 
       

Search for company: using search methods: @@ -29,7 +33,9 @@


Explanation of search methods:
    +
  • All - Try all search methods.
  • Fuzzy - Searches for matches that are close to your text. +
  • Substring - Searches for matches that contain your text.
  • Exact - Finds exact matches only, but much faster than the other search methods.
-- cgit v1.2.1 From f38abb144955686f880a528ed6fe4c9c5453517b Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 24 Mar 2002 20:01:31 +0000 Subject: UI improvements for agents --- httemplate/search/svc_acct.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 2666ef621..daf025a38 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -141,7 +141,7 @@ END my $conf = new FS::Conf; unless ( $mydomain = $conf->config('domain') ) { die "No legacy domain config file and no svc_domain.svcnum record ". - "for svc_acct.domsvc: ". $cust_svc->domsvc; + "for svc_acct.domsvc: ". $svc_acct->domsvc; } } $domain = "$mydomain*"; -- 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-otaker.cgi | 29 ++++++++++++++++ httemplate/search/cust_main.cgi | 63 ++++++++++++++++++++++++++-------- 2 files changed, 77 insertions(+), 15 deletions(-) create mode 100755 httemplate/search/cust_main-otaker.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/cust_main-otaker.cgi b/httemplate/search/cust_main-otaker.cgi new file mode 100755 index 000000000..b7173c49c --- /dev/null +++ b/httemplate/search/cust_main-otaker.cgi @@ -0,0 +1,29 @@ + + + Customer Search + + + + Customer Search + +
+
+ Search for Order taker: + + <% my $dbh = dbh; + my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_main") + or eidiot $dbh->errstr; + $sth->execute() or eidiot $sth->errstr; +# my @otakers = map { $_->[0] } @{$sth->selectall_arrayref}; + %> + +

+ +

+ + + 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') 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 12fca9ac80c2b0444a7916506f6e2a8fa98bc24d Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 29 Mar 2002 17:27:18 +0000 Subject: fix unlinked svc browse! --- httemplate/search/svc_acct.cgi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index daf025a38..e28e00e61 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -21,13 +21,14 @@ $query ||= ''; #to avoid use of unitialized value errors my $unlinked = ''; if ( $query =~ /^UN_(.*)$/ ) { $query = $1; - $unlinked = ' + my $empty = driver_name =~ /^Pg$/i ? qq('') : qq(""); + $unlinked = " WHERE 0 < ( SELECT count(*) FROM cust_svc WHERE cust_svc.svcnum = svc_acct.svcnum - AND pkgnum IS NULL + AND ( pkgnum IS NULL OR pkgnum = 0 OR pkgnum = $empty ) ) - '; + "; } my(@svc_acct, $sortby); -- cgit v1.2.1 From 20d1b5c39c3674f3fdf5c0f784697a4442658648 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 5 Apr 2002 16:37:42 +0000 Subject: oops forgot these from working on the road --- httemplate/search/sql.cgi | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 httemplate/search/sql.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/sql.cgi b/httemplate/search/sql.cgi new file mode 100755 index 000000000..b83ef039f --- /dev/null +++ b/httemplate/search/sql.cgi @@ -0,0 +1,76 @@ +<% + +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); + +my $limit = ''; +$limit .= "LIMIT $maxrecords" if $maxrecords; + +my $offset = $cgi->param('offset') || 0; +$limit .= " OFFSET $offset" if $offset; + +my $total; + +my $sql = $cgi->param('sql'); +$sql =~ s/^\s*SELECT//i; + +my $count_sql = $sql; +$count_sql =~ s/^(.*)\s+FROM\s/COUNT(*) FROM /i; + +my $sth = dbh->prepare("SELECT $count_sql") + or eidiot dbh->errstr. " doing $count_sql\n"; +$sth->execute or eidiot "Error executing \"$count_sql\": ". $sth->errstr; + +$total = $sth->fetchrow_arrayref->[0]; + +my $sth = dbh->prepare("SELECT $sql $limit") + or eidiot dbh->errstr. " doing $sql\n"; +$sth->execute or eidiot "Error executing \"$sql\": ". $sth->errstr; +my $rows = $sth->fetchall_arrayref; + +%> + +<% + + #begin pager + my $pager = ''; + if ( $total != scalar(@$rows) && $maxrecords ) { + unless ( $offset == 0 ) { + $cgi->param('offset', $offset - $maxrecords); + $pager .= 'Previous '; + } + my $poff; + my $page; + for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { + $page++; + if ( $offset == $poff ) { + $pager .= qq!$page !; + } else { + $cgi->param('offset', $poff); + $pager .= qq!$page !; + } + } + unless ( $offset + $maxrecords > $total ) { + $cgi->param('offset', $offset + $maxrecords); + $pager .= 'Next '; + } + } + #end pager + + print header('Query Results', menubar('Main Menu'=>$p) ). + "$total total rows

$pager". table(). + ""; + print "$_" foreach @{$sth->{NAME}}; + print ""; + + foreach $row ( @$rows ) { + print ""; + print "$_" foreach @$row; + print ""; + } + + print "$pager"; + +%> -- 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') 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 4201aaaae8a957bc98ce345d3ee0e599da354766 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Apr 2002 10:47:35 +0000 Subject: report on failed billing events... --- httemplate/search/cust_bill_event.cgi | 62 ++++++++++++++++++++++++++++++++++ httemplate/search/cust_bill_event.html | 23 +++++++++++++ httemplate/search/report_cc.html | 4 +-- httemplate/search/report_credit.html | 4 +-- httemplate/search/report_tax.html | 4 +-- 5 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 httemplate/search/cust_bill_event.cgi create mode 100755 httemplate/search/cust_bill_event.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi new file mode 100644 index 000000000..9cb36d28e --- /dev/null +++ b/httemplate/search/cust_bill_event.cgi @@ -0,0 +1,62 @@ + +<% + +#false laziness with view/cust_bill.cgi + +$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; +my $beginning = str2time($1); + +$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; +my $ending = str2time($1) + 86400; + +my @cust_bill_event = + sort { $a->_date <=> $b->_date } + qsearch('cust_bill_event', { + _date => { op=> '>=', value=>$beginning }, + statustext => { op=> '!=', value=>'' }, +# i wish... +# _date => { op=> '<=', value=>$ending }, + }, '', "AND _date <= $ending"); + +%> + +<%= header('Failed billing events') %> + +<%= table() %> + + Event + Date + Status + Invoice + (bill) name + company +<% if ( defined dbdef->table('cust_main')->column('ship_last') ) { %> + (service) name + company +<% } %> + + +<% foreach my $cust_bill_event ( @cust_bill_event ) { + my $status = $cust_bill_event->status; + $status .= ': '.$cust_bill_event->statustext if $cust_bill_event->statustext; + my $cust_bill = $cust_bill_event->cust_bill; + my $cust_main = $cust_bill->cust_main; + my $invlink = "${p}view/cust_bill.cgi?". $cust_bill->invnum; + my $custlink = "${p}view/cust_main.cgi?". $cust_main->custnum; +%> + + <%= $cust_bill_event->part_bill_event->event %> + <%= time2str("%a %b %e %T %Y", $cust_bill_event->_date) %> + <%= $status %> + Invoice #<%= $cust_bill->invnum %> (<%= time2str("%D", $cust_bill->_date ) %>) + <%= $cust_main->last. ', '. $cust_main->first %> + <%= $cust_main->company %> + <% if ( defined dbdef->table('cust_main')->column('ship_last') ) { %> + <%= $cust_main->ship_last. ', '. $cust_main->ship_first %> + <%= $cust_main->ship_company %> + <% } %> + +<% } %> + + + diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html new file mode 100755 index 000000000..d76ce3c8c --- /dev/null +++ b/httemplate/search/cust_bill_event.html @@ -0,0 +1,23 @@ + + + Failed billing events + + +
+

Failed billing events

+
+
+
+ Return failed billing events for period: + from m/d/y + to m/d/y + +

+ +

+ +
+ + + + diff --git a/httemplate/search/report_cc.html b/httemplate/search/report_cc.html index a028a87df..8653dcc69 100755 --- a/httemplate/search/report_cc.html +++ b/httemplate/search/report_cc.html @@ -9,8 +9,8 @@
Return credit card receipt report for period: - from - to + from m/d/y + to m/d/y

diff --git a/httemplate/search/report_credit.html b/httemplate/search/report_credit.html index bda08e31d..df9b9581f 100755 --- a/httemplate/search/report_credit.html +++ b/httemplate/search/report_credit.html @@ -9,8 +9,8 @@


Return in house credit report for period: - from - to + from m/d/y + to m/d/y

diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index a7beb2471..7bf681b42 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -9,8 +9,8 @@


Return tax report for period: - from - to + from m/d/y + to m/d/y

-- 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') 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 b697a86ff35212aaf5ab8cf06d05ab3f7c619d20 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 4 May 2002 00:32:21 +0000 Subject: lilunixbtch: trying to pull accounts based on next billdate tofu_beast420: hmm a report ordered by next bill date? tofu_beast420: i don't know how you'd do that per _customer_ since a customer could have lots of packages, but you could do a per-package report maybe? --- httemplate/search/cust_pkg.cgi | 135 +++++++++++++++++++++++++--------------- httemplate/search/cust_pkg.html | 24 +++++++ 2 files changed, 108 insertions(+), 51 deletions(-) create mode 100755 httemplate/search/cust_pkg.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 54e02ce9d..dee2fbdab 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -13,64 +13,93 @@ $limit .= " OFFSET $offset" if $offset; my $total; -my $unconf = ''; my($query) = $cgi->keywords; my $sortby; -if ( $query eq 'pkgnum' ) { - $sortby=\*pkgnum_sort; - -} elsif ( $query eq 'APKG_pkgnum' ) { - - $sortby=\*pkgnum_sort; - - $unconf = " - WHERE 0 < - ( SELECT count(*) FROM pkg_svc - WHERE pkg_svc.pkgpart = cust_pkg.pkgpart - AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc - WHERE cust_svc.pkgnum = cust_pkg.pkgnum - AND cust_svc.svcpart = pkg_svc.svcpart - ) - ) - "; - - #@cust_pkg=(); - ##perhaps this should go in cust_pkg as a qsearch-like constructor? - #my($cust_pkg); - #foreach $cust_pkg ( - # qsearch('cust_pkg',{}, '', "ORDER BY pkgnum $limit" ) - #) { - # my($flag)=0; - # my($pkg_svc); - # PKG_SVC: - # foreach $pkg_svc (qsearch('pkg_svc',{ 'pkgpart' => $cust_pkg->pkgpart })) { - # if ( $pkg_svc->quantity - # > scalar(qsearch('cust_svc',{ - # 'pkgnum' => $cust_pkg->pkgnum, - # 'svcpart' => $pkg_svc->svcpart, - # })) - # ) - # { - # $flag=1; - # last PKG_SVC; - # } - # } - # push @cust_pkg, $cust_pkg if $flag; - #} +my @cust_pkg; + +if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { + $sortby=\*bill_sort; + my($beginning, $ending) = (0, 0); + my $range = ''; + if ( $cgi->param('beginning') + && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $beginning = str2time($1); + $range = " WHERE bill >= $beginning "; + } elsif ( $cgi->param('ending') + && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { + $ending = str2time($1) + 86400; + $range = ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; + } + + #false laziness with below + my $statement = "SELECT COUNT(*) FROM cust_pkg $range"; + my $sth = dbh->prepare($statement) + or die dbh->errstr. " doing $statement"; + $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; -} else { - die "Empty QUERY_STRING!"; -} + $total = $sth->fetchrow_arrayref->[0]; + + @cust_pkg = qsearch('cust_pkg',{}, '', " $range ORDER BY bill $limit" ); -my $statement = "SELECT COUNT(*) FROM cust_pkg $unconf"; -my $sth = dbh->prepare($statement) - or die dbh->errstr. " doing $statement"; -$sth->execute or die "Error executing \"$statement\": ". $sth->errstr; +} else { -$total = $sth->fetchrow_arrayref->[0]; + my $unconf = ''; + if ( $query eq 'pkgnum' ) { + $sortby=\*pkgnum_sort; -my @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); + } elsif ( $query eq 'APKG_pkgnum' ) { + + $sortby=\*pkgnum_sort; + + $unconf = " + WHERE 0 < + ( SELECT count(*) FROM pkg_svc + WHERE pkg_svc.pkgpart = cust_pkg.pkgpart + AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc + WHERE cust_svc.pkgnum = cust_pkg.pkgnum + AND cust_svc.svcpart = pkg_svc.svcpart + ) + ) + "; + + #@cust_pkg=(); + ##perhaps this should go in cust_pkg as a qsearch-like constructor? + #my($cust_pkg); + #foreach $cust_pkg ( + # qsearch('cust_pkg',{}, '', "ORDER BY pkgnum $limit" ) + #) { + # my($flag)=0; + # my($pkg_svc); + # PKG_SVC: + # foreach $pkg_svc (qsearch('pkg_svc',{ 'pkgpart' => $cust_pkg->pkgpart })) { + # if ( $pkg_svc->quantity + # > scalar(qsearch('cust_svc',{ + # 'pkgnum' => $cust_pkg->pkgnum, + # 'svcpart' => $pkg_svc->svcpart, + # })) + # ) + # { + # $flag=1; + # last PKG_SVC; + # } + # } + # push @cust_pkg, $cust_pkg if $flag; + #} + + } else { + die "Empty QUERY_STRING!"; + } + + my $statement = "SELECT COUNT(*) FROM cust_pkg $unconf"; + 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]; + + @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); +} if ( scalar(@cust_pkg) == 1 ) { my($pkgnum)=$cust_pkg[0]->pkgnum; @@ -243,4 +272,8 @@ sub pkgnum_sort { $a->getfield('pkgnum') <=> $b->getfield('pkgnum'); } +sub bill_sort { + $a->getfield('bill') <=> $b->getfield('bill'); +} + %> diff --git a/httemplate/search/cust_pkg.html b/httemplate/search/cust_pkg.html new file mode 100755 index 000000000..c69e8d711 --- /dev/null +++ b/httemplate/search/cust_pkg.html @@ -0,0 +1,24 @@ + + + Packages + + +

+

Packages

+
+
+ + + Return packages with next bill date: + from m/d/y + to m/d/y + +

+ +

+ +
+ + + + -- cgit v1.2.1 From f15ded7fdcbe0869d1e51e2dab1cc4409c0ce92f Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 4 May 2002 00:49:06 +0000 Subject: point at correct .cgi --- httemplate/search/cust_pkg.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.html b/httemplate/search/cust_pkg.html index c69e8d711..bb0a5407c 100755 --- a/httemplate/search/cust_pkg.html +++ b/httemplate/search/cust_pkg.html @@ -7,7 +7,7 @@

Packages


-
+ Return packages with next bill date: from m/d/y -- cgit v1.2.1 From 1c773e927ea1bc90ec94873f801d9b3edb57acd7 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 4 May 2002 00:59:08 +0000 Subject: fix ranges on cust_pkg search --- httemplate/search/cust_pkg.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index dee2fbdab..8c5d35be5 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -28,7 +28,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } elsif ( $cgi->param('ending') && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { $ending = str2time($1) + 86400; - $range = ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; + $range .= ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; } #false laziness with below -- cgit v1.2.1 From 8af9903c96ca6a3d78e7779cbc4c5e773aaf3ae0 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 4 May 2002 01:11:04 +0000 Subject: add package search by next bill date to main menu --- httemplate/search/cust_pkg.cgi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 8c5d35be5..ec1bda900 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -19,20 +19,21 @@ my @cust_pkg; if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $sortby=\*bill_sort; - my($beginning, $ending) = (0, 0); my $range = ''; if ( $cgi->param('beginning') && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { my $beginning = str2time($1); $range = " WHERE bill >= $beginning "; - } elsif ( $cgi->param('ending') + } + if ( $cgi->param('ending') && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - $ending = str2time($1) + 86400; + my $ending = str2time($1) + 86400; $range .= ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; } #false laziness with below my $statement = "SELECT COUNT(*) FROM cust_pkg $range"; + warn $statement; my $sth = dbh->prepare($statement) or die dbh->errstr. " doing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; -- 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 +++++++++++++++++++++++++++++++---------- httemplate/search/cust_pkg.cgi | 74 +++++++++++++++++++++++++++++-------- httemplate/search/svc_acct.cgi | 36 ++++++++++++------ 3 files changed, 145 insertions(+), 46 deletions(-) (limited to 'httemplate/search') 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 ) { diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index ec1bda900..7dfacf189 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -34,8 +34,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { #false laziness with below my $statement = "SELECT COUNT(*) FROM cust_pkg $range"; warn $statement; - my $sth = dbh->prepare($statement) - or die dbh->errstr. " doing $statement"; + 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]; @@ -52,17 +51,6 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $sortby=\*pkgnum_sort; - $unconf = " - WHERE 0 < - ( SELECT count(*) FROM pkg_svc - WHERE pkg_svc.pkgpart = cust_pkg.pkgpart - AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc - WHERE cust_svc.pkgnum = cust_pkg.pkgnum - AND cust_svc.svcpart = pkg_svc.svcpart - ) - ) - "; - #@cust_pkg=(); ##perhaps this should go in cust_pkg as a qsearch-like constructor? #my($cust_pkg); @@ -86,20 +74,74 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { # } # push @cust_pkg, $cust_pkg if $flag; #} + + if ( driver_name eq 'mysql' ) { + #$query = "DROP TABLE temp1_$$,temp2_$$;"; + #my $sth = dbh->prepare($query); + #$sth->execute; + + $query = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM + SELECT cust_svc.pkgnum,cust_svc.svcpart,COUNT(*) as count + FROM cust_pkg,cust_svc,pkg_svc + WHERE cust_pkg.pkgnum = cust_svc.pkgnum + AND cust_svc.svcpart = pkg_svc.svcpart + AND cust_pkg.pkgpart = pkg_svc.pkgpart + GROUP BY cust_svc.pkgnum,cust_svc.svcnum"; + $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.pkgnum FROM cust_pkg + LEFT JOIN pkg_svc ON (cust_pkg.pkgpart=pkg_svc.pkgpart) + LEFT JOIN temp1_$$ ON (cust_pkg.pkgnum = temp1_$$.pkgnum + AND pkg_svc.svcpart=temp1_$$.svcpart) + WHERE ( pkg_svc.quantity > temp1_$$.count + OR temp1_$$.pkgnum IS NULL ) + AND pkg_svc.quantity != 0;"; + $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + $unconf = " LEFT JOIN temp2_$$ ON cust_pkg.pkgnum = temp2_$$.pkgnum + WHERE temp2_$$.pkgnum IS NOT NULL"; + + } else { + + $unconf = " + WHERE 0 < + ( SELECT count(*) FROM pkg_svc + WHERE pkg_svc.pkgpart = cust_pkg.pkgpart + AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc + WHERE cust_svc.pkgnum = cust_pkg.pkgnum + AND cust_svc.svcpart = pkg_svc.svcpart + ) + ) + "; + + } } else { die "Empty QUERY_STRING!"; } my $statement = "SELECT COUNT(*) FROM cust_pkg $unconf"; - my $sth = dbh->prepare($statement) - or die dbh->errstr. " doing $statement"; + 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]; - + + #if ( driver_name eq 'mysql' ) { #remove ORDER BY for mysql? hua? + # @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf $limit" ); + #} else { + # @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); + #} @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); + if ( driver_name eq 'mysql' ) { + $query = "DROP TABLE temp1_$$,temp2_$$;"; + my $sth = dbh->prepare($query) or die dbh->errstr. " doing $query"; + $sth->execute; # or die "Error executing \"$query\": ". $sth->errstr; + } + } if ( scalar(@cust_pkg) == 1 ) { diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index e28e00e61..eba032d52 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -21,26 +21,35 @@ $query ||= ''; #to avoid use of unitialized value errors my $unlinked = ''; if ( $query =~ /^UN_(.*)$/ ) { $query = $1; - my $empty = driver_name =~ /^Pg$/i ? qq('') : qq(""); - $unlinked = " - WHERE 0 < - ( SELECT count(*) FROM cust_svc - WHERE cust_svc.svcnum = svc_acct.svcnum - AND ( pkgnum IS NULL OR pkgnum = 0 OR pkgnum = $empty ) - ) - "; + my $empty = driver_name eq 'Pg' ? qq('') : qq(""); + if ( driver_name eq 'mysql' ) { + $unlinked = "LEFT JOIN cust_svc ON cust_svc.svcnum = svc_acct.svcnum + WHERE cust_svc.pkgnum IS NULL + OR cust_svc.pkgnum = 0 + OR cust_svc.pkgnum = $empty"; + } else { + $unlinked = " + WHERE 0 < + ( SELECT count(*) FROM cust_svc + WHERE cust_svc.svcnum = svc_acct.svcnum + AND ( pkgnum IS NULL OR pkgnum = 0 OR pkgnum = $empty ) + ) + "; + } } +my $tblname = driver_name eq 'mysql' ? 'svc_acct.' : ''; my(@svc_acct, $sortby); if ( $query eq 'svcnum' ) { $sortby=\*svcnum_sort; - $orderby = 'ORDER BY svcnum'; + $orderby = "ORDER BY ${tblname}svcnum"; } elsif ( $query eq 'username' ) { $sortby=\*username_sort; - $orderby = 'ORDER BY username'; + $orderby = "ORDER BY ${tblname}username"; } elsif ( $query eq 'uid' ) { $sortby=\*uid_sort; - $orderby = ( $unlinked ? 'AND' : 'WHERE' ). ' uid IS NOT NULL ORDER BY uid'; + $orderby = ( $unlinked ? 'AND' : 'WHERE' ). + " ${tblname}uid IS NOT NULL ORDER BY ${tblname}uid"; } else { $sortby=\*uid_sort; @svc_acct = @{&usernamesearch}; @@ -55,6 +64,11 @@ if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' ) { $total = $sth->fetchrow_arrayref->[0]; + #if ( driver_name eq 'mysql' ) { #remove ORDER BY for mysql? hua? + # @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $limit"); + #} else { + # @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $orderby $limit"); + #} @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $orderby $limit"); } -- 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 +- httemplate/search/cust_pkg.cgi | 11 ++++------- httemplate/search/svc_acct.cgi | 5 ----- 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'httemplate/search') 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 { diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 7dfacf189..abf6eee4c 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -86,7 +86,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { WHERE cust_pkg.pkgnum = cust_svc.pkgnum AND cust_svc.svcpart = pkg_svc.svcpart AND cust_pkg.pkgpart = pkg_svc.pkgpart - GROUP BY cust_svc.pkgnum,cust_svc.svcnum"; + GROUP BY cust_svc.pkgnum,cust_svc.svcpart"; $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; $sth->execute or die "Error executing \"$query\": ". $sth->errstr; @@ -129,12 +129,9 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $total = $sth->fetchrow_arrayref->[0]; - #if ( driver_name eq 'mysql' ) { #remove ORDER BY for mysql? hua? - # @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf $limit" ); - #} else { - # @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); - #} - @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); + my $tblname = driver_name eq 'mysql' ? 'cust_pkg.' : ''; + @cust_pkg = + qsearch('cust_pkg',{}, '', "$unconf ORDER BY ${tblname}pkgnum $limit" ); if ( driver_name eq 'mysql' ) { $query = "DROP TABLE temp1_$$,temp2_$$;"; diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index eba032d52..0a4338b52 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -64,11 +64,6 @@ if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' ) { $total = $sth->fetchrow_arrayref->[0]; - #if ( driver_name eq 'mysql' ) { #remove ORDER BY for mysql? hua? - # @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $limit"); - #} else { - # @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $orderby $limit"); - #} @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $orderby $limit"); } -- 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') 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 13f822a442f093f5658e5571c3d236b80be0113f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 13 Jun 2002 23:00:15 +0000 Subject: fuzzy username searching (Bug#422) --- httemplate/search/svc_acct.cgi | 44 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 0a4338b52..549231d3f 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -244,10 +244,50 @@ sub uid_sort { sub usernamesearch { + my @svc_acct; + + my %username_type; + foreach ( $cgi->param('username_type') ) { + $username_type{$_}++; + } + $cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text - my($username)=$1; + my $username = $1; + + if ( $username_type{'Exact'} || $username_type{'Fuzzy'} ) { + push @svc_acct, qsearch( 'svc_acct', + { 'username' => { 'op' => 'ILIKE', + 'value' => $username } } ); + } + + if ( $username_type{'Substring'} || $username_type{'All'} ) { + push @svc_acct, qsearch( 'svc_acct', + { 'username' => { 'op' => 'ILIKE', + 'value' => "%$username%" } } ); + } + + if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { + &FS::svc_acct::check_and_rebuild_fuzzyfiles; + my $all_username = &FS::svc_acct::all_username; + + my %username; + if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { + foreach ( amatch($username, [ qw(i) ], @$all_username) ) { + $username{$_}++; + } + } + + #if ($username_type{'Sound-alike'}) { + #} + + foreach ( keys %username ) { + push @svc_acct, qsearch('svc_acct',{'username'=>$_}); + } + + } - [ qsearch('svc_acct',{'username'=>$username}) ]; + #[ qsearch('svc_acct',{'username'=>$username}) ]; + \@svc_acct; } -- 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') 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') 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 73233cfa60984978f1593bf86c248c0bab3620a5 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 11:03:08 +0000 Subject: move query logic from perl to sql for scalability --- httemplate/search/cust_bill.cgi | 65 ++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 13 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index d83851804..dbe7e7dcd 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -1,44 +1,83 @@ <% +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); + +my $orderby = ''; #removeme + +my $limit = ''; +$limit .= "LIMIT $maxrecords" if $maxrecords; + +my $offset = $cgi->param('offset') || 0; +$limit .= " OFFSET $offset" if $offset; + +my $total; + my(@cust_bill, $sortby); if ( $cgi->keywords ) { my($query) = $cgi->keywords; + my $open_sql = + "having 0 != charged - coalesce(sum(cust_bill_pay.amount),0) + - coalesce(sum(cust_credit_bill.amount),0)"; + my $having = ''; + my $where = ''; if ( $query eq 'invnum' ) { $sortby = \*invnum_sort; - @cust_bill = qsearch('cust_bill', {} ); + #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'date' ) { $sortby = \*date_sort; - @cust_bill = qsearch('cust_bill', {} ); + #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'custnum' ) { $sortby = \*custnum_sort; - @cust_bill = qsearch('cust_bill', {} ); + #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'OPEN_invnum' ) { $sortby = \*invnum_sort; - @cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + $having = $open_sql; } elsif ( $query eq 'OPEN_date' ) { $sortby = \*date_sort; - @cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + $having = $open_sql; } elsif ( $query eq 'OPEN_custnum' ) { $sortby = \*custnum_sort; - @cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); + $having = $open_sql; } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { my $open = $1 * 86400; $sortby = \*invnum_sort; - @cust_bill = - grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + #@cust_bill = + # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + $having = $open_sql; + $where = "where cust_bill._date < ". (time-$open); } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { my $open = $1 * 86400; $sortby = \*date_sort; - @cust_bill = - grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + #@cust_bill = + # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + $having = $open_sql; + $where = "where cust_bill._date < ". (time-$open); } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { my $open = $1 * 86400; $sortby = \*custnum_sort; - @cust_bill = - grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + #@cust_bill = + # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); + $having = $open_sql; + $where = "where cust_bill._date < ". (time-$open); } else { die "unknown query string $query"; } + @cust_bill = qsearch( + 'cust_bill', + {}, + 'cust_bill.*, + charged - coalesce(sum(cust_bill_pay.amount),0) + - coalesce(sum(cust_credit_bill.amount),0) as owed', + "left outer join cust_bill_pay using ( invnum ) + left outer join cust_credit_bill using ( invnum ) + $where + group by ". join(', ', map "cust_bill.$_", fields('cust_bill') ). ' '. + $having + ); } else { $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; my $invnum = $2; @@ -58,7 +97,7 @@ if ( scalar(@cust_bill) == 1 ) { %> <% - my $total = scalar(@cust_bill); + $total = scalar(@cust_bill); print header("Invoice Search Results", menubar( 'Main Menu', popurl(2) )), "$total matching invoices found
", &table(), < Date: Sun, 7 Jul 2002 11:30:07 +0000 Subject: invoice search with possibly working pager --- httemplate/search/cust_bill.cgi | 60 ++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index dbe7e7dcd..d6492fe49 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -66,26 +66,38 @@ if ( $cgi->keywords ) { } else { die "unknown query string $query"; } + + my $extra_sql = " + left outer join cust_bill_pay using ( invnum ) + left outer join cust_credit_bill using ( invnum ) + $where + group by ". join(', ', map "cust_bill.$_", fields('cust_bill') ). ' '. + $having; + + my $statement = "SELECT COUNT(*) FROM cust_bill $extra_sql"; + 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]; + @cust_bill = qsearch( 'cust_bill', {}, 'cust_bill.*, charged - coalesce(sum(cust_bill_pay.amount),0) - coalesce(sum(cust_credit_bill.amount),0) as owed', - "left outer join cust_bill_pay using ( invnum ) - left outer join cust_credit_bill using ( invnum ) - $where - group by ". join(', ', map "cust_bill.$_", fields('cust_bill') ). ' '. - $having + "$extra_sql $orderby $limit" ); } else { $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; my $invnum = $2; @cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum } ); $sortby = \*invnum_sort; + $total = scalar(@cust_bill); } -if ( scalar(@cust_bill) == 1 ) { +#if ( scalar(@cust_bill) == 1 ) { +if ( $total == 1 ) { my $invnum = $cust_bill[0]->invnum; print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect } elsif ( scalar(@cust_bill) == 0 ) { @@ -97,10 +109,38 @@ if ( scalar(@cust_bill) == 1 ) { %> <% - $total = scalar(@cust_bill); + #$total = scalar(@cust_bill); + + #begin pager + my $pager = ''; + if ( $total != scalar(@cust_bill) && $maxrecords ) { + unless ( $offset == 0 ) { + $cgi->param('offset', $offset - $maxrecords); + $pager .= 'Previous '; + } + my $poff; + my $page; + for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { + $page++; + if ( $offset == $poff ) { + $pager .= qq!$page !; + } else { + $cgi->param('offset', $poff); + $pager .= qq!$page !; + } + } + unless ( $offset + $maxrecords > $total ) { + $cgi->param('offset', $offset + $maxrecords); + $pager .= 'Next '; + } + } + #end pager + print header("Invoice Search Results", menubar( 'Main Menu', popurl(2) - )), "$total matching invoices found
", &table(), <
$pager", &table(), < Balance @@ -112,7 +152,7 @@ if ( scalar(@cust_bill) == 1 ) { END my(%saw, $cust_bill); - my($tot_balance, $tot_amount) = (0, 0); + my($tot_balance, $tot_amount) = (0, 0); #BOGUS foreach $cust_bill ( sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) ) { @@ -162,7 +202,7 @@ END print <TotalTotal \$$tot_balance\$$tot_amount - + $pager END -- cgit v1.2.1 From 589e9de82292f85a9f09b3075375342db42a0614 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 11:45:39 +0000 Subject: wtf? --- httemplate/search/cust_bill.cgi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index d6492fe49..b49296b80 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -97,7 +97,8 @@ if ( $cgi->keywords ) { } #if ( scalar(@cust_bill) == 1 ) { -if ( $total == 1 ) { +if ( scalar(@cust_bill) == 1 && $total == 1) { +#if ( $total == 1 ) { my $invnum = $cust_bill[0]->invnum; print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect } elsif ( scalar(@cust_bill) == 0 ) { -- cgit v1.2.1 From c89d696aae0a695b107e7c20ac06aa4b5e69cdac Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 13:23:57 +0000 Subject: try for working paged invoices, this time with subqueries --- httemplate/search/cust_bill.cgi | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index b49296b80..6eba4bd49 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -16,11 +16,11 @@ my $total; my(@cust_bill, $sortby); if ( $cgi->keywords ) { my($query) = $cgi->keywords; - my $open_sql = - "having 0 != charged - coalesce(sum(cust_bill_pay.amount),0) - - coalesce(sum(cust_credit_bill.amount),0)"; - my $having = ''; - my $where = ''; + my $owed = "charged - ( select coalesce(sum(amount),0) from cust_bill_pay + where cust_bill_pay.invnum = cust_bill.invnum ) + - ( select coalesce(sum(amount),0) from cust_credit_bill + where cust_credit_bill.invnum = cust_bill.invnum )"; + my @where; if ( $query eq 'invnum' ) { $sortby = \*invnum_sort; #@cust_bill = qsearch('cust_bill', {} ); @@ -33,46 +33,42 @@ if ( $cgi->keywords ) { } elsif ( $query eq 'OPEN_invnum' ) { $sortby = \*invnum_sort; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); - $having = $open_sql; + push @where, "0 != $owed"; } elsif ( $query eq 'OPEN_date' ) { $sortby = \*date_sort; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); - $having = $open_sql; + push @where, "0 != $owed"; } elsif ( $query eq 'OPEN_custnum' ) { $sortby = \*custnum_sort; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); - $having = $open_sql; + push @where, "0 != $owed"; } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { my $open = $1 * 86400; $sortby = \*invnum_sort; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - $having = $open_sql; - $where = "where cust_bill._date < ". (time-$open); + push @where, "0 != $owed". + "cust_bill._date < ". (time-$open); } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { my $open = $1 * 86400; $sortby = \*date_sort; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - $having = $open_sql; - $where = "where cust_bill._date < ". (time-$open); + push @where, "0 != $owed". + "cust_bill._date < ". (time-$open); + } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { my $open = $1 * 86400; $sortby = \*custnum_sort; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - $having = $open_sql; - $where = "where cust_bill._date < ". (time-$open); + push @where, "0 != $owed". + "cust_bill._date < ". (time-$open); } else { die "unknown query string $query"; } - my $extra_sql = " - left outer join cust_bill_pay using ( invnum ) - left outer join cust_credit_bill using ( invnum ) - $where - group by ". join(', ', map "cust_bill.$_", fields('cust_bill') ). ' '. - $having; + my $extra_sql = scalar(@where) ? join(' AND ', @where) : ''; my $statement = "SELECT COUNT(*) FROM cust_bill $extra_sql"; my $sth = dbh->prepare($statement) or die dbh->errstr. " doing $statement"; -- cgit v1.2.1 From 6a22335d0376846dfbbfda0bb952719b30ce2d30 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 13:25:12 +0000 Subject: don't forget to where the where clause --- httemplate/search/cust_bill.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 6eba4bd49..f4ead7042 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -68,7 +68,7 @@ if ( $cgi->keywords ) { die "unknown query string $query"; } - my $extra_sql = scalar(@where) ? join(' AND ', @where) : ''; + my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; my $statement = "SELECT COUNT(*) FROM cust_bill $extra_sql"; my $sth = dbh->prepare($statement) or die dbh->errstr. " doing $statement"; -- cgit v1.2.1 From 32b6d9deddc928f98dcad15ff306015d7e0070c5 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 13:30:02 +0000 Subject: calculate owed as subquery here too --- httemplate/search/cust_bill.cgi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index f4ead7042..d2a3573d4 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -79,9 +79,7 @@ if ( $cgi->keywords ) { @cust_bill = qsearch( 'cust_bill', {}, - 'cust_bill.*, - charged - coalesce(sum(cust_bill_pay.amount),0) - - coalesce(sum(cust_credit_bill.amount),0) as owed', + "cust_bill.*, $owed as owed" "$extra_sql $orderby $limit" ); } else { -- cgit v1.2.1 From 6e80f8889a13c47343d81de796f2a7ed4f036803 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 13:31:14 +0000 Subject: comma --- httemplate/search/cust_bill.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index d2a3573d4..cb358f9e9 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -79,7 +79,7 @@ if ( $cgi->keywords ) { @cust_bill = qsearch( 'cust_bill', {}, - "cust_bill.*, $owed as owed" + "cust_bill.*, $owed as owed", "$extra_sql $orderby $limit" ); } else { -- cgit v1.2.1 From f9bab439b413fa0c9a3f495da090ce1c67f6e654 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 13:52:07 +0000 Subject: don't recalculate owed --- httemplate/search/cust_bill.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index cb358f9e9..3b6b8fad9 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -147,13 +147,13 @@ if ( scalar(@cust_bill) == 1 && $total == 1) { END my(%saw, $cust_bill); - my($tot_balance, $tot_amount) = (0, 0); #BOGUS +# my($tot_balance, $tot_amount) = (0, 0); #BOGUS foreach $cust_bill ( sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) ) { my($invnum, $owed, $charged, $date ) = ( $cust_bill->invnum, - sprintf("%.2f", $cust_bill->owed), + sprintf("%.2f", $cust_bill->getfield('owed')), sprintf("%.2f", $cust_bill->charged), $cust_bill->_date, ); -- cgit v1.2.1 From 012523fcc0f3bc9994a429eb96b32eab6b3c04ce Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:00:49 +0000 Subject: try for correct totals --- httemplate/search/cust_bill.cgi | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 3b6b8fad9..6d00593bd 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -70,11 +70,13 @@ if ( $cgi->keywords ) { my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; - my $statement = "SELECT COUNT(*) FROM cust_bill $extra_sql"; + my $statement = "SELECT COUNT(*), sum(charged), sum($owed) + FROM cust_bill $extra_sql"; 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]; + #$total = $sth->fetchrow_arrayref->[0]; + ( $total, $tot_amount, $tot_balance ) = @{$sth->fetchrow_arrayref}; @cust_bill = qsearch( 'cust_bill', @@ -91,8 +93,7 @@ if ( $cgi->keywords ) { } #if ( scalar(@cust_bill) == 1 ) { -if ( scalar(@cust_bill) == 1 && $total == 1) { -#if ( $total == 1 ) { +if ( $total == 1 ) { my $invnum = $cust_bill[0]->invnum; print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect } elsif ( scalar(@cust_bill) == 0 ) { @@ -159,8 +160,8 @@ END ); my $pdate = time2str("%b %d %Y", $date); - $tot_balance += $owed; - $tot_amount += $charged; + #$tot_balance += $owed; + #$tot_amount += $charged; my $rowspan = 1; -- cgit v1.2.1 From 4cf0547217f3ccbca2aa9024ab0b396aef8bab5c Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:12:53 +0000 Subject: totals and order by --- httemplate/search/cust_bill.cgi | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 6d00593bd..45ff9f157 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -23,28 +23,35 @@ if ( $cgi->keywords ) { my @where; if ( $query eq 'invnum' ) { $sortby = \*invnum_sort; + $orderby = "ORDER BY cust_bill.invnum"; #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'date' ) { $sortby = \*date_sort; + $orderby = "ORDER BY cust_bill._date"; #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'custnum' ) { $sortby = \*custnum_sort; + $orderby = "ORDER BY cust_bill.custnum"; #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'OPEN_invnum' ) { $sortby = \*invnum_sort; + $orderby = "ORDER BY cust_bill.invnum"; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); push @where, "0 != $owed"; } elsif ( $query eq 'OPEN_date' ) { $sortby = \*date_sort; + $orderby = "ORDER BY cust_bill._date"; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); push @where, "0 != $owed"; } elsif ( $query eq 'OPEN_custnum' ) { $sortby = \*custnum_sort; + $orderby = "ORDER BY cust_bill.custnum"; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); push @where, "0 != $owed"; } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { my $open = $1 * 86400; $sortby = \*invnum_sort; + $orderby = "ORDER BY cust_bill.invnum"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); push @where, "0 != $owed". @@ -52,6 +59,7 @@ if ( $cgi->keywords ) { } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { my $open = $1 * 86400; $sortby = \*date_sort; + $orderby = "ORDER BY cust_bill._date"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); push @where, "0 != $owed". @@ -60,6 +68,7 @@ if ( $cgi->keywords ) { } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { my $open = $1 * 86400; $sortby = \*custnum_sort; + $orderby = "ORDER BY cust_bill.custnum"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); push @where, "0 != $owed". @@ -136,7 +145,11 @@ if ( $total == 1 ) { print header("Invoice Search Results", menubar( 'Main Menu', popurl(2) - )), "$total matching invoices found

$pager", &table(), <". + "\$$tot_balance total balance
". + "\$$tot_amount total amount
". + "
$pager". table(). < Balance @@ -148,7 +161,6 @@ if ( $total == 1 ) { END my(%saw, $cust_bill); -# my($tot_balance, $tot_amount) = (0, 0); #BOGUS foreach $cust_bill ( sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) ) { @@ -160,9 +172,6 @@ END ); my $pdate = time2str("%b %d %Y", $date); - #$tot_balance += $owed; - #$tot_amount += $charged; - my $rowspan = 1; my $view = popurl(2). "view/cust_bill.cgi?$invnum"; @@ -195,10 +204,10 @@ END } $tot_balance = sprintf("%.2f", $tot_balance); $tot_amount = sprintf("%.2f", $tot_amount); - print <TotalTotal + print "$pager

". table(). <-----Total
Balance
Total
Amount
\$$tot_balance\$$tot_amount - $pager + END -- cgit v1.2.1 From 9b76e0bd55bb4df1b9cad6d717bf0b27af72736c Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:14:32 +0000 Subject: UI --- httemplate/search/cust_bill.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 45ff9f157..1ce25d591 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -204,8 +204,8 @@ END } $tot_balance = sprintf("%.2f", $tot_balance); $tot_amount = sprintf("%.2f", $tot_amount); - print "$pager

". table(). <-----Total
Balance
Total
Amount
+ print "$pager
". table(). <       Total
Balance
Total
Amount
\$$tot_balance\$$tot_amount -- cgit v1.2.1 From 508721f2941f287c841f57e6b3077aa90265826c Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:18:58 +0000 Subject: fix 30/60/90/120 browses --- httemplate/search/cust_bill.cgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 1ce25d591..6b6158943 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -54,7 +54,7 @@ if ( $cgi->keywords ) { $orderby = "ORDER BY cust_bill.invnum"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed". + push @where, "0 != $owed", "cust_bill._date < ". (time-$open); } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { my $open = $1 * 86400; @@ -62,7 +62,7 @@ if ( $cgi->keywords ) { $orderby = "ORDER BY cust_bill._date"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed". + push @where, "0 != $owed", "cust_bill._date < ". (time-$open); } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { @@ -71,7 +71,7 @@ if ( $cgi->keywords ) { $orderby = "ORDER BY cust_bill.custnum"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed". + push @where, "0 != $owed", "cust_bill._date < ". (time-$open); } else { die "unknown query string $query"; -- cgit v1.2.1 From cec3bd39647288b37e32d63ff17c54917ebfe72f Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:24:54 +0000 Subject: that would be nice... --- httemplate/search/cust_bill.cgi | 110 +++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 52 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 6b6158943..6e5d20100 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -21,58 +21,64 @@ if ( $cgi->keywords ) { - ( select coalesce(sum(amount),0) from cust_credit_bill where cust_credit_bill.invnum = cust_bill.invnum )"; my @where; - if ( $query eq 'invnum' ) { - $sortby = \*invnum_sort; - $orderby = "ORDER BY cust_bill.invnum"; - #@cust_bill = qsearch('cust_bill', {} ); - } elsif ( $query eq 'date' ) { - $sortby = \*date_sort; - $orderby = "ORDER BY cust_bill._date"; - #@cust_bill = qsearch('cust_bill', {} ); - } elsif ( $query eq 'custnum' ) { - $sortby = \*custnum_sort; - $orderby = "ORDER BY cust_bill.custnum"; - #@cust_bill = qsearch('cust_bill', {} ); - } elsif ( $query eq 'OPEN_invnum' ) { - $sortby = \*invnum_sort; - $orderby = "ORDER BY cust_bill.invnum"; - #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); - push @where, "0 != $owed"; - } elsif ( $query eq 'OPEN_date' ) { - $sortby = \*date_sort; - $orderby = "ORDER BY cust_bill._date"; - #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); - push @where, "0 != $owed"; - } elsif ( $query eq 'OPEN_custnum' ) { - $sortby = \*custnum_sort; - $orderby = "ORDER BY cust_bill.custnum"; - #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); - push @where, "0 != $owed"; - } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { - my $open = $1 * 86400; - $sortby = \*invnum_sort; - $orderby = "ORDER BY cust_bill.invnum"; - #@cust_bill = - # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed", - "cust_bill._date < ". (time-$open); - } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { - my $open = $1 * 86400; - $sortby = \*date_sort; - $orderby = "ORDER BY cust_bill._date"; - #@cust_bill = - # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed", - "cust_bill._date < ". (time-$open); - - } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { - my $open = $1 * 86400; - $sortby = \*custnum_sort; - $orderby = "ORDER BY cust_bill.custnum"; - #@cust_bill = - # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed", - "cust_bill._date < ". (time-$open); + if ( $query =~ /^(OPEN(\d*)_)?(invnum|date|custnum)$/ ) { + my($open, $days, $field) = ($1, $2, $3); + $field = "_date" if $field eq 'date'; + $orderby = "ORDER BY cust_bill.$field"; + push @where, "0 != $owed" if $open; + push @where, "cust_bill._date < ". (time-86400*days) if $days; +# if ( $query eq 'invnum' ) { +# $sortby = \*invnum_sort; +# $orderby = "ORDER BY cust_bill.invnum"; +# #@cust_bill = qsearch('cust_bill', {} ); +# } elsif ( $query eq 'date' ) { +# $sortby = \*date_sort; +# $orderby = "ORDER BY cust_bill._date"; +# #@cust_bill = qsearch('cust_bill', {} ); +# } elsif ( $query eq 'custnum' ) { +# $sortby = \*custnum_sort; +# $orderby = "ORDER BY cust_bill.custnum"; +# #@cust_bill = qsearch('cust_bill', {} ); +# } elsif ( $query eq 'OPEN_invnum' ) { +# $sortby = \*invnum_sort; +# $orderby = "ORDER BY cust_bill.invnum"; +# #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); +# push @where, "0 != $owed"; +# } elsif ( $query eq 'OPEN_date' ) { +# $sortby = \*date_sort; +# $orderby = "ORDER BY cust_bill._date"; +# #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); +# push @where, "0 != $owed"; +# } elsif ( $query eq 'OPEN_custnum' ) { +# $sortby = \*custnum_sort; +# $orderby = "ORDER BY cust_bill.custnum"; +# #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); +# push @where, "0 != $owed"; +# } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { +# my $open = $1 * 86400; +# $sortby = \*invnum_sort; +# $orderby = "ORDER BY cust_bill.invnum"; +# #@cust_bill = +# # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); +# push @where, "0 != $owed", +# "cust_bill._date < ". (time-$open); +# } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { +# my $open = $1 * 86400; +# $sortby = \*date_sort; +# $orderby = "ORDER BY cust_bill._date"; +# #@cust_bill = +# # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); +# push @where, "0 != $owed", +# "cust_bill._date < ". (time-$open); +# +# } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { +# my $open = $1 * 86400; +# $sortby = \*custnum_sort; +# $orderby = "ORDER BY cust_bill.custnum"; +# #@cust_bill = +# # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); +# push @where, "0 != $owed", +# "cust_bill._date < ". (time-$open); } else { die "unknown query string $query"; } -- cgit v1.2.1 From 9ab3b58fe7df492c72959a40cf9c070e10995333 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:26:17 +0000 Subject: just might work --- httemplate/search/cust_bill.cgi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 6e5d20100..a5d3842b9 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -103,7 +103,7 @@ if ( $cgi->keywords ) { $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; my $invnum = $2; @cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum } ); - $sortby = \*invnum_sort; +# $sortby = \*invnum_sort; $total = scalar(@cust_bill); } @@ -166,10 +166,11 @@ if ( $total == 1 ) { END - my(%saw, $cust_bill); - foreach $cust_bill ( - sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) - ) { +# my(%saw, $cust_bill); +# foreach $cust_bill ( +# sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) +# ) { + foreach my $cust_bill ( @cust_bill ) { my($invnum, $owed, $charged, $date ) = ( $cust_bill->invnum, sprintf("%.2f", $cust_bill->getfield('owed')), -- cgit v1.2.1 From e96628dfc2204658ed879e2858d4f49bd6b1d0f2 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:28:13 +0000 Subject: fixing 30/60/90/120... --- httemplate/search/cust_bill.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index a5d3842b9..89c91f576 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -26,7 +26,7 @@ if ( $cgi->keywords ) { $field = "_date" if $field eq 'date'; $orderby = "ORDER BY cust_bill.$field"; push @where, "0 != $owed" if $open; - push @where, "cust_bill._date < ". (time-86400*days) if $days; + push @where, "cust_bill._date < ". (time-86400*$days) if $days; # if ( $query eq 'invnum' ) { # $sortby = \*invnum_sort; # $orderby = "ORDER BY cust_bill.invnum"; -- cgit v1.2.1 From 91c1b8e16502b31bf824a010a4e2ad1dcf247ec4 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Jul 2002 14:33:12 +0000 Subject: clean up after rewrite... turned out rather nice --- httemplate/search/cust_bill.cgi | 61 +---------------------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 89c91f576..d1b054dcd 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -13,7 +13,7 @@ $limit .= " OFFSET $offset" if $offset; my $total; -my(@cust_bill, $sortby); +my(@cust_bill); if ( $cgi->keywords ) { my($query) = $cgi->keywords; my $owed = "charged - ( select coalesce(sum(amount),0) from cust_bill_pay @@ -27,58 +27,6 @@ if ( $cgi->keywords ) { $orderby = "ORDER BY cust_bill.$field"; push @where, "0 != $owed" if $open; push @where, "cust_bill._date < ". (time-86400*$days) if $days; -# if ( $query eq 'invnum' ) { -# $sortby = \*invnum_sort; -# $orderby = "ORDER BY cust_bill.invnum"; -# #@cust_bill = qsearch('cust_bill', {} ); -# } elsif ( $query eq 'date' ) { -# $sortby = \*date_sort; -# $orderby = "ORDER BY cust_bill._date"; -# #@cust_bill = qsearch('cust_bill', {} ); -# } elsif ( $query eq 'custnum' ) { -# $sortby = \*custnum_sort; -# $orderby = "ORDER BY cust_bill.custnum"; -# #@cust_bill = qsearch('cust_bill', {} ); -# } elsif ( $query eq 'OPEN_invnum' ) { -# $sortby = \*invnum_sort; -# $orderby = "ORDER BY cust_bill.invnum"; -# #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); -# push @where, "0 != $owed"; -# } elsif ( $query eq 'OPEN_date' ) { -# $sortby = \*date_sort; -# $orderby = "ORDER BY cust_bill._date"; -# #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); -# push @where, "0 != $owed"; -# } elsif ( $query eq 'OPEN_custnum' ) { -# $sortby = \*custnum_sort; -# $orderby = "ORDER BY cust_bill.custnum"; -# #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); -# push @where, "0 != $owed"; -# } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { -# my $open = $1 * 86400; -# $sortby = \*invnum_sort; -# $orderby = "ORDER BY cust_bill.invnum"; -# #@cust_bill = -# # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); -# push @where, "0 != $owed", -# "cust_bill._date < ". (time-$open); -# } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { -# my $open = $1 * 86400; -# $sortby = \*date_sort; -# $orderby = "ORDER BY cust_bill._date"; -# #@cust_bill = -# # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); -# push @where, "0 != $owed", -# "cust_bill._date < ". (time-$open); -# -# } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { -# my $open = $1 * 86400; -# $sortby = \*custnum_sort; -# $orderby = "ORDER BY cust_bill.custnum"; -# #@cust_bill = -# # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); -# push @where, "0 != $owed", -# "cust_bill._date < ". (time-$open); } else { die "unknown query string $query"; } @@ -90,7 +38,6 @@ if ( $cgi->keywords ) { 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]; ( $total, $tot_amount, $tot_balance ) = @{$sth->fetchrow_arrayref}; @cust_bill = qsearch( @@ -103,7 +50,6 @@ if ( $cgi->keywords ) { $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; my $invnum = $2; @cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum } ); -# $sortby = \*invnum_sort; $total = scalar(@cust_bill); } @@ -120,7 +66,6 @@ if ( $total == 1 ) { %> <% - #$total = scalar(@cust_bill); #begin pager my $pager = ''; @@ -166,10 +111,6 @@ if ( $total == 1 ) { END -# my(%saw, $cust_bill); -# foreach $cust_bill ( -# sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) -# ) { foreach my $cust_bill ( @cust_bill ) { my($invnum, $owed, $charged, $date ) = ( $cust_bill->invnum, -- cgit v1.2.1 From e61703420a7eaef1f16ad4251cc7733e7a35604f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 8 Jul 2002 10:52:47 +0000 Subject: remove perl-side sort routines, no longer needed --- httemplate/search/cust_bill.cgi | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index d1b054dcd..586399a41 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -162,17 +162,4 @@ END } -# - -sub invnum_sort { - $a->invnum <=> $b->invnum; -} - -sub custnum_sort { - $a->custnum <=> $b->custnum || $a->invnum <=> $b->invnum; -} - -sub date_sort { - $a->_date <=> $b->_date || $a->invnum <=> $b->invnum; -} %> -- cgit v1.2.1 From 068eda26651713cf318f69908b82d7d34f9716b4 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Aug 2002 14:11:00 +0000 Subject: UI ROWSPAN fix --- httemplate/search/cust_pkg.cgi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index abf6eee4c..5f0782b8c 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -263,11 +263,11 @@ END my $p = popurl(2); print $n1, <$pkgnum - $pkg - $setup - $bill - $susp - $expire - $cancel + $setup + $bill + $susp + $expire + $cancel END if ( $cust_main ) { print < 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') 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 3595c874f8e476e58b98b7ab6d86918d4dbb1d5c Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Sep 2002 09:19:42 +0000 Subject: remove svc_acct_sm --- httemplate/search/svc_acct_sm.cgi | 84 -------------------------------------- httemplate/search/svc_acct_sm.html | 23 ----------- httemplate/search/svc_domain.cgi | 12 ------ 3 files changed, 119 deletions(-) delete mode 100755 httemplate/search/svc_acct_sm.cgi delete mode 100755 httemplate/search/svc_acct_sm.html (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi deleted file mode 100755 index 4ee300612..000000000 --- a/httemplate/search/svc_acct_sm.cgi +++ /dev/null @@ -1,84 +0,0 @@ -<% - -my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); - -$cgi->param('domuser') =~ /^([a-z0-9_\-]{0,32})$/; -my $domuser = $1; - -$cgi->param('domain') =~ /^([\w\-\.]+)$/ or die "Illegal domain"; -my $svc_domain = qsearchs('svc_domain',{'domain'=>$1}) - or die "Unknown domain"; -my $domsvc = $svc_domain->svcnum; - -my @svc_acct_sm; -if ($domuser) { - @svc_acct_sm=qsearch('svc_acct_sm',{ - 'domuser' => $domuser, - 'domsvc' => $domsvc, - }); -} else { - @svc_acct_sm=qsearch('svc_acct_sm',{'domsvc' => $domsvc}); -} - -if ( scalar(@svc_acct_sm) == 1 ) { - my($svcnum)=$svc_acct_sm[0]->svcnum; - print $cgi->redirect(popurl(2). "view/svc_acct_sm.cgi?$svcnum"); -} elsif ( scalar(@svc_acct_sm) > 1 ) { -%> - -<% - print header('Mail Alias Search Results'), &table(), < - Mail to
(click to view mail alias) - Forwards to
(click to view account) - -END - - my($svc_acct_sm); - foreach $svc_acct_sm (@svc_acct_sm) { - my($svcnum,$domuser,$domuid,$domsvc)=( - $svc_acct_sm->svcnum, - $svc_acct_sm->domuser, - $svc_acct_sm->domuid, - $svc_acct_sm->domsvc, - ); - - my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $domsvc } ); - if ( $svc_domain ) { - my $domain = $svc_domain->domain; - - print qq!!, - #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); - ( ($domuser eq '*') ? "(anything)" : $domuser ), - qq!\@$domain !, - ; - } else { - my $warning = "couldn't find svc_domain.svcnum $svcnum ( svc_acct_sm.svcnum $svcnum"; - warn $warning; - print "WARNING: $warning"; - } - - my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $domuid } ); - if ( $svc_acct ) { - my $username = $svc_acct->username; - my $svc_acct_svcnum =$svc_acct->svcnum; - print qq!$username\@$mydomain!, - qq!! - ; - } else { - my $warning = "couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum $svcnum)!"; - warn $warning; - print "WARNING: $warning"; - } - - } - - print ''; - -} else { #error - idiot("Mail Alias not found"); -} - -%> diff --git a/httemplate/search/svc_acct_sm.html b/httemplate/search/svc_acct_sm.html deleted file mode 100755 index 0719856db..000000000 --- a/httemplate/search/svc_acct_sm.html +++ /dev/null @@ -1,23 +0,0 @@ - - - Mail Alias Search - - -
-

Mail Alias Search

-
-
- - Search for mail alias: - (opt.) @ - (req.) - -

- -

- -
- - - - diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index fb372db14..0bb39f191 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -67,18 +67,6 @@ END $svc_domain->svcnum, $svc_domain->domain, ); - #my($malias); - #if ( qsearch('svc_acct_sm',{'domsvc'=>$svcnum}) ) { - # $malias=( - # qq|
|. - # qq||. - # qq||. - # qq||. - # qq|
| - # ); - #} else { - # $malias=''; - #} my @svc_acct=qsearch('svc_acct',{'domsvc' => $svcnum}); my $rowspan = 0; -- cgit v1.2.1 From c1e33a61324f4e06157c522af7882a97a021830f Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 18 Sep 2002 22:50:44 +0000 Subject: remove domain config file, closes: Bug#269 --- httemplate/search/svc_acct.cgi | 25 ++++--------------------- httemplate/search/svc_domain.cgi | 1 - 2 files changed, 4 insertions(+), 22 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 549231d3f..dcf261296 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,7 +1,5 @@ <% -my $mydomain = ''; - my $conf = new FS::Conf; my $maxrecords = $conf->config('maxsearchrecordsperpage'); @@ -147,14 +145,8 @@ END $domain = "svcnum. "\">". $svc_domain->domain. ""; } else { - unless ( $mydomain ) { - my $conf = new FS::Conf; - unless ( $mydomain = $conf->config('domain') ) { - die "No legacy domain config file and no svc_domain.svcnum record ". - "for svc_acct.domsvc: ". $svc_acct->domsvc; - } - } - $domain = "$mydomain*"; + die "No svc_domain.svcnum record for svc_acct.domsvc: ".' + $svc_acct->domsvc; } my($cust_pkg,$cust_main); if ( $cust_svc->pkgnum ) { @@ -216,17 +208,8 @@ END } - print "$pager
"; - - if ( $mydomain ) { - print "
* The $mydomain domain ". - "is contained in your legacy domain ". - "configuration file. ". - "You should run the bin/fs-migrate-svc_acct_sm script ". - "to create a proper svc_domain record for this domain."; - } - - print ''; + print "$pager
". + ''; } diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 0bb39f191..60f1f8c81 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,7 +1,6 @@ <% my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors -- cgit v1.2.1 From abfd68d00c867c64c033915374f8fc6b1ff7e6d2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 26 Sep 2002 04:45:21 +0000 Subject: tyop --- httemplate/search/svc_acct.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index dcf261296..b2ed723e2 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -145,7 +145,7 @@ END $domain = "svcnum. "\">". $svc_domain->domain. ""; } else { - die "No svc_domain.svcnum record for svc_acct.domsvc: ".' + die "No svc_domain.svcnum record for svc_acct.domsvc: ". $svc_acct->domsvc; } my($cust_pkg,$cust_main); -- 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') 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 61e25db54f2da624a79ecedb6bf3d678c7fdefc5 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 8 Oct 2002 11:10:51 +0000 Subject: add suspended package browse (closes: Bug#467) --- httemplate/search/cust_pkg.cgi | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 5f0782b8c..78a5bb3bb 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -43,10 +43,16 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } else { - my $unconf = ''; + my $qual = ''; if ( $query eq 'pkgnum' ) { $sortby=\*pkgnum_sort; + } elsif ( $query eq 'SUSP_pkgnum' ) { + + $sortby=\*pkgnum_sort; + + $qual = 'WHERE susp IS NOT NULL AND susp != 0'; + } elsif ( $query eq 'APKG_pkgnum' ) { $sortby=\*pkgnum_sort; @@ -101,12 +107,12 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { AND pkg_svc.quantity != 0;"; $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; $sth->execute or die "Error executing \"$query\": ". $sth->errstr; - $unconf = " LEFT JOIN temp2_$$ ON cust_pkg.pkgnum = temp2_$$.pkgnum - WHERE temp2_$$.pkgnum IS NOT NULL"; + $qual = " LEFT JOIN temp2_$$ ON cust_pkg.pkgnum = temp2_$$.pkgnum + WHERE temp2_$$.pkgnum IS NOT NULL"; } else { - $unconf = " + $qual = " WHERE 0 < ( SELECT count(*) FROM pkg_svc WHERE pkg_svc.pkgpart = cust_pkg.pkgpart @@ -120,10 +126,10 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } } else { - die "Empty QUERY_STRING!"; + die "Empty or unknown QUERY_STRING!"; } - my $statement = "SELECT COUNT(*) FROM cust_pkg $unconf"; + my $statement = "SELECT COUNT(*) FROM cust_pkg $qual"; my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; @@ -131,7 +137,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { my $tblname = driver_name eq 'mysql' ? 'cust_pkg.' : ''; @cust_pkg = - qsearch('cust_pkg',{}, '', "$unconf ORDER BY ${tblname}pkgnum $limit" ); + qsearch('cust_pkg',{}, '', "$qual ORDER BY ${tblname}pkgnum $limit" ); if ( driver_name eq 'mysql' ) { $query = "DROP TABLE temp1_$$,temp2_$$;"; -- cgit v1.2.1 From bc1639be3d9f32711b4740324c6de1f3bffb0124 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 17 Oct 2002 11:17:50 +0000 Subject: another mason fix, this one from 5 --- httemplate/search/cust_bill.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 586399a41..985e3dbf5 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -11,7 +11,7 @@ $limit .= "LIMIT $maxrecords" if $maxrecords; my $offset = $cgi->param('offset') || 0; $limit .= " OFFSET $offset" if $offset; -my $total; +my($total, $tot_amount, $tot_balance); my(@cust_bill); if ( $cgi->keywords ) { -- cgit v1.2.1 From 38198ddef5f92e95ae3f0a151759931400a6ad44 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 21 Dec 2002 23:44:14 +0000 Subject: don't display all accounts in each domain --- httemplate/search/svc_domain.cgi | 110 ++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 53 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 60f1f8c81..c397714e5 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -50,8 +50,9 @@ if ( scalar(@svc_domain) == 1 ) { Service # Domain - Mail to
(click to view account) + END @@ -67,57 +68,60 @@ END $svc_domain->domain, ); - my @svc_acct=qsearch('svc_acct',{'domsvc' => $svcnum}); - my $rowspan = 0; - - my $n1 = ''; - my($svc_acct, @rows); - foreach $svc_acct ( - sort {$b->getfield('username') cmp $a->getfield('username')} (@svc_acct) - ) { - - my (@forwards) = (); - - my($svcnum,$username)=( - $svc_acct->svcnum, - $svc_acct->username, - ); - - my @svc_forward = qsearch( 'svc_forward', { 'srcsvc' => $svcnum } ); - my $svc_forward; - foreach $svc_forward (@svc_forward) { - my($dstsvc,$dst) = ( - $svc_forward->dstsvc, - $svc_forward->dst, - ); - if ($dstsvc) { - my $dst_svc_acct=qsearchs( 'svc_acct', { 'svcnum' => $dstsvc } ); - my $destination=$dst_svc_acct->email; - push @forwards, qq!$destination!, - qq!! - ; - }else{ - push @forwards, qq!$dst! - ; - } - } - - push @rows, qq!$n1!, - #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); - ( ($username eq '*') ? "(anything)" : $username ), - qq!\@$domain !, - ; - - push @rows, @forwards; - - $rowspan += (scalar(@svc_forward) || 1); - $n1 = ""; - } - #end of false laziness - - + #don't display all accounts here + my $rowspan = 1; + + #my @svc_acct=qsearch('svc_acct',{'domsvc' => $svcnum}); + #my $rowspan = 0; + # + #my $n1 = ''; + #my($svc_acct, @rows); + #foreach $svc_acct ( + # sort {$b->getfield('username') cmp $a->getfield('username')} (@svc_acct) + #) { + # + # my (@forwards) = (); + # + # my($svcnum,$username)=( + # $svc_acct->svcnum, + # $svc_acct->username, + # ); + # + # my @svc_forward = qsearch( 'svc_forward', { 'srcsvc' => $svcnum } ); + # my $svc_forward; + # foreach $svc_forward (@svc_forward) { + # my($dstsvc,$dst) = ( + # $svc_forward->dstsvc, + # $svc_forward->dst, + # ); + # if ($dstsvc) { + # my $dst_svc_acct=qsearchs( 'svc_acct', { 'svcnum' => $dstsvc } ); + # my $destination=$dst_svc_acct->email; + # push @forwards, qq!$destination!, + # qq!! + # ; + # }else{ + # push @forwards, qq!$dst! + # ; + # } + # } + # + # push @rows, qq!$n1!, + # #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); + # ( ($username eq '*') ? "(anything)" : $username ), + # qq!\@$domain !, + # ; + # + # push @rows, @forwards; + # + # $rowspan += (scalar(@svc_forward) || 1); + # $n1 = ""; + #} + ##end of false laziness + # + # print < @@ -125,7 +129,7 @@ END $domain END - print @rows; + #print @rows; print ""; } -- cgit v1.2.1 From b3cf415f88878300916d3e85910693b7315ef7b3 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 21 Dec 2002 23:48:00 +0000 Subject: UI --- httemplate/search/svc_domain.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index c397714e5..c0acf1143 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -125,8 +125,8 @@ END print < - $svcnum - $domain + $svcnum + $domain END #print @rows; -- cgit v1.2.1 From ad90599960b1c4f44a96985e9716c1bc5d04d596 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 24 Mar 2003 08:30:35 +0000 Subject: another Pg7.3 fix --- httemplate/search/svc_acct.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index b2ed723e2..e43f4f79b 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -30,7 +30,7 @@ if ( $query =~ /^UN_(.*)$/ ) { WHERE 0 < ( SELECT count(*) FROM cust_svc WHERE cust_svc.svcnum = svc_acct.svcnum - AND ( pkgnum IS NULL OR pkgnum = 0 OR pkgnum = $empty ) + AND ( pkgnum IS NULL OR pkgnum = 0 ) ) "; } -- cgit v1.2.1 From f3b8b72d2a07683b2deb2774f29407e25e725b5a Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 1 Apr 2003 01:22:25 +0000 Subject: correct last_bill problems with $0 invoice (non-existant) edge cases --- httemplate/search/cust_pkg.cgi | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 78a5bb3bb..3cc520fa8 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -194,6 +194,12 @@ if ( scalar(@cust_pkg) == 1 ) { Package Setup +END + + print 'Next
bill
' + if defined dbdef->table('cust_pkg')->column('last_bill'); + + print <Next
bill
Susp. Expire @@ -203,17 +209,10 @@ if ( scalar(@cust_pkg) == 1 ) { company END -if ( defined dbdef->table('cust_main')->column('ship_last') ) { - print <(service) name - company -END -} + print '(service) namecompany' + if defined dbdef->table('cust_main')->column('ship_last'); -print <Services - -END + print 'Services'; my $n1 = ''; my(%saw,$cust_pkg); @@ -244,6 +243,12 @@ END $cust_main ? $cust_main->first : '', $cust_main ? $cust_main->company : '', ); + + my $last_bill = $cust_pkg->getfield('last_bill') + ? time2str("%D", $cust_pkg->getfield('last_bill') ) + : '' + if defined dbdef->table('cust_pkg')->column('last_bill'); + my($ship_last, $ship_first, $ship_company); if ( defined dbdef->table('cust_main')->column('ship_last') ) { ($ship_last, $ship_first, $ship_company) = ( @@ -270,6 +275,12 @@ END print $n1, <$pkgnum - $pkg $setup +END + + print "$last_bill" + if defined dbdef->table('cust_pkg')->column('last_bill'); + + print <$bill $susp $expire -- 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') 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') 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 bace32bf9341c78d1a068b302dbba031c79c128d Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 11 May 2003 22:53:49 +0000 Subject: patch from Richard Siddall for strict vars --- httemplate/search/cust_pkg.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 3cc520fa8..538edf3f1 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -93,7 +93,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { AND cust_svc.svcpart = pkg_svc.svcpart AND cust_pkg.pkgpart = pkg_svc.pkgpart GROUP BY cust_svc.pkgnum,cust_svc.svcpart"; - $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; $sth->execute or die "Error executing \"$query\": ". $sth->errstr; -- cgit v1.2.1 From 4bf86e5f7f44e77159564804d09e0938a8edc905 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 4 Jun 2003 12:44:57 +0000 Subject: fix last bill label --- httemplate/search/cust_pkg.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 538edf3f1..12179eaca 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -196,7 +196,7 @@ if ( scalar(@cust_pkg) == 1 ) { Setup END - print 'Next
bill
' + print 'Last
bill
' if defined dbdef->table('cust_pkg')->column('last_bill'); print < Date: Wed, 25 Jun 2003 10:22:22 +0000 Subject: Pg 7.3 incompatibility with empty dates in Failed Invoice Event search, patch from rlucas@tercent.net --- httemplate/search/cust_bill_event.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index 9cb36d28e..b76f66b76 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -4,7 +4,7 @@ #false laziness with view/cust_bill.cgi $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; -my $beginning = str2time($1); +my $beginning = str2time($1) || 0; $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; my $ending = str2time($1) + 86400; -- cgit v1.2.1 From 3d7644882ebf59fcac7230a408d06e7c4e1bb34b Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 11 Jul 2003 15:23:33 +0000 Subject: payments report for inventivemedia / hpnx --- httemplate/search/cust_pay.cgi | 71 ++++++++++++++++++++++++++++------ httemplate/search/cust_pkg.cgi | 2 + httemplate/search/report_cust_pay.html | 24 ++++++++++++ 3 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 httemplate/search/report_cust_pay.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index b5bdf8296..d601617f9 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,12 +1,46 @@ <% -$cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; -my $payinfo = $1; -$cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; -my $payby = $1; -my @cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo, +my $sortby; +my @cust_pay; +if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { + + my %search; + if ( $cgi->param('payby') ) { + $cgi->param('payby') =~ /^(CARD|CHEK|BILL)$/ + or die "illegal payby ". $cgi->param('payby'); + $search{'payby'} = $1; + } + + #false laziness with cust_pkg.cgi + my $range = ''; + if ( $cgi->param('beginning') + && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $beginning = str2time($1); + $range = " WHERE _date >= $beginning "; + } + if ( $cgi->param('ending') + && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $ending = str2time($1) + 86400; + $range .= ( $range ? ' AND ' : ' WHERE ' ). " _date <= $ending "; + } + + @cust_pay = qsearch('cust_pay', \%search, '', " $range" ); + + $sortby = \*date_sort; + +} else { + + $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; + my $payinfo = $1; + + $cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; + my $payby = $1; + + @cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo, 'payby' => $payby } ); -my $sortby = \*date_sort; + $sortby = \*date_sort; + +} if (0) { #if ( scalar(@cust_pay) == 1 ) { @@ -16,7 +50,7 @@ if (0) { %> <% - idiot("Check # not found."); + idiot("Payment not found."); #exit; } else { my $total = scalar(@cust_pay); @@ -24,9 +58,9 @@ if (0) { %> <% - print header("Check # Search Results", menubar( + print header("Payment Search Results", menubar( 'Main Menu', popurl(2) - )), "$total matching check$s found
", &table(), <", &table(), < Amount @@ -40,23 +74,36 @@ END foreach my $cust_pay ( sort $sortby grep(!$saw{$_->paynum}++, @cust_pay) ) { - my($paynum, $custnum, $payinfo, $amount, $date ) = ( + my($paynum, $custnum, $payby, $payinfo, $amount, $date ) = ( $cust_pay->paynum, $cust_pay->custnum, + $cust_pay->payby, $cust_pay->payinfo, sprintf("%.2f", $cust_pay->paid), $cust_pay->_date, ); - my $pdate = time2str("%b %d %Y", $date); + my $pdate = time2str("%b %d %Y", $date); my $rowspan = 1; my $view = popurl(2). "view/cust_main.cgi?". $custnum. "#". $payby. $payinfo; + my $payment_info; + if ( $payby eq 'CARD' ) { + $payment_info = 'Card #'. 'x'x(length($payinfo)-4). + substr($payinfo,(length($payinfo)-4)); + } elsif ( $payby eq 'CHEK' ) { + $payment_info = "E-check acct#$payinfo"; + } elsif ( $payby eq 'BILL' ) { + $payment_info = "Check #$payinfo"; + } else { + $payment_info = "$payby $payinfo"; + } + print < - $payinfo + $payment_info \$$amount $pdate END diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 12179eaca..603b5654c 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -19,6 +19,8 @@ my @cust_pkg; if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $sortby=\*bill_sort; + + #false laziness with cust_pay.cgi my $range = ''; if ( $cgi->param('beginning') && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html new file mode 100644 index 000000000..93053e1ee --- /dev/null +++ b/httemplate/search/report_cust_pay.html @@ -0,0 +1,24 @@ + + + Payment report criteria + + +
+

Payment report criteria

+
+
+
+ + Return payments for period
+ from m/d/y + to m/d/y +

+

+
+ + -- cgit v1.2.1 From 7c319f1608fd3459c992eda7743696fc745fccf1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 12 Jul 2003 11:09:33 +0000 Subject: - better description of payment search - some clarification of services/packages vs. service/package definitions in browse/part_{svc,pkg}.cgi - package definition report by # of active customer packages (with links to customer package listing) --- httemplate/search/cust_pkg.cgi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 603b5654c..8b2fd0ca0 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -46,7 +46,19 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } else { my $qual = ''; - if ( $query eq 'pkgnum' ) { + if ( $cgi->param('magic') && $cgi->param('magic') eq 'active' ) { + + $qual = 'WHERE ( susp IS NULL OR susp = 0 )'. + ' AND ( cancel IS NULL OR cancel = 0)'; + + $sortby = \*pkgnum_sort; + + if ( $cgi->param('pkgpart') =~ /^(\d+)$/ ) { + $qual .= " AND pkgpart = $1"; + } + + } elsif ( $query eq 'pkgnum' ) { + $sortby=\*pkgnum_sort; } elsif ( $query eq 'SUSP_pkgnum' ) { -- cgit v1.2.1 From c39eb764e9dc1355b5d085b1fd1660e8cd999841 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 14 Jul 2003 06:21:29 +0000 Subject: fix bug when both a payment type and date range are specified --- httemplate/search/cust_pay.cgi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index d601617f9..7a983703f 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -23,8 +23,9 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { my $ending = str2time($1) + 86400; $range .= ( $range ? ' AND ' : ' WHERE ' ). " _date <= $ending "; } + $range =~ s/^\s*WHERE/ AND/ if scalar(keys %search) ; - @cust_pay = qsearch('cust_pay', \%search, '', " $range" ); + @cust_pay = qsearch('cust_pay', \%search, '', $range ); $sortby = \*date_sort; -- cgit v1.2.1 From b541a7851e891c8fb8150ba930c90600a4c68465 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 16 Jul 2003 16:01:39 +0000 Subject: show totals in payment report --- httemplate/search/cust_pay.cgi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 7a983703f..0f7b7b791 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -72,6 +72,7 @@ if (0) { END my(%saw, $cust_pay); + my $tot_amount = 0; foreach my $cust_pay ( sort $sortby grep(!$saw{$_->paynum}++, @cust_pay) ) { @@ -83,6 +84,7 @@ END sprintf("%.2f", $cust_pay->paid), $cust_pay->_date, ); + $tot_amount += $amount; my $pdate = time2str("%b %d %Y", $date); my $rowspan = 1; @@ -127,7 +129,11 @@ END print ""; } - print <
'. table(). <                Total
Amount + \$$tot_amount -- cgit v1.2.1 From e6af26844ebc727340f92cf6ecfe94d6a1110afe Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 16 Jul 2003 16:05:43 +0000 Subject: UI --- httemplate/search/cust_pay.cgi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 0f7b7b791..e4dba01e9 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -132,8 +132,10 @@ END $tot_amount = sprintf("%.2f", $tot_amount); print '
'. table(). <                Total
Amount - \$$tot_amount + + Total Amount + \$$tot_amount + -- cgit v1.2.1 From ef7bb336cc67f127fb1d77532ad3da1369c0ae36 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 8 Aug 2003 02:02:41 +0000 Subject: - fix Mason profiling to pass-through images (for graph/) - fix graph/money-time.cgi use of $m interfering with Mason - fix graph/money-time-graph.cgi to set content-type in a Mason/ASP-independant fashion - (beginning of) includes! - (beginning of) moving SQL search to including generic elements/search.html - fix global.asa typo - fix masonize to not prepend an extraneous blank line (breaking graph/money-time-graph.cgi) --- httemplate/search/elements/search.html | 8 ++++++++ httemplate/search/sql.html | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 httemplate/search/elements/search.html create mode 100644 httemplate/search/sql.html (limited to 'httemplate/search') diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html new file mode 100644 index 000000000..fba8ee815 --- /dev/null +++ b/httemplate/search/elements/search.html @@ -0,0 +1,8 @@ +<% + +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); + +my $limit = $maxrecords ? "LIMIT $maxrecords" : ''; + +%> diff --git a/httemplate/search/sql.html b/httemplate/search/sql.html new file mode 100644 index 000000000..e61ce1538 --- /dev/null +++ b/httemplate/search/sql.html @@ -0,0 +1,8 @@ +<%= include( '/elements/header', 'Query Results', + include( '/elements/menubar', 'Main Menu' => $p ) +%> +<%= include( 'elements/search.html', + 'name' => 'rows', + +%> + -- cgit v1.2.1 From e283ab567e6890727e4d8e35c1d8097398678753 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 8 Aug 2003 05:42:13 +0000 Subject: - (finish) includes! (closes: Bug#551) - (finish) moving SQL search to including generic elements/search.html - new elements: menubar.html, header.html, pager.html and table.html - have masonize process .html files also --- httemplate/search/elements/search.html | 57 +++++++++++++++++++++++-- httemplate/search/sql.cgi | 76 ---------------------------------- httemplate/search/sql.html | 12 ++++-- 3 files changed, 62 insertions(+), 83 deletions(-) delete mode 100755 httemplate/search/sql.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index fba8ee815..fbedcaa26 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -1,8 +1,59 @@ <% -my $conf = new FS::Conf; -my $maxrecords = $conf->config('maxsearchrecordsperpage'); + my %opt = @_; + unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { + ( $opt{'count_query'} = $opt{'query'} ) =~ + s/^\s*SELECT\s*(.*)\s+FROM\s/SELECT COUNT(*) FROM /i; + } -my $limit = $maxrecords ? "LIMIT $maxrecords" : ''; + my $conf = new FS::Conf; + my $maxrecords = $conf->config('maxsearchrecordsperpage'); + my $limit = $maxrecords ? "LIMIT $maxrecords" : ''; + + my $offset = $cgi->param('offset') || 0; + $limit .= " OFFSET $offset" if $offset; + + my $count_sth = dbh->prepare($opt{'count_query'}) + or die "Error preparing $opt{'count_query'}: ". dbh->errstr; + $count_sth->execute + or die "Error executing $opt{'count_query'}: ". $count_sth->errstr; + my $total = $count_sth->fetchrow_arrayref->[0]; + + my $sth = dbh->prepare("$opt{'query'} $limit") + or die "Error preparing $opt{'query'}: ". dbh->errstr; + $sth->execute + or die "Error executing $opt{'query'}: ". $sth->errstr; + + #can get # of rows without fetching them all? + my $rows = $sth->fetchall_arrayref; + +%> + +<% my $pager = include ( '/elements/pager.html', + 'offset' => $offset, + 'num_rows' => scalar(@$rows), + 'total' => $total, + 'maxrecords' => $maxrecords, + ); %> + +<%= $total %> total <%= $opt{'name'} %>

<%= $pager %> +<%= include( '/elements/table.html' ) %> + + <% foreach ( @{$sth->{NAME}} ) { %> + <%= $_ %> + <% } %> + + <% foreach my $row ( @$rows ) { %> + + <% foreach ( @$row ) { %> + <%= $_ %> + <% } %> + + <% } %> + + +<%= $pager %> + + diff --git a/httemplate/search/sql.cgi b/httemplate/search/sql.cgi deleted file mode 100755 index b83ef039f..000000000 --- a/httemplate/search/sql.cgi +++ /dev/null @@ -1,76 +0,0 @@ -<% - -my $conf = new FS::Conf; -my $maxrecords = $conf->config('maxsearchrecordsperpage'); - -my $limit = ''; -$limit .= "LIMIT $maxrecords" if $maxrecords; - -my $offset = $cgi->param('offset') || 0; -$limit .= " OFFSET $offset" if $offset; - -my $total; - -my $sql = $cgi->param('sql'); -$sql =~ s/^\s*SELECT//i; - -my $count_sql = $sql; -$count_sql =~ s/^(.*)\s+FROM\s/COUNT(*) FROM /i; - -my $sth = dbh->prepare("SELECT $count_sql") - or eidiot dbh->errstr. " doing $count_sql\n"; -$sth->execute or eidiot "Error executing \"$count_sql\": ". $sth->errstr; - -$total = $sth->fetchrow_arrayref->[0]; - -my $sth = dbh->prepare("SELECT $sql $limit") - or eidiot dbh->errstr. " doing $sql\n"; -$sth->execute or eidiot "Error executing \"$sql\": ". $sth->errstr; -my $rows = $sth->fetchall_arrayref; - -%> - -<% - - #begin pager - my $pager = ''; - if ( $total != scalar(@$rows) && $maxrecords ) { - unless ( $offset == 0 ) { - $cgi->param('offset', $offset - $maxrecords); - $pager .= 'Previous '; - } - my $poff; - my $page; - for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { - $page++; - if ( $offset == $poff ) { - $pager .= qq!$page !; - } else { - $cgi->param('offset', $poff); - $pager .= qq!$page !; - } - } - unless ( $offset + $maxrecords > $total ) { - $cgi->param('offset', $offset + $maxrecords); - $pager .= 'Next '; - } - } - #end pager - - print header('Query Results', menubar('Main Menu'=>$p) ). - "$total total rows

$pager". table(). - ""; - print "$_" foreach @{$sth->{NAME}}; - print ""; - - foreach $row ( @$rows ) { - print ""; - print "$_" foreach @$row; - print ""; - } - - print "$pager"; - -%> diff --git a/httemplate/search/sql.html b/httemplate/search/sql.html index e61ce1538..7d7fc0890 100644 --- a/httemplate/search/sql.html +++ b/httemplate/search/sql.html @@ -1,8 +1,12 @@ -<%= include( '/elements/header', 'Query Results', - include( '/elements/menubar', 'Main Menu' => $p ) +<%= include( '/elements/header.html', 'Query Results', + include( '/elements/menubar.html', 'Main Menu' => $p ) + ) %> + <%= include( 'elements/search.html', - 'name' => 'rows', - + 'name' => 'rows', + 'query' => 'SELECT '. ( $cgi->param('sql') + || eidiot('Empty query') ), + ) %> -- cgit v1.2.1 From 32ba5c8d264479a302c1524165d708ce11243d69 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Sep 2003 21:33:03 +0000 Subject: package search skips cancelled packages when searching by date range --- httemplate/search/cust_pkg.cgi | 2 ++ 1 file changed, 2 insertions(+) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 8b2fd0ca0..f735fbf42 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -33,6 +33,8 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $range .= ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; } + $range .= ( $range ? 'AND ' : ' WHERE ' ). '( cancel IS NULL OR cancel = 0 )'; + #false laziness with below my $statement = "SELECT COUNT(*) FROM cust_pkg $range"; warn $statement; -- 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') 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 56c771abafb2cad3430fee10deacba6e561933de Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 30 Sep 2003 08:23:16 +0000 Subject: calendar popups! --- httemplate/search/cust_pkg.html | 46 ++++++++++++++++++++------- httemplate/search/report_cc.html | 44 +++++++++++++++++++------- httemplate/search/report_credit.html | 44 +++++++++++++++++++------- httemplate/search/report_cust_pay.html | 57 +++++++++++++++++++++++++--------- httemplate/search/report_tax.html | 46 +++++++++++++++++++-------- 5 files changed, 173 insertions(+), 64 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.html b/httemplate/search/cust_pkg.html index bb0a5407c..3d80d51a9 100755 --- a/httemplate/search/cust_pkg.html +++ b/httemplate/search/cust_pkg.html @@ -1,24 +1,46 @@ Packages + + + + - -
-

Packages

-
-
+ +

Packages

- Return packages with next bill date: - from m/d/y - to m/d/y - -

+ Return packages with next bill date:

+ + + + + + + + + + + +
From:
m/d/y
To:
m/d/y
+

-
- diff --git a/httemplate/search/report_cc.html b/httemplate/search/report_cc.html index 8653dcc69..7bbfa40ce 100755 --- a/httemplate/search/report_cc.html +++ b/httemplate/search/report_cc.html @@ -1,23 +1,43 @@ Credit Card Receipt Report Criteria - - -
-

Credit Card Receipt Report Criteria

-
-
+ + + + + +

Credit Card Receipt Report Criteria

Return credit card receipt report for period: - from m/d/y - to m/d/y + + + + + + + + + + +
From:
m/d/y
To:
m/d/y
-

+

- -
- diff --git a/httemplate/search/report_credit.html b/httemplate/search/report_credit.html index df9b9581f..310b9cb59 100755 --- a/httemplate/search/report_credit.html +++ b/httemplate/search/report_credit.html @@ -1,23 +1,43 @@ In House Credit Report Criteria - - -
-

In House Credit Report Criteria

-
-
+ + + + + +

In House Credit Report Criteria

Return in house credit report for period: - from m/d/y - to m/d/y + + + + + + + + + + +
From:
m/d/y
To:
m/d/y
-

+

- -
- diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 93053e1ee..9d9fffb16 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -1,24 +1,51 @@ Payment report criteria + + + + - -
-

Payment report criteria

-
-
+ +

Payment report criteria

- Return payments for period
- from m/d/y - to m/d/y -

+ + + + + + + + + + + + + + +
Payments of type: +
From:
m/d/y
To:
m/d/y
+

-
diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index 7bf681b42..55b9e097b 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -1,23 +1,43 @@ Tax Report Criteria - - -
-

Tax Report Criteria

-
-
+ + + + + +

Tax Report Criteria

- Return tax report for period: - from m/d/y - to m/d/y + Return tax report for period: + + + + + + + + + + +
From:
m/d/y
To:
m/d/y
-

+

- -
- -- cgit v1.2.1 From 71eb3c33da045ffdc963b5ad8111af8a8bef878d Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Oct 2003 11:14:30 +0000 Subject: agent browse shows # of active accounts & links to appropriate account search --- httemplate/search/svc_acct.cgi | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index e43f4f79b..0954bf652 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -48,12 +48,23 @@ if ( $query eq 'svcnum' ) { $sortby=\*uid_sort; $orderby = ( $unlinked ? 'AND' : 'WHERE' ). " ${tblname}uid IS NOT NULL ORDER BY ${tblname}uid"; +} elsif ( $query =~ /popnum=(\d+)/ ) { + my $popnum = $1; + $unlinked .= ( $unlinked ? 'AND' : 'WHERE' ). + " popnum = $popnum"; + $sortby=\*username_sort; + $orderby = "ORDER BY ${tblname}username"; } else { $sortby=\*uid_sort; @svc_acct = @{&usernamesearch}; } -if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' ) { + +if ( $query eq 'svcnum' + || $query eq 'username' + || $query eq 'uid' + || $query eq 'popnum' + ) { my $statement = "SELECT COUNT(*) FROM svc_acct $unlinked"; my $sth = dbh->prepare($statement) -- cgit v1.2.1 From 83178acdc79de25f98c3e7eee9a4de1a17eaf9f4 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Oct 2003 11:20:58 +0000 Subject: fix linking to account list per access number --- httemplate/search/svc_acct.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 0954bf652..bbcac30b5 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -48,7 +48,7 @@ if ( $query eq 'svcnum' ) { $sortby=\*uid_sort; $orderby = ( $unlinked ? 'AND' : 'WHERE' ). " ${tblname}uid IS NOT NULL ORDER BY ${tblname}uid"; -} elsif ( $query =~ /popnum=(\d+)/ ) { +} elsif ( $query =~ /^popnum=(\d+)$/ ) { my $popnum = $1; $unlinked .= ( $unlinked ? 'AND' : 'WHERE' ). " popnum = $popnum"; @@ -63,7 +63,7 @@ if ( $query eq 'svcnum' ) { if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' - || $query eq 'popnum' + || $query =~ /^popnum=(\d+)$/ ) { ) { my $statement = "SELECT COUNT(*) FROM svc_acct $unlinked"; -- cgit v1.2.1 From 3ca42bd26b6724fa389c9a3e08d091e65954b616 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Oct 2003 11:22:26 +0000 Subject: typo --- httemplate/search/svc_acct.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index bbcac30b5..cd86031c5 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -63,7 +63,7 @@ if ( $query eq 'svcnum' ) { if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' - || $query =~ /^popnum=(\d+)$/ ) { + || $query =~ /^popnum=(\d+)$/ ) { my $statement = "SELECT COUNT(*) FROM svc_acct $unlinked"; -- cgit v1.2.1 From b144cab922a4c09462f0335e4835a72c985bb56a Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Oct 2003 11:39:19 +0000 Subject: fix URL argument processing for account searches by popnum --- httemplate/search/svc_acct.cgi | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index cd86031c5..e20649cd9 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -48,10 +48,9 @@ if ( $query eq 'svcnum' ) { $sortby=\*uid_sort; $orderby = ( $unlinked ? 'AND' : 'WHERE' ). " ${tblname}uid IS NOT NULL ORDER BY ${tblname}uid"; -} elsif ( $query =~ /^popnum=(\d+)$/ ) { - my $popnum = $1; +} elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { $unlinked .= ( $unlinked ? 'AND' : 'WHERE' ). - " popnum = $popnum"; + " popnum = $1"; $sortby=\*username_sort; $orderby = "ORDER BY ${tblname}username"; } else { @@ -63,7 +62,7 @@ if ( $query eq 'svcnum' ) { if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' - || $query =~ /^popnum=(\d+)$/ + || $cgi->param('popnum') =~ /^(\d+)$/ ) { my $statement = "SELECT COUNT(*) FROM svc_acct $unlinked"; -- cgit v1.2.1 From e4cb834b6ae70167fd95b2c2048d6c2082a07aed Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Oct 2003 12:05:47 +0000 Subject: - put link to main menu on quick payment search page --- httemplate/search/cust_main-quickpay.html | 1 + 1 file changed, 1 insertion(+) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_main-quickpay.html b/httemplate/search/cust_main-quickpay.html index 9f39db914..25d9db36b 100755 --- a/httemplate/search/cust_main-quickpay.html +++ b/httemplate/search/cust_main-quickpay.html @@ -7,6 +7,7 @@ Quick payment entry

+ Main Menu

Search for last name: -- cgit v1.2.1 From 2f38a129b2eab044dce82ff4391f7c1779bdab2f Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 26 Oct 2003 00:39:13 +0000 Subject: payment reports broken down by Visa/MC / Amex / Discover --- httemplate/search/cust_pay.cgi | 38 ++++++++++++++++++++++++++++------ httemplate/search/report_cust_pay.html | 9 +++++--- 2 files changed, 38 insertions(+), 9 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index e4dba01e9..9eab5f82e 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -5,27 +5,53 @@ my @cust_pay; if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { my %search; + my @search; + if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ /^(CARD|CHEK|BILL)$/ + $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ or die "illegal payby ". $cgi->param('payby'); $search{'payby'} = $1; + if ( $3 ) { + if ( $3 eq 'VisaMC' ) { + #avoid posix regexes for portability + push @search, " ( substring(payinfo from 1 for 1) = '4' ". + " OR substring(payinfo from 1 for 2) = '51' ". + " OR substring(payinfo from 1 for 2) = '52' ". + " OR substring(payinfo from 1 for 2) = '53' ". + " OR substring(payinfo from 1 for 2) = '54' ". + " OR substring(payinfo from 1 for 2) = '54' ". + " OR substring(payinfo from 1 for 2) = '55' ". + " ) "; + } elsif ( $3 eq 'Amex' ) { + push @search, " ( substring(payinfo from 1 for 2 ) = '34' ". + " OR substring(payinfo from 1 for 2 ) = '37' ". + " ) "; + } elsif ( $3 eq 'Discover' ) { + push @search, " substring(payinfo from 1 for 4 ) = '6011' "; + } else { + die "unknown card type $3"; + } + } } #false laziness with cust_pkg.cgi - my $range = ''; if ( $cgi->param('beginning') && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { my $beginning = str2time($1); - $range = " WHERE _date >= $beginning "; + push @search, "_date >= $beginning "; } if ( $cgi->param('ending') && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { my $ending = str2time($1) + 86400; - $range .= ( $range ? ' AND ' : ' WHERE ' ). " _date <= $ending "; + push @search, " _date <= $ending "; + } + my $search; + if ( @search ) { + $search = ( scalar(keys %search) ? ' AND ' : ' WHERE ' ). + join(' AND ', @search); } - $range =~ s/^\s*WHERE/ AND/ if scalar(keys %search) ; - @cust_pay = qsearch('cust_pay', \%search, '', $range ); + @cust_pay = qsearch('cust_pay', \%search, '', $search ); $sortby = \*date_sort; diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 9d9fffb16..b8581ba4b 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -15,9 +15,12 @@ Payments of type: -- cgit v1.2.1 From c81ce77af66d49a2aafb4bc6361844748fa00d7e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 26 Oct 2003 17:30:13 +0000 Subject: default quickpay to exact search --- httemplate/search/cust_main-quickpay.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_main-quickpay.html b/httemplate/search/cust_main-quickpay.html index 25d9db36b..d48f1d08f 100755 --- a/httemplate/search/cust_main-quickpay.html +++ b/httemplate/search/cust_main-quickpay.html @@ -13,22 +13,22 @@ Search for last name: using search method:

Search for company: using search methods: -

Note: Fuzzy searching can take a while. Please be patient. +

-- cgit v1.2.1 From de38e11cb5a40c78ef5543f59f6ce968e7fd613b Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Nov 2003 05:48:14 +0000 Subject: add suspended/canceled package browse --- httemplate/search/cust_pkg.cgi | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index f735fbf42..1d54a53f6 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -48,10 +48,21 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } else { my $qual = ''; - if ( $cgi->param('magic') && $cgi->param('magic') eq 'active' ) { + if ( $cgi->param('magic') && + $cgi->param('magic') =~ /^(active|suspended|canceled)$/ + ) { - $qual = 'WHERE ( susp IS NULL OR susp = 0 )'. - ' AND ( cancel IS NULL OR cancel = 0)'; + if ( $cgi->param('magic') eq 'active' ) { + $qual = 'WHERE ( susp IS NULL OR susp = 0 )'. + ' AND ( cancel IS NULL OR cancel = 0)'; + } elsif ( $cgi->param('magic') eq 'suspended' ) { + $qual = 'WHERE susp IS NOT NULL AND susp > 0'. + ' AND ( cancel IS NULL OR cancel = 0)'; + } elsif ( $cgi->param('magic') eq 'canceled' ) { + $qual = 'WHERE cancel IS NOT NULL AND cancel > 0'; + } else { + die "guru meditation #420"; + } $sortby = \*pkgnum_sort; -- cgit v1.2.1 From d9c51bdc266798d01247e0ff72f6d64aefb91a2e Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Nov 2003 05:57:28 +0000 Subject: add suspended/canceled browse, fix the old suspended browse --- httemplate/search/cust_pkg.cgi | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 1d54a53f6..3c3e17864 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -56,10 +56,10 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $qual = 'WHERE ( susp IS NULL OR susp = 0 )'. ' AND ( cancel IS NULL OR cancel = 0)'; } elsif ( $cgi->param('magic') eq 'suspended' ) { - $qual = 'WHERE susp IS NOT NULL AND susp > 0'. + $qual = 'WHERE susp IS NOT NULL AND susp != 0'. ' AND ( cancel IS NULL OR cancel = 0)'; } elsif ( $cgi->param('magic') eq 'canceled' ) { - $qual = 'WHERE cancel IS NOT NULL AND cancel > 0'; + $qual = 'WHERE cancel IS NOT NULL AND cancel != 0'; } else { die "guru meditation #420"; } @@ -74,12 +74,6 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $sortby=\*pkgnum_sort; - } elsif ( $query eq 'SUSP_pkgnum' ) { - - $sortby=\*pkgnum_sort; - - $qual = 'WHERE susp IS NOT NULL AND susp != 0'; - } elsif ( $query eq 'APKG_pkgnum' ) { $sortby=\*pkgnum_sort; -- cgit v1.2.1 From 3a4b4ab1673766048a33c970f5926b2bf07b535c Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Nov 2003 13:39:29 +0000 Subject: "current receivables" -> A/R Aging summary --- httemplate/search/report_receivables.cgi | 191 +++++++++++++++++++++++++++++-- 1 file changed, 181 insertions(+), 10 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index fdd3779a9..241ca581c 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -1,19 +1,190 @@ <% + my $sql = < extract(epoch from now())-2592000 + and cust_main.custnum = cust_bill.custnum + ) + ,0 + ) as owed_0_30, -print '
';
-while() {
-  print $_;
-}
-print '
'; + coalesce( + ( select sum( charged + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) -print ''; + ) + from cust_bill + where cust_bill._date > extract(epoch from now())-5184000 + and cust_bill._date <= extract(epoch from now())-2592000 + and cust_main.custnum = cust_bill.custnum + ) + ,0 + ) as owed_30_60, -%> + coalesce( + ( select sum( charged + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + + ) + from cust_bill + where cust_bill._date > extract(epoch from now())-7776000 + and cust_bill._date <= extract(epoch from now())-5184000 + and cust_main.custnum = cust_bill.custnum + ) + ,0 + ) as owed_60_90, + + coalesce( + ( select sum( charged + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + + ) + from cust_bill + where cust_bill._date <= extract(epoch from now())-7776000 + and cust_main.custnum = cust_bill.custnum + ) + ,0 + ) as owed_90_plus, + + coalesce( + ( select sum( charged + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + + ) + from cust_bill + where cust_main.custnum = cust_bill.custnum + ) + ,0 + ) as owed_total + +from cust_main + +where 0 < + coalesce( + ( select sum( charged + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + - coalesce( + ( select sum(amount) from cust_bill_pay + where cust_bill.invnum = cust_bill_pay.invnum ) + ,0 + ) + + ) + from cust_bill + where cust_main.custnum = cust_bill.custnum + ) + ,0 + ) +order by company, last + +END + + + #order by! + + #the grep (and the sort ) should be pushed down to SQL + #my @cust_main = sort { $a->company cmp $b->company + # || $a->last cmp $b->last } + # grep { $_->balance } + # qsearch('cust_main', {} ); + + my $totals_table = table(). 'Total'. + '0-30'. + '30-60'. + '60-90'. + '90+'. + 'total'. + ''; + $totals_table = ''; + + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + +%> +<%= header('Accounts Receivable Aging Summary', menubar( 'Main Menu'=>$p, ) ) %> +<%= $totals_table %> +<%= table() %> + + Customer + 0-30 + 30-60 + 60-90 + 90+ + Total + +<% while ( my $row = $sth->fetchrow_hashref() ) { %> + + <%= $row->{'custnum'} %>: + <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %> + <%= $row->{'last'}. ', '. $row->{'first'} %> + <%= $row->{'company'} ? ')' : '' %> + + $<%= sprintf("%.2f", $row->{'owed_0_30'} ) %> + $<%= sprintf("%.2f", $row->{'owed_30_60'} ) %> + $<%= sprintf("%.2f", $row->{'owed_60_90'} ) %> + $<%= sprintf("%.2f", $row->{'owed_90_plus'} ) %> + $<%= sprintf("%.2f", $row->{'owed_total'} ) %> + +<% } %> + +<%= $totals_table %> + + -- cgit v1.2.1 From 0d83329036f8768c2bc974c3d8713a6089479610 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Nov 2003 13:56:50 +0000 Subject: link to customer, don't show custnum --- httemplate/search/report_receivables.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 241ca581c..9938abdc6 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -172,10 +172,10 @@ END <% while ( my $row = $sth->fetchrow_hashref() ) { %> - <%= $row->{'custnum'} %>: + <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %> <%= $row->{'last'}. ', '. $row->{'first'} %> - <%= $row->{'company'} ? ')' : '' %> + <%= $row->{'company'} ? ')' : '' %> $<%= sprintf("%.2f", $row->{'owed_0_30'} ) %> $<%= sprintf("%.2f", $row->{'owed_30_60'} ) %> -- cgit v1.2.1 From 1203c14b5b34bc848c3176899767a4fbc13f914a Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Nov 2003 14:00:27 +0000 Subject: typo --- httemplate/search/report_receivables.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 9938abdc6..f0274d026 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -172,7 +172,7 @@ END <% while ( my $row = $sth->fetchrow_hashref() ) { %> - + <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %> <%= $row->{'last'}. ', '. $row->{'first'} %> <%= $row->{'company'} ? ')' : '' %> -- cgit v1.2.1 From 5a77da3b812de3d218edc3faba3aefc777e5ca71 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Nov 2003 14:08:14 +0000 Subject: ack! count credits, not payments twice --- httemplate/search/report_receivables.cgi | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index f0274d026..1fd7d03c7 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -12,8 +12,8 @@ select *, ,0 ) - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) + ( select sum(amount) from cust_credit_bill + where cust_bill.invnum = cust_credit_bill.invnum ) ,0 ) @@ -33,8 +33,8 @@ select *, ,0 ) - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) + ( select sum(amount) from cust_credit_bill + where cust_bill.invnum = cust_credit_bill.invnum ) ,0 ) @@ -55,8 +55,8 @@ select *, ,0 ) - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) + ( select sum(amount) from cust_credit_bill + where cust_bill.invnum = cust_credit_bill.invnum ) ,0 ) @@ -77,8 +77,8 @@ select *, ,0 ) - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) + ( select sum(amount) from cust_credit_bill + where cust_bill.invnum = cust_credit_bill.invnum ) ,0 ) @@ -98,8 +98,8 @@ select *, ,0 ) - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) + ( select sum(amount) from cust_credit_bill + where cust_bill.invnum = cust_credit_bill.invnum ) ,0 ) @@ -121,8 +121,8 @@ where 0 < ,0 ) - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) + ( select sum(amount) from cust_credit_bill + where cust_bill.invnum = cust_credit_bill.invnum) ,0 ) -- cgit v1.2.1 From 9d3055def8da004cc1b7c7f9b1ce88da3eca3bba Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Nov 2003 14:45:59 +0000 Subject: add totals & simplify expressions --- httemplate/search/report_receivables.cgi | 147 +++++++++---------------------- 1 file changed, 41 insertions(+), 106 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 1fd7d03c7..d0665164c 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -1,24 +1,25 @@ <% - my $sql = < extract(epoch from now())-2592000 and cust_main.custnum = cust_bill.custnum ) @@ -26,20 +27,7 @@ select *, ) as owed_0_30, coalesce( - ( select sum( charged - - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) - ,0 - ) - - coalesce( - ( select sum(amount) from cust_credit_bill - where cust_bill.invnum = cust_credit_bill.invnum ) - ,0 - ) - - ) - from cust_bill + ( select $charged from cust_bill where cust_bill._date > extract(epoch from now())-5184000 and cust_bill._date <= extract(epoch from now())-2592000 and cust_main.custnum = cust_bill.custnum @@ -48,20 +36,7 @@ select *, ) as owed_30_60, coalesce( - ( select sum( charged - - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) - ,0 - ) - - coalesce( - ( select sum(amount) from cust_credit_bill - where cust_bill.invnum = cust_credit_bill.invnum ) - ,0 - ) - - ) - from cust_bill + ( select $charged from cust_bill where cust_bill._date > extract(epoch from now())-7776000 and cust_bill._date <= extract(epoch from now())-5184000 and cust_main.custnum = cust_bill.custnum @@ -70,20 +45,7 @@ select *, ) as owed_60_90, coalesce( - ( select sum( charged - - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) - ,0 - ) - - coalesce( - ( select sum(amount) from cust_credit_bill - where cust_bill.invnum = cust_credit_bill.invnum ) - ,0 - ) - - ) - from cust_bill + ( select $charged from cust_bill where cust_bill._date <= extract(epoch from now())-7776000 and cust_main.custnum = cust_bill.custnum ) @@ -91,43 +53,19 @@ select *, ) as owed_90_plus, coalesce( - ( select sum( charged - - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) - ,0 - ) - - coalesce( - ( select sum(amount) from cust_credit_bill - where cust_bill.invnum = cust_credit_bill.invnum ) - ,0 - ) - - ) - from cust_bill + ( select $charged from cust_bill where cust_main.custnum = cust_bill.custnum ) ,0 ) as owed_total +END -from cust_main + my $sql = <company cmp $b->company - # || $a->last cmp $b->last } - # grep { $_->balance } - # qsearch('cust_main', {} ); - - my $totals_table = table(). 'Total'. - '0-30'. - '30-60'. - '60-90'. - '90+'. - 'total'. - ''; - $totals_table = ''; + my $total_sql = "select $owed_cols"; my $sth = dbh->prepare($sql) or die dbh->errstr; $sth->execute or die $sth->errstr; + my $total_sth = dbh->prepare($total_sql) or die dbh->errstr; + $total_sth->execute or die $total_sth->errstr; + %> <%= header('Accounts Receivable Aging Summary', menubar( 'Main Menu'=>$p, ) ) %> -<%= $totals_table %> <%= table() %> Customer @@ -184,7 +108,18 @@ END $<%= sprintf("%.2f", $row->{'owed_total'} ) %> <% } %> +<% my $row = $total_sth->fetchrow_hashref(); %> + +   + + + Total + $<%= sprintf("%.2f", $row->{'owed_0_30'} ) %> + $<%= sprintf("%.2f", $row->{'owed_30_60'} ) %> + $<%= sprintf("%.2f", $row->{'owed_60_90'} ) %> + $<%= sprintf("%.2f", $row->{'owed_90_plus'} ) %> + $<%= sprintf("%.2f", $row->{'owed_total'} ) %> + -<%= $totals_table %> -- cgit v1.2.1 From b82db29351ceec512b527f415d91b7b462172a85 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Nov 2003 08:01:23 +0000 Subject: remove spaces between parens and contact name --- httemplate/search/report_receivables.cgi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index d0665164c..60abb12ab 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -97,9 +97,7 @@ END <% while ( my $row = $sth->fetchrow_hashref() ) { %> - <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %> - <%= $row->{'last'}. ', '. $row->{'first'} %> - <%= $row->{'company'} ? ')' : '' %> + <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %><%= $row->{'last'}. ', '. $row->{'first'} %><%= $row->{'company'} ? ')' : '' %> $<%= sprintf("%.2f", $row->{'owed_0_30'} ) %> $<%= sprintf("%.2f", $row->{'owed_30_60'} ) %> -- cgit v1.2.1 From 948d16c8038c5976c71a32b00a1ff3f46f97262e Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 14 Nov 2003 02:52:13 +0000 Subject: sort these case-insensitive --- httemplate/search/report_receivables.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 60abb12ab..587108e33 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -71,7 +71,7 @@ where 0 < ,0 ) -order by company, last +order by lower(company), lower(last) END -- cgit v1.2.1 From 4eec09b9bb69dea116c0f8b5fa81862125aa587c Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 19 Nov 2003 12:21:09 +0000 Subject: fix jscalendar date ifFormat --- httemplate/search/cust_pkg.html | 4 ++-- httemplate/search/report_cc.html | 4 ++-- httemplate/search/report_credit.html | 4 ++-- httemplate/search/report_cust_pay.html | 4 ++-- httemplate/search/report_tax.html | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pkg.html b/httemplate/search/cust_pkg.html index 3d80d51a9..0dad83a2a 100755 --- a/httemplate/search/cust_pkg.html +++ b/httemplate/search/cust_pkg.html @@ -18,7 +18,7 @@ - - - - -

Packages

-
- - Return packages with next bill date:

- - - - - - - - - - - -
From:
m/d/y
To:
m/d/y
-
- -
- - - - diff --git a/httemplate/search/cust_pkg_report.cgi b/httemplate/search/cust_pkg_report.cgi new file mode 100755 index 000000000..b31674540 --- /dev/null +++ b/httemplate/search/cust_pkg_report.cgi @@ -0,0 +1,63 @@ + + + Packages + + + + + + +

Packages

+
+ + Return packages with next bill date:

+ + + + + + + + + + + +<% my %agent_search = dbdef->table('agent')->column('disabled') + ? ( 'disabled' => '' ) : (); + my @agents = qsearch( 'agent', \%agent_search ); + if ( scalar(@agents) == 1 ) { +%> + +<% } else { %> + + + + + +<% } %> +
From:
m/d/y
To:
m/d/y
Agent:
+
+ +
+ + + + -- cgit v1.2.1 From 86794f71a5fec8cbb6ab3a49d9bfe7fdaf21d183 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 9 Jan 2004 22:46:48 +0000 Subject: add customer number --- httemplate/search/report_receivables.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 66928ebbb..ad353a1b3 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -130,7 +130,7 @@ END } %> - + <%= $row->{'custnum'} %>: <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %><%= $row->{'last'}. ', '. $row->{'first'} %><%= $row->{'company'} ? ')' : '' %> <%= $status %> -- cgit v1.2.1 From 0c0cb89fbf23c575cab2cac5519b6051288a7d3f Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 21 Jan 2004 00:04:07 +0000 Subject: don't include the _next_ day, just the full ending day --- httemplate/search/cust_bill_event.cgi | 2 +- httemplate/search/cust_pay.cgi | 2 +- httemplate/search/cust_pkg.cgi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index b76f66b76..ec952ea5b 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -7,7 +7,7 @@ $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; my $beginning = str2time($1) || 0; $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; -my $ending = str2time($1) + 86400; +my $ending = str2time($1) + 86399; my @cust_bill_event = sort { $a->_date <=> $b->_date } diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 9eab5f82e..51dd3b340 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -42,7 +42,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { } if ( $cgi->param('ending') && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $ending = str2time($1) + 86400; + my $ending = str2time($1) + 86399; push @search, " _date <= $ending "; } my $search; diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index c2f6272c4..45420f4c4 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -29,7 +29,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } if ( $cgi->param('ending') && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $ending = str2time($1) + 86400; + my $ending = str2time($1) + 86399; $range .= ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; } -- cgit v1.2.1 From 0cb82fbbb68d51ea51cdc321c6322ab22508373c Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Jan 2004 08:55:10 +0000 Subject: first try at prepaid income report --- httemplate/search/report_prepaid_income.cgi | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 httemplate/search/report_prepaid_income.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/report_prepaid_income.cgi b/httemplate/search/report_prepaid_income.cgi new file mode 100644 index 000000000..f1d284b1a --- /dev/null +++ b/httemplate/search/report_prepaid_income.cgi @@ -0,0 +1,67 @@ + +<% + + #doesn't yet deal with daily/weekly packages + + #needs to be re-written in sql for efficiency + + my $now = time; + + my %prepaid; + + my @cust_bill_pkg = + grep { $_->cust_pkg && $_->cust_pkg->part_pkg->freq !~ /^([01]|\d+[dw])$/ } + qsearch( 'cust_bill_pkg', { + 'recur' => { op=>'!=', value=>0 }, + 'edate' => { op=>'>', value=>$now }, + }, ); + + foreach my $cust_bill_pkg ( @cust_bill_pkg ) { + + #conceptual false laziness w/texas tax exempt_amount stuff in + #FS::cust_main::bill + + my $freq = $cust_bill_pkg->cust_pkg->part_pkg->freq; + my $per_month = sprintf("%.2f", $cust_bill_pkg->recur / $freq); + + my($mon, $year) = (localtime($cust_bill_pkg->sdate) )[4,5]; + $mon+=2; $year+=1900; + + foreach my $which_month ( 2 .. $freq ) { + until ( $mon < 13 ) { $mon -= 12; $year++; } + $prepaid{"$year-$mon"} += $per_month; + } + + } + +%> + +<%= header('Prepaid Income Report', menubar( 'Main Menu'=>$p, ) ) %> +<%= table() %> +<% + + my $total = 0; + + my ($now_mon, $now_year) = (localtime($now))[4,5]; + $now_mon+=2; $now_year+=1900; + until ( $now_mon < 13 ) { $now_mon -= 12; $now_year++; } + + my $subseq = 0; + for my $year ( $now_year .. 2037 ) { + for my $mon ( ( $subseq++ ? 1 : $now_mon ) .. 12 ) { + if ( $prepaid{"$year-$mon"} ) { + $total += $prepaid{"$year-$mon"}; + %> <%= "$year-$mon" %> + <%= sprintf("%.2f", $prepaid{"$year-$mon"} ) %> + + <% + } + } + + } + +%> +Total<%= sprintf("%.2f", $total) %> + + + -- cgit v1.2.1 From 55de0fac57f2a71bd05aa5ce583601fb2edeacdf Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Jan 2004 08:58:35 +0000 Subject: oops --- httemplate/search/report_prepaid_income.cgi | 1 + 1 file changed, 1 insertion(+) (limited to 'httemplate/search') diff --git a/httemplate/search/report_prepaid_income.cgi b/httemplate/search/report_prepaid_income.cgi index f1d284b1a..bcad93325 100644 --- a/httemplate/search/report_prepaid_income.cgi +++ b/httemplate/search/report_prepaid_income.cgi @@ -30,6 +30,7 @@ foreach my $which_month ( 2 .. $freq ) { until ( $mon < 13 ) { $mon -= 12; $year++; } $prepaid{"$year-$mon"} += $per_month; + $mon++; } } -- cgit v1.2.1 From c9544281f45155587a54aa435500887d74e5c9f5 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Jan 2004 09:04:00 +0000 Subject: tidy up look --- httemplate/search/report_prepaid_income.cgi | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_prepaid_income.cgi b/httemplate/search/report_prepaid_income.cgi index bcad93325..9f045738a 100644 --- a/httemplate/search/report_prepaid_income.cgi +++ b/httemplate/search/report_prepaid_income.cgi @@ -35,6 +35,8 @@ } + my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); + %> <%= header('Prepaid Income Report', menubar( 'Main Menu'=>$p, ) ) %> @@ -52,8 +54,10 @@ for my $mon ( ( $subseq++ ? 1 : $now_mon ) .. 12 ) { if ( $prepaid{"$year-$mon"} ) { $total += $prepaid{"$year-$mon"}; - %> <%= "$year-$mon" %> - <%= sprintf("%.2f", $prepaid{"$year-$mon"} ) %> + %> <%= $mon[$mon-1]. ' '. $year %> + + <%= sprintf("%.2f", $prepaid{"$year-$mon"} ) %> + <% } @@ -62,7 +66,7 @@ } %> -Total<%= sprintf("%.2f", $total) %> +Total<%= sprintf("%.2f", $total) %> -- cgit v1.2.1 From ff15db0f2fa18e67498d0097797b667a81b51f71 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Jan 2004 11:20:43 +0000 Subject: add prepaid income to main menu and allow arbitrary dates --- httemplate/search/report_prepaid_income.cgi | 9 ++++++--- httemplate/search/report_prepaid_income.html | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 httemplate/search/report_prepaid_income.html (limited to 'httemplate/search') diff --git a/httemplate/search/report_prepaid_income.cgi b/httemplate/search/report_prepaid_income.cgi index 9f045738a..eb8bbb55e 100644 --- a/httemplate/search/report_prepaid_income.cgi +++ b/httemplate/search/report_prepaid_income.cgi @@ -5,7 +5,9 @@ #needs to be re-written in sql for efficiency - my $now = time; + my $now = $cgi->param('date') && str2time($cgi->param('date')) || time; + $now =~ /^(\d+)$/ or die "unparsable date?"; + $now = $1; my %prepaid; @@ -39,7 +41,8 @@ %> -<%= header('Prepaid Income Report', menubar( 'Main Menu'=>$p, ) ) %> +<%= header( 'Prepaid Income (Unearned Revenue) Report', + menubar( 'Main Menu'=>$p, ) ) %> <%= table() %> <% @@ -54,7 +57,7 @@ for my $mon ( ( $subseq++ ? 1 : $now_mon ) .. 12 ) { if ( $prepaid{"$year-$mon"} ) { $total += $prepaid{"$year-$mon"}; - %> <%= $mon[$mon-1]. ' '. $year %> + %> <%= $mon[$mon-1]. ' '. $year %> <%= sprintf("%.2f", $prepaid{"$year-$mon"} ) %> diff --git a/httemplate/search/report_prepaid_income.html b/httemplate/search/report_prepaid_income.html new file mode 100644 index 000000000..b85a481be --- /dev/null +++ b/httemplate/search/report_prepaid_income.html @@ -0,0 +1,17 @@ + + + Prepaid Income (Unearned Revenue) Report + + + + + + +

Prepaid Income (Unearned Revenue) Report

+
+ Prepaid income (unearned revenue) as of + + + + + -- cgit v1.2.1 From bb6dfc07af5c7fee85f2c76ee22a833b41e13c36 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 28 Jan 2004 01:39:07 +0000 Subject: add service definition browse by number of active services --- httemplate/search/svc_acct.cgi | 8 +++++++- httemplate/search/svc_domain.cgi | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index e20649cd9..671575b55 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -46,13 +46,19 @@ if ( $query eq 'svcnum' ) { $orderby = "ORDER BY ${tblname}username"; } elsif ( $query eq 'uid' ) { $sortby=\*uid_sort; - $orderby = ( $unlinked ? 'AND' : 'WHERE' ). + $orderby = ( $unlinked ? ' AND' : ' WHERE' ). " ${tblname}uid IS NOT NULL ORDER BY ${tblname}uid"; } elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { $unlinked .= ( $unlinked ? 'AND' : 'WHERE' ). " popnum = $1"; $sortby=\*username_sort; $orderby = "ORDER BY ${tblname}username"; +} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { + $unlinked .= ( $unlinked ? ' AND' : ' WHERE' ). + " $1 = ( SELECT svcpart FROM cust_svc ". + " WHERE cust_svc.svcnum = svc_acct.svcnum ) "; + $sortby=\*uid_sort; + #$sortby=\*svcnum_sort; } else { $sortby=\*uid_sort; @svc_acct = @{&usernamesearch}; diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index c0acf1143..948b1d9ae 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -23,6 +23,13 @@ if ( $query eq 'svcnum' ) { 'svcnum' => $_->svcnum, 'pkgnum' => '', }), qsearch('svc_domain',{}); +} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { + @svc_domain = + qsearch( 'svc_domain', {}, '', + " WHERE $1 = ( SELECT svcpart FROM cust_svc ". + " WHERE cust_svc.svcnum = svc_domain.svcnum ) " + ); + $sortby=\*svcnum_sort; } else { $cgi->param('domain') =~ /^([\w\-\.]+)$/; my($domain)=$1; -- cgit v1.2.1 From c4ff840a85e33c86ecad9223d074d57cba50e0f9 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 28 Jan 2004 01:45:31 +0000 Subject: fix link from service definition browse to services --- httemplate/search/svc_acct.cgi | 1 + 1 file changed, 1 insertion(+) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 671575b55..1e4a03d84 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -69,6 +69,7 @@ if ( $query eq 'svcnum' || $query eq 'username' || $query eq 'uid' || $cgi->param('popnum') =~ /^(\d+)$/ + || $cgi->param('svcpart') =~ /^(\d+)$/ ) { my $statement = "SELECT COUNT(*) FROM svc_acct $unlinked"; -- cgit v1.2.1 From ecf57b84d7a29c9bebac62eb5ebf178332163fd9 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 13 Feb 2004 11:28:07 +0000 Subject: add mail alias browse to main menu and fix mail alias view to recognize new schema also --- httemplate/search/svc_forward.cgi | 79 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 httemplate/search/svc_forward.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi new file mode 100755 index 000000000..10094bc99 --- /dev/null +++ b/httemplate/search/svc_forward.cgi @@ -0,0 +1,79 @@ +<% + +my $conf = new FS::Conf; + +my($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors +my(@svc_forward,$sortby); +if ( $query eq 'svcnum' ) { + $sortby=\*svcnum_sort; + @svc_forward=qsearch('svc_forward',{}); +} else { + eidiot('unimplemented'); +} + +if ( scalar(@svc_forward) == 1 ) { + print $cgi->redirect(popurl(2). "view/svc_forward.cgi?". $svc_forward[0]->svcnum); + #exit; +} elsif ( scalar(@svc_forward) == 0 ) { +%> + +<% + eidiot "No matching forwards found!\n"; +} else { +%> + +<% + my $total = scalar(@svc_forward); + print header("Mail forward Search Results",''), < + + + + + +END + + foreach my $svc_forward ( + sort $sortby (@svc_forward) + ) { + my $svcnum = $svc_forward->svcnum; + + my $src = $svc_forward->src; + $src = "(anything)$src" if $src =~ /^@/; + if ( $svc_forward->srcsvc_acct ) { + $src = qq!'. + $svc_forward->srcsvc_acct->email. ''; + } + + my $dst = $svc_forward->dst; + if ( $svc_forward->dstsvc_acct ) { + $dst = qq!'. + $svc_forward->dstsvc_acct->email. ''; + } + + print < + + + + +END + + } + + print < + + +END + +} + +sub svcnum_sort { + $a->getfield('svcnum') <=> $b->getfield('svcnum'); +} + +%> -- 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 +- httemplate/search/cust_pkg.cgi | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'httemplate/search') 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; diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 45420f4c4..6d26317e0 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -175,8 +175,8 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } if ( scalar(@cust_pkg) == 1 ) { - my($pkgnum)=$cust_pkg[0]->pkgnum; - print $cgi->redirect(popurl(2). "view/cust_pkg.cgi?$pkgnum"); + print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum. + "#cust_pkg". $cust_pkg[0]->pkgnum ); #exit; } elsif ( scalar(@cust_pkg) == 0 ) { #error %> @@ -300,7 +300,7 @@ END my $rowspan = scalar(@cust_svc) || 1; my $p = popurl(2); print $n1, <$pkgnum - $pkg + END -- cgit v1.2.1 From cec266740d89b82ce9075954928c5b336d0ec18e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Mar 2004 00:06:08 +0000 Subject: fix sorting of NULL companies differently than empty companies --- httemplate/search/report_receivables.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index ad353a1b3..0e95ad73c 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -93,7 +93,7 @@ where 0 < ,0 ) -order by lower(company), lower(last) +order by coalesce(lower(company), ''), lower(last) END -- cgit v1.2.1 From 6211a2be71abf13187aaf10f3923ba377ae4c73e Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 3 Apr 2004 00:45:38 +0000 Subject: UI: stop making things small for no reason --- httemplate/search/cust_bill.cgi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 985e3dbf5..5b0538ca3 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -125,10 +125,10 @@ END my $view = popurl(2). "view/cust_bill.cgi?$invnum"; print < - - - - + + + + END my $custnum = $cust_bill->custnum; my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); @@ -139,8 +139,8 @@ END $cust_main->company, ); print <$name - + + END } else { print <$pager
". table(). <
- + +
Service #
(click to view forward)
Mail to
(click to view account)
Forwards to
(click to view account)
$svcnum$src$dst
$pkgnum - $pkg $setup$invnum\$$owed\$$charged$pdate$invnum\$$owed\$$charged$pdate$company$name$company       Total
Balance
Total
Amount
\$$tot_balance\$$tot_amount
       Total
Balance
Total
Amount
\$$tot_balance\$$tot_amount
-- cgit v1.2.1 From 76e907f24d984319b7c1e0e9374b99535a99ab43 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 11 Apr 2004 01:50:47 +0000 Subject: update unearned revenue report based on feedback from kevin --- httemplate/search/report_prepaid_income.cgi | 91 ++++++++++++++++------------ httemplate/search/report_prepaid_income.html | 24 +++++++- 2 files changed, 74 insertions(+), 41 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_prepaid_income.cgi b/httemplate/search/report_prepaid_income.cgi index eb8bbb55e..1677591a3 100644 --- a/httemplate/search/report_prepaid_income.cgi +++ b/httemplate/search/report_prepaid_income.cgi @@ -5,11 +5,13 @@ #needs to be re-written in sql for efficiency - my $now = $cgi->param('date') && str2time($cgi->param('date')) || time; + my $time = time; + + my $now = $cgi->param('date') && str2time($cgi->param('date')) || $time; $now =~ /^(\d+)$/ or die "unparsable date?"; $now = $1; - my %prepaid; + my( $total, $total_legacy ) = ( 0, 0 ); my @cust_bill_pkg = grep { $_->cust_pkg && $_->cust_pkg->part_pkg->freq !~ /^([01]|\d+[dw])$/ } @@ -18,58 +20,67 @@ 'edate' => { op=>'>', value=>$now }, }, ); - foreach my $cust_bill_pkg ( @cust_bill_pkg ) { + my @cust_pkg = + grep { $_->part_pkg->recur != 0 + && $_->part_pkg->freq !~ /^([01]|\d+[dw])$/ + } + qsearch ( 'cust_pkg', { + 'bill' => { op=>'>', value=>$now } + } ); - #conceptual false laziness w/texas tax exempt_amount stuff in - #FS::cust_main::bill + foreach my $cust_bill_pkg ( @cust_bill_pkg) { + my $period = $cust_bill_pkg->edate - $cust_bill_pkg->sdate; - my $freq = $cust_bill_pkg->cust_pkg->part_pkg->freq; - my $per_month = sprintf("%.2f", $cust_bill_pkg->recur / $freq); + my $elapsed = $now - $cust_bill_pkg->sdate; + $elapsed = 0 if $elapsed < 0; - my($mon, $year) = (localtime($cust_bill_pkg->sdate) )[4,5]; - $mon+=2; $year+=1900; + my $remaining = 1 - $elapsed/$period; - foreach my $which_month ( 2 .. $freq ) { - until ( $mon < 13 ) { $mon -= 12; $year++; } - $prepaid{"$year-$mon"} += $per_month; - $mon++; - } + my $unearned = $remaining * $cust_bill_pkg->recur; + $total += $unearned; } - my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); + foreach my $cust_pkg ( @cust_pkg ) { + my $period = $cust_pkg->bill - $cust_pkg->last_bill; -%> + my $elapsed = $now - $cust_pkg->last_bill; + $elapsed = 0 if $elapsed < 0; -<%= header( 'Prepaid Income (Unearned Revenue) Report', - menubar( 'Main Menu'=>$p, ) ) %> -<%= table() %> -<% + my $remaining = 1 - $elapsed/$period; - my $total = 0; - - my ($now_mon, $now_year) = (localtime($now))[4,5]; - $now_mon+=2; $now_year+=1900; - until ( $now_mon < 13 ) { $now_mon -= 12; $now_year++; } - - my $subseq = 0; - for my $year ( $now_year .. 2037 ) { - for my $mon ( ( $subseq++ ? 1 : $now_mon ) .. 12 ) { - if ( $prepaid{"$year-$mon"} ) { - $total += $prepaid{"$year-$mon"}; - %> <%= $mon[$mon-1]. ' '. $year %> - - <%= sprintf("%.2f", $prepaid{"$year-$mon"} ) %> - - - <% - } - } + my $unearned = $remaining * $cust_pkg->part_pkg->recur; #!! only works for flat/legacy + $total_legacy += $unearned; } + $total = sprintf('%.2f', $total); + $total_legacy = sprintf('%.2f', $total_legacy); + %> -Total<%= sprintf("%.2f", $total) %> + +<%= header( 'Prepaid Income (Unearned Revenue) Report', + menubar( 'Main Menu'=>$p, ) ) %> +<%= table() %> + + Actual Unearned Revenue + Legacy Unearned Revenue + + + $<%= $total %> + + <%= $now == $time ? "\$$total_legacy" : 'N/A'%> + + + +
+Actual unearned revenue is the amount of unearned revenue Freeside has +actually invoiced for packages with longer-than monthly terms. +

+Legacy unearned revenue is the amount of unearned revenue represented by +customer packages. This number may be larger than actual unearned +revenue if you have imported longer-than monthly customer packages from +a previous billing system. diff --git a/httemplate/search/report_prepaid_income.html b/httemplate/search/report_prepaid_income.html index b85a481be..e8b6ac4b1 100644 --- a/httemplate/search/report_prepaid_income.html +++ b/httemplate/search/report_prepaid_income.html @@ -9,7 +9,29 @@

Prepaid Income (Unearned Revenue) Report

- Prepaid income (unearned revenue) as of + + + + + + + + + +
Prepaid income (unearned revenue) as of + + +
+ m/d/y
+ + -- cgit v1.2.1 From 47208f7694a6ec1cb979d7d0da7848dfe0e0aa7b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 22 Apr 2004 07:07:30 +0000 Subject: initial copy from report_cust_pay.html --- httemplate/search/report_cust_credit.html | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 httemplate/search/report_cust_credit.html (limited to 'httemplate/search') diff --git a/httemplate/search/report_cust_credit.html b/httemplate/search/report_cust_credit.html new file mode 100644 index 000000000..1b30685dc --- /dev/null +++ b/httemplate/search/report_cust_credit.html @@ -0,0 +1,54 @@ + + + Payment report criteria + + + + + + +

Payment report criteria

+ + + + + + + + + + + + + + + + +
Payments of type: +
From:
m/d/y
To:
m/d/y
+
+ + + -- cgit v1.2.1 From 5cd995865b91204f7ce9233a8ba4d5eee62f9be4 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Apr 2004 02:32:38 +0000 Subject: working templated invoice search! --- httemplate/search/cust_bill.html | 94 ++++++++++++++++++++++++++++------ httemplate/search/elements/search.html | 86 +++++++++++++++++++++++++------ httemplate/search/sql.html | 7 +-- 3 files changed, 149 insertions(+), 38 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 36e8bc91b..51241575c 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -1,19 +1,81 @@ - - - Invoice Search - - - - Invoice Search - -

-
- Search for invoice #: - +<% + my( $count_query, $sql_query ); + if ( $cgi->keywords ) { + my($query) = $cgi->keywords; + my $owed = + "charged - ( SELECT COALESCE(SUM(amount),0) FROM cust_bill_pay + WHERE cust_bill_pay.invnum = cust_bill.invnum ) + - ( SELECT COALESCE(SUM(amount),0) FROM cust_credit_bill + WHERE cust_credit_bill.invnum = cust_bill.invnum )"; + my @where; + my $orderby = ''; + if ( $query =~ /^(OPEN(\d*)_)?(invnum|date|custnum)$/ ) { + my($open, $days, $field) = ($1, $2, $3); + $field = "_date" if $field eq 'date'; + $orderby = "ORDER BY cust_bill.$field"; + push @where, "0 != $owed" if $open; + push @where, "cust_bill._date < ". (time-86400*$days) if $days; + } else { + die "unknown query string $query"; + } + + my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; + + $count_query = "SELECT COUNT(*), sum(charged), sum($owed) + FROM cust_bill $extra_sql"; + + $sql_query = { + 'table' => 'cust_bill', + 'hashref' => {}, + 'select' => "cust_bill.*, $owed as owed", + 'extra_sql' => "$extra_sql $orderby" + }; + + } else { + $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; + $count_query = 'SELECT 1'; + $sql_query = { + 'table' => 'cust_bill', + 'hashref' => { 'invnum' => $2 }, + #'select' => '*', + }; + } -

+ my $link = [ "${p}view/cust_bill.cgi?", 'invnum', ]; + my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; -

- - +%> +<%= include( 'elements/search.html', + 'title' => 'Invoice Search Results', + 'name' => 'invoices', + 'query' => $sql_query, + 'count_query' => $count_query, + 'count_addl' => [ '$%.2f total amount', + '$%.2f total outstanding balance', + ], + 'redirect' => $link, + 'header' => + [ '', qw(Balance Amount Date ), 'Contact name', 'Company' ], + 'fields' => [ + 'invnum', + sub { sprintf('$%.2f', shift->get('owed') ) }, + sub { sprintf('$%.2f', shift->charged ) }, + sub { time2str('%b %d %Y', shift->_date ) }, + sub { my $cust_main = shift->cust_main; + $cust_main->get('last'). ', '. $cust_main->first; + }, + sub { my $cust_main = shift->cust_main; + $cust_main->company; + }, + ], + 'links' => [ + $link, + $link, + $link, + $link, + $clink, + $clink, + ], + ) +%> diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index fbedcaa26..37a3718ce 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -1,9 +1,14 @@ <% - my %opt = @_; + my(%opt) = @_; + + if ( ref($opt{'query'}) ) { + + } + unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { ( $opt{'count_query'} = $opt{'query'} ) =~ - s/^\s*SELECT\s*(.*)\s+FROM\s/SELECT COUNT(*) FROM /i; + s/^\s*SELECT\s*(.*?)\s+FROM\s/SELECT COUNT(*) FROM /i; } my $conf = new FS::Conf; @@ -18,18 +23,43 @@ or die "Error preparing $opt{'count_query'}: ". dbh->errstr; $count_sth->execute or die "Error executing $opt{'count_query'}: ". $count_sth->errstr; - my $total = $count_sth->fetchrow_arrayref->[0]; + my $count_arrayref = $count_sth->fetchrow_arrayref; + my $total = $count_arrayref->[0]; + + #warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n"; - my $sth = dbh->prepare("$opt{'query'} $limit") - or die "Error preparing $opt{'query'}: ". dbh->errstr; - $sth->execute - or die "Error executing $opt{'query'}: ". $sth->errstr; + my $header = $opt{'header'}; + my $rows; + if ( ref($opt{'query'}) ) { + #eval "use FS::$opt{'query'};"; + $rows = [ qsearch( + $opt{'query'}->{'table'}, + $opt{'query'}->{'hashref'} || {}, + $opt{'query'}->{'select'}, + $opt{'query'}->{'extra_sql'}. " $limit", + ) ]; + } else { + my $sth = dbh->prepare("$opt{'query'} $limit") + or die "Error preparing $opt{'query'}: ". dbh->errstr; + $sth->execute + or die "Error executing $opt{'query'}: ". $sth->errstr; - #can get # of rows without fetching them all? - my $rows = $sth->fetchall_arrayref; + #can get # of rows without fetching them all? + $rows = $sth->fetchall_arrayref; + $header ||= $sth->{NAME}; + } + + if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 ) { + my( $url, $method ) = @{$opt{'redirect'}}; + redirect( $url. $rows->[0]->$method() ); + } else { + +%> +<%= include( '/elements/header.html', $opt{'title'}, + include( '/elements/menubar.html', 'Main menu' => $p ) + ) %> - <% my $pager = include ( '/elements/pager.html', 'offset' => $offset, 'num_rows' => scalar(@$rows), @@ -37,18 +67,41 @@ 'maxrecords' => $maxrecords, ); %> - -<%= $total %> total <%= $opt{'name'} %>

<%= $pager %> +<%= $total %> total <%= $opt{'name'} %>
+<% if ( $opt{'count_addl'} ) { %> + <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %> + <%= sprintf( $count, $count_arrayref->[++$n] ) %>
+ <% } %> +<% } %> +
<%= $pager %> <%= include( '/elements/table.html' ) %> - <% foreach ( @{$sth->{NAME}} ) { %> - <%= $_ %> + <% foreach my $header ( @$header ) { %> + <%= $header %> <% } %> <% foreach my $row ( @$rows ) { %> - <% foreach ( @$row ) { %> - <%= $_ %> + <% if ( $opt{'fields'} ) { %> + <% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; %> + <% foreach my $field ( @{$opt{'fields'}} ) { %> + <% my $a = ''; %> + <% if ( $links ) { + my( $url, $method ) = @{shift @$links}; + $a = $url. $row->$method(); + $a = qq(); + } + %> + <% if ( ref($field) eq 'CODE' ) { %> + <%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %> + <% } else { %> + <%= $a %><%= $row->$field() %><%= $a ? '' : '' %> + <% } %> + <% } %> + <% } else { %> + <% foreach ( @$row ) { %> + <%= $_ %> + <% } %> <% } %> <% } %> @@ -57,3 +110,4 @@ <%= $pager %> +<% } %> diff --git a/httemplate/search/sql.html b/httemplate/search/sql.html index 7d7fc0890..b28c045d1 100644 --- a/httemplate/search/sql.html +++ b/httemplate/search/sql.html @@ -1,12 +1,7 @@ -<%= include( '/elements/header.html', 'Query Results', - include( '/elements/menubar.html', 'Main Menu' => $p ) - ) -%> - <%= include( 'elements/search.html', + 'title' => 'Query Results', 'name' => 'rows', 'query' => 'SELECT '. ( $cgi->param('sql') || eidiot('Empty query') ), ) %> - -- cgit v1.2.1 From 87227cd405166484ca7b791b2bd3c8829ce8d969 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Apr 2004 12:19:40 +0000 Subject: credit report, add some links to sales/credits/receipts summary, move payment search to template --- httemplate/search/cust_bill.html | 23 ++- httemplate/search/cust_credit.html | 76 ++++++++ httemplate/search/cust_pay.cgi | 310 +++++++++++++----------------- httemplate/search/elements/search.html | 17 +- httemplate/search/report_cust_credit.html | 25 +-- 5 files changed, 247 insertions(+), 204 deletions(-) create mode 100755 httemplate/search/cust_credit.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 51241575c..27b147108 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -1,22 +1,30 @@ <% my( $count_query, $sql_query ); - if ( $cgi->keywords ) { - my($query) = $cgi->keywords; + if ( $cgi->param('begin') || $cgi->param('end') || $cgi->keywords ) { + my $owed = "charged - ( SELECT COALESCE(SUM(amount),0) FROM cust_bill_pay WHERE cust_bill_pay.invnum = cust_bill.invnum ) - ( SELECT COALESCE(SUM(amount),0) FROM cust_credit_bill WHERE cust_credit_bill.invnum = cust_bill.invnum )"; + my @where; - my $orderby = ''; + my $orderby = 'ORDER BY cust_bill._date'; + + if ( $cgi->param('begin') =~ /^(\d+)$/ ) { + push @where, "cust_bill._date >= $1", + } + if ( $cgi->param('end') =~ /^(\d+)$/ ) { + push @where, "cust_bill._date < $1", + } + + my($query) = $cgi->keywords; if ( $query =~ /^(OPEN(\d*)_)?(invnum|date|custnum)$/ ) { my($open, $days, $field) = ($1, $2, $3); $field = "_date" if $field eq 'date'; $orderby = "ORDER BY cust_bill.$field"; push @where, "0 != $owed" if $open; push @where, "cust_bill._date < ". (time-86400*$days) if $days; - } else { - die "unknown query string $query"; } my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; @@ -50,12 +58,13 @@ 'name' => 'invoices', 'query' => $sql_query, 'count_query' => $count_query, - 'count_addl' => [ '$%.2f total amount', + 'count_addl' => [ '$%.2f total invoiced', '$%.2f total outstanding balance', ], 'redirect' => $link, 'header' => - [ '', qw(Balance Amount Date ), 'Contact name', 'Company' ], + [ 'Invoice #', qw(Balance Amount Date), 'Contact name', + 'Company' ], 'fields' => [ 'invnum', sub { sprintf('$%.2f', shift->get('owed') ) }, diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html new file mode 100755 index 000000000..c46caba13 --- /dev/null +++ b/httemplate/search/cust_credit.html @@ -0,0 +1,76 @@ +<% + #my( $count_query, $sql_query ); + + my @search = (); + + if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) { + push @search, "otaker = '$1'"; + } + + #false laziness with cust_pkg.cgi and cust_pay.cgi + if ( $cgi->param('beginning') + && $cgi->param('beginning') =~ /^([ 0-9\-\/]{1,10})$/ ) { + my $beginning = str2time($1); + push @search, "_date >= $beginning "; + } + if ( $cgi->param('ending') + && $cgi->param('ending') =~ /^([ 0-9\-\/]{1,10})$/ ) { + my $ending = str2time($1) + 86399; + push @search, " _date <= $ending "; + } + + if ( $cgi->param('begin') + && $cgi->param('begin') =~ /^(\d+)$/ ) { + push @search, "_date >= $1 "; + } + if ( $cgi->param('end') + && $cgi->param('end') =~ /^(\d+)$/ ) { + push @search, " _date < $1 "; + } + + my $where = scalar(@search) + ? 'WHERE '. join(' AND ', @search) + : ''; + + my $count_query = "SELECT COUNT(*), SUM(amount) FROM cust_credit $where"; + my $sql_query = { + 'table' => 'cust_credit', + 'hashref' => {}, + 'extra_sql' => $where, + }; + + my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; + +%> +<%= include( 'elements/search.html', + 'title' => 'Credit Search Results', + 'name' => 'credits', + 'query' => $sql_query, + 'count_query' => $count_query, + 'count_addl' => [ '$%.2f total credited', ], + #'redirect' => $link, + 'header' => + [ qw(Amount Date), 'Contact name', qw(Company By Reason) ], + 'fields' => [ + #'crednum', + sub { sprintf('$%.2f', shift->amount ) }, + sub { time2str('%b %d %Y', shift->_date ) }, + sub { my $cust_main = shift->cust_main; + $cust_main->get('last'). ', '. $cust_main->first; + }, + sub { my $cust_main = shift->cust_main; + $cust_main->company; + }, + 'otaker', + 'reason', + ], + 'links' => [ + '', + '', + $clink, + $clink, + '', + '', + ], + ) +%> diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 51dd3b340..ba2bc63f0 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,185 +1,133 @@ <% + my( $count_query, $sql_query ); + if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { + + my %search; + my @search; + + if ( $cgi->param('payby') ) { + $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ + or die "illegal payby ". $cgi->param('payby'); + $search{'payby'} = $1; + if ( $3 ) { + if ( $3 eq 'VisaMC' ) { + #avoid posix regexes for portability + push @search, " ( substring(payinfo from 1 for 1) = '4' ". + " OR substring(payinfo from 1 for 2) = '51' ". + " OR substring(payinfo from 1 for 2) = '52' ". + " OR substring(payinfo from 1 for 2) = '53' ". + " OR substring(payinfo from 1 for 2) = '54' ". + " OR substring(payinfo from 1 for 2) = '54' ". + " OR substring(payinfo from 1 for 2) = '55' ". + " ) "; + } elsif ( $3 eq 'Amex' ) { + push @search, " ( substring(payinfo from 1 for 2 ) = '34' ". + " OR substring(payinfo from 1 for 2 ) = '37' ". + " ) "; + } elsif ( $3 eq 'Discover' ) { + push @search, " substring(payinfo from 1 for 4 ) = '6011' "; + } else { + die "unknown card type $3"; + } + } + } + + #false laziness with cust_pkg.cgi + if ( $cgi->param('beginning') + && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $beginning = str2time($1); + push @search, "_date >= $beginning "; + } + if ( $cgi->param('ending') + && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $ending = str2time($1) + 86399; + push @search, " _date <= $ending "; + } + if ( $cgi->param('begin') + && $cgi->param('begin') =~ /^(\d+)$/ ) { + push @search, "_date >= $1 "; + } + if ( $cgi->param('end') + && $cgi->param('end') =~ /^(\d+)$/ ) { + push @search, " _date < $1 "; + } + + my $search; + if ( @search ) { + $search = ( scalar(keys %search) ? ' AND ' : ' WHERE ' ). + join(' AND ', @search); + } + + my $hsearch = join(' AND ', map { "$_ = '$search{$_}'" } keys %search ); + $count_query = "SELECT COUNT(*), SUM(paid) FROM cust_pay ". + ( $hsearch ? " WHERE $hsearch " : '' ). + $search; + + $sql_query = { + 'table' => 'cust_pay', + 'hashref' => \%search, + 'extra_sql' => "$search ORDER BY _date", + }; + + } else { + + $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; + my $payinfo = $1; + + $cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; + my $payby = $1; + + $count_query = "SELECT COUNT(*), SUM(paid) FROM cust_pay ". + "WHERE payinfo = '$payinfo' AND payby = '$payby'"; + + $sql_query = { + 'table' => 'cust_pay', + 'hashref' => { 'payinfo' => $payinfo, + 'payby' => $payby }, + 'extra_sql' => "ORDER BY _date", + }; + + } + + my $link = [ "${p}view/cust_main.cgi?", 'custnum' ]; -my $sortby; -my @cust_pay; -if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { - - my %search; - my @search; - - if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ - or die "illegal payby ". $cgi->param('payby'); - $search{'payby'} = $1; - if ( $3 ) { - if ( $3 eq 'VisaMC' ) { - #avoid posix regexes for portability - push @search, " ( substring(payinfo from 1 for 1) = '4' ". - " OR substring(payinfo from 1 for 2) = '51' ". - " OR substring(payinfo from 1 for 2) = '52' ". - " OR substring(payinfo from 1 for 2) = '53' ". - " OR substring(payinfo from 1 for 2) = '54' ". - " OR substring(payinfo from 1 for 2) = '54' ". - " OR substring(payinfo from 1 for 2) = '55' ". - " ) "; - } elsif ( $3 eq 'Amex' ) { - push @search, " ( substring(payinfo from 1 for 2 ) = '34' ". - " OR substring(payinfo from 1 for 2 ) = '37' ". - " ) "; - } elsif ( $3 eq 'Discover' ) { - push @search, " substring(payinfo from 1 for 4 ) = '6011' "; - } else { - die "unknown card type $3"; - } - } - } - - #false laziness with cust_pkg.cgi - if ( $cgi->param('beginning') - && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $beginning = str2time($1); - push @search, "_date >= $beginning "; - } - if ( $cgi->param('ending') - && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $ending = str2time($1) + 86399; - push @search, " _date <= $ending "; - } - my $search; - if ( @search ) { - $search = ( scalar(keys %search) ? ' AND ' : ' WHERE ' ). - join(' AND ', @search); - } - - @cust_pay = qsearch('cust_pay', \%search, '', $search ); - - $sortby = \*date_sort; - -} else { - - $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; - my $payinfo = $1; - - $cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; - my $payby = $1; - - @cust_pay = qsearch('cust_pay', { 'payinfo' => $payinfo, - 'payby' => $payby } ); - $sortby = \*date_sort; - -} - -if (0) { -#if ( scalar(@cust_pay) == 1 ) { -# my $invnum = $cust_bill[0]->invnum; -# print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect -} elsif ( scalar(@cust_pay) == 0 ) { -%> - -<% - idiot("Payment not found."); - #exit; -} else { - my $total = scalar(@cust_pay); - my $s = $total > 1 ? 's' : ''; %> - -<% - print header("Payment Search Results", menubar( - 'Main Menu', popurl(2) - )), "$total matching payment$s found
", &table(), < - - Amount - Date - Contact name - Company - -END - - my(%saw, $cust_pay); - my $tot_amount = 0; - foreach my $cust_pay ( - sort $sortby grep(!$saw{$_->paynum}++, @cust_pay) - ) { - my($paynum, $custnum, $payby, $payinfo, $amount, $date ) = ( - $cust_pay->paynum, - $cust_pay->custnum, - $cust_pay->payby, - $cust_pay->payinfo, - sprintf("%.2f", $cust_pay->paid), - $cust_pay->_date, - ); - $tot_amount += $amount; - my $pdate = time2str("%b %d %Y", $date); - - my $rowspan = 1; - - my $view = popurl(2). "view/cust_main.cgi?". $custnum. - "#". $payby. $payinfo; - - my $payment_info; - if ( $payby eq 'CARD' ) { - $payment_info = 'Card #'. 'x'x(length($payinfo)-4). - substr($payinfo,(length($payinfo)-4)); - } elsif ( $payby eq 'CHEK' ) { - $payment_info = "E-check acct#$payinfo"; - } elsif ( $payby eq 'BILL' ) { - $payment_info = "Check #$payinfo"; - } else { - $payment_info = "$payby $payinfo"; - } - - print < - $payment_info - \$$amount - $pdate -END - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); - if ( $cust_main ) { - #my $cview = popurl(2). "view/cust_main.cgi?". $cust_main->custnum; - my ( $name, $company ) = ( - $cust_main->last. ', '. $cust_main->first, - $cust_main->company, - ); - print <$name - $company -END - } else { - print <WARNING: couldn't find cust_main.custnum $custnum (cust_pay.paynum $paynum) -END - } - - print ""; - } - - $tot_amount = sprintf("%.2f", $tot_amount); - print '
'. table(). < - Total Amount - \$$tot_amount - - - - -END - -} - -# - -#sub invnum_sort { -# $a->invnum <=> $b->invnum; -#} -# -#sub custnum_sort { -# $a->custnum <=> $b->custnum || $a->invnum <=> $b->invnum; -#} - -sub date_sort { - $a->_date <=> $b->_date || $a->invnum <=> $b->invnum; -} +<%= include( 'elements/search.html', + 'title' => 'Payment Search Results', + 'name' => 'payments', + 'query' => $sql_query, + 'count_query' => $count_query, + 'count_addl' => [ '$%.2f total paid', ], + 'header' => + [ qw(Payment Amount Date), 'Contact name', 'Company', ], + 'fields' => [ + sub { + my $cust_pay = shift; + if ( $cust_pay->payby eq 'CARD' ) { + 'Card #'. $cust_pay->payinfo_masked; + } elsif ( $cust_pay->payby eq 'CHEK' ) { + 'E-check acct#'. $cust_pay->payinfo; + } elsif ( $cust_pay->payby eq 'BILL' ) { + 'Check #'. $cust_pay->payinfo; + } else { + $cust_pay->payby. ' '. $cust_pay->payinfo; + } + }, + sub { sprintf('$%.2f', shift->paid ) }, + sub { time2str('%b %d %Y', shift->_date ) }, + sub { my $cust_main = shift->cust_main; + $cust_main->get('last'). ', '. $cust_main->first; + }, + sub { my $cust_main = shift->cust_main; + $cust_main->company; + }, + ], + 'links' => [ + '', + '', + '', + $link, + $link, + ], + ) %> diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 37a3718ce..226c4f784 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -50,11 +50,11 @@ $header ||= $sth->{NAME}; } - if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 ) { + if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) { my( $url, $method ) = @{$opt{'redirect'}}; redirect( $url. $rows->[0]->$method() ); } else { - + $opt{'name'} =~ s/s$// if $total == 1; %> <%= include( '/elements/header.html', $opt{'title'}, include( '/elements/menubar.html', 'Main menu' => $p ) @@ -87,9 +87,16 @@ <% foreach my $field ( @{$opt{'fields'}} ) { %> <% my $a = ''; %> <% if ( $links ) { - my( $url, $method ) = @{shift @$links}; - $a = $url. $row->$method(); - $a = qq(); + my $link = shift @$links; + if ( $link ) { + my( $url, $method ) = @{$link}; + if ( ref($method) eq 'CODE' ) { + $a = $url. &{$method}($row); + } else { + $a = $url. $row->$method(); + } + $a = qq(); + } } %> <% if ( ref($field) eq 'CODE' ) { %> diff --git a/httemplate/search/report_cust_credit.html b/httemplate/search/report_cust_credit.html index 1b30685dc..8a0f0ed7b 100644 --- a/httemplate/search/report_cust_credit.html +++ b/httemplate/search/report_cust_credit.html @@ -1,26 +1,29 @@ - Payment report criteria + Credit report criteria -

Payment report criteria

-
+

Credit report criteria

+ - - +<% + my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_credit") + or die dbh->errstr; + $sth->execute or die $sth->errstr; + my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref}; +%> + -- cgit v1.2.1 From c29fa7acc16efcc86af06077e739fca8b783c3c1 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Apr 2004 13:15:17 +0000 Subject: add link to new credit report on main menu, remove old obsolete shell-out reports --- httemplate/search/report_cc.cgi | 25 --------------------- httemplate/search/report_cc.html | 43 ------------------------------------ httemplate/search/report_credit.cgi | 25 --------------------- httemplate/search/report_credit.html | 43 ------------------------------------ 4 files changed, 136 deletions(-) delete mode 100755 httemplate/search/report_cc.cgi delete mode 100755 httemplate/search/report_cc.html delete mode 100755 httemplate/search/report_credit.cgi delete mode 100755 httemplate/search/report_credit.html (limited to 'httemplate/search') diff --git a/httemplate/search/report_cc.cgi b/httemplate/search/report_cc.cgi deleted file mode 100755 index c2ab726b6..000000000 --- a/httemplate/search/report_cc.cgi +++ /dev/null @@ -1,25 +0,0 @@ - -<% - -my $user = getotaker; - -$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; -my $beginning = $1; - -$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; -my $ending = $1; - -print header('Credit Card Recipt Report Results'); - -open (REPORT, "freeside-cc-receipts-report -v -s $beginning -f $ending $user |"); - -print '
';
-while() {
-  print $_;
-}
-print '
'; - -print ''; - -%> - diff --git a/httemplate/search/report_cc.html b/httemplate/search/report_cc.html deleted file mode 100755 index 595a7b150..000000000 --- a/httemplate/search/report_cc.html +++ /dev/null @@ -1,43 +0,0 @@ - - - Credit Card Receipt Report Criteria - - - - - -

Credit Card Receipt Report Criteria

- - Return credit card receipt report for period: -
Payments of type: Credits by employee:
- - - - - - - - - -
From:
m/d/y
To:
m/d/y
- -
- -
- - - diff --git a/httemplate/search/report_credit.cgi b/httemplate/search/report_credit.cgi deleted file mode 100755 index 2adafc06e..000000000 --- a/httemplate/search/report_credit.cgi +++ /dev/null @@ -1,25 +0,0 @@ - -<% - -my $user = getotaker; - -$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; -my $beginning = $1; - -$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; -my $ending = $1; - -print header('In House Credit Report Results'); - -open (REPORT, "freeside-credit-report -v -s $beginning -f $ending $user |"); - -print '
';
-while() {
-  print $_;
-}
-print '
'; - -print ''; - -%> - diff --git a/httemplate/search/report_credit.html b/httemplate/search/report_credit.html deleted file mode 100755 index 11cb32ed8..000000000 --- a/httemplate/search/report_credit.html +++ /dev/null @@ -1,43 +0,0 @@ - - - In House Credit Report Criteria - - - - - -

In House Credit Report Criteria

-
- Return in house credit report for period: - - - - - - - - - - -
From:
m/d/y
To:
m/d/y
- -
- -
- - - -- cgit v1.2.1 From bfb3a80bc91a835513e437b242de366f190e9021 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 1 May 2004 21:05:48 +0000 Subject: handle missing customer records without erroring out --- httemplate/search/cust_bill.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 27b147108..3a5db3549 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -71,10 +71,14 @@ sub { sprintf('$%.2f', shift->charged ) }, sub { time2str('%b %d %Y', shift->_date ) }, sub { my $cust_main = shift->cust_main; - $cust_main->get('last'). ', '. $cust_main->first; + $cust_main + ? $cust_main->get('last'). ', '. $cust_main->first + : 'WARNING: can't find cust_main.custnum '. + shift->custnum. ' (cust_bill.invnum '. + shift->invnum. ')'; }, sub { my $cust_main = shift->cust_main; - $cust_main->company; + $cust_main ? $cust_main->company : ''; }, ], 'links' => [ -- cgit v1.2.1 From 79803ed2813d72e572feac02576bc591c835f049 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 1 May 2004 21:38:26 +0000 Subject: oops tyop --- httemplate/search/cust_bill.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 3a5db3549..874c77035 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -73,7 +73,7 @@ sub { my $cust_main = shift->cust_main; $cust_main ? $cust_main->get('last'). ', '. $cust_main->first - : 'WARNING: can't find cust_main.custnum '. + : "WARNING: can't find cust_main.custnum ". shift->custnum. ' (cust_bill.invnum '. shift->invnum. ')'; }, -- cgit v1.2.1 From 6e0b2d0a94827df55364a45fe1d1ba8928c5d659 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 1 May 2004 21:40:41 +0000 Subject: I'm slow this morning --- httemplate/search/cust_bill.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 874c77035..f65b08260 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -70,12 +70,13 @@ sub { sprintf('$%.2f', shift->get('owed') ) }, sub { sprintf('$%.2f', shift->charged ) }, sub { time2str('%b %d %Y', shift->_date ) }, - sub { my $cust_main = shift->cust_main; + sub { my $cust_bill = shift; + my $cust_main = $cust_bill->cust_main; $cust_main ? $cust_main->get('last'). ', '. $cust_main->first : "WARNING: can't find cust_main.custnum ". - shift->custnum. ' (cust_bill.invnum '. - shift->invnum. ')'; + $cust_bill->custnum. ' (cust_bill.invnum '. + $cust_bill->invnum. ')'; }, sub { my $cust_main = shift->cust_main; $cust_main ? $cust_main->company : ''; -- cgit v1.2.1 From 0f5028bc5a7789429a41bca886e5a38ed0fa099f Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 1 May 2004 22:49:09 +0000 Subject: don't display links to missing customers --- httemplate/search/cust_bill.html | 8 +++++++- httemplate/search/elements/search.html | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index f65b08260..337e9e859 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -50,7 +50,13 @@ } my $link = [ "${p}view/cust_bill.cgi?", 'invnum', ]; - my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; + my $clink = sub { + my $cust_bill = shift; + my $cust_main = $cust_bill->cust_main; + $cust_main + ? [ "${p}view/cust_main.cgi?", 'custnum' ] + : ''; + }; %> <%= include( 'elements/search.html', diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 226c4f784..e739afb1d 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -88,6 +88,7 @@ <% my $a = ''; %> <% if ( $links ) { my $link = shift @$links; + $link = &{$link}($row) if ref($link) eq 'CODE'; if ( $link ) { my( $url, $method ) = @{$link}; if ( ref($method) eq 'CODE' ) { -- cgit v1.2.1 From 699ce04c670c2da6b1b3821c960467b1c427d249 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 May 2004 00:46:59 +0000 Subject: vary basic virtual host browse --- httemplate/search/svc_www.cgi | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 httemplate/search/svc_www.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi new file mode 100755 index 000000000..1f05c2377 --- /dev/null +++ b/httemplate/search/svc_www.cgi @@ -0,0 +1,42 @@ +<% + +#my $conf = new FS::Conf; + +my($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors +my(@svc_www, $orderby); +if ( $query eq 'svcnum' ) { + $orderby = 'ORDER BY svcnum'; +} else { + eidiot('unimplemented'); +} + +my $count_query = 'SELECT COUNT(*) FROM svc_www'; +my $sql_query = { + 'table' => 'svc_www', + 'hashref' => {}, + 'extra_sql' => $orderby, +}; + +my $link = [ "${p}view/svc_www.cgi?", 'svcnum', ]; +#my $dlink = [ "${p}view/svc_www.cgi?", 'svcnum', ]; +my $ulink = [ "${p}view/svc_acct.cgi?", 'usersvc', ]; + + +%> +<%= include( 'elements/search.html', + 'title' => 'Virtual Host Search Results', + 'name' => 'virtual hosts', + 'query' => $sql_query, + 'count_query' => $count_query, + 'header' => [ '#', 'Zone', 'User', ], + 'fields' => [ 'svcnum', + sub { $_[0]->domain_record->zone }, + sub { $_[0]->svc_acct->email }, + ], + 'links' => [ $link, + '', + $ulink, + ], + ) +%> -- cgit v1.2.1 From 0d81e56d3651752576b4969b39b49dc80012fc0e Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 May 2004 10:17:08 +0000 Subject: correct count statement when searching for individual invoices by # --- httemplate/search/cust_bill.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 337e9e859..3ae624af2 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -41,7 +41,7 @@ } else { $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; - $count_query = 'SELECT 1'; + $count_query = "SELECT COUNT(*) FROM cust_bill WHERE invnum = $2"; $sql_query = { 'table' => 'cust_bill', 'hashref' => { 'invnum' => $2 }, -- cgit v1.2.1 From d8ff6db2dbaec9cc8daad2d4af0254f167aa7a66 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 May 2004 10:38:00 +0000 Subject: show a better message when no results are found --- httemplate/search/elements/search.html | 93 ++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 44 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index e739afb1d..12ab83ba5 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -67,55 +67,60 @@ 'maxrecords' => $maxrecords, ); %> -<%= $total %> total <%= $opt{'name'} %>
-<% if ( $opt{'count_addl'} ) { %> - <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %> - <%= sprintf( $count, $count_arrayref->[++$n] ) %>
+<% unless ( $total ) { %> + No matching <%= $opt{'name'} %> found.
+<% } else { %> + <%= $total %> total <%= $opt{'name'} %>
+ <% if ( $opt{'count_addl'} ) { %> + <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %> + <%= sprintf( $count, $count_arrayref->[++$n] ) %>
+ <% } %> <% } %> -<% } %> -
<%= $pager %> -<%= include( '/elements/table.html' ) %> - - <% foreach my $header ( @$header ) { %> - <%= $header %> - <% } %> - - <% foreach my $row ( @$rows ) { %> - - <% if ( $opt{'fields'} ) { %> - <% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; %> - <% foreach my $field ( @{$opt{'fields'}} ) { %> - <% my $a = ''; %> - <% if ( $links ) { - my $link = shift @$links; - $link = &{$link}($row) if ref($link) eq 'CODE'; - if ( $link ) { - my( $url, $method ) = @{$link}; - if ( ref($method) eq 'CODE' ) { - $a = $url. &{$method}($row); - } else { - $a = $url. $row->$method(); +
<%= $pager %> + <%= include( '/elements/table.html' ) %> + + <% foreach my $header ( @$header ) { %> + <%= $header %> + <% } %> + + <% foreach my $row ( @$rows ) { %> + + <% if ( $opt{'fields'} ) { %> + <% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; %> + <% foreach my $field ( @{$opt{'fields'}} ) { %> + <% my $a = ''; %> + <% if ( $links ) { + my $link = shift @$links; + $link = &{$link}($row) if ref($link) eq 'CODE'; + if ( $link ) { + my( $url, $method ) = @{$link}; + if ( ref($method) eq 'CODE' ) { + $a = $url. &{$method}($row); + } else { + $a = $url. $row->$method(); + } + $a = qq(
); } - $a = qq(); } - } - %> - <% if ( ref($field) eq 'CODE' ) { %> - <%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %> - <% } else { %> - <%= $a %><%= $row->$field() %><%= $a ? '' : '' %> + %> + <% if ( ref($field) eq 'CODE' ) { %> + <%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %> + <% } else { %> + <%= $a %><%= $row->$field() %><%= $a ? '' : '' %> + <% } %> + <% } %> + <% } else { %> + <% foreach ( @$row ) { %> + <%= $_ %> <% } %> <% } %> - <% } else { %> - <% foreach ( @$row ) { %> - <%= $_ %> - <% } %> - <% } %> - - <% } %> - - -<%= $pager %> + + <% } %> + + + <%= $pager %> +<% } %> <% } %> + -- cgit v1.2.1 From e0c62c388f74e543328f3691e8a8a1edb451a804 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 10 Jun 2004 11:28:19 +0000 Subject: tyop --- httemplate/search/cust_main-otaker.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_main-otaker.cgi b/httemplate/search/cust_main-otaker.cgi index b7173c49c..68569f085 100755 --- a/httemplate/search/cust_main-otaker.cgi +++ b/httemplate/search/cust_main-otaker.cgi @@ -11,7 +11,7 @@ Search for Order taker: <% my $dbh = dbh; - my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_main") + my $sth = $dbh->prepare("SELECT DISTINCT otaker FROM cust_main") or eidiot $dbh->errstr; $sth->execute() or eidiot $sth->errstr; # my @otakers = map { $_->[0] } @{$sth->selectall_arrayref}; -- 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') 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 8f6a34b553a7ca9b7fc9c9cf5802ce418e3a5296 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 11 Jun 2004 13:44:40 +0000 Subject: tax report! --- httemplate/search/report_tax.cgi | 132 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 123 insertions(+), 9 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index ac76fad6e..08b6d0796 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -4,22 +4,136 @@ my $user = getotaker; $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; -my $beginning = $1; +my $pbeginning = $1; +my $beginning = str2time($1) || 0; $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; -my $ending = $1; +my $pending = $1; +my $ending = ( str2time($1) || 4294880896 ) + 86399; -print header('Tax Report Results'); +my($total, $exempt, $taxable, $tax) = ( 0, 0, 0, 0 ); +my $out = 'Out of taxable region(s)'; +my %regions; +foreach my $r ( qsearch('cust_main_county', {}) ) { + my $label; + if ( $r->tax == 0 ) { + $label = $out; + } elsif ( $r->taxname ) { + $label = $r->taxname; + } else { + $label = $r->country; + $label = $r->state.", $label" if $r->state; + $label = $r->county." county, $label" if $r->county; + } -open (REPORT, "freeside-tax-report -v -s $beginning -f $ending $user |"); + #match taxclass too? + + my $fromwhere = " + FROM cust_bill_pkg + JOIN cust_bill USING ( invnum ) + JOIN cust_main USING ( custnum ) + WHERE _date >= $beginning AND _date <= $ending + AND county = ? AND state = ? AND country = ? + "; + my $nottax = 'pkgnum != 0'; + + my $a = scalar_sql($r, + "SELECT SUM(setup+recur) $fromwhere AND $nottax" + ); + $total += $a; + $regions{$label}->{'total'} += $a; + + foreach my $e ( grep { $r->get($_.'tax') =~ /^Y/i } qw( setup recur ) ) { + my $x = scalar_sql($r, + "SELECT SUM($e) $fromwhere AND $nottax" + ); + $exempt += $x; + $regions{$label}->{'exempt'} += $x; + } + + foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( setup recur ) ) { + my $x = scalar_sql($r, + "SELECT SUM($e) $fromwhere AND $nottax" + ); + $taxable += $x; + $regions{$label}->{'taxable'} += $x; + } + + if ( defined($regions{$label}->{'rate'}) + && $regions{$label}->{'rate'} != $r->tax.'%' ) { + $regions{$label}->{'rate'} = 'variable'; + } else { + $regions{$label}->{'rate'} = $r->tax.'%'; + } + + #match itemdesc if necessary! + my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) : ''; + my $x = scalar_sql($r, + "SELECT SUM(setup+recur) $fromwhere AND pkgnum = 0 $named_tax", + ); + $tax += $x; + $regions{$label}->{'tax'} += $x; + + $regions{$label}->{'label'} = $label; -print '
';
-while() {
-  print $_;
 }
-print '
'; -print ''; +#ordering +my @regions = map $regions{$_}, + sort { ( $b eq $out cmp $a eq $out ) || ( $a cmp $b ) } + keys %regions; + +push @regions, { + 'label' => 'Total', + 'total' => $total, + 'exempt' => $exempt, + 'taxable' => $taxable, + 'rate' => '', + 'tax' => $tax, +}; + +#-- + +#false laziness w/FS::Report::Table::Monthly (sub should probably be moved up +#to FS::Report or FS::Record or who the fuck knows where) +sub scalar_sql { + my( $r, $sql ) = @_; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute( map $r->$_(), qw( county state country ) ) + or die "Unexpected error executing statement $sql: ". $sth->errstr; + $sth->fetchrow_arrayref->[0] || 0; +} %> +<%= header( "Sales Tax Report - $pbeginning through ".($pending||'now'), + menubar( 'Main Menu'=>$p, ) ) %> +<%= table() %> + + + Sales + Rate + Tax + + + Total + Non-taxable + Taxable + + <% foreach my $region ( @regions ) { %> + + <%= $region->{'label'} %> + $<%= $region->{'total'} %> + $<%= $region->{'exempt'} %> + $<%= $region->{'taxable'} %> + <%= $region->{'rate'} %> + $<%= $region->{'tax'} %> + + <% } %> + + + + + + + -- cgit v1.2.1 From 1b0d5782e4cc1cfb6f3f75bb8d0a9b4c13749986 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 11 Jun 2004 14:25:05 +0000 Subject: tax report fix sort --- httemplate/search/report_tax.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 08b6d0796..ed7f9ffb8 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -80,7 +80,7 @@ foreach my $r ( qsearch('cust_main_county', {}) ) { #ordering my @regions = map $regions{$_}, - sort { ( $b eq $out cmp $a eq $out ) || ( $a cmp $b ) } + sort { ( ($b eq $out) cmp ($a eq $out) ) || ($a cmp $b) } keys %regions; push @regions, { -- cgit v1.2.1 From 7b973e57e167efdce2218209e9198ae34f2483b2 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 11 Jun 2004 14:57:31 +0000 Subject: fix to find all customer scorrectly --- httemplate/search/report_tax.cgi | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index ed7f9ffb8..0a368d33c 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -33,7 +33,9 @@ foreach my $r ( qsearch('cust_main_county', {}) ) { JOIN cust_bill USING ( invnum ) JOIN cust_main USING ( custnum ) WHERE _date >= $beginning AND _date <= $ending - AND county = ? AND state = ? AND country = ? + AND ( county = ? OR ( ? = '' AND county IS NULL ) ) + AND ( state = ? OR ( ? = '' AND state IS NULL ) ) + AND ( country = ? OR ( ? = '' AND country IS NULL ) ) "; my $nottax = 'pkgnum != 0'; @@ -80,7 +82,7 @@ foreach my $r ( qsearch('cust_main_county', {}) ) { #ordering my @regions = map $regions{$_}, - sort { ( ($b eq $out) cmp ($a eq $out) ) || ($a cmp $b) } + sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } keys %regions; push @regions, { @@ -99,7 +101,7 @@ push @regions, { sub scalar_sql { my( $r, $sql ) = @_; my $sth = dbh->prepare($sql) or die dbh->errstr; - $sth->execute( map $r->$_(), qw( county state country ) ) + $sth->execute( map $r->$_(), map { $_, $_ } qw( county state country ) ) or die "Unexpected error executing statement $sql: ". $sth->errstr; $sth->fetchrow_arrayref->[0] || 0; } @@ -123,11 +125,11 @@ sub scalar_sql { <% foreach my $region ( @regions ) { %> <%= $region->{'label'} %> - $<%= $region->{'total'} %> - $<%= $region->{'exempt'} %> - $<%= $region->{'taxable'} %> + $<%= sprintf('%.2f', $region->{'total'} ) %> + $<%= sprintf('%.2f', $region->{'exempt'} ) %> + $<%= sprintf('%.2f', $region->{'taxable'} ) %> <%= $region->{'rate'} %> - $<%= $region->{'tax'} %> + $<%= sprintf('%.2f', $region->{'tax'} ) %> <% } %> -- cgit v1.2.1 From 402ac7d54021caf6797efc47d33983be51eef049 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 11 Jun 2004 16:44:05 +0000 Subject: fix date range for old perl, count tax exempt and COMP customers correctly --- httemplate/search/report_tax.cgi | 42 ++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 0a368d33c..4de733c23 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -5,16 +5,30 @@ my $user = getotaker; $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; my $pbeginning = $1; -my $beginning = str2time($1) || 0; +my $beginning = $1 ? str2time($1) : 0; $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; my $pending = $1; -my $ending = ( str2time($1) || 4294880896 ) + 86399; +my $ending = ( $1 ? str2time($1) : 4294880896 ) + 86399; my($total, $exempt, $taxable, $tax) = ( 0, 0, 0, 0 ); my $out = 'Out of taxable region(s)'; my %regions; -foreach my $r ( qsearch('cust_main_county', {}) ) { +foreach my $r ( + qsearch('cust_main_county', {}, '', + "WHERE 0 < ( SELECT COUNT(*) FROM cust_main + WHERE ( cust_main.county = cust_main_county.county + OR cust_main_county.county = '' + OR cust_main_county.county IS NULL ) + AND ( cust_main.state = cust_main_county.state + OR cust_main_county.state = '' + OR cust_main_county.state IS NULL ) + AND ( cust_main.country = cust_main_county.country ) + LIMIT 1 + )" + ) +) { + #warn $r->county. ' '. $r->state. ' '. $r->country. "\n"; my $label; if ( $r->tax == 0 ) { $label = $out; @@ -33,9 +47,10 @@ foreach my $r ( qsearch('cust_main_county', {}) ) { JOIN cust_bill USING ( invnum ) JOIN cust_main USING ( custnum ) WHERE _date >= $beginning AND _date <= $ending - AND ( county = ? OR ( ? = '' AND county IS NULL ) ) - AND ( state = ? OR ( ? = '' AND state IS NULL ) ) - AND ( country = ? OR ( ? = '' AND country IS NULL ) ) + AND ( county = ? OR ? = '' ) + AND ( state = ? OR ? = '' ) + AND ( country = ? ) + AND payby != 'COMP' "; my $nottax = 'pkgnum != 0'; @@ -54,11 +69,17 @@ foreach my $r ( qsearch('cust_main_county', {}) ) { } foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( setup recur ) ) { + my $t = scalar_sql($r, + "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" + ); + $taxable += $t; + $regions{$label}->{'taxable'} += $t; + my $x = scalar_sql($r, - "SELECT SUM($e) $fromwhere AND $nottax" + "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" ); - $taxable += $x; - $regions{$label}->{'taxable'} += $x; + $exempt += $x; + $regions{$label}->{'exempt'} += $x; } if ( defined($regions{$label}->{'rate'}) @@ -100,8 +121,9 @@ push @regions, { #to FS::Report or FS::Record or who the fuck knows where) sub scalar_sql { my( $r, $sql ) = @_; + #warn "$sql\n"; my $sth = dbh->prepare($sql) or die dbh->errstr; - $sth->execute( map $r->$_(), map { $_, $_ } qw( county state country ) ) + $sth->execute( map $r->$_(), qw( county county state state country ) ) or die "Unexpected error executing statement $sql: ". $sth->errstr; $sth->fetchrow_arrayref->[0] || 0; } -- cgit v1.2.1 From 1238858779262e56f45aef69d33b54052407c7f7 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 16 Jun 2004 14:07:46 +0000 Subject: update tax report for taxclass --- httemplate/search/report_tax.cgi | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 4de733c23..a98d36f3c 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -40,27 +40,29 @@ foreach my $r ( $label = $r->county." county, $label" if $r->county; } - #match taxclass too? - my $fromwhere = " FROM cust_bill_pkg JOIN cust_bill USING ( invnum ) JOIN cust_main USING ( custnum ) + JOIN cust_pkg USING ( pkgnum ) + JOIN part_pkg USING ( pkgpart ) WHERE _date >= $beginning AND _date <= $ending AND ( county = ? OR ? = '' ) AND ( state = ? OR ? = '' ) AND ( country = ? ) + AND ( taxclass = ? OR ? = '' ) AND payby != 'COMP' "; my $nottax = 'pkgnum != 0'; my $a = scalar_sql($r, - "SELECT SUM(setup+recur) $fromwhere AND $nottax" + "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere AND $nottax" ); $total += $a; $regions{$label}->{'total'} += $a; - foreach my $e ( grep { $r->get($_.'tax') =~ /^Y/i } qw( setup recur ) ) { + foreach my $e ( grep { $r->get($_.'tax') =~ /^Y/i } + qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { my $x = scalar_sql($r, "SELECT SUM($e) $fromwhere AND $nottax" ); @@ -68,7 +70,8 @@ foreach my $r ( $regions{$label}->{'exempt'} += $x; } - foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( setup recur ) ) { + foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } + qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { my $t = scalar_sql($r, "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" ); @@ -92,7 +95,8 @@ foreach my $r ( #match itemdesc if necessary! my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) : ''; my $x = scalar_sql($r, - "SELECT SUM(setup+recur) $fromwhere AND pkgnum = 0 $named_tax", + "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere ". + "AND pkgnum = 0 $named_tax", ); $tax += $x; $regions{$label}->{'tax'} += $x; @@ -123,7 +127,8 @@ sub scalar_sql { my( $r, $sql ) = @_; #warn "$sql\n"; my $sth = dbh->prepare($sql) or die dbh->errstr; - $sth->execute( map $r->$_(), qw( county county state state country ) ) + $sth->execute( map $r->$_(), + qw( county county state state country taxclass taxclass ) ) or die "Unexpected error executing statement $sql: ". $sth->errstr; $sth->fetchrow_arrayref->[0] || 0; } -- cgit v1.2.1 From 4dbd0e09bd8fe1958eb294ebd425878c420afe6a Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 18 Jun 2004 10:28:11 +0000 Subject: masonize fix: avoid newline prepend fix from borking indented first <%, fixes customer search by otaker under mason, closes: Bug#830 --- httemplate/search/cust_main-otaker.cgi | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_main-otaker.cgi b/httemplate/search/cust_main-otaker.cgi index 68569f085..44214368a 100755 --- a/httemplate/search/cust_main-otaker.cgi +++ b/httemplate/search/cust_main-otaker.cgi @@ -10,10 +10,9 @@
Search for Order taker: - <% my $dbh = dbh; - my $sth = $dbh->prepare("SELECT DISTINCT otaker FROM cust_main") - or eidiot $dbh->errstr; - $sth->execute() or eidiot $sth->errstr; + <% my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_main") + or die dbh->errstr; + $sth->execute() or die $sth->errstr; # my @otakers = map { $_->[0] } @{$sth->selectall_arrayref}; %> m/d/y - to m/d/y - -

- + + + + + + + + + + + +
From:
m/d/y
To:
m/d/y
+

- -
- -- cgit v1.2.1 From 19ca51b6b215fc76757812b5b4d2bea6dd6e4cf7 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Aug 2004 00:22:29 +0000 Subject: add customer # to payment reports, add table cell alignment option to general search component --- httemplate/search/cust_pay.cgi | 6 +++++- httemplate/search/elements/search.html | 27 ++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index ba2bc63f0..3f5b72ab5 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -99,7 +99,8 @@ 'count_query' => $count_query, 'count_addl' => [ '$%.2f total paid', ], 'header' => - [ qw(Payment Amount Date), 'Contact name', 'Company', ], + [ qw(Payment Amount Date), 'Cust #', 'Contact name', + 'Company', ], 'fields' => [ sub { my $cust_pay = shift; @@ -115,6 +116,7 @@ }, sub { sprintf('$%.2f', shift->paid ) }, sub { time2str('%b %d %Y', shift->_date ) }, + 'custnum', sub { my $cust_main = shift->cust_main; $cust_main->get('last'). ', '. $cust_main->first; }, @@ -122,12 +124,14 @@ $cust_main->company; }, ], + 'align' => 'lrrrll', 'links' => [ '', '', '', $link, $link, + $link, ], ) %> diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 12ab83ba5..566ea8391 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -2,6 +2,16 @@ my(%opt) = @_; + my %align = ( + 'l' => 'left', + 'r' => 'right', + 'c' => 'center', + ' ' => '', + '.' => '', + ); + $opt{align} = [ map $align{$_}, split(//, $opt{align}) ], + unless !$opt{align} || ref($opt{align}); + if ( ref($opt{'query'}) ) { } @@ -85,11 +95,14 @@ <% foreach my $row ( @$rows ) { %> - <% if ( $opt{'fields'} ) { %> - <% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; %> - <% foreach my $field ( @{$opt{'fields'}} ) { %> - <% my $a = ''; %> - <% if ( $links ) { + <% if ( $opt{'fields'} ) { + my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; + my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; + foreach my $field ( @{$opt{'fields'}} ) { + my $align = $aligns ? shift @$aligns : ''; + $align = " ALIGN=$align" if $align; + my $a = ''; + if ( $links ) { my $link = shift @$links; $link = &{$link}($row) if ref($link) eq 'CODE'; if ( $link ) { @@ -104,9 +117,9 @@ } %> <% if ( ref($field) eq 'CODE' ) { %> - <%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %> + ><%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %> <% } else { %> - <%= $a %><%= $row->$field() %><%= $a ? '' : '' %> + ><%= $a %><%= $row->$field() %><%= $a ? '' : '' %> <% } %> <% } %> <% } else { %> -- cgit v1.2.1 From bb8ac5b48b2a5c38b75f5f6eb09a31194f81786b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Aug 2004 16:35:17 +0000 Subject: add customer # to credit reports too --- httemplate/search/cust_credit.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index c46caba13..faaa7a817 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -50,11 +50,13 @@ 'count_addl' => [ '$%.2f total credited', ], #'redirect' => $link, 'header' => - [ qw(Amount Date), 'Contact name', qw(Company By Reason) ], + [ qw(Amount Date), 'Cust #', 'Contact name', + qw(Company By Reason) ], 'fields' => [ #'crednum', sub { sprintf('$%.2f', shift->amount ) }, sub { time2str('%b %d %Y', shift->_date ) }, + 'custnum', sub { my $cust_main = shift->cust_main; $cust_main->get('last'). ', '. $cust_main->first; }, @@ -64,11 +66,13 @@ 'otaker', 'reason', ], + 'align' => 'rrrllll', 'links' => [ '', '', $clink, $clink, + $clink, '', '', ], -- 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') 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 470c3559d5077d2db4779610bbd798d58eaec27f Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 22 Sep 2004 11:28:13 +0000 Subject: add missing tags --- httemplate/search/cust_bill_event.html | 1 + httemplate/search/report_cust_credit.html | 1 + httemplate/search/report_cust_pay.html | 1 + httemplate/search/report_tax.html | 1 + 4 files changed, 4 insertions(+) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index e0878e497..cd96ddf51 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -34,6 +34,7 @@ }); + To:
m/d/y + To:
m/d/y + To:
m/d/y + To:
m/d/y + + +') %> +
+<% #include( '/elements/table.html' ) %> +<%= ntable('#cccccc') %> + + Username: + + + + + (leave blank to show all users) + + + IP address: + + + + + (leave blank to show all IPs) + + + From: + + + + + + + + m/d/y + + + To: + + + + + + + + m/d/y +
(leave one or both dates blank for an open-ended search) + + + +
+
+ + + + -- cgit v1.2.1 From eb4cf5563939a08eba1a10d8c2a8f52205f6535b Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 6 Oct 2004 13:27:49 +0000 Subject: small formatting updates to RADIUS report --- httemplate/search/sqlradius.cgi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index 3c5046bea..9cc5958ee 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -123,9 +123,9 @@ my $time_format = sub { my $time = shift; - $time > 0 - ? time2str('%T%P %a %b %o %Y', $time ) - : ' '; + return ' ' if $time == 0; + my $pretty = time2str('%T%P %a %b %o %Y', $time ); + $pretty =~ s/ (\d)(st|dn|rd|th)/ $1$2/; }; my $duration_format = sub { @@ -223,7 +223,7 @@ <% foreach my $field ( keys %fields ) { %> <%= $fields{$field}->{name} %>
- <%= $fields{$field}->{attrib} %> + <%= $fields{$field}->{attrib} %> <% } %> -- cgit v1.2.1 From 8590a91eb0d64755dff5622a152ab6b5136d8520 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 6 Oct 2004 13:33:25 +0000 Subject: small formatting updates to RADIUS report --- httemplate/search/sqlradius.cgi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index 9cc5958ee..bb51acb7a 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -126,6 +126,7 @@ return ' ' if $time == 0; my $pretty = time2str('%T%P %a %b %o %Y', $time ); $pretty =~ s/ (\d)(st|dn|rd|th)/ $1$2/; + $pretty; }; my $duration_format = sub { @@ -171,19 +172,19 @@ fmt => $customer_format, }, 'framedipaddress' => { - name => 'IP Address', + name => 'IP Address', attrib => 'Framed-IP-Address', fmt => sub { my $ip = shift; length($ip) ? $ip : ' '; }, }, 'acctstarttime' => { - name => 'Start time', + name => 'Start time', attrib => 'Acct-Start-Time', fmt => $time_format, }, 'acctstoptime' => { - name => 'End time', + name => 'End time', attrib => 'Acct-Stop-Time', fmt => $time_format, }, -- cgit v1.2.1 From 85277a99fc463da9da890d0fa11df4abf0af6fe0 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 6 Oct 2004 13:39:17 +0000 Subject: more formatting updates to RADIUS report --- httemplate/search/sqlradius.cgi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index bb51acb7a..11edf3cf9 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -125,7 +125,7 @@ my $time = shift; return ' ' if $time == 0; my $pretty = time2str('%T%P %a %b %o %Y', $time ); - $pretty =~ s/ (\d)(st|dn|rd|th)/ $1$2/; + $pretty =~ s/ (\d)(st|dn|rd|th)/$1$2/; $pretty; }; @@ -161,15 +161,18 @@ name => 'User', attrib => 'UserName', fmt => $user_format, + align => 'left', }, 'realm' => { name => 'Realm', attrib => 'Realm', + align => 'left', }, 'dummy' => { name => 'Customer', attrib => '', fmt => $customer_format, + align => 'left', }, 'framedipaddress' => { name => 'IP Address', @@ -177,31 +180,37 @@ fmt => sub { my $ip = shift; length($ip) ? $ip : ' '; }, + align => 'right', }, 'acctstarttime' => { name => 'Start time', attrib => 'Acct-Start-Time', fmt => $time_format, + align => 'left', }, 'acctstoptime' => { name => 'End time', attrib => 'Acct-Stop-Time', fmt => $time_format, + align => 'left', }, 'acctsessiontime' => { name => 'Duration', attrib => 'Acct-Session-Time', fmt => $duration_format, + align => 'right', }, 'acctinputoctets' => { name => 'Upload', # (from user)', attrib => 'Acct-Input-Octets', fmt => $octets_format, + align => 'right', }, 'acctoutputoctets' => { name => 'Download', # (to user)', attrib => 'Acct-Output-Octets', fmt => $octets_format, + align => 'right', }, ; $fields{$_}->{fmt} ||= sub { length($_[0]) ? shift : ' '; } -- cgit v1.2.1 From 83ccbe7d9626cea57ad70a9c22d8fa4518e39919 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 6 Oct 2004 13:41:49 +0000 Subject: more formatting updates to RADIUS report --- httemplate/search/sqlradius.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index 11edf3cf9..5fd32f4dc 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -242,7 +242,7 @@ ) { %> <% foreach my $field ( keys %fields ) { %> - + <%= &{ $fields{$field}->{fmt} }( $session->{$field}, $session, $part_export, -- cgit v1.2.1 From 6083603212ea08b80c0f48ad61f4421aae85c31d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 12 Oct 2004 06:08:03 +0000 Subject: more info in error message for unknown export type, fix test for sqlradius_withdomain export, woo! --- httemplate/search/sqlradius.cgi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index 5fd32f4dc..b506ba1cb 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -64,7 +64,7 @@ $svc_acct = $user2svc_acct{$user}; } else { my %search = (); - if ( $part_export->exporrtype eq 'sqlradius_withdomain' ) { + if ( $part_export->exporttype eq 'sqlradius_withdomain' ) { my $domain; if ( $user =~ /^([^@]+)\@([^@]+)$/ ) { $search{'username'} = $1; @@ -82,7 +82,8 @@ } elsif ( $part_export->exporttype eq 'sqlradius' ) { $search{'username'} = $user; } else { - die "guru meditation #420"; + die 'unknown export type '. $part_export->exporttype. + " for $part_export\n"; } if ( keys %search ) { my @svc_acct = -- cgit v1.2.1 From eaf44792a30d0e879e5ab12682d0cd07faa77380 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 20 Oct 2004 08:07:58 +0000 Subject: add svc_external search --- httemplate/search/svc_external.cgi | 101 +++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 httemplate/search/svc_external.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/svc_external.cgi b/httemplate/search/svc_external.cgi new file mode 100755 index 000000000..c5ac13498 --- /dev/null +++ b/httemplate/search/svc_external.cgi @@ -0,0 +1,101 @@ +<% + +my $conf = new FS::Conf; + +my($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors +my(@svc_external,$sortby); +if ( $query eq 'svcnum' ) { + $sortby=\*svcnum_sort; + @svc_external=qsearch('svc_external',{}); +} elsif ( $query eq 'id' ) { + $sortby=\*id_sort; + @svc_external=qsearch('svc_external',{}); +} elsif ( $query eq 'UN_svcnum' ) { + $sortby=\*svcnum_sort; + @svc_external = grep qsearchs('cust_svc',{ + 'svcnum' => $_->svcnum, + 'pkgnum' => '', + }), qsearch('svc_external',{}); +} elsif ( $query eq 'UN_id' ) { + $sortby=\*id_sort; + @svc_external = grep qsearchs('cust_svc',{ + 'svcnum' => $_->svcnum, + 'pkgnum' => '', + }), qsearch('svc_external',{}); +} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { + @svc_external = + qsearch( 'svc_external', {}, '', + " WHERE $1 = ( SELECT svcpart FROM cust_svc ". + " WHERE cust_svc.svcnum = svc_external.svcnum ) " + ); + $sortby=\*svcnum_sort; +} else { + $cgi->param('id') =~ /^([\w\-\.]+)$/; + my($id)=$1; + #push @svc_domain, qsearchs('svc_domain',{'domain'=>$domain}); + @svc_external = qsearchs('svc_external',{'id'=>$id}); +} + +if ( scalar(@svc_external) == 1 ) { + print $cgi->redirect(popurl(2). "view/svc_external.cgi?". $svc_external[0]->svcnum); + #exit; +} elsif ( scalar(@svc_external) == 0 ) { +%> + +<% + eidiot "No matching external services found!\n"; +} else { +%> + +<%= header("External Search Results",'') %> + + <%= scalar(@svc_external) %> matching external services found + + + + + + + +<% + foreach my $svc_external ( + sort $sortby (@svc_external) + ) { + my($svcnum, $id, $title)=( + $svc_external->svcnum, + $svc_external->id, + $svc_external->title, + ); + + my $rowspan = 1; + + print < + + + +END + + #print @rows; + print ""; + + } + + print < + + +END + +} + +sub svcnum_sort { + $a->getfield('svcnum') <=> $b->getfield('svcnum'); +} + +sub id_sort { + $a->getfield('id') <=> $b->getfield('id'); +} + +%> -- cgit v1.2.1 From 0c84048cb76f67fea02b1d6f86c850b26f70bdc2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 21 Oct 2004 07:07:14 +0000 Subject: fix tax report edge cases when using taxclasses in some regions but not others --- httemplate/search/report_tax.cgi | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index a98d36f3c..f37e1275d 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -50,12 +50,29 @@ foreach my $r ( AND ( county = ? OR ? = '' ) AND ( state = ? OR ? = '' ) AND ( country = ? ) - AND ( taxclass = ? OR ? = '' ) AND payby != 'COMP' "; + my @param = qw( county county state state country ); # taxclass); + + my $num_others = + scalar_sql( $r, [qw( country state state county county taxname taxname )], + "SELECT COUNT(*) FROM cust_main_county + WHERE country = ? + AND ( state = ? OR ( state IS NULL AND ? = '' ) ) + AND ( county = ? OR ( county IS NULL AND ? = '' ) ) + AND ( taxname = ? OR ( taxname IS NULL AND ? = '' ) ) " + ); + + die "didn't even find self?" unless $num_others; + + if ( $num_others > 1 ) { + $fromwhere .= " AND ( taxclass = ? ) "; + push @param, 'taxclass'; + } + my $nottax = 'pkgnum != 0'; - my $a = scalar_sql($r, + my $a = scalar_sql($r, \@param, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere AND $nottax" ); $total += $a; @@ -63,7 +80,7 @@ foreach my $r ( foreach my $e ( grep { $r->get($_.'tax') =~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { - my $x = scalar_sql($r, + my $x = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax" ); $exempt += $x; @@ -72,13 +89,13 @@ foreach my $r ( foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { - my $t = scalar_sql($r, + my $t = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" ); $taxable += $t; $regions{$label}->{'taxable'} += $t; - my $x = scalar_sql($r, + my $x = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" ); $exempt += $x; @@ -94,7 +111,7 @@ foreach my $r ( #match itemdesc if necessary! my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) : ''; - my $x = scalar_sql($r, + my $x = scalar_sql($r, \@param, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere ". "AND pkgnum = 0 $named_tax", ); @@ -124,11 +141,10 @@ push @regions, { #false laziness w/FS::Report::Table::Monthly (sub should probably be moved up #to FS::Report or FS::Record or who the fuck knows where) sub scalar_sql { - my( $r, $sql ) = @_; + my( $r, $param, $sql ) = @_; #warn "$sql\n"; my $sth = dbh->prepare($sql) or die dbh->errstr; - $sth->execute( map $r->$_(), - qw( county county state state country taxclass taxclass ) ) + $sth->execute( map $r->$_(), @$param ) or die "Unexpected error executing statement $sql: ". $sth->errstr; $sth->fetchrow_arrayref->[0] || 0; } -- cgit v1.2.1 From 7c17ae7d898fcbaa1b95c821b72b2250e02a0f3b Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 25 Oct 2004 21:35:32 +0000 Subject: fix joins for proper tax reporting --- httemplate/search/report_tax.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index f37e1275d..8b1c095b6 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -44,8 +44,8 @@ foreach my $r ( FROM cust_bill_pkg JOIN cust_bill USING ( invnum ) JOIN cust_main USING ( custnum ) - JOIN cust_pkg USING ( pkgnum ) - JOIN part_pkg USING ( pkgpart ) + LEFT OUTER JOIN cust_pkg USING ( pkgnum ) + LEFT OUTER JOIN part_pkg USING ( pkgpart ) WHERE _date >= $beginning AND _date <= $ending AND ( county = ? OR ? = '' ) AND ( state = ? OR ? = '' ) -- cgit v1.2.1 From ee3760985fc43588e7eab5033b704cb7528f049d Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 25 Oct 2004 22:48:02 +0000 Subject: hopefully fix tax report for taxclass & named tax edge cases --- httemplate/search/report_tax.cgi | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 8b1c095b6..bb376214f 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -40,19 +40,29 @@ foreach my $r ( $label = $r->county." county, $label" if $r->county; } - my $fromwhere = " - FROM cust_bill_pkg - JOIN cust_bill USING ( invnum ) - JOIN cust_main USING ( custnum ) - LEFT OUTER JOIN cust_pkg USING ( pkgnum ) - LEFT OUTER JOIN part_pkg USING ( pkgpart ) + my $join_pkg = " + JOIN cust_pkg USING ( pkgnum ) + JOIN part_pkg USING ( pkgpart ) + "; + + my $where = " WHERE _date >= $beginning AND _date <= $ending AND ( county = ? OR ? = '' ) AND ( state = ? OR ? = '' ) AND ( country = ? ) AND payby != 'COMP' "; - my @param = qw( county county state state country ); # taxclass); + + my $taxwhere = my $fromwhere = " + FROM cust_bill_pkg + JOIN cust_bill USING ( invnum ) + JOIN cust_main USING ( custnum ) + "; + + $fromwhere .= $join_pkg. $where; + $taxwhere .= $where; + + my @taxparam = my @param = qw( county county state state country ); my $num_others = scalar_sql( $r, [qw( country state state county county taxname taxname )], @@ -111,8 +121,8 @@ foreach my $r ( #match itemdesc if necessary! my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) : ''; - my $x = scalar_sql($r, \@param, - "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere ". + my $x = scalar_sql($r, \@taxparam, + "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $taxwhere ". "AND pkgnum = 0 $named_tax", ); $tax += $x; -- cgit v1.2.1 From 5f69e7b4fa45c720a366eee314379ba10d5f8d34 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 25 Oct 2004 23:39:06 +0000 Subject: hopefully fix tax report for taxclass & named tax edge cases --- httemplate/search/report_tax.cgi | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index bb376214f..885c764da 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -64,18 +64,18 @@ foreach my $r ( my @taxparam = my @param = qw( county county state state country ); - my $num_others = - scalar_sql( $r, [qw( country state state county county taxname taxname )], - "SELECT COUNT(*) FROM cust_main_county - WHERE country = ? - AND ( state = ? OR ( state IS NULL AND ? = '' ) ) - AND ( county = ? OR ( county IS NULL AND ? = '' ) ) - AND ( taxname = ? OR ( taxname IS NULL AND ? = '' ) ) " - ); - - die "didn't even find self?" unless $num_others; - - if ( $num_others > 1 ) { +# my $num_others = +# scalar_sql( $r, [qw( country state state county county taxname taxname )], +# "SELECT COUNT(*) FROM cust_main_county +# WHERE country = ? +# AND ( state = ? OR ( state IS NULL AND ? = '' ) ) +# AND ( county = ? OR ( county IS NULL AND ? = '' ) ) +# AND ( taxname = ? OR ( taxname IS NULL AND ? = '' ) ) " +# ); +# +# die "didn't even find self?" unless $num_others; + + if ( $r->taxclass ) { $fromwhere .= " AND ( taxclass = ? ) "; push @param, 'taxclass'; } -- cgit v1.2.1 From 29a82b24b37fee37588efb96928574ac1a452d88 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 25 Oct 2004 23:47:30 +0000 Subject: hopefully fix tax report for taxclass & named tax edge cases --- httemplate/search/report_tax.cgi | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 885c764da..aec91c415 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -64,17 +64,6 @@ foreach my $r ( my @taxparam = my @param = qw( county county state state country ); -# my $num_others = -# scalar_sql( $r, [qw( country state state county county taxname taxname )], -# "SELECT COUNT(*) FROM cust_main_county -# WHERE country = ? -# AND ( state = ? OR ( state IS NULL AND ? = '' ) ) -# AND ( county = ? OR ( county IS NULL AND ? = '' ) ) -# AND ( taxname = ? OR ( taxname IS NULL AND ? = '' ) ) " -# ); -# -# die "didn't even find self?" unless $num_others; - if ( $r->taxclass ) { $fromwhere .= " AND ( taxclass = ? ) "; push @param, 'taxclass'; -- cgit v1.2.1 From a060dff493749162467afbdb5ccdb7144ea0c2d5 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Oct 2004 06:04:10 +0000 Subject: taxes are hard --- httemplate/search/report_tax.cgi | 128 ++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 49 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index aec91c415..838335b78 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -11,58 +11,48 @@ $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; my $pending = $1; my $ending = ( $1 ? str2time($1) : 4294880896 ) + 86399; +my $from_join_cust = " + FROM cust_bill_pkg + JOIN cust_bill USING ( invnum ) + JOIN cust_main USING ( custnum ) +"; +my $join_pkg = " + JOIN cust_pkg USING ( pkgnum ) + JOIN part_pkg USING ( pkgpart ) +"; +my $where = " + WHERE _date >= $beginning AND _date <= $ending + AND ( county = ? OR ? = '' ) + AND ( state = ? OR ? = '' ) + AND ( country = ? ) + AND payby != 'COMP' +"; +my @base_param = qw( county county state state country ); + +my $gotcust = " + WHERE 0 < ( SELECT COUNT(*) FROM cust_main + WHERE ( cust_main.county = cust_main_county.county + OR cust_main_county.county = '' + OR cust_main_county.county IS NULL ) + AND ( cust_main.state = cust_main_county.state + OR cust_main_county.state = '' + OR cust_main_county.state IS NULL ) + AND ( cust_main.country = cust_main_county.country ) + LIMIT 1 + ) +"; + my($total, $exempt, $taxable, $tax) = ( 0, 0, 0, 0 ); my $out = 'Out of taxable region(s)'; my %regions; -foreach my $r ( - qsearch('cust_main_county', {}, '', - "WHERE 0 < ( SELECT COUNT(*) FROM cust_main - WHERE ( cust_main.county = cust_main_county.county - OR cust_main_county.county = '' - OR cust_main_county.county IS NULL ) - AND ( cust_main.state = cust_main_county.state - OR cust_main_county.state = '' - OR cust_main_county.state IS NULL ) - AND ( cust_main.country = cust_main_county.country ) - LIMIT 1 - )" - ) -) { +foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { #warn $r->county. ' '. $r->state. ' '. $r->country. "\n"; - my $label; - if ( $r->tax == 0 ) { - $label = $out; - } elsif ( $r->taxname ) { - $label = $r->taxname; - } else { - $label = $r->country; - $label = $r->state.", $label" if $r->state; - $label = $r->county." county, $label" if $r->county; - } - - my $join_pkg = " - JOIN cust_pkg USING ( pkgnum ) - JOIN part_pkg USING ( pkgpart ) - "; - - my $where = " - WHERE _date >= $beginning AND _date <= $ending - AND ( county = ? OR ? = '' ) - AND ( state = ? OR ? = '' ) - AND ( country = ? ) - AND payby != 'COMP' - "; - my $taxwhere = my $fromwhere = " - FROM cust_bill_pkg - JOIN cust_bill USING ( invnum ) - JOIN cust_main USING ( custnum ) - "; - - $fromwhere .= $join_pkg. $where; - $taxwhere .= $where; + my $label = getlabel($r); + $regions{$label}->{'label'} = $label; - my @taxparam = my @param = qw( county county state state country ); + my $fromwhere = $from_join_cust. $join_pkg. $where; + my @param = @base_param; if ( $r->taxclass ) { $fromwhere .= " AND ( taxclass = ? ) "; @@ -93,6 +83,8 @@ foreach my $r ( ); $taxable += $t; $regions{$label}->{'taxable'} += $t; + $owed += $t * ($r->tax/100); + $regions{$label}->{'owed'} += $t * ($r->tax/100); my $x = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" @@ -108,6 +100,27 @@ foreach my $r ( $regions{$label}->{'rate'} = $r->tax.'%'; } +} + +my $taxwhere = "$from_join_cust $where"; +my @taxparam = @base_param; + +#foreach my $label ( keys %regions ) { +foreach my $r ( + qsearch( 'cust_main_county', + {}, + 'DISTINCT ON (country, state, county, taxname) *', + $gotcust + ) +) { + + #warn join('-', map { $r->$_() } qw( country state county taxname ) )."\n"; + + my $label = getlabel($r); + + my $fromwhere = $join_pkg. $where; + my @param = @base_param; + #match itemdesc if necessary! my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) : ''; my $x = scalar_sql($r, \@taxparam, @@ -117,8 +130,6 @@ foreach my $r ( $tax += $x; $regions{$label}->{'tax'} += $x; - $regions{$label}->{'label'} = $label; - } #ordering @@ -137,6 +148,23 @@ push @regions, { #-- +sub getlabel { + my $r = shift; + if ( $r->tax == 0 ) { + $label = $out; + } elsif ( $r->taxname ) { + $label = $r->taxname; +# $regions{$label}->{'taxname'} = $label; +# push @{$regions{$label}->{$_}}, $r->$_() foreach qw( county state country ); + } else { + $label = $r->country; + $label = $r->state.", $label" if $r->state; + $label = $r->county." county, $label" if $r->county; + #$label = $r->taxname. " ($label)" if $r->taxname; + } + return $label; +} + #false laziness w/FS::Report::Table::Monthly (sub should probably be moved up #to FS::Report or FS::Record or who the fuck knows where) sub scalar_sql { @@ -157,7 +185,8 @@ sub scalar_sql { - + + @@ -171,6 +200,7 @@ sub scalar_sql { + <% } %> -- cgit v1.2.1 From 717d562bcfb691d971a01b738d0b55cdda480cf0 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Oct 2004 06:33:29 +0000 Subject: and one last case with named and not named taxes in the same region, ack --- httemplate/search/report_tax.cgi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 838335b78..aa9ed6f11 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -122,7 +122,10 @@ foreach my $r ( my @param = @base_param; #match itemdesc if necessary! - my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) : ''; + my $named_tax = + $r->taxname + ? 'AND itemdesc = '. dbh->quote($r->taxname) + : "AND itemdesc IS NULL or itemdesc = ''"; my $x = scalar_sql($r, \@taxparam, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $taxwhere ". "AND pkgnum = 0 $named_tax", -- cgit v1.2.1 From fc1979c359ec54f2270f09480a9064e7b68019fe Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 31 Oct 2004 00:01:34 +0000 Subject: quick pay shouldnt default to exact search --- httemplate/search/cust_main-quickpay.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_main-quickpay.html b/httemplate/search/cust_main-quickpay.html index d48f1d08f..077d290d9 100755 --- a/httemplate/search/cust_main-quickpay.html +++ b/httemplate/search/cust_main-quickpay.html @@ -13,19 +13,19 @@ Search for last name: using search method:

Search for company: - using search methods: +

-- cgit v1.2.1 From 743a09e78017b7b03ed79dccb54accfa1b26c95f Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 9 Nov 2004 07:23:09 +0000 Subject: fixes to run under the mason strictness --- httemplate/search/report_tax.cgi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index aa9ed6f11..e3d203eb3 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -42,7 +42,7 @@ my $gotcust = " ) "; -my($total, $exempt, $taxable, $tax) = ( 0, 0, 0, 0 ); +my($total, $exempt, $taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); my $out = 'Out of taxable region(s)'; my %regions; foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { @@ -153,7 +153,11 @@ push @regions, { sub getlabel { my $r = shift; + + my $label; if ( $r->tax == 0 ) { + #kludge to avoid "will not stay shared" warning + my $out = 'Out of taxable region(s)'; $label = $out; } elsif ( $r->taxname ) { $label = $r->taxname; -- cgit v1.2.1 From 5b385021976c25fd312da16e9430df1fe4e89457 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 9 Nov 2004 09:13:37 +0000 Subject: fix for correct reporting of generic taxes --- httemplate/search/report_tax.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index e3d203eb3..601763bba 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -125,7 +125,7 @@ foreach my $r ( my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) - : "AND itemdesc IS NULL or itemdesc = ''"; + : "AND itemdesc IS NULL OR itemdesc = '' OR itemdesc = 'Tax'"; my $x = scalar_sql($r, \@taxparam, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $taxwhere ". "AND pkgnum = 0 $named_tax", -- cgit v1.2.1 From f2eeb9006f36d49a222e55f4d595a79cdef496fb Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 9 Nov 2004 09:31:09 +0000 Subject: parenthesis help alot --- httemplate/search/report_tax.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 601763bba..8cf6bd758 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -125,7 +125,7 @@ foreach my $r ( my $named_tax = $r->taxname ? 'AND itemdesc = '. dbh->quote($r->taxname) - : "AND itemdesc IS NULL OR itemdesc = '' OR itemdesc = 'Tax'"; + : "AND ( itemdesc IS NULL OR itemdesc = '' OR itemdesc = 'Tax' )"; my $x = scalar_sql($r, \@taxparam, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $taxwhere ". "AND pkgnum = 0 $named_tax", -- cgit v1.2.1 From 8d08e1ab9469979d5213621139a3f308ad7e5d16 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 9 Nov 2004 11:00:08 +0000 Subject: add handling for texas tax exemption and warning that report might not make sense for partial months other than the current one --- httemplate/search/report_tax.cgi | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 8cf6bd758..aa85be686 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -42,6 +42,7 @@ my $gotcust = " ) "; +my $monthly_exempt_warning = 0; my($total, $exempt, $taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); my $out = 'Out of taxable region(s)'; my %regions; @@ -81,16 +82,37 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my $t = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" ); - $taxable += $t; - $regions{$label}->{'taxable'} += $t; - $owed += $t * ($r->tax/100); - $regions{$label}->{'owed'} += $t * ($r->tax/100); my $x = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" ); + + my($sday,$smon,$syear) = (localtime($beginning) )[ 3, 4, 5 ]; + $monthly_exempt_warning=1 if $sday != 1 && $beginning; + $smon++; $syear+=1900; + + my($eday,$emon,$eyear) = (localtime($ending) )[ 3, 4, 5 ]; + $emon++; $eyear+=1900; + + my $monthly_exemption = scalar_sql($r, [ 'taxnum' ], + "SELECT SUM(amount) FROM cust_tax_exempt where taxnum = ? ". + " AND ( year > $syear OR ( year = $syear and month >= $smon ) )". + " AND ( year < $eyear OR ( year = $eyear and month <= $emon ) )" + ); + if ( $monthly_exemption ) { + $t -= $monthly_exemption; + $x += $monthly_exemption; + } + + $taxable += $t; + $regions{$label}->{'taxable'} += $t; + $exempt += $x; $regions{$label}->{'exempt'} += $x; + + $owed += $t * ($r->tax/100); + $regions{$label}->{'owed'} += $t * ($r->tax/100); + } if ( defined($regions{$label}->{'rate'}) @@ -214,6 +236,14 @@ sub scalar_sql {

Service #<%= FS::Msgcat::_gettext('svc_external-id') || 'External ID' %><%= FS::Msgcat::_gettext('svc_external-title') || 'Title' %>
$svcnum$id$title
Sales RateTaxTax owedTax invoiced
Total$<%= sprintf('%.2f', $region->{'exempt'} ) %> $<%= sprintf('%.2f', $region->{'taxable'} ) %> <%= $region->{'rate'} %>$<%= sprintf('%.2f', $region->{'owed'} ) %> $<%= sprintf('%.2f', $region->{'tax'} ) %>
+<% if ( $monthly_exempt_warning ) { %> +
+ Partial-month tax reports (except for current month) may not be correct due + to month-granularity tax exemption (usually "texas tax"). For an accurate + report, start on the first of a month and end on the last day of a month (or + leave blank for to now). +<% } %> + -- cgit v1.2.1 From bff7161b7d9f6d7218e69333556c2011d57049e1 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 9 Nov 2004 11:42:56 +0000 Subject: add handling for texas tax exemption and warning that report might not make sense for partial months other than the current one --- httemplate/search/report_tax.cgi | 51 +++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index aa85be686..587665740 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -77,43 +77,45 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { $regions{$label}->{'exempt'} += $x; } + my($t, $x) = (0, 0); foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { - my $t = scalar_sql($r, \@param, + $t += scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" ); - my $x = scalar_sql($r, \@param, + $x += scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" ); + } - my($sday,$smon,$syear) = (localtime($beginning) )[ 3, 4, 5 ]; - $monthly_exempt_warning=1 if $sday != 1 && $beginning; - $smon++; $syear+=1900; - - my($eday,$emon,$eyear) = (localtime($ending) )[ 3, 4, 5 ]; - $emon++; $eyear+=1900; + my($sday,$smon,$syear) = (localtime($beginning) )[ 3, 4, 5 ]; + $monthly_exempt_warning=1 if $sday != 1 && $beginning; + $smon++; $syear+=1900; - my $monthly_exemption = scalar_sql($r, [ 'taxnum' ], - "SELECT SUM(amount) FROM cust_tax_exempt where taxnum = ? ". - " AND ( year > $syear OR ( year = $syear and month >= $smon ) )". - " AND ( year < $eyear OR ( year = $eyear and month <= $emon ) )" - ); - if ( $monthly_exemption ) { - $t -= $monthly_exemption; - $x += $monthly_exemption; - } + my $eending = ( $ending == 4294967295 ) ? time : $ending; + my($eday,$emon,$eyear) = (localtime($eending) )[ 3, 4, 5 ]; + $emon++; $eyear+=1900; - $taxable += $t; - $regions{$label}->{'taxable'} += $t; + my $monthly_exemption = scalar_sql($r, [ 'taxnum' ], + "SELECT SUM(amount) FROM cust_tax_exempt where taxnum = ? ". + " AND ( year > $syear OR ( year = $syear and month >= $smon ) )". + " AND ( year < $eyear OR ( year = $eyear and month <= $emon ) )" + ); + #warn $r->taxnum(). ": $monthly_exemption\n"; + if ( $monthly_exemption ) { + $t -= $monthly_exemption; + $x += $monthly_exemption; + } - $exempt += $x; - $regions{$label}->{'exempt'} += $x; + $taxable += $t; + $regions{$label}->{'taxable'} += $t; - $owed += $t * ($r->tax/100); - $regions{$label}->{'owed'} += $t * ($r->tax/100); + $exempt += $x; + $regions{$label}->{'exempt'} += $x; - } + $owed += $t * ($r->tax/100); + $regions{$label}->{'owed'} += $t * ($r->tax/100); if ( defined($regions{$label}->{'rate'}) && $regions{$label}->{'rate'} != $r->tax.'%' ) { @@ -168,6 +170,7 @@ push @regions, { 'exempt' => $exempt, 'taxable' => $taxable, 'rate' => '', + 'owed' => $owed, 'tax' => $tax, }; -- cgit v1.2.1 From 48ba2845d0119c56971d5b724661aa37e73b49dd Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 20 Nov 2004 17:26:56 +0000 Subject: first pass at VoIP rating --- httemplate/search/sqlradius.cgi | 36 +++++++++++++++++++++++++++++++++--- httemplate/search/sqlradius.html | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 11 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index b506ba1cb..9e4a55e62 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -51,6 +51,15 @@ $ip = $1; } + my $prefix = $cgi->param('prefix'); + $prefix =~ s/\D//g; + if ( $prefix =~ /^(\d+)$/ ) { + $prefix = $1; + $prefix = "011$prefix" unless $prefix =~ /^1/; + } else { + $prefix = ''; + } + ### # field formatting subroutines ### @@ -221,11 +230,30 @@ # and finally, display the thing ### - foreach my $part_export ( map $_->rebless, + foreach my $part_export ( + #grep $_->can('usage_sessions'), qsearch( 'part_export' ) qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ), qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ) ) { %user2svc_acct = (); + + my $efields = tie my %efields, 'Tie::IxHash', %fields; + delete $efields{'framedipaddress'} if $part_export->option('hide_ip'); + if ( $part_export->option('hide_data') ) { + delete $efields{$_} foreach qw(acctinputoctets acctoutputoctets); + } + if ( $part_export->option('show_called_station') ) { + $efields->Splice(1, 0, + 'calledstationid' => { + 'name' => + 'attrib' => 'Called-Station-ID', + 'fmt' => + sub { length($_[0]) ? shift : ' '; }, + 'align' => 'left', + }, + ); + } + %> <%= $part_export->exporttype %> to <%= $part_export->machine %>
@@ -239,8 +267,10 @@ <% } %> <% foreach my $session ( - @{ $part_export->usage_sessions( $beginning, $ending, $cgi_svc_acct, $ip ) } -) { %> + @{ $part_export->usage_sessions( + $beginning, $ending, $cgi_svc_acct, $ip, $prefix, ) } + ) { +%> <% foreach my $field ( keys %fields ) { %> diff --git a/httemplate/search/sqlradius.html b/httemplate/search/sqlradius.html index 48a3d8680..f33313f81 100644 --- a/httemplate/search/sqlradius.html +++ b/httemplate/search/sqlradius.html @@ -15,14 +15,35 @@ (leave blank to show all users) - - IP address: - - - - - (leave blank to show all IPs) - + +<% my @part_export = qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ); + push @part_export, + qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ); +%> + +<% if ( grep { ! $_->option('hide_ip') } @part_export ) { %> + + IP address: + + + + + (leave blank to show all IPs) + +<% } %> + +<% if ( grep { $_->option('show_called_station') } @part_export ) { %> + + Destination prefix: + + + + + (country code or country code and prefix) + (leave blank to show all destinations) + +<% } %> + From: -- cgit v1.2.1 From d14421ac2a351bb1d934b1e3b16f3f806a239331 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Nov 2004 02:31:17 +0000 Subject: UI fix on search directions, fix bug preventing show_called_station, hide_ip and hide_data form working --- httemplate/search/sqlradius.cgi | 12 ++++++------ httemplate/search/sqlradius.html | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index 9e4a55e62..af6a4c640 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -259,10 +259,10 @@ <%= $part_export->exporttype %> to <%= $part_export->machine %>
<%= include( '/elements/table.html' ) %> - <% foreach my $field ( keys %fields ) { %> + <% foreach my $field ( keys %efields ) { %> - <%= $fields{$field}->{name} %>
- <%= $fields{$field}->{attrib} %> + <%= $efields{$field}->{name} %>
+ <%= $efields{$field}->{attrib} %> <% } %> @@ -272,9 +272,9 @@ ) { %> - <% foreach my $field ( keys %fields ) { %> - - <%= &{ $fields{$field}->{fmt} }( $session->{$field}, + <% foreach my $field ( keys %efields ) { %> + + <%= &{ $efields{$field}->{fmt} }( $session->{$field}, $session, $part_export, ) diff --git a/httemplate/search/sqlradius.html b/httemplate/search/sqlradius.html index f33313f81..20e8fb817 100644 --- a/httemplate/search/sqlradius.html +++ b/httemplate/search/sqlradius.html @@ -40,6 +40,9 @@ (country code or country code and prefix) + + + (leave blank to show all destinations) <% } %> -- cgit v1.2.1 From 97ddf39b5798913bbd2b0205b2767df2cd362a2b Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Nov 2004 11:11:02 +0000 Subject: Called-Station-ID label --- httemplate/search/sqlradius.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index af6a4c640..b84df1a03 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -245,7 +245,7 @@ if ( $part_export->option('show_called_station') ) { $efields->Splice(1, 0, 'calledstationid' => { - 'name' => + 'name' => 'Destination', 'attrib' => 'Called-Station-ID', 'fmt' => sub { length($_[0]) ? shift : ' '; }, -- cgit v1.2.1 From 6c6fb883997516b5369fe697ed79079a38f6c742 Mon Sep 17 00:00:00 2001 From: khoff Date: Wed, 24 Nov 2004 18:28:08 +0000 Subject: Added IP address search. --- httemplate/search/svc_broadband.cgi | 96 +++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 httemplate/search/svc_broadband.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/svc_broadband.cgi b/httemplate/search/svc_broadband.cgi new file mode 100755 index 000000000..efadce600 --- /dev/null +++ b/httemplate/search/svc_broadband.cgi @@ -0,0 +1,96 @@ +<% + +my $conf = new FS::Conf; + +my($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors +my(@svc_broadband,$sortby); +if ( $query eq 'svcnum' ) { + $sortby=\*svcnum_sort; + @svc_broadband=qsearch('svc_broadband',{}); +} elsif ( $query eq 'blocknum' ) { + $sortby=\*blocknum_sort; + @svc_broadband=qsearch('svc_broadband',{}); +} else { + $cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; + my($ip_addr)=$1; + @svc_broadband = qsearchs('svc_broadband',{'ip_addr'=>$ip_addr}); +} + +my %routerbyblock = (); +foreach my $router (qsearch('router', {})) { + foreach ($router->addr_block) { + $routerbyblock{$_->blocknum} = $router; + } +} + +if ( scalar(@svc_broadband) == 1 ) { + print $cgi->redirect(popurl(2). "view/svc_broadband.cgi?". $svc_broadband[0]->svcnum); + #exit; +} elsif ( scalar(@svc_broadband) == 0 ) { +%> + +<% + eidiot "No matching ip address found!\n"; +} else { +%> + +<% + my($total)=scalar(@svc_broadband); + print header("IP Address Search Results",''), < + + Service # + Router + IP Address + +END + + foreach my $svc_broadband ( + sort $sortby (@svc_broadband) + ) { + my($svcnum,$ip_addr,$routername,$routernum)=( + $svc_broadband->svcnum, + $svc_broadband->ip_addr, + $routerbyblock{$svc_broadband->blocknum}->routername, + $routerbyblock{$svc_broadband->blocknum}->routernum, + ); + + my $rowspan = 1; + + print < + $svcnum + $routername + $ip_addr +END + + #print @rows; + print ""; + + } + + print < + + +END + +} + +sub svcnum_sort { + $a->getfield('svcnum') <=> $b->getfield('svcnum'); +} + +sub blocknum_sort { + if ($a->getfield('blocknum') == $b->getfield('blocknum')) { + $a->getfield('ip_addr') cmp $b->getfield('ip_addr'); + } else { + $a->getfield('blocknum') cmp $b->getfield('blocknum'); + } +} + + +%> -- 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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 55a68e4aabe10db4d9c3ab1bb8befd2f9f4b9008 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 29 Jan 2005 12:34:12 +0000 Subject: registration codes --- httemplate/search/reg_code.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 httemplate/search/reg_code.html (limited to 'httemplate/search') diff --git a/httemplate/search/reg_code.html b/httemplate/search/reg_code.html new file mode 100644 index 000000000..ba1eee078 --- /dev/null +++ b/httemplate/search/reg_code.html @@ -0,0 +1,35 @@ +<% + +my $agentnum = $cgi->param('agentnum'); +$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum"; +$agentnum = $1; +my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); + +my $count_query = "SELECT COUNT(*) FROM reg_code WHERE agentnum = $agentnum"; + +%> +<%= include( 'elements/search.html', + 'title' => 'Unused Registration Codes for '. $agent->agent, + 'name' => 'registration codes', + 'query' => { 'table' => 'reg_code', + 'hashref' => { 'agentnum' => $agentnum, }, + }, + 'count_query' => $count_query, + #'redirect' => $link, + 'header' => [ qw(Code Packages) ], + 'fields' => [ + 'code', + sub { map { + qq!'. + $_->pkg. ' - '. $_->comment. + '
' + } $_[0]->part_pkg + }, + ], + 'links' => [ + '', + #$plink, + '', + ], + ) +%> -- cgit v1.2.1 From b1fc20ef3b68a8536163fbb17c57bca15555f3c4 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 4 Mar 2005 12:34:56 +0000 Subject: add agent selection to payment and credit reports, add link to agent browse, closes: Bug#1105 --- httemplate/search/cust_credit.html | 24 ++++++++++++++++-------- httemplate/search/cust_pay.cgi | 27 +++++++++++++++++---------- httemplate/search/elements/search.html | 8 +++++--- httemplate/search/report_cust_credit.html | 10 ++++++++++ httemplate/search/report_cust_pay.html | 10 ++++++++++ 5 files changed, 58 insertions(+), 21 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index faaa7a817..a3f88cc21 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -1,4 +1,5 @@ <% + my $title = 'Credit Search Results'; #my( $count_query, $sql_query ); my @search = (); @@ -7,6 +8,13 @@ push @search, "otaker = '$1'"; } + if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { + push @search, "agentnum = $1"; # $search{'agentnum'} = $1; + my $agent = qsearchs('agent', { 'agentnum' => $1 } ); + die "unknown agentnum $1" unless $agent; + $title = $agent->agent. " $title"; + } + #false laziness with cust_pkg.cgi and cust_pay.cgi if ( $cgi->param('beginning') && $cgi->param('beginning') =~ /^([ 0-9\-\/]{1,10})$/ ) { @@ -32,18 +40,22 @@ ? 'WHERE '. join(' AND ', @search) : ''; - my $count_query = "SELECT COUNT(*), SUM(amount) FROM cust_credit $where"; + my $count_query = 'SELECT COUNT(*), SUM(amount) '. + 'FROM cust_credit JOIN cust_main USING ( custnum ) '. + $where; + my $sql_query = { 'table' => 'cust_credit', 'hashref' => {}, 'extra_sql' => $where, + 'addl_from' => 'JOIN cust_main USING ( custnum )', }; my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; %> <%= include( 'elements/search.html', - 'title' => 'Credit Search Results', + 'title' => $title, 'name' => 'credits', 'query' => $sql_query, 'count_query' => $count_query, @@ -57,12 +69,8 @@ sub { sprintf('$%.2f', shift->amount ) }, sub { time2str('%b %d %Y', shift->_date ) }, 'custnum', - sub { my $cust_main = shift->cust_main; - $cust_main->get('last'). ', '. $cust_main->first; - }, - sub { my $cust_main = shift->cust_main; - $cust_main->company; - }, + sub { $_[0]->get('last'). ', '. $_[0]->first; }, + 'company', 'otaker', 'reason', ], diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 3f5b72ab5..42b3c01bc 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,9 +1,17 @@ <% + my $title = 'Payment Search Results'; my( $count_query, $sql_query ); if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { - my %search; - my @search; + my %search = (); + my @search = (); + + if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { + push @search, "agentnum = $1"; # $search{'agentnum'} = $1; + my $agent = qsearchs('agent', { 'agentnum' => $1 } ); + die "unknown agentnum $1" unless $agent; + $title = $agent->agent. " $title"; + } if ( $cgi->param('payby') ) { $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ @@ -59,14 +67,17 @@ } my $hsearch = join(' AND ', map { "$_ = '$search{$_}'" } keys %search ); - $count_query = "SELECT COUNT(*), SUM(paid) FROM cust_pay ". + $count_query = "SELECT COUNT(*), SUM(paid) ". + "FROM cust_pay JOIN cust_main USING ( custnum )". ( $hsearch ? " WHERE $hsearch " : '' ). $search; + warn join('-', keys %search); $sql_query = { 'table' => 'cust_pay', 'hashref' => \%search, 'extra_sql' => "$search ORDER BY _date", + 'addl_from' => 'JOIN cust_main USING ( custnum )', }; } else { @@ -93,7 +104,7 @@ %> <%= include( 'elements/search.html', - 'title' => 'Payment Search Results', + 'title' => $title, 'name' => 'payments', 'query' => $sql_query, 'count_query' => $count_query, @@ -117,12 +128,8 @@ sub { sprintf('$%.2f', shift->paid ) }, sub { time2str('%b %d %Y', shift->_date ) }, 'custnum', - sub { my $cust_main = shift->cust_main; - $cust_main->get('last'). ', '. $cust_main->first; - }, - sub { my $cust_main = shift->cust_main; - $cust_main->company; - }, + sub { $_[0]->get('last'). ', '. $_[0]->first; }, + 'company', ], 'align' => 'lrrrll', 'links' => [ diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 566ea8391..712d63a91 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -12,9 +12,9 @@ $opt{align} = [ map $align{$_}, split(//, $opt{align}) ], unless !$opt{align} || ref($opt{align}); - if ( ref($opt{'query'}) ) { - - } + #if ( ref($opt{'query'}) ) { + # + #} unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { ( $opt{'count_query'} = $opt{'query'} ) =~ @@ -47,6 +47,8 @@ $opt{'query'}->{'hashref'} || {}, $opt{'query'}->{'select'}, $opt{'query'}->{'extra_sql'}. " $limit", + '', + (exists($opt{'query'}->{'addl_from'}) ? $opt{'query'}->{'addl_from'} : '') ) ]; } else { my $sth = dbh->prepare("$opt{'query'} $limit") diff --git a/httemplate/search/report_cust_credit.html b/httemplate/search/report_cust_credit.html index ceffca75d..b614e87b2 100644 --- a/httemplate/search/report_cust_credit.html +++ b/httemplate/search/report_cust_credit.html @@ -27,6 +27,16 @@ + + for agent: + + + From:
m/d/y diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 95198c7b2..d1d4cb983 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -24,6 +24,16 @@ + + for agent: + + + From:
m/d/y -- cgit v1.2.1 From f8e7f53109f36e3c649dc509b61c75c3c44fb519 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 4 Mar 2005 12:57:53 +0000 Subject: report correctly even if the customer record has somehow been removed... --- httemplate/search/cust_credit.html | 4 ++-- httemplate/search/cust_pay.cgi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index a3f88cc21..85128bca2 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -41,14 +41,14 @@ : ''; my $count_query = 'SELECT COUNT(*), SUM(amount) '. - 'FROM cust_credit JOIN cust_main USING ( custnum ) '. + 'FROM cust_credit LEFT JOIN cust_main USING ( custnum ) '. $where; my $sql_query = { 'table' => 'cust_credit', 'hashref' => {}, 'extra_sql' => $where, - 'addl_from' => 'JOIN cust_main USING ( custnum )', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', }; my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 42b3c01bc..64fe1f93a 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -68,7 +68,7 @@ my $hsearch = join(' AND ', map { "$_ = '$search{$_}'" } keys %search ); $count_query = "SELECT COUNT(*), SUM(paid) ". - "FROM cust_pay JOIN cust_main USING ( custnum )". + "FROM cust_pay LEFT JOIN cust_main USING ( custnum )". ( $hsearch ? " WHERE $hsearch " : '' ). $search; @@ -77,7 +77,7 @@ 'table' => 'cust_pay', 'hashref' => \%search, 'extra_sql' => "$search ORDER BY _date", - 'addl_from' => 'JOIN cust_main USING ( custnum )', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', }; } else { -- cgit v1.2.1 From f34557b8890dcc63db6c5588233dc7bfa9d39f22 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 4 Mar 2005 22:24:27 +0000 Subject: fix "Column reference "payby" is ambiguous" error when selecting by payment type, fix missing check #s caused by cust_main.payinfo masking cust_pay.payinfo, closes (really this time): Bug#1105 --- httemplate/search/cust_credit.html | 3 ++- httemplate/search/cust_pay.cgi | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index 85128bca2..8f6258e4e 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -9,7 +9,7 @@ } if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { - push @search, "agentnum = $1"; # $search{'agentnum'} = $1; + push @search, "agentnum = $1"; my $agent = qsearchs('agent', { 'agentnum' => $1 } ); die "unknown agentnum $1" unless $agent; $title = $agent->agent. " $title"; @@ -46,6 +46,7 @@ my $sql_query = { 'table' => 'cust_credit', + 'select' => 'cust_credit.*, cust_main.last, cust_main.first, cust_main.company', 'hashref' => {}, 'extra_sql' => $where, 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 64fe1f93a..d4aaaa89c 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -3,7 +3,6 @@ my( $count_query, $sql_query ); if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { - my %search = (); my @search = (); if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { @@ -16,7 +15,7 @@ if ( $cgi->param('payby') ) { $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ or die "illegal payby ". $cgi->param('payby'); - $search{'payby'} = $1; + push @search, "cust_pay.payby = '$1'"; if ( $3 ) { if ( $3 eq 'VisaMC' ) { #avoid posix regexes for portability @@ -60,22 +59,19 @@ push @search, " _date < $1 "; } - my $search; + my $search = ''; if ( @search ) { - $search = ( scalar(keys %search) ? ' AND ' : ' WHERE ' ). - join(' AND ', @search); + $search = ' WHERE '. join(' AND ', @search); } - my $hsearch = join(' AND ', map { "$_ = '$search{$_}'" } keys %search ); $count_query = "SELECT COUNT(*), SUM(paid) ". "FROM cust_pay LEFT JOIN cust_main USING ( custnum )". - ( $hsearch ? " WHERE $hsearch " : '' ). $search; - warn join('-', keys %search); $sql_query = { 'table' => 'cust_pay', - 'hashref' => \%search, + 'select' => 'cust_pay.*, cust_main.last, cust_main.first, cust_main.company', + 'hashref' => {}, 'extra_sql' => "$search ORDER BY _date", 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', }; -- 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_bill.html | 79 ++++--- httemplate/search/cust_bill_event.html | 2 +- httemplate/search/cust_credit.html | 63 +++-- httemplate/search/cust_main-otaker.cgi | 2 +- httemplate/search/cust_main-payinfo.html | 2 +- httemplate/search/cust_main-quickpay.html | 2 +- httemplate/search/cust_main.cgi | 2 +- httemplate/search/cust_main.html | 2 +- httemplate/search/cust_pay.cgi | 77 +++--- httemplate/search/cust_pay.html | 2 +- httemplate/search/cust_pkg_report.cgi | 2 +- httemplate/search/elements/search.html | 334 +++++++++++++++++++-------- httemplate/search/reg_code.html | 51 ++-- httemplate/search/report_cust_credit.html | 2 +- httemplate/search/report_cust_pay.html | 2 +- httemplate/search/report_prepaid_income.html | 2 +- httemplate/search/report_tax.html | 2 +- httemplate/search/sqlradius.html | 2 +- httemplate/search/svc_acct.html | 2 +- httemplate/search/svc_domain.html | 2 +- httemplate/search/svc_www.cgi | 31 ++- 21 files changed, 404 insertions(+), 261 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 3ae624af2..440e468e3 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -58,44 +58,43 @@ : ''; }; -%> -<%= include( 'elements/search.html', - 'title' => 'Invoice Search Results', - 'name' => 'invoices', - 'query' => $sql_query, - 'count_query' => $count_query, - 'count_addl' => [ '$%.2f total invoiced', - '$%.2f total outstanding balance', - ], - 'redirect' => $link, - 'header' => - [ 'Invoice #', qw(Balance Amount Date), 'Contact name', - 'Company' ], - 'fields' => [ - 'invnum', - sub { sprintf('$%.2f', shift->get('owed') ) }, - sub { sprintf('$%.2f', shift->charged ) }, - sub { time2str('%b %d %Y', shift->_date ) }, - sub { my $cust_bill = shift; - my $cust_main = $cust_bill->cust_main; - $cust_main - ? $cust_main->get('last'). ', '. $cust_main->first - : "WARNING: can't find cust_main.custnum ". - $cust_bill->custnum. ' (cust_bill.invnum '. - $cust_bill->invnum. ')'; - }, - sub { my $cust_main = shift->cust_main; - $cust_main ? $cust_main->company : ''; - }, - ], - 'links' => [ - $link, - $link, - $link, - $link, - $clink, - $clink, - ], - - ) +%><%= include( 'elements/search.html', + 'title' => 'Invoice Search Results', + 'name' => 'invoices', + 'query' => $sql_query, + 'count_query' => $count_query, + 'count_addl' => [ '$%.2f total invoiced', + '$%.2f total outstanding balance', + ], + 'redirect' => $link, + 'header' => + [ 'Invoice #', qw(Balance Amount Date), 'Contact name', + 'Company' ], + 'fields' => [ + 'invnum', + sub { sprintf('$%.2f', shift->get('owed') ) }, + sub { sprintf('$%.2f', shift->charged ) }, + sub { time2str('%b %d %Y', shift->_date ) }, + sub { my $cust_bill = shift; + my $cust_main = $cust_bill->cust_main; + $cust_main + ? $cust_main->get('last'). ', '. $cust_main->first + : "WARNING: can't find cust_main.custnum ". + $cust_bill->custnum. ' (cust_bill.invnum '. + $cust_bill->invnum. ')'; + }, + sub { my $cust_main = shift->cust_main; + $cust_main ? $cust_main->company : ''; + }, + ], + 'links' => [ + $link, + $link, + $link, + $link, + $clink, + $clink, + ], + + ) %> diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index cd96ddf51..6de27091f 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -8,7 +8,7 @@

Invoice event errors

-
+ -<% - eidiot "No matching forwards found!\n"; -} else { -%> - -<% - my $total = scalar(@svc_forward); - print header("Mail forward Search Results",''), < 'svc_forward', + 'hashref' => {}, + 'extra_sql' => $orderby, +}; - $total matching mail forwards found -
- - - - - -END +# +# +# - foreach my $svc_forward ( - sort $sortby (@svc_forward) - ) { - my $svcnum = $svc_forward->svcnum; +my $link = [ "${p}/view/svc_forward.cgi?", 'svcnum' ]; +my $format_src = sub { + my $svc_forward = shift; + if ( $svc_forward->srcsvc_acct ) { + $svc_forward->srcsvc_acct->email; + } else { my $src = $svc_forward->src; $src = "(anything)$src" if $src =~ /^@/; - if ( $svc_forward->srcsvc_acct ) { - $src = qq!'. - $svc_forward->srcsvc_acct->email. ''; - } + $src; + } +}; - my $dst = $svc_forward->dst; - if ( $svc_forward->dstsvc_acct ) { - $dst = qq!'. - $svc_forward->dstsvc_acct->email. ''; - } +my $link_src = sub { + my $svc_forward = shift; + if ( $svc_forward->srcsvc_acct ) { + [ "${p}view/svc_acct.cgi?", 'srcsvc' ]; + } else { + ''; + } +}; - print < - - - - -END +my $format_dst = sub { + my $svc_forward = shift; + if ( $svc_forward->dstsvc_acct ) { + $svc_forward->dstsvc_acct->email; + } else { + $svc_forward->dst; + } +}; +my $link_dst = sub { + my $svc_forward = shift; + if ( $svc_forward->dstsvc_acct ) { + [ "${p}view/svc_acct.cgi?", 'dstsvc' ]; + } else { + ''; } - - print < - - -END +}; -} +#this would quite a bit more efficient as a left join as part of the main query +my $format_cust = sub { + my $svc_forward = shift; + my $cust_pkg = $svc_forward->cust_svc->cust_pkg; + if ( $cust_pkg ) { + $cust_pkg->cust_main->name; + } else { + ''; + } +}; -sub svcnum_sort { - $a->getfield('svcnum') <=> $b->getfield('svcnum'); -} +my $link_cust = sub { + my $svc_forward = shift; + my $cust_pkg = $svc_forward->cust_svc->cust_pkg; + if ( $cust_pkg ) { + [ "${p}view/cust_main.cgi?", sub { shift->cust_svc->cust_pkg->custnum } ]; + } else { + ''; + } +}; +%><%= include ('elements/search.html', + 'title' => "Mail forward Search Results", + 'name' => 'mail forwards', + 'query' => $sql_query, + 'count_query' => $count_query, + 'redirect' => $link, + 'header' => [ '#', + 'Mail to', + 'Forwards to', + 'Customer', + ], + 'fields' => [ 'svcnum', + $format_src, + $format_dst, + $format_cust, + ], + 'links' => [ $link, + $link_src, + $link_dst, + $link_cust, + ], + ) %> diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index 141661992..5ae72f8b3 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -4,7 +4,7 @@ my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors -my(@svc_www, $orderby); +my $orderby; if ( $query eq 'svcnum' ) { $orderby = 'ORDER BY svcnum'; } else { -- cgit v1.2.1 From d99603dfa659bc8890433e7de0c3e64ecc82fd9c Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 30 Apr 2005 09:45:39 +0000 Subject: pull in the customer information as part of the main query for efficiency --- httemplate/search/svc_forward.cgi | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index 9ffbab3d1..1785fa00b 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -15,14 +15,21 @@ my $count_query = 'SELECT COUNT(*) FROM svc_forward'; my $sql_query = { 'table' => 'svc_forward', 'hashref' => {}, + 'select' => join(', ', + 'svc_forward.*', + map "cust_main.$_", qw(custnum last first company) + ), 'extra_sql' => $orderby, + 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. + 'LEFT JOIN cust_pkg USING ( pkgnum )'. + 'LEFT JOIN cust_main USING ( custnum )', }; # # # -my $link = [ "${p}/view/svc_forward.cgi?", 'svcnum' ]; +my $link = [ "${p}view/svc_forward.cgi?", 'svcnum' ]; my $format_src = sub { my $svc_forward = shift; @@ -62,12 +69,14 @@ my $link_dst = sub { } }; -#this would quite a bit more efficient as a left join as part of the main query my $format_cust = sub { my $svc_forward = shift; - my $cust_pkg = $svc_forward->cust_svc->cust_pkg; - if ( $cust_pkg ) { - $cust_pkg->cust_main->name; + + if ( $svc_forward->custnum ) { + #false laziness w/FS::cust_main::name + my $name = $svc_forward->get('last'). ', '. $svc_forward->first; + $name = $svc_forward->company. " ($name)" if $svc_forward->company; + $name; } else { ''; } @@ -75,9 +84,8 @@ my $format_cust = sub { my $link_cust = sub { my $svc_forward = shift; - my $cust_pkg = $svc_forward->cust_svc->cust_pkg; - if ( $cust_pkg ) { - [ "${p}view/cust_main.cgi?", sub { shift->cust_svc->cust_pkg->custnum } ]; + if ( $svc_forward->custnum ) { + [ "${p}view/cust_main.cgi?", 'custnum' ]; } else { ''; } -- cgit v1.2.1 From aea197c3f695b917a0dbdef5ec056d583f6df55d Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 30 Apr 2005 09:47:40 +0000 Subject: show "(unlinked)" for unlined forwards instead of nothing --- httemplate/search/svc_forward.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index 1785fa00b..f54822572 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -78,7 +78,7 @@ my $format_cust = sub { $name = $svc_forward->company. " ($name)" if $svc_forward->company; $name; } else { - ''; + '(unlinked)'; } }; -- cgit v1.2.1 From 2eb5fc5cdbe002fd17a4d3ee5bde71b4f5422f8b Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 2 May 2005 06:32:10 +0000 Subject: move httemplate/search/svc_domain to the new search template along with svc_www and svc_forward --- httemplate/search/svc_domain.cgi | 206 ++++++++++++-------------------------- httemplate/search/svc_forward.cgi | 26 +---- httemplate/search/svc_www.cgi | 21 +++- 3 files changed, 89 insertions(+), 164 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 948b1d9ae..8d6547ca8 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -4,158 +4,80 @@ my $conf = new FS::Conf; my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors -my(@svc_domain,$sortby); + +my $orderby = 'ORDER BY svcnum'; +my $join = ''; +my %svc_domain = (); +my $extra_sql = ''; if ( $query eq 'svcnum' ) { - $sortby=\*svcnum_sort; - @svc_domain=qsearch('svc_domain',{}); + #$orderby = 'ORDER BY svcnum'; } elsif ( $query eq 'domain' ) { - $sortby=\*domain_sort; - @svc_domain=qsearch('svc_domain',{}); + $orderby = 'ORDER BY domain'; } elsif ( $query eq 'UN_svcnum' ) { - $sortby=\*svcnum_sort; - @svc_domain = grep qsearchs('cust_svc',{ - 'svcnum' => $_->svcnum, - 'pkgnum' => '', - }), qsearch('svc_domain',{}); + #$orderby = 'ORDER BY svcnum'; + $join = 'LEFT JOIN cust_svc USING ( svcnum )'; + $extra_sql = ' WHERE pkgnum IS NULL'; } elsif ( $query eq 'UN_domain' ) { - $sortby=\*domain_sort; - @svc_domain = grep qsearchs('cust_svc',{ - 'svcnum' => $_->svcnum, - 'pkgnum' => '', - }), qsearch('svc_domain',{}); + $orderby = 'ORDER BY domain'; + $join = 'LEFT JOIN cust_svc USING ( svcnum )'; + $extra_sql = ' WHERE pkgnum IS NULL'; } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { - @svc_domain = - qsearch( 'svc_domain', {}, '', - " WHERE $1 = ( SELECT svcpart FROM cust_svc ". - " WHERE cust_svc.svcnum = svc_domain.svcnum ) " - ); - $sortby=\*svcnum_sort; + #$orderby = 'ORDER BY svcnum'; + $join = 'LEFT JOIN cust_svc USING ( svcnum )'; + $extra_sql = " WHERE svcpart = $1"; } else { $cgi->param('domain') =~ /^([\w\-\.]+)$/; - my($domain)=$1; - #push @svc_domain, qsearchs('svc_domain',{'domain'=>$domain}); - @svc_domain = qsearchs('svc_domain',{'domain'=>$domain}); + $join = ''; + $svc_domain{'domain'} = $1; } -if ( scalar(@svc_domain) == 1 ) { - print $cgi->redirect(popurl(2). "view/svc_domain.cgi?". $svc_domain[0]->svcnum); - #exit; -} elsif ( scalar(@svc_domain) == 0 ) { -%> - -<% - eidiot "No matching domains found!\n"; -} else { -%> - -<% - my($total)=scalar(@svc_domain); - print header("Domain Search Results",''), < - - - - - -END - -# my(%saw); # if we've multiple domains with the same - # svcnum, then we've a corrupt database - - foreach my $svc_domain ( -# sort $sortby grep(!$saw{$_->svcnum}++, @svc_domain) - sort $sortby (@svc_domain) - ) { - my($svcnum,$domain)=( - $svc_domain->svcnum, - $svc_domain->domain, - ); - - #don't display all accounts here - my $rowspan = 1; - - #my @svc_acct=qsearch('svc_acct',{'domsvc' => $svcnum}); - #my $rowspan = 0; - # - #my $n1 = ''; - #my($svc_acct, @rows); - #foreach $svc_acct ( - # sort {$b->getfield('username') cmp $a->getfield('username')} (@svc_acct) - #) { - # - # my (@forwards) = (); - # - # my($svcnum,$username)=( - # $svc_acct->svcnum, - # $svc_acct->username, - # ); - # - # my @svc_forward = qsearch( 'svc_forward', { 'srcsvc' => $svcnum } ); - # my $svc_forward; - # foreach $svc_forward (@svc_forward) { - # my($dstsvc,$dst) = ( - # $svc_forward->dstsvc, - # $svc_forward->dst, - # ); - # if ($dstsvc) { - # my $dst_svc_acct=qsearchs( 'svc_acct', { 'svcnum' => $dstsvc } ); - # my $destination=$dst_svc_acct->email; - # push @forwards, qq!! - # ; - # }else{ - # push @forwards, qq!! - # ; - # } - # } - # - # push @rows, qq!$n1!, - # ; - # - # push @rows, @forwards; - # - # $rowspan += (scalar(@svc_forward) || 1); - # $n1 = ""; - #} - ##end of false laziness - # - # - - print < - - -END - - #print @rows; - print ""; - - } - - print < - - -END +my $count_query = "SELECT COUNT(*) FROM svc_domain $join $extra_sql"; +if ( keys %svc_domain ) { + $count_query .= ' WHERE '. + join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}), + keys %svc_domain + ); } -sub svcnum_sort { - $a->getfield('svcnum') <=> $b->getfield('svcnum'); -} - -sub domain_sort { - $a->getfield('domain') cmp $b->getfield('domain'); -} - - +my $sql_query = { + 'table' => 'svc_domain', + 'hashref' => \%svc_domain, + 'select' => join(', ', + 'svc_domain.*', + map "cust_main.$_", qw(custnum last first company) + ), + 'extra_sql' => "$extra_sql $orderby", + 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. + 'LEFT JOIN cust_pkg USING ( pkgnum )'. + 'LEFT JOIN cust_main USING ( custnum )', +}; + +my $link = [ "${p}view/svc_domain.cgi", 'svcnum' ]; + +#smaller false laziness w/svc_*.cgi here +my $link_cust = sub { + my $svc_x = shift; + $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; +}; + +%><%= include ('elements/search.html', + 'title' => "Domain Search Results", + 'name' => 'domains', + 'query' => $sql_query, + 'count_query' => $count_query, + 'redirect' => $link, + 'header' => [ '#', + 'Domain', + 'Customer', + ], + 'fields' => [ 'svcnum', + 'domain', + \&FS::svc_Common::cust_name, + ], + 'links' => [ $link, + $link, + $link_cust, + ], + ) %> diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index f54822572..1c1c6e4dd 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -4,7 +4,7 @@ my $conf = new FS::Conf; my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors -my($orderby); +my $orderby; if ( $query eq 'svcnum' ) { $orderby = 'ORDER BY svcnum'; } else { @@ -69,26 +69,10 @@ my $link_dst = sub { } }; -my $format_cust = sub { - my $svc_forward = shift; - - if ( $svc_forward->custnum ) { - #false laziness w/FS::cust_main::name - my $name = $svc_forward->get('last'). ', '. $svc_forward->first; - $name = $svc_forward->company. " ($name)" if $svc_forward->company; - $name; - } else { - '(unlinked)'; - } -}; - +#smaller false laziness w/svc_*.cgi here my $link_cust = sub { - my $svc_forward = shift; - if ( $svc_forward->custnum ) { - [ "${p}view/cust_main.cgi?", 'custnum' ]; - } else { - ''; - } + my $svc_x = shift; + $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; }; %><%= include ('elements/search.html', @@ -105,7 +89,7 @@ my $link_cust = sub { 'fields' => [ 'svcnum', $format_src, $format_dst, - $format_cust, + \&FS::svc_Common::cust_name, ], 'links' => [ $link, $link_src, diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index 5ae72f8b3..de1f5dd78 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -15,27 +15,46 @@ my $count_query = 'SELECT COUNT(*) FROM svc_www'; my $sql_query = { 'table' => 'svc_www', 'hashref' => {}, + 'select' => join(', ', + 'svc_www.*', + map "cust_main.$_", qw(custnum last first company) + ), 'extra_sql' => $orderby, + 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. + 'LEFT JOIN cust_pkg USING ( pkgnum )'. + 'LEFT JOIN cust_main USING ( custnum )', }; my $link = [ "${p}view/svc_www.cgi?", 'svcnum', ]; #my $dlink = [ "${p}view/svc_www.cgi?", 'svcnum', ]; my $ulink = [ "${p}view/svc_acct.cgi?", 'usersvc', ]; +#smaller false laziness w/svc_*.cgi here +my $link_cust = sub { + my $svc_x = shift; + $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; +}; %><%= include( 'elements/search.html', 'title' => 'Virtual Host Search Results', 'name' => 'virtual hosts', 'query' => $sql_query, 'count_query' => $count_query, - 'header' => [ '#', 'Zone', 'User', ], + 'redirect' => $link, + 'header' => [ '#', + 'Zone', + 'User', + 'Customer', + ], 'fields' => [ 'svcnum', sub { $_[0]->domain_record->zone }, sub { $_[0]->svc_acct->email }, + \&FS::svc_Common::cust_name, ], 'links' => [ $link, '', $ulink, + $link_cust, ], ) %> -- cgit v1.2.1 From d0772a4270e8a4d54770c2f33591a69bb94a9dc9 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 5 May 2005 01:46:30 +0000 Subject: the ? between svc_domain.cgi and the domain id is missing --- httemplate/search/svc_domain.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 8d6547ca8..06041e03b 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -53,7 +53,7 @@ my $sql_query = { 'LEFT JOIN cust_main USING ( custnum )', }; -my $link = [ "${p}view/svc_domain.cgi", 'svcnum' ]; +my $link = [ "${p}view/svc_domain.cgi?", 'svcnum' ]; #smaller false laziness w/svc_*.cgi here my $link_cust = sub { -- cgit v1.2.1 From 4f4b72f7bc9399ab3bab5963cbde8f51865f1aea Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 May 2005 11:46:58 +0000 Subject: align --- httemplate/search/cust_bill.html | 1 + 1 file changed, 1 insertion(+) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 440e468e3..9cd5a7041 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -87,6 +87,7 @@ $cust_main ? $cust_main->company : ''; }, ], + 'align' => 'rrrrll', 'links' => [ $link, $link, -- cgit v1.2.1 From ccf0fd3e5cbdb4b3d88b11b7ab290d9a280a4c5c Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 May 2005 11:58:41 +0000 Subject: use money_char config --- httemplate/search/cust_bill.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 9cd5a7041..c41befa41 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -58,6 +58,9 @@ : ''; }; + my $conf = new FS::Conf; + my $money_char = $conf->config('money_char') || '$'; + %><%= include( 'elements/search.html', 'title' => 'Invoice Search Results', 'name' => 'invoices', @@ -72,8 +75,8 @@ 'Company' ], 'fields' => [ 'invnum', - sub { sprintf('$%.2f', shift->get('owed') ) }, - sub { sprintf('$%.2f', shift->charged ) }, + sub { sprintf($money_char.'%.2f', shift->get('owed') ) }, + sub { sprintf($money_char.'%.2f', shift->charged ) }, sub { time2str('%b %d %Y', shift->_date ) }, sub { my $cust_bill = shift; my $cust_main = $cust_bill->cust_main; -- cgit v1.2.1 From ae7a7aedd844e581638d435e432e08a76f8097d1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 May 2005 13:01:00 +0000 Subject: move receivables report to search template --- httemplate/search/elements/search.html | 42 +++++++- httemplate/search/report_receivables.cgi | 171 +++++++++++++++++++------------ 2 files changed, 146 insertions(+), 67 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 92889c5f7..529f48f20 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -245,11 +245,18 @@ %> <% if ( $opt{'fields'} ) { - my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; + + my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; + my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : []; + my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : []; + my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : []; + foreach my $field ( @{$opt{'fields'}} ) { + my $align = $aligns ? shift @$aligns : ''; $align = " ALIGN=$align" if $align; + my $a = ''; if ( $links ) { my $link = shift @$links; @@ -264,11 +271,32 @@ $a = qq(); } } + + my $font = ''; + my $color = shift @$colors; + $color = &{$color}($row) if ref($color) eq 'CODE'; + my $size = shift @$sizes; + $size = &{$size}($row) if ref($size) eq 'CODE'; + if ( $color || $size ) { + $font = ''; + } + + my($s, $es) = ( '', '' ); + my $style = shift @$styles; + $style = &{$style}($row) if ref($style) eq 'CODE'; + if ( $style ) { + $s = join( '', map "<$_>", split('', $style) ); + $es = join( '', map "", split('', $style) ); + } + %> <% if ( ref($field) eq 'CODE' ) { %> - + <% } else { %> - + <% } %> <% } %> <% } else { %> @@ -278,6 +306,14 @@ <% } %> <% } %> + + <% if ( $opt{'footer'} ) { %> + + <% foreach my $footer ( @{ $opt{'footer'} } ) { %> + + <% } %>
Service #
(click to view forward)
Mail to
(click to view account)
Forwards to
(click to view account)
Service #
(click to view forward)
Mail to
(click to view account)
Forwards to
(click to view account)
$svcnum$src$dst
Service #
(click to view forward)
Mail to
(click to view account)
Forwards to
(click to view account)
Service #Domain
$destination!, - # qq!
$dst
!, - # #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); - # ( ($username eq '*') ? "(anything)" : $username ), - # qq!\@$domain
$svcnum$domain
><%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %>><%= $font %><%= $a %><%= $s %><%= &{$field}($row) %><%= $es %><%= $a ? '' : '' %><%= $font ? '' : '' %>><%= $a %><%= $row->$field() %><%= $a ? '' : '' %>><%= $font %><%= $a %><%= $s %><%= $row->$field() %><%= $es %><%= $a ? '' : '' %><%= $font ? '' : '' %>
<%= $footer %> + <% } %> +
<%= $pager %> diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 0e95ad73c..6a2dff3e1 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -1,4 +1,3 @@ - <% my $charged = <prepare($sql) or die dbh->errstr; - $sth->execute or die $sth->errstr; + my $sql_query = { + 'table' => 'cust_main', + 'hashref' => {}, + 'select' => "*, $owed_cols, $packages_cols", + 'extra_sql' => "$where order by coalesce(lower(company), ''), lower(last)", + }; + my $total_sql = "select $owed_cols"; my $total_sth = dbh->prepare($total_sql) or die dbh->errstr; $total_sth->execute or die $total_sth->errstr; - -%> -<%= header('Accounts Receivable Aging Summary', menubar( 'Main Menu'=>$p, ) ) %> -<%= table() %> - - Customer - Status - 0-30 - 30-60 - 60-90 - 90+ - Total - -<% while ( my $row = $sth->fetchrow_hashref() ) { - my $status = 'Cancelled'; - my $statuscol = 'FF0000'; - if ( $row->{uncancelled_pkgs} ) { - $status = 'Suspended'; - $statuscol = 'FF9900'; - if ( $row->{active_pkgs} ) { - $status = 'Active'; - $statuscol = '00CC00'; - } - } + my $row = $total_sth->fetchrow_hashref(); + + my $conf = new FS::Conf; + my $money_char = $conf->config('money_char') || '$'; + +%><%= include( 'elements/search.html', + 'title' => 'Accounts Receivable Aging Summary', + 'name' => 'customers', + 'query' => $sql_query, + 'count_query' => $count_sql, + 'header' => [ + '#', + 'Customer', + 'Status (me)', + 'Status (cust_main)', + '0-30', + '30-60', + '60-90', + '90+', + 'Total', + ], + 'footer' => [ + '', + 'Total', + '', + '', + sprintf( $money_char.'%.2f', + $row->{'owed_0_30'} ), + sprintf( $money_char.'%.2f', + $row->{'owed_30_60'} ), + sprintf( $money_char.'%.2f', + $row->{'owed_60_90'} ), + sprintf( $money_char.'%.2f', + $row->{'owed_90_pl'} ), + sprintf( ''. $money_char.'%.2f'. '', + $row->{'owed_total'} ), + ], + 'align' => 'rlccrrrrr', + 'size' => [ '', '', '-1', '-1', '', '', '', '', '', ], + 'style' => [ '', '', 'b', 'b', '', '', '', '', 'b', ], + 'color' => [ + '', + '', + sub { + my $row = shift; + my $status = 'Cancelled'; + my $statuscol = 'FF0000'; + if ( $row->uncancelled_pkgs ) { + $status = 'Suspended'; + $statuscol = 'FF9900'; + if ( $row->active_pkgs ) { + $status = 'Active'; + $statuscol = '00CC00'; + } + } + $statuscol; + }, + sub { shift->statuscolor; }, + '', + '', + '', + '', + '', + ], + 'fields' => [ + 'custnum', + 'name', + sub { + my $row = shift; + my $status = 'Cancelled'; + my $statuscol = 'FF0000'; + if ( $row->uncancelled_pkgs ) { + $status = 'Suspended'; + $statuscol = 'FF9900'; + if ( $row->active_pkgs ) { + $status = 'Active'; + $statuscol = '00CC00'; + } + } + $status; + }, + sub { ucfirst(shift->status) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_0_30') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_30_60') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_60_90') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_90_pl') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_total') ) }, + ], + ) %> - - <%= $row->{'custnum'} %>: - <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %><%= $row->{'last'}. ', '. $row->{'first'} %><%= $row->{'company'} ? ')' : '' %> - - <%= $status %> - $<%= sprintf("%.2f", $row->{'owed_0_30'} ) %> - $<%= sprintf("%.2f", $row->{'owed_30_60'} ) %> - $<%= sprintf("%.2f", $row->{'owed_60_90'} ) %> - $<%= sprintf("%.2f", $row->{'owed_90_plus'} ) %> - $<%= sprintf("%.2f", $row->{'owed_total'} ) %> - -<% } %> -<% my $row = $total_sth->fetchrow_hashref(); %> - -   - - - Total - $<%= sprintf("%.2f", $row->{'owed_0_30'} ) %> - $<%= sprintf("%.2f", $row->{'owed_30_60'} ) %> - $<%= sprintf("%.2f", $row->{'owed_60_90'} ) %> - $<%= sprintf("%.2f", $row->{'owed_90_plus'} ) %> - $<%= sprintf("%.2f", $row->{'owed_total'} ) %> - - - - + -- cgit v1.2.1 From 2fd0023de631502a7a3b86cf7e8269ae7030d248 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 May 2005 13:49:39 +0000 Subject: this status column is probably faster, one giant SQL query. and add back in the customer link, oops --- httemplate/search/report_receivables.cgi | 71 +++++++++++++++++++------------- 1 file changed, 43 insertions(+), 28 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 6a2dff3e1..4c835fb7a 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -116,8 +116,8 @@ END 'header' => [ '#', 'Customer', - 'Status (me)', - 'Status (cust_main)', + 'Status', # (me)', + #'Status', # (cust_main)', '0-30', '30-60', '60-90', @@ -128,7 +128,7 @@ END '', 'Total', '', - '', + #'', sprintf( $money_char.'%.2f', $row->{'owed_0_30'} ), sprintf( $money_char.'%.2f', @@ -140,13 +140,10 @@ END sprintf( ''. $money_char.'%.2f'. '', $row->{'owed_total'} ), ], - 'align' => 'rlccrrrrr', - 'size' => [ '', '', '-1', '-1', '', '', '', '', '', ], - 'style' => [ '', '', 'b', 'b', '', '', '', '', 'b', ], - 'color' => [ - '', - '', - sub { + 'fields' => [ + 'custnum', + 'name', + sub { my $row = shift; my $status = 'Cancelled'; my $statuscol = 'FF0000'; @@ -158,19 +155,41 @@ END $statuscol = '00CC00'; } } - $statuscol; + $status; }, - sub { shift->statuscolor; }, + #sub { ucfirst(shift->status) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_0_30') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_30_60') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_60_90') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_90_pl') ) }, + sub { sprintf( $money_char.'%.2f', + shift->get('owed_total') ) }, + ], + 'links' => [ + [ "${p}view/cust_main.cgi?", 'custnum' ], + [ "${p}view/cust_main.cgi?", 'custnum' ], + '', + #'', '', '', '', '', '', ], - 'fields' => [ - 'custnum', - 'name', - sub { + #'align' => 'rlccrrrrr', + 'align' => 'rlcrrrrr', + #'size' => [ '', '', '-1', '-1', '', '', '', '', '', ], + #'style' => [ '', '', 'b', 'b', '', '', '', '', 'b', ], + 'size' => [ '', '', '-1', '', '', '', '', '', ], + 'style' => [ '', '', 'b', '', '', '', '', 'b', ], + 'color' => [ + '', + '', + sub { my $row = shift; my $status = 'Cancelled'; my $statuscol = 'FF0000'; @@ -182,20 +201,16 @@ END $statuscol = '00CC00'; } } - $status; + $statuscol; }, - sub { ucfirst(shift->status) }, - sub { sprintf( $money_char.'%.2f', - shift->get('owed_0_30') ) }, - sub { sprintf( $money_char.'%.2f', - shift->get('owed_30_60') ) }, - sub { sprintf( $money_char.'%.2f', - shift->get('owed_60_90') ) }, - sub { sprintf( $money_char.'%.2f', - shift->get('owed_90_pl') ) }, - sub { sprintf( $money_char.'%.2f', - shift->get('owed_total') ) }, + #sub { shift->statuscolor; }, + '', + '', + '', + '', + '', ], + ) %> -- cgit v1.2.1 From 2f3390c76813f42a5456730f58a5fcb69d320bde Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 18 May 2005 16:55:23 +0000 Subject: add agent-specific A/R aging report, closes: bug#1229 --- httemplate/search/report_receivables.cgi | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 4c835fb7a..77e1d4a36 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -91,6 +91,12 @@ where 0 < ) END + my $agentnum = ''; + if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { + $agentnum = $1; + $where .= " AND agentnum = '$agentnum' "; + } + my $count_sql = "select count(*) from cust_main $where"; my $sql_query = { @@ -100,6 +106,10 @@ END 'extra_sql' => "$where order by coalesce(lower(company), ''), lower(last)", }; + if ( $agentnum ) { + $owed_cols =~ + s/cust_bill\.custnum/cust_bill.custnum AND cust_main.agentnum = '$agentnum'/g; + } my $total_sql = "select $owed_cols"; my $total_sth = dbh->prepare($total_sql) or die dbh->errstr; $total_sth->execute or die $total_sth->errstr; -- 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') 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 From 6e918c4ba54daf05f833920ff6ac648f58fa6d17 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 1 Jun 2005 21:40:59 +0000 Subject: remove trailing whitespace --- httemplate/search/report_receivables.cgi | 1 - 1 file changed, 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 77e1d4a36..82ce5d777 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -223,4 +223,3 @@ END ) %> - -- cgit v1.2.1 From 684a478c0f88e5bf6d1d3f32f4618089146b5709 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Jun 2005 09:29:56 +0000 Subject: add ability to search on a date range of invoice events and then reprint or reemail (boy was that a bit more work than i expected), closes: Bug#946 --- httemplate/search/cust_bill_event.cgi | 166 ++++++++++++++++++++++----------- httemplate/search/cust_bill_event.html | 18 ++-- httemplate/search/elements/search.html | 1 + 3 files changed, 124 insertions(+), 61 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index 7c2b3a24c..253aa78ad 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -1,62 +1,120 @@ - <% -#false laziness with view/cust_bill.cgi +my $title = $cgi->param('failed') ? 'Failed invoice events' : 'Invoice events'; -$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; -my $beginning = str2time($1) || 0; +my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); -$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; -my $ending = ( $1 ? str2time($1) : 4294880896 ) + 86399; +##tie my %hash, 'Tie::DxHash', +#my %hash = ( +# _date => { op=> '>=', value=>$beginning }, +## i wish... +## _date => { op=> '<=', value=>$ending }, +#); +#$hash{'statustext'} = { op=> '!=', value=>'' } +# if $cgi->param('failed'); -my @cust_bill_event = - sort { $a->_date <=> $b->_date } - qsearch('cust_bill_event', { - _date => { op=> '>=', value=>$beginning }, - statustext => { op=> '!=', value=>'' }, -# i wish... -# _date => { op=> '<=', value=>$ending }, - }, '', "AND _date <= $ending"); +my $where = " WHERE cust_bill_event._date >= $beginning". + " AND cust_bill_event._date <= $ending"; +$where .= " AND statustext != '' AND statustext IS NOT NULL" + if $cgi->param('failed'); + +my $sql_query = { + 'table' => 'cust_bill_event', + #'hashref' => \%hash, + 'hashref' => {}, + 'select' => join(', ', + 'cust_bill_event.*', + 'part_bill_event.event', + 'cust_bill.custnum', + 'cust_bill._date AS cust_bill_date', + map "cust_main.$_", qw(last first company) + + ), + 'extra_sql' => "$where ORDER BY _date ASC", + 'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '. + 'LEFT JOIN cust_bill USING ( invnum ) '. + 'LEFT JOIN cust_main USING ( custnum ) ', +}; + +my $count_sql = "select count(*) from cust_bill_event $where"; + +my $conf = new FS::Conf; + +my $failed = $cgi->param('failed'); + +my $html_init = join("\n", map { + ( my $action = $_ ) =~ s/_$//; + include('/elements/progress-init.html', + $_.'form', + [ 'action', 'beginning', 'ending', 'failed' ], + "../misc/${_}invoices.cgi", + { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but... + $_, #key + ), + qq!!, + qq!!, #not used though + qq!!, + qq!!, + qq!!, + qq!! +} qw( print_ email_ fax_ ) ); + +my $menubar = [ + 'Main menu' => $p, + 'Re-print these events' => + "javascript:print_process()", + 'Re-email these events' => + "javascript:email_process()", + ]; + +push @$menubar, 'Re-fax these events' => + "javascript:fax_process()" + if $conf->exists('hylafax'); + +%><%= include( 'elements/search.html', + 'title' => $title, + 'html_init' => $html_init, + 'menubar' => $menubar, + 'name' => 'billing events', + 'query' => $sql_query, + 'count_query' => $count_sql, + 'header' => [ qw( Event Date Status ), + #'Inv #', 'Inv Date', 'Cust #', + 'Invoice', 'Cust #', + ], + 'fields' => [ + 'event', + sub { time2str("%b %d %Y %T", $_[0]->_date) }, + sub { + #my $cust_bill_event = shift; + my $status = $_[0]->status; + $status .= ': '.$_[0]->statustext + if $_[0]->statustext; + $status; + }, + sub { + #my $cust_bill_event = shift; + 'Invoice #'. $_[0]->invnum. + ' ('. + time2str("%D", $_[0]->cust_bill_date). + ')'; + }, + sub { FS::cust_main::name($_[0]) }, -%> -<%= header('Failed billing events') %> - -<%= table() %> - - Event - Date - Status - Invoice - (bill) name - company -<% if ( defined dbdef->table('cust_main')->column('ship_last') ) { %> - (service) name - company -<% } %> - - -<% foreach my $cust_bill_event ( @cust_bill_event ) { - my $status = $cust_bill_event->status; - $status .= ': '.$cust_bill_event->statustext if $cust_bill_event->statustext; - my $cust_bill = $cust_bill_event->cust_bill; - my $cust_main = $cust_bill->cust_main; - my $invlink = "${p}view/cust_bill.cgi?". $cust_bill->invnum; - my $custlink = "${p}view/cust_main.cgi?". $cust_main->custnum; + ], + 'links' => [ + '', + '', + '', + sub { + my $part_bill_event = shift; + my $template = $part_bill_event->templatename; + $template .= '-' if $template; + [ "${p}view/cust_bill.cgi?$template", 'invnum']; + }, + [ "${p}view/cust_main.cgi?", 'custnum' ], + [ "${p}view/cust_main.cgi?", 'custnum' ], + ], + ) %> - - <%= $cust_bill_event->part_bill_event->event %> - <%= time2str("%a %b %e %T %Y", $cust_bill_event->_date) %> - <%= $status %> - Invoice #<%= $cust_bill->invnum %> (<%= time2str("%D", $cust_bill->_date ) %>) - <%= $cust_main->last. ', '. $cust_main->first %> - <%= $cust_main->company %> - <% if ( defined dbdef->table('cust_main')->column('ship_last') ) { %> - <%= $cust_main->ship_last. ', '. $cust_main->ship_first %> - <%= $cust_main->ship_company %> - <% } %> - -<% } %> - - - diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index 6de27091f..cebb3035f 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -1,14 +1,19 @@ - - - Invoice event errors +<%= include( + '/elements/header.html', + ( $cgi->param('failed') ? 'Failed invoice events' : 'invoice events' ), + include('/elements/menubar.html', + 'Main menu' => $p, # popurl(2), + ), + + ) +%> - - -

Invoice event errors

+
+ -<% - idiot("Account not found"); -} else { -%> - -<% - $total ||= scalar(@svc_acct); - - #begin pager - my $pager = ''; - if ( $total != scalar(@svc_acct) && $maxrecords ) { - unless ( $offset == 0 ) { - $cgi->param('offset', $offset - $maxrecords); - $pager .= 'Previous '; - } - my $poff; - my $page; - for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { - $page++; - if ( $offset == $poff ) { - $pager .= qq!$page !; - } else { - $cgi->param('offset', $poff); - $pager .= qq!$page !; - } - } - unless ( $offset + $maxrecords > $total ) { - $cgi->param('offset', $offset + $maxrecords); - $pager .= 'Next '; - } - } - #end pager - - print header("Account Search Results",menubar('Main Menu'=>popurl(2))), - "$total matching accounts found

$pager", - &table(), < - - - - - - - - -END - if ( defined dbdef->table('cust_main')->column('ship_last') ) { - print <(service) name - -END - } - print ""; + $orderby = "ORDER BY uid"; - my(%saw,$svc_acct); - my $p = popurl(2); - foreach $svc_acct ( - sort $sortby grep(!$saw{$_->svcnum}++, @svc_acct) - ) { - my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svc_acct->svcnum }) - or die "No cust_svc record for svcnum ". $svc_acct->svcnum; - my $part_svc = qsearchs('part_svc', { 'svcpart' => $cust_svc->svcpart }) - or die "No part_svc record for svcpart ". $cust_svc->svcpart; - - my $domain; - my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc }); - if ( $svc_domain ) { - $domain = "svcnum. - "\">". $svc_domain->domain. ""; - } else { - die "No svc_domain.svcnum record for svc_acct.domsvc: ". - $svc_acct->domsvc; - } - my($cust_pkg,$cust_main); - if ( $cust_svc->pkgnum ) { - $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc->pkgnum }) - or die "No cust_pkg record for pkgnum ". $cust_svc->pkgnum; - $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pkg->custnum }) - or die "No cust_main record for custnum ". $cust_pkg->custnum; - } - my($svcnum, $username, $uid, $svc, $custnum, $last, $first, $company) = ( - $svc_acct->svcnum, - $svc_acct->getfield('username'), - $svc_acct->getfield('uid'), - $part_svc->svc, - $cust_svc->pkgnum ? $cust_main->custnum : '', - $cust_svc->pkgnum ? $cust_main->getfield('last') : '', - $cust_svc->pkgnum ? $cust_main->getfield('first') : '', - $cust_svc->pkgnum ? $cust_main->company : '', - ); - my($pcustnum) = $custnum - ? "$custnum" - : "(unlinked)" - ; - my $pname = $custnum ? "$last, $first" : ''; - my $pcompany = $custnum ? "$company" : ''; - my($pship_name, $pship_company); - if ( defined dbdef->table('cust_main')->column('ship_last') ) { - my($ship_last, $ship_first, $ship_company) = ( - $cust_svc->pkgnum ? ( $cust_main->ship_last || $last ) : '', - $cust_svc->pkgnum ? ( $cust_main->ship_last - ? $cust_main->ship_first - : $first - ) : '', - $cust_svc->pkgnum ? ( $cust_main->ship_last - ? $cust_main->ship_company - : $company - ) : '', - ); - $pship_name = $custnum ? "$ship_last, $ship_first" : ''; - $pship_company = $custnum ? "$ship_company" : ''; - } - print < - - - - - "; - - } - - print "
#UsernameDomainUIDServiceCust#(bill) namecompanycompany
$svcnum$username$domain$uid$svc - $pcustnum - $pname - $pcompany -END - if ( defined dbdef->table('cust_main')->column('ship_last') ) { - print <$pship_name - $pship_company -END - } - print "
$pager
". - ''; - -} - -sub svcnum_sort { - $a->getfield('svcnum') <=> $b->getfield('svcnum'); -} - -sub username_sort { - $a->getfield('username') cmp $b->getfield('username'); -} - -sub uid_sort { - $a->getfield('uid') <=> $b->getfield('uid'); -} - -sub usernamesearch { - - my @svc_acct; + my @username_sql; my %username_type; foreach ( $cgi->param('username_type') ) { @@ -254,17 +41,13 @@ sub usernamesearch { $cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text my $username = $1; - if ( $username_type{'Exact'} || $username_type{'Fuzzy'} ) { - push @svc_acct, qsearch( 'svc_acct', - { 'username' => { 'op' => 'ILIKE', - 'value' => $username } } ); - } + push @username_sql, "username ILIKE '$username'" + if $username_type{'Exact'} + || $username_type{'Fuzzy'}; - if ( $username_type{'Substring'} || $username_type{'All'} ) { - push @svc_acct, qsearch( 'svc_acct', - { 'username' => { 'op' => 'ILIKE', - 'value' => "%$username%" } } ); - } + push @username_sql, "username ILIKE '\%$username\%'" + if $username_type{'Substring'} + || $username_type{'All'}; if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { &FS::svc_acct::check_and_rebuild_fuzzyfiles; @@ -280,15 +63,78 @@ sub usernamesearch { #if ($username_type{'Sound-alike'}) { #} - foreach ( keys %username ) { - push @svc_acct, qsearch('svc_acct',{'username'=>$_}); - } + push @username_sql, "username = '$_'" + foreach (keys %username); } - #[ qsearch('svc_acct',{'username'=>$username}) ]; - \@svc_acct; + push @extra_sql, '( '. join( ' OR ', @username_sql). ' )'; } +my $extra_sql = + scalar(@extra_sql) + ? ' WHERE '. join(' AND ', @extra_sql ) + : ''; + +my $count_query = "SELECT COUNT(*) FROM svc_acct $cjoin $extra_sql"; +#if ( keys %svc_acct ) { +# $count_query .= ' WHERE '. +# join(' AND ', map "$_ = ". dbh->quote($svc_acct{$_}), +# keys %svc_acct +# ); +#} + +my $sql_query = { + 'table' => 'svc_acct', + 'hashref' => {}, # \%svc_acct, + 'select' => join(', ', + 'svc_acct.*', + 'cust_main.custnum', + FS::UI::Web::cust_sql_fields(), + ), + 'extra_sql' => "$extra_sql $orderby", + 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) '. + 'LEFT JOIN part_svc USING ( svcpart ) '. + 'LEFT JOIN cust_pkg USING ( pkgnum ) '. + 'LEFT JOIN cust_main USING ( custnum ) ', +}; + +my $link = [ "${p}view/svc_acct.cgi?", 'svcnum' ]; +my $link_cust = sub { + my $svc_acct = shift; + if ( $svc_acct->custnum ) { + [ "${p}view/cust_main.cgi?", 'custnum' ]; + } else { + ''; + } +}; + +%><%= include( 'elements/search.html', + 'title' => 'Account Search Results', + 'name' => 'accounts', + 'query' => $sql_query, + 'count_query' => $count_query, + 'redirect' => $link, + 'header' => [ '#', + 'Account', + 'UID', + 'Service', + FS::UI::Web::cust_header(), + ], + 'fields' => [ 'svcnum', + 'email', + 'uid', + 'svc', + \&FS::UI::Web::cust_fields, + ], + 'links' => [ $link, + $link, + $link, + '', + ( map { $link_cust } + FS::UI::Web::cust_header() + ), + ], + ) %> diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 06041e03b..f261ea9f3 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -37,7 +37,6 @@ if ( keys %svc_domain ) { join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}), keys %svc_domain ); - } my $sql_query = { @@ -45,12 +44,13 @@ my $sql_query = { 'hashref' => \%svc_domain, 'select' => join(', ', 'svc_domain.*', - map "cust_main.$_", qw(custnum last first company) + 'cust_main.custnum', + FS::UI::Web::cust_sql_fields(), ), 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. - 'LEFT JOIN cust_pkg USING ( pkgnum )'. - 'LEFT JOIN cust_main USING ( custnum )', + 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) '. + 'LEFT JOIN cust_pkg USING ( pkgnum ) '. + 'LEFT JOIN cust_main USING ( custnum ) ', }; my $link = [ "${p}view/svc_domain.cgi?", 'svcnum' ]; @@ -69,15 +69,17 @@ my $link_cust = sub { 'redirect' => $link, 'header' => [ '#', 'Domain', - 'Customer', + FS::UI::Web::cust_header(), ], 'fields' => [ 'svcnum', 'domain', - \&FS::svc_Common::cust_name, + \&FS::UI::Web::cust_fields, ], 'links' => [ $link, $link, - $link_cust, + ( map { $link_cust } + FS::UI::Web::cust_header() + ), ], ) %> diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index 1c1c6e4dd..330c0ee83 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -17,7 +17,8 @@ my $sql_query = { 'hashref' => {}, 'select' => join(', ', 'svc_forward.*', - map "cust_main.$_", qw(custnum last first company) + 'cust_main.custnum', + FS::UI::Web::cust_sql_fields(), ), 'extra_sql' => $orderby, 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. @@ -75,7 +76,7 @@ my $link_cust = sub { $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; }; -%><%= include ('elements/search.html', +%><%= include( 'elements/search.html', 'title' => "Mail forward Search Results", 'name' => 'mail forwards', 'query' => $sql_query, @@ -84,17 +85,19 @@ my $link_cust = sub { 'header' => [ '#', 'Mail to', 'Forwards to', - 'Customer', + FS::UI::Web::cust_header(), ], 'fields' => [ 'svcnum', $format_src, $format_dst, - \&FS::svc_Common::cust_name, + \&FS::UI::Web::cust_fields, ], 'links' => [ $link, $link_src, $link_dst, - $link_cust, + ( map { $link_cust } + FS::UI::Web::cust_header() + ), ], - ) + ) %> diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index de1f5dd78..ae51c61fc 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -17,7 +17,8 @@ my $sql_query = { 'hashref' => {}, 'select' => join(', ', 'svc_www.*', - map "cust_main.$_", qw(custnum last first company) + 'cust_main.custnum', + FS::UI::Web::cust_sql_fields(), ), 'extra_sql' => $orderby, 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. @@ -44,17 +45,25 @@ my $link_cust = sub { 'header' => [ '#', 'Zone', 'User', - 'Customer', + FS::UI::Web::cust_header(), ], 'fields' => [ 'svcnum', sub { $_[0]->domain_record->zone }, - sub { $_[0]->svc_acct->email }, - \&FS::svc_Common::cust_name, + sub { + my $svc_www = shift; + my $svc_acct = $svc_www->svc_acct; + $svc_acct + ? $svc_acct->email + : ''; + }, + \&FS::UI::Web::cust_fields, ], 'links' => [ $link, '', $ulink, - $link_cust, + ( map { $link_cust } + FS::UI::Web::cust_header() + ), ], ) %> -- cgit v1.2.1 From 541d9682ea6f43e78b59dbf2f2aa282843117360 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 14 Jul 2005 11:18:06 +0000 Subject: move account search (httemplate/search/svc_acct.cgi) to new template, cust-fields configuration value to control which customer fields are shown on reports --- httemplate/search/cust_bill.html | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 5e904e114..2108653a8 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -95,7 +95,7 @@ 'cust_bill.*', #( map "cust_main.$_", qw(custnum last first company) ), 'cust_main.custnum as cust_main_custnum', - ( map "cust_main.$_", qw(last first company) ), + FS::UI::Web::cust_sql_fields(), "$owed as owed", ), 'extra_sql' => "$extra_sql $orderby" @@ -106,8 +106,7 @@ my $link = [ "${p}view/cust_bill.cgi?", 'invnum', ]; my $clink = sub { my $cust_bill = shift; - my $cust_main = $cust_bill->cust_main; - $cust_main + $cust_bill->cust_main_custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; }; @@ -154,32 +153,18 @@ 'count_query' => $count_query, 'count_addl' => $count_addl, 'redirect' => $link, - 'header' => - [ 'Invoice #', qw(Balance Amount Date), 'Contact name', - 'Company' ], + 'header' => [ 'Invoice #', + 'Balance', + 'Amount', + 'Date', + FS::UI::Web::cust_header(), + ], 'fields' => [ 'invnum', sub { sprintf($money_char.'%.2f', shift->get('owed') ) }, sub { sprintf($money_char.'%.2f', shift->charged ) }, sub { time2str('%b %d %Y', shift->_date ) }, - sub { my $cust_bill = shift; - # my $cust_main = $cust_bill->cust_main; - # $cust_main - # ? $cust_main->get('last'). ', '. $cust_main->first - # : "WARNING: can't find cust_main.custnum ". - # $cust_bill->custnum. ' (cust_bill.invnum '. - # $cust_bill->invnum. ')'; - if ( $cust_bill->cust_main_custnum ) { - FS::cust_main::name($cust_bill); - } else { - "WARNING: can't find cust_main.custnum ". - $cust_bill->custnum. ' (cust_bill.invnum '. - $cust_bill->invnum. ')'; - } - }, - sub { my $cust_main = shift->cust_main; - $cust_main ? $cust_main->company : ''; - }, + \&FS::UI::Web::cust_fields, ], 'align' => 'rrrrll', 'links' => [ @@ -187,8 +172,7 @@ $link, $link, $link, - $clink, - $clink, + ( map { $clink } FS::UI::Web::cust_header() ), ], ) -- cgit v1.2.1 From 49d7852b0a4f44ada7bf704ebdaaa856a9e828a3 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 14 Jul 2005 11:31:35 +0000 Subject: add unlinked mail forward (svc_forward) report --- httemplate/search/svc_acct.cgi | 8 ++++---- httemplate/search/svc_forward.cgi | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index d4565aefc..b14591958 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -94,10 +94,10 @@ my $sql_query = { FS::UI::Web::cust_sql_fields(), ), 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) '. - 'LEFT JOIN part_svc USING ( svcpart ) '. - 'LEFT JOIN cust_pkg USING ( pkgnum ) '. - 'LEFT JOIN cust_main USING ( custnum ) ', + 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '. + ' LEFT JOIN part_svc USING ( svcpart ) '. + ' LEFT JOIN cust_pkg USING ( pkgnum ) '. + ' LEFT JOIN cust_main USING ( custnum ) ', }; my $link = [ "${p}view/svc_acct.cgi?", 'svcnum' ]; diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index 330c0ee83..a204e345f 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -4,14 +4,30 @@ my $conf = new FS::Conf; my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors + + my $orderby; + +my $cjoin = ''; +my @extra_sql = (); +if ( $query =~ /^UN_(.*)$/ ) { + $query = $1; + $cjoin = 'LEFT JOIN cust_svc USING ( svcnum )'; + push @extra_sql, 'pkgnum IS NULL'; +} + if ( $query eq 'svcnum' ) { $orderby = 'ORDER BY svcnum'; } else { eidiot('unimplemented'); } -my $count_query = 'SELECT COUNT(*) FROM svc_forward'; +my $extra_sql = + scalar(@extra_sql) + ? ' WHERE '. join(' AND ', @extra_sql ) + : ''; + +my $count_query = "SELECT COUNT(*) FROM svc_forward $cjoin $extra_sql"; my $sql_query = { 'table' => 'svc_forward', 'hashref' => {}, @@ -20,10 +36,11 @@ my $sql_query = { 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), - 'extra_sql' => $orderby, - 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. - 'LEFT JOIN cust_pkg USING ( pkgnum )'. - 'LEFT JOIN cust_main USING ( custnum )', + 'extra_sql' => "$extra_sql $orderby", + 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '. + ' LEFT JOIN part_svc USING ( svcpart ) '. + ' LEFT JOIN cust_pkg USING ( pkgnum ) '. + ' LEFT JOIN cust_main USING ( custnum ) ', }; # Service #
(click to view forward) -- cgit v1.2.1 From 05d94720d26ca009b06f21534b06d1650d9f2915 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 5 Aug 2005 00:57:59 +0000 Subject: fix credit searches by otaker --- httemplate/search/cust_credit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index 4b3da605a..279d682cd 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -5,7 +5,7 @@ my @search = (); if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) { - push @search, "otaker = '$1'"; + push @search, "cust_credit.otaker = '$1'"; } if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { -- cgit v1.2.1 From 6ed5d51b3a72e2935dd5d084c9e24567150b03ca Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Aug 2005 00:40:02 +0000 Subject: move cust_pkg search to new template, add active/suspended/cancelled customer packages to agent browse --- httemplate/search/cust_pay.cgi | 26 +- httemplate/search/cust_pkg.cgi | 517 +++++++++++++-------------------- httemplate/search/elements/search.html | 59 +++- 3 files changed, 256 insertions(+), 346 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index a680479f3..da3d12523 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -41,27 +41,11 @@ } } } - - #false laziness with cust_pkg.cgi - if ( $cgi->param('beginning') - && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $beginning = str2time($1); - push @search, "_date >= $beginning "; - } - if ( $cgi->param('ending') - && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $ending = str2time($1) + 86399; - push @search, " _date <= $ending "; - } - if ( $cgi->param('begin') - && $cgi->param('begin') =~ /^(\d+)$/ ) { - push @search, "_date >= $1 "; - } - if ( $cgi->param('end') - && $cgi->param('end') =~ /^(\d+)$/ ) { - push @search, " _date < $1 "; - } - + + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); + push @search, "_date >= $beginning ", + "_date <= $ending"; + my $search = ''; if ( @search ) { $search = ' WHERE '. join(' AND ', @search); diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 6d26317e0..5da4d82fb 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,363 +1,234 @@ <% -my $conf = new FS::Conf; -my $maxrecords = $conf->config('maxsearchrecordsperpage'); - my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {}); -my $limit = ''; -$limit .= "LIMIT $maxrecords" if $maxrecords; - -my $offset = $cgi->param('offset') || 0; -$limit .= " OFFSET $offset" if $offset; - -my $total; - my($query) = $cgi->keywords; -my $sortby; -my @cust_pkg; -if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { - $sortby=\*bill_sort; - - #false laziness with cust_pay.cgi - my $range = ''; - if ( $cgi->param('beginning') - && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $beginning = str2time($1); - $range = " WHERE bill >= $beginning "; - } - if ( $cgi->param('ending') - && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - my $ending = str2time($1) + 86399; - $range .= ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; - } +my $orderby; +my @where; +my $cjoin = ''; - $range .= ( $range ? 'AND ' : ' WHERE ' ). '( cancel IS NULL OR cancel = 0 )'; +if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { + $cjoin = "LEFT JOIN cust_main USING ( custnum )"; + push @where, + "agentnum = $1"; +} - if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { - $range .= ( $range ? 'AND ' : ' WHERE ' ). - "$1 = ( SELECT agentnum FROM cust_main". - " WHERE cust_main.custnum = cust_pkg.custnum )"; - } +if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { + $orderby = 'ORDER BY bill'; - #false laziness with below - my $statement = "SELECT COUNT(*) FROM cust_pkg $range"; - warn $statement; - 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]; - - @cust_pkg = qsearch('cust_pkg',{}, '', " $range ORDER BY bill $limit" ); + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); + push @where, + "bill >= $beginning ", + "bill <= $ending", + '( cancel IS NULL OR cancel = 0 )'; } else { - my $qual = ''; if ( $cgi->param('magic') && - $cgi->param('magic') =~ /^(active|suspended|canceled)$/ + $cgi->param('magic') =~ /^(active|suspended|cancell?ed)$/ ) { + $orderby = 'ORDER BY pkgnum'; + if ( $cgi->param('magic') eq 'active' ) { - $qual = 'WHERE ( susp IS NULL OR susp = 0 )'. - ' AND ( cancel IS NULL OR cancel = 0)'; + + #push @where, + # '( susp IS NULL OR susp = 0 )', + # '( cancel IS NULL OR cancel = 0)'; + push @where, FS::cust_pkg->active_sql(); + } elsif ( $cgi->param('magic') eq 'suspended' ) { - $qual = 'WHERE susp IS NOT NULL AND susp != 0'. - ' AND ( cancel IS NULL OR cancel = 0)'; - } elsif ( $cgi->param('magic') eq 'canceled' ) { - $qual = 'WHERE cancel IS NOT NULL AND cancel != 0'; + + push @where, + 'susp IS NOT NULL', + 'susp != 0', + '( cancel IS NULL OR cancel = 0)'; + + } elsif ( $cgi->param('magic') =~ /^cancell?ed$/ ) { + + push @where, + 'cancel IS NOT NULL', + 'cancel != 0'; + } else { die "guru meditation #420"; } - $sortby = \*pkgnum_sort; - if ( $cgi->param('pkgpart') =~ /^(\d+)$/ ) { - $qual .= " AND pkgpart = $1"; + push @where, "pkgpart = $1"; } } elsif ( $query eq 'pkgnum' ) { - $sortby=\*pkgnum_sort; + $orderby = 'ORDER BY pkgnum'; } elsif ( $query eq 'APKG_pkgnum' ) { - $sortby=\*pkgnum_sort; - - #@cust_pkg=(); - ##perhaps this should go in cust_pkg as a qsearch-like constructor? - #my($cust_pkg); - #foreach $cust_pkg ( - # qsearch('cust_pkg',{}, '', "ORDER BY pkgnum $limit" ) - #) { - # my($flag)=0; - # my($pkg_svc); - # PKG_SVC: - # foreach $pkg_svc (qsearch('pkg_svc',{ 'pkgpart' => $cust_pkg->pkgpart })) { - # if ( $pkg_svc->quantity - # > scalar(qsearch('cust_svc',{ - # 'pkgnum' => $cust_pkg->pkgnum, - # 'svcpart' => $pkg_svc->svcpart, - # })) - # ) - # { - # $flag=1; - # last PKG_SVC; - # } - # } - # push @cust_pkg, $cust_pkg if $flag; - #} - - if ( driver_name eq 'mysql' ) { - #$query = "DROP TABLE temp1_$$,temp2_$$;"; - #my $sth = dbh->prepare($query); - #$sth->execute; - - $query = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM - SELECT cust_svc.pkgnum,cust_svc.svcpart,COUNT(*) as count - FROM cust_pkg,cust_svc,pkg_svc - WHERE cust_pkg.pkgnum = cust_svc.pkgnum - AND cust_svc.svcpart = pkg_svc.svcpart - AND cust_pkg.pkgpart = pkg_svc.pkgpart - GROUP BY cust_svc.pkgnum,cust_svc.svcpart"; - my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + $orderby = 'ORDER BY pkgnum'; - $query = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM - SELECT cust_pkg.pkgnum FROM cust_pkg - LEFT JOIN pkg_svc ON (cust_pkg.pkgpart=pkg_svc.pkgpart) - LEFT JOIN temp1_$$ ON (cust_pkg.pkgnum = temp1_$$.pkgnum - AND pkg_svc.svcpart=temp1_$$.svcpart) - WHERE ( pkg_svc.quantity > temp1_$$.count - OR temp1_$$.pkgnum IS NULL ) - AND pkg_svc.quantity != 0;"; - $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; - $qual = " LEFT JOIN temp2_$$ ON cust_pkg.pkgnum = temp2_$$.pkgnum - WHERE temp2_$$.pkgnum IS NOT NULL"; - - } else { - - $qual = " - WHERE 0 < - ( SELECT count(*) FROM pkg_svc - WHERE pkg_svc.pkgpart = cust_pkg.pkgpart - AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc - WHERE cust_svc.pkgnum = cust_pkg.pkgnum - AND cust_svc.svcpart = pkg_svc.svcpart - ) - ) - "; - - } + push @where, '0 < ( + SELECT count(*) FROM pkg_svc + WHERE pkg_svc.pkgpart = cust_pkg.pkgpart + AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc + WHERE cust_svc.pkgnum = cust_pkg.pkgnum + AND cust_svc.svcpart = pkg_svc.svcpart + ) + )'; } else { die "Empty or unknown QUERY_STRING!"; } - - my $statement = "SELECT COUNT(*) FROM cust_pkg $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 $tblname = driver_name eq 'mysql' ? 'cust_pkg.' : ''; - @cust_pkg = - qsearch('cust_pkg',{}, '', "$qual ORDER BY ${tblname}pkgnum $limit" ); - - if ( driver_name eq 'mysql' ) { - $query = "DROP TABLE temp1_$$,temp2_$$;"; - my $sth = dbh->prepare($query) or die dbh->errstr. " doing $query"; - $sth->execute; # or die "Error executing \"$query\": ". $sth->errstr; - } - -} - -if ( scalar(@cust_pkg) == 1 ) { - print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum. - "#cust_pkg". $cust_pkg[0]->pkgnum ); - #exit; -} elsif ( scalar(@cust_pkg) == 0 ) { #error -%> - -<% - eidiot("No packages found"); -} else { -%> - -<% - $total ||= scalar(@cust_pkg); - - #begin pager - my $pager = ''; - if ( $total != scalar(@cust_pkg) && $maxrecords ) { - unless ( $offset == 0 ) { - $cgi->param('offset', $offset - $maxrecords); - $pager .= 'Previous '; - } - my $poff; - my $page; - for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { - $page++; - if ( $offset == $poff ) { - $pager .= qq!$page !; - } else { - $cgi->param('offset', $poff); - $pager .= qq!$page !; - } - } - unless ( $offset + $maxrecords > $total ) { - $cgi->param('offset', $offset + $maxrecords); - $pager .= 'Next '; - } - } - #end pager - - print header('Package Search Results',''), - "$total matching packages found

$pager", &table(), < - Package - Setup -END - - print 'Last
bill
' - if defined dbdef->table('cust_pkg')->column('last_bill'); - - print <Next
bill
- Susp. - Expire - Cancel - Cust# - (bill) name - company -END - - print '(service) namecompany' - if defined dbdef->table('cust_main')->column('ship_last'); - - print 'Services'; - - my $n1 = ''; - my(%saw,$cust_pkg); - foreach $cust_pkg ( - sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg) - ) { - my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); - my($pkgnum, $setup, $bill, $susp, $expire, $cancel, - $custnum, $last, $first, $company ) = ( - $cust_pkg->pkgnum, - $cust_pkg->getfield('setup') - ? time2str("%D", $cust_pkg->getfield('setup') ) - : '', - $cust_pkg->getfield('bill') - ? time2str("%D", $cust_pkg->getfield('bill') ) - : '', - $cust_pkg->getfield('susp') - ? time2str("%D", $cust_pkg->getfield('susp') ) - : '', - $cust_pkg->getfield('expire') - ? time2str("%D", $cust_pkg->getfield('expire') ) - : '', - $cust_pkg->getfield('cancel') - ? time2str("%D", $cust_pkg->getfield('cancel') ) - : '', - $cust_pkg->custnum, - $cust_main ? $cust_main->last : '', - $cust_main ? $cust_main->first : '', - $cust_main ? $cust_main->company : '', - ); - - my $last_bill = $cust_pkg->getfield('last_bill') - ? time2str("%D", $cust_pkg->getfield('last_bill') ) - : '' - if defined dbdef->table('cust_pkg')->column('last_bill'); - - my($ship_last, $ship_first, $ship_company); - if ( defined dbdef->table('cust_main')->column('ship_last') ) { - ($ship_last, $ship_first, $ship_company) = ( - $cust_main - ? ( $cust_main->ship_last || $cust_main->getfield('last') ) - : '', - $cust_main - ? ( $cust_main->ship_last - ? $cust_main->ship_first - : $cust_main->first ) - : '', - $cust_main - ? ( $cust_main->ship_last - ? $cust_main->ship_company - : $cust_main->company ) - : '', - ); - } - my $pkg = $part_pkg{$cust_pkg->pkgpart}->pkg; - #$pkg .= ' - '. $part_pkg{$cust_pkg->pkgpart}->comment; - my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); - my $rowspan = scalar(@cust_svc) || 1; - my $p = popurl(2); - print $n1, <$pkgnum - $pkg - $setup -END - - print "$last_bill" - if defined dbdef->table('cust_pkg')->column('last_bill'); - - print <$bill - $susp - $expire - $cancel -END - if ( $cust_main ) { - print <$custnum - $last, $first - $company -END - if ( defined dbdef->table('cust_main')->column('ship_last') ) { - print <$ship_last, $ship_first - $ship_company -END - } - } else { - my $colspan = defined dbdef->table('cust_main')->column('ship_last') - ? 5 : 3; - print <WARNING: couldn't find cust_main.custnum $custnum (cust_pkg.pkgnum $pkgnum) -END - } - - my $n2 = ''; - foreach my $cust_svc ( @cust_svc ) { - my($label, $value, $svcdb) = $cust_svc->label; - my $svcnum = $cust_svc->svcnum; - my $sview = $p. "view"; - print $n2,qq!$label!, - qq!$value!; - $n2=""; - } - - $n1 = ""; - - } - print ''; - - print "$pager"; - -} -sub pkgnum_sort { - $a->getfield('pkgnum') <=> $b->getfield('pkgnum'); } -sub bill_sort { - $a->getfield('bill') <=> $b->getfield('bill'); +my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : ''; + +my $count_query = "SELECT COUNT(*) FROM cust_pkg $cjoin $extra_sql"; + +my $sql_query = { + 'table' => 'cust_pkg', + 'hashref' => {}, + 'select' => join(', ', + 'cust_pkg.*', + 'cust_main.custnum as cust_main_custnum', + FS::UI::Web::cust_sql_fields(), + ), + 'extra_sql' => "$extra_sql $orderby", + 'addl_from' => ' LEFT JOIN cust_main USING ( custnum ) ', + #' LEFT JOIN part_pkg USING ( pkgpart ) ' +}; + +my $link = sub { + [ "${p}view/cust_main.cgi?".shift->custnum.'#cust_pkg', 'pkgnum' ]; +}; + +my $clink = sub { + my $cust_pkg = shift; + $cust_pkg->cust_main_custnum + ? [ "${p}view/cust_main.cgi?", 'custnum' ] + : ''; +}; + +#if ( scalar(@cust_pkg) == 1 ) { +# print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum. +# "#cust_pkg". $cust_pkg[0]->pkgnum ); + +# my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); +# my $rowspan = scalar(@cust_svc) || 1; + +# my $n2 = ''; +# foreach my $cust_svc ( @cust_svc ) { +# my($label, $value, $svcdb) = $cust_svc->label; +# my $svcnum = $cust_svc->svcnum; +# my $sview = $p. "view"; +# print $n2,qq!$label!, +# qq!$value!; +# $n2=""; +# } + +sub time_or_blank { + my $column = shift; + return sub { + my $record = shift; + my $value = $record->get($column); #mmm closures + $value ? time2str('%b %d %Y', $value ) : ''; + }; } +%><%= include( 'elements/search.html', + 'title' => 'Package Search Results', + 'name' => 'packages', + 'query' => $sql_query, + 'count_query' => $count_query, + 'redirect' => $link, + 'header' => [ '#', + 'Package', + 'Status', + 'Freq.', + 'Setup', + 'Last bill', + 'Next bill', + 'Susp.', + 'Expire', + 'Cancel', + FS::UI::Web::cust_header(), + 'Services', + ], + 'fields' => [ + 'pkgnum', + sub { my $part_pkg = $part_pkg{shift->pkgpart}; + $part_pkg->pkg; # ' - '. $part_pkg->comment; + }, + sub { ucfirst(shift->status); }, + sub { #shift->part_pkg->freq_pretty; + my $part_pkg = $part_pkg{shift->pkgpart}; + $part_pkg->freq_pretty; + }, + + #sub { time2str('%b %d %Y', shift->setup); }, + #sub { time2str('%b %d %Y', shift->last_bill); }, + #sub { time2str('%b %d %Y', shift->bill); }, + #sub { time2str('%b %d %Y', shift->susp); }, + #sub { time2str('%b %d %Y', shift->expire); }, + #sub { time2str('%b %d %Y', shift->get('cancel')); }, + ( map { time_or_blank($_) } + qw( setup last_bill bill susp expire cancel ) ), + + \&FS::UI::Web::cust_fields, + #sub { ''. + # join('', map { '' } + # shift->labels + # ). + # '
'. $_->[0]. + # ':'. $_->[1]. '
'; + # }, + sub { + [ map { + [ + { 'data' => $_->[0]. ':', + 'align'=> 'right', + }, + { 'data' => $_->[1], + 'align'=> 'left', + 'link' => $p. 'view/' . + $_->[2]. '.cgi?'. $_->[3], + }, + ]; + } shift->labels + ]; + }, + ], + 'color' => [ + '', + '', + sub { shift->statuscolor; }, + '', + '', + '', + '', + '', + '', + '', + ( map { '' } FS::UI::Web::cust_header() ), + '', + ], + 'style' => [ '', '', 'b' ], + 'size' => [ '', '', '-1', ], + 'align' => 'rlclrrrrrr', + 'links' => [ + $link, + $link, + '', + '', + '', + '', + '', + '', + '', + '', + ( map { $clink } FS::UI::Web::cust_header() ), + '', + ], + ) %> diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 78754fe00..0f499d2d0 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -91,7 +91,12 @@ foreach my $field ( @{$opt{'fields'}} ) { if ( ref($field) eq 'CODE' ) { - push @line, &{$field}($row); + push @line, map { + ref($_) eq 'ARRAY' + ? '(N/A)' #unimplemented + : $_; + } + &{$field}($row); } else { push @line, $row->$field(); } @@ -153,7 +158,11 @@ #} if ( ref($field) eq 'CODE' ) { foreach my $value ( &{$field}($row) ) { - $worksheet->write($r, $c++, $value ); + if ( ref($value) eq 'ARRAY' ) { + $worksheet->write($r, $c++, '(N/A)' ); #unimplemented + } else { + $worksheet->write($r, $c++, $value ); + } } } else { $worksheet->write($r, $c++, $row->$field() ); @@ -257,6 +266,52 @@ foreach my $field ( + map { + if ( ref($_) eq 'ARRAY' ) { + + my $tableref = $_; + + ''. + + join('', map { + + my $rowref = $_; + + ''. + + join('', map { + + my $element = $_; + + ''; + + } @$rowref ). + + ''; + } @$tableref ). + + '
{'align'} + ? ' ALIGN="'. $element->{'align'}. '"' + : '' + ). '>'. + ( $element->{'link'} + ? '' + : '' + ). + $element->{'data'}. + ( $element->{'link'} + ? '' + : '' + ). + '
'; + + } else { + $_; + } + } + map { if ( ref($_) eq 'CODE' ) { &{$_}($row); -- cgit v1.2.1 From c2f77e3e9f95934545331b62a19579e45c98d403 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 13 Sep 2005 20:12:04 +0000 Subject: fix redirect with single item returned from search results and a coderef redirect --- httemplate/search/elements/search.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 0f499d2d0..7882bbf56 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -183,7 +183,9 @@ } else { # regular HTML if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) { - my( $url, $method ) = @{$opt{'redirect'}}; + my $redirect = $opt{'redirect'}; + $redirect = &{$redirect}($rows->[0]) if ref($redirect) eq 'CODE'; + my( $url, $method ) = @$redirect; redirect( $url. $rows->[0]->$method() ); } else { ( my $xlsname = $opt{'name'} ) =~ s/\W//g; -- cgit v1.2.1 From 550685eff557af23e242c545d6a9e27a7ef44f23 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 10 Oct 2005 12:20:57 +0000 Subject: updated quick payment entry --- httemplate/search/cust_pay.cgi | 104 ++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 43 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index da3d12523..89da7426a 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,60 +1,78 @@ <% my $title = 'Payment Search Results'; my( $count_query, $sql_query ); - if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { - - my @search = (); + if ( $cgi->param('magic') ) { - if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { - push @search, "agentnum = $1"; # $search{'agentnum'} = $1; - my $agent = qsearchs('agent', { 'agentnum' => $1 } ); - die "unknown agentnum $1" unless $agent; - $title = $agent->agent. " $title"; - } + my @search = (); + my $orderby; + if ( $cgi->param('magic') eq '_date' ) { - if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ - or die "illegal payby ". $cgi->param('payby'); - push @search, "cust_pay.payby = '$1'"; - if ( $3 ) { - if ( $3 eq 'VisaMC' ) { - #avoid posix regexes for portability - push @search, - " ( substring(cust_pay.payinfo from 1 for 1) = '4' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '55' ". - " ) "; - } elsif ( $3 eq 'Amex' ) { - push @search, - " ( substring(cust_pay.payinfo from 1 for 2 ) = '34' ". - " OR substring(cust_pay.payinfo from 1 for 2 ) = '37' ". - " ) "; - } elsif ( $3 eq 'Discover' ) { - push @search, - " substring(cust_pay.payinfo from 1 for 4 ) = '6011' "; - } else { - die "unknown card type $3"; + + if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { + push @search, "agentnum = $1"; # $search{'agentnum'} = $1; + my $agent = qsearchs('agent', { 'agentnum' => $1 } ); + die "unknown agentnum $1" unless $agent; + $title = $agent->agent. " $title"; + } + + if ( $cgi->param('payby') ) { + $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ + or die "illegal payby ". $cgi->param('payby'); + push @search, "cust_pay.payby = '$1'"; + if ( $3 ) { + if ( $3 eq 'VisaMC' ) { + #avoid posix regexes for portability + push @search, + " ( substring(cust_pay.payinfo from 1 for 1) = '4' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '55' ". + " ) "; + } elsif ( $3 eq 'Amex' ) { + push @search, + " ( substring(cust_pay.payinfo from 1 for 2 ) = '34' ". + " OR substring(cust_pay.payinfo from 1 for 2 ) = '37' ". + " ) "; + } elsif ( $3 eq 'Discover' ) { + push @search, + " substring(cust_pay.payinfo from 1 for 4 ) = '6011' "; + } else { + die "unknown card type $3"; + } } } - } + + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); + push @search, "_date >= $beginning ", + "_date <= $ending"; + + $orderby = '_date'; + + } elsif ( $cgi->param('magic') eq 'paybatch' ) { + + $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/ + or die "illegal paybatch: ". $cgi->param('paybatch'); - my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - push @search, "_date >= $beginning ", - "_date <= $ending"; + push @search, "paybatch = '$1'"; + + $orderby = "LOWER(company || ' ' || last || ' ' || first )"; + + } else { + die "unknown search magic: ". $cgi->param('magic'); + } my $search = ''; if ( @search ) { $search = ' WHERE '. join(' AND ', @search); } - + $count_query = "SELECT COUNT(*), SUM(paid) ". "FROM cust_pay LEFT JOIN cust_main USING ( custnum )". $search; - + $sql_query = { 'table' => 'cust_pay', 'select' => join(', ', @@ -63,10 +81,10 @@ FS::UI::Web::cust_sql_fields(), ), 'hashref' => {}, - 'extra_sql' => "$search ORDER BY _date", + 'extra_sql' => "$search ORDER BY $orderby", 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', }; - + } else { $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; -- cgit v1.2.1 From cccd0b7cd38a88c131e19981be38434f87abe194 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 21 Oct 2005 15:21:37 +0000 Subject: add CASH and WEST payment types (payments only, not cust_main.payby) --- httemplate/search/cust_pay.cgi | 43 ++++++++++++++++++++++++++++++---- httemplate/search/report_cust_pay.html | 6 ++++- 2 files changed, 44 insertions(+), 5 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 89da7426a..2106a649a 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -16,14 +16,27 @@ } if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ - or die "illegal payby ". $cgi->param('payby'); + $cgi->param('payby') =~ + /^(CARD|CHEK|BILL|PREP|CASH|WEST)(-(VisaMC|Amex|Discover|Maestro))?$/ + or die "illegal payby ". $cgi->param('payby'); push @search, "cust_pay.payby = '$1'"; if ( $3 ) { if ( $3 eq 'VisaMC' ) { #avoid posix regexes for portability push @search, - " ( substring(cust_pay.payinfo from 1 for 1) = '4' ". + " ( ( substring(cust_pay.payinfo from 1 for 1) = '4' ". + " AND substring(cust_pay.payinfo from 1 for 4) != '4936' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49030[2-9]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49033[5-9]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49110[1-2]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49117[4-9]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49118[1-2]' ". + " )". " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". @@ -38,7 +51,25 @@ " ) "; } elsif ( $3 eq 'Discover' ) { push @search, - " substring(cust_pay.payinfo from 1 for 4 ) = '6011' "; + " substring(cust_pay.payinfo from 1 for 4 ) = '6011' ". + " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' "; + } elsif ( $3 eq 'Maestro' ) { + push @search, + " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ". + ' OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ". + ' OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ". + " OR substring(cust_pay.payinfo from 1 for 4 ) = '4936' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49030[2-9]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49033[5-9]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49110[1-2]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49117[4-9]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49118[1-2]' ". + " ) "; } else { die "unknown card type $3"; } @@ -134,6 +165,10 @@ 'Check #'. $cust_pay->payinfo; } elsif ( $cust_pay->payby eq 'PREP' ) { 'Prepaid card #'. $cust_pay->payinfo; + } elsif ( $cust_pay->payby eq 'CASH' ) { + 'Cash '. $cust_pay->payinfo; + } elsif ( $cust_pay->payby eq 'WEST' ) { + 'Western Union'; #. $cust_pay->payinfo; } else { $cust_pay->payby. ' '. $cust_pay->payinfo; } diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 8b9e27302..18501d5b5 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -19,8 +19,12 @@ + - + + + + -- cgit v1.2.1 From e0ab4446794f3c9ad0ecf012fcc8b1b3ef4d48cf Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 27 Oct 2005 15:48:36 +0000 Subject: fix from joe @ surferz: lines 59 and 60 had the wrote quote. they had single quote where double was needed... --- httemplate/search/cust_pay.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 2106a649a..9b9458e63 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -56,8 +56,8 @@ } elsif ( $3 eq 'Maestro' ) { push @search, " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ". - ' OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ". - ' OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ". + " OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ". " OR substring(cust_pay.payinfo from 1 for 4 ) = '4936' ". " OR substring(cust_pay.payinfo from 1 for 6 ) ". " SIMILAR TO '49030[2-9]' ". -- cgit v1.2.1 From f1a6cb69d064ea81e51f6bc29e2cdb7d695980a6 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Oct 2005 11:56:48 +0000 Subject: don't show 'N/A' statustext as a failed billing event --- httemplate/search/cust_bill_event.cgi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index df4dcbf42..a21fb1912 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -15,7 +15,9 @@ my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); my $where = " WHERE cust_bill_event._date >= $beginning". " AND cust_bill_event._date <= $ending"; -$where .= " AND statustext != '' AND statustext IS NOT NULL" +$where .= " AND statustext != '' ". + " AND statustext IS NOT NULL ". + " AND statustext != 'N/A' " if $cgi->param('failed'); my $sql_query = { -- cgit v1.2.1 From 48767efdf16b2c9db3cc003128f82b30d10c777a Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 7 Nov 2005 22:07:01 +0000 Subject: fix Discover card report, closes: Bug#1270 --- httemplate/search/cust_pay.cgi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 9b9458e63..bf3df9846 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -51,8 +51,9 @@ " ) "; } elsif ( $3 eq 'Discover' ) { push @search, - " substring(cust_pay.payinfo from 1 for 4 ) = '6011' ". - " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' "; + " ( substring(cust_pay.payinfo from 1 for 4 ) = '6011' ". + " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' ". + " ) "; } elsif ( $3 eq 'Maestro' ) { push @search, " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ". -- cgit v1.2.1 From 24df1738d4227d02c2ade9c1c83099503b91a1aa Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 10 Nov 2005 12:47:31 +0000 Subject: add part_bill_event.payby selection to failed invoice event search --- httemplate/search/cust_bill_event.cgi | 18 +++++++++++++----- httemplate/search/cust_bill_event.html | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index a21fb1912..d82a83368 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -15,10 +15,16 @@ my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); my $where = " WHERE cust_bill_event._date >= $beginning". " AND cust_bill_event._date <= $ending"; -$where .= " AND statustext != '' ". - " AND statustext IS NOT NULL ". - " AND statustext != 'N/A' " - if $cgi->param('failed'); + +if ( $cgi->param('failed') ) { + $where .= " AND statustext != '' ". + " AND statustext IS NOT NULL ". + " AND statustext != 'N/A' " +} + +if ( $cgi->param('part_bill_event.payby') =~ /^(\w+)$/ ) { + $where .= " AND part_bill_event.payby = '$1' "; +} my $sql_query = { 'table' => 'cust_bill_event', @@ -38,7 +44,9 @@ my $sql_query = { 'LEFT JOIN cust_main USING ( custnum ) ', }; -my $count_sql = "select count(*) from cust_bill_event $where"; +my $count_sql = "SELECT COUNT(*) FROM cust_bill_event ". + "LEFT JOIN part_bill_event USING ( eventpart ) ". + $where; my $conf = new FS::Conf; diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index 476d22161..7bc428f5d 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -51,6 +51,33 @@ }); + + + Events for payment type: + + + +
-- cgit v1.2.1 From ae042530347d0ba3615d2d91f283e729d80eee67 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 18 Nov 2005 15:08:56 +0000 Subject: fix link glitch in receivables reports --- httemplate/search/report_receivables.cgi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 535afcca0..d675346f0 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -121,6 +121,8 @@ END my $align = join('', map { /#/ ? 'r' : 'l' } FS::UI::Web::cust_header() ). 'crrrrr'; + my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; + %><%= include( 'elements/search.html', 'title' => 'Accounts Receivable Aging Summary', 'name' => 'customers', @@ -185,8 +187,7 @@ END shift->get('owed_total') ) }, ], 'links' => [ - [ "${p}view/cust_main.cgi?", 'custnum' ], - [ "${p}view/cust_main.cgi?", 'custnum' ], + ( map $clink, FS::UI::Web::cust_header() ), '', #'', '', -- cgit v1.2.1 From f10cd68f08a6bfbd565a83b40bacc3f55a1265b3 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 21 Nov 2005 10:47:12 +0000 Subject: add MCRD payment type for manually processed ccards --- httemplate/search/cust_pay.cgi | 4 +++- httemplate/search/report_cust_pay.html | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index bf3df9846..99ffc3d20 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -17,7 +17,7 @@ if ( $cgi->param('payby') ) { $cgi->param('payby') =~ - /^(CARD|CHEK|BILL|PREP|CASH|WEST)(-(VisaMC|Amex|Discover|Maestro))?$/ + /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/ or die "illegal payby ". $cgi->param('payby'); push @search, "cust_pay.payby = '$1'"; if ( $3 ) { @@ -170,6 +170,8 @@ 'Cash '. $cust_pay->payinfo; } elsif ( $cust_pay->payby eq 'WEST' ) { 'Western Union'; #. $cust_pay->payinfo; + } elsif ( $cust_pay->payby eq 'MCRD' ) { + 'Manual credit card'; #. $cust_pay->payinfo; } else { $cust_pay->payby. ' '. $cust_pay->payinfo; } diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 18501d5b5..a28ead92d 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -25,6 +25,7 @@ + -- cgit v1.2.1 From 386ec52836abbe32ce2fbf575e851a75f6e112f8 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 22 Dec 2005 04:01:17 +0000 Subject: tax report update, link to new line item report, per-agent tax reporting --- httemplate/search/cust_bill_event.html | 29 +---- httemplate/search/cust_bill_pkg.cgi | 145 ++++++++++++++++++++++ httemplate/search/cust_pkg_report.cgi | 50 +------- httemplate/search/elements/search.html | 10 +- httemplate/search/report_cust_bill.html | 44 +------ httemplate/search/report_cust_credit.html | 44 +------ httemplate/search/report_cust_pay.html | 44 +------ httemplate/search/report_tax.cgi | 198 +++++++++++++++++++++--------- httemplate/search/report_tax.html | 32 +---- 9 files changed, 318 insertions(+), 278 deletions(-) create mode 100644 httemplate/search/cust_bill_pkg.cgi (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index 7bc428f5d..197f28028 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -7,10 +7,6 @@ ) %> - - - -
@@ -27,30 +23,7 @@ --> - - From: -
m/d/y - - - - To: -
m/d/y - - + <%= include( '/elements/tr-input-beginning_ending.html' ) %> <% my $user = getotaker; -$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; -my $pbeginning = $1; -my $beginning = $1 ? str2time($1) : 0; - -$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; -my $pending = $1; -my $ending = ( $1 ? str2time($1) : 4294880896 ) + 86399; +my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); my $from_join_cust = " FROM cust_bill_pkg @@ -24,11 +17,19 @@ my $where = " WHERE _date >= $beginning AND _date <= $ending AND ( county = ? OR ? = '' ) AND ( state = ? OR ? = '' ) - AND ( country = ? ) + AND country = ? AND payby != 'COMP' "; my @base_param = qw( county county state state country ); +my $agentname = ''; +if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { + my $agent = qsearchs('agent', { 'agentnum' => $1 } ); + die "agent not found" unless $agent; + $agentname = $agent->agent; + $where .= ' AND agentnum = '. $agent->agentnum; +} + my $gotcust = " WHERE 0 < ( SELECT COUNT(*) FROM cust_main WHERE ( cust_main.county = cust_main_county.county @@ -43,52 +44,70 @@ my $gotcust = " "; my $monthly_exempt_warning = 0; -my($total, $exempt, $taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); +my($total, $taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); +my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0 ); my $out = 'Out of taxable region(s)'; -my %regions; +my %regions = (); foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { #warn $r->county. ' '. $r->state. ' '. $r->country. "\n"; my $label = getlabel($r); $regions{$label}->{'label'} = $label; + $regions{$label}->{'url_param'} = join(';', map "$_=".$r->$_(), qw( county state country ) ); + my $fromwhere = $from_join_cust. $join_pkg. $where; - my @param = @base_param; + my @param = @base_param; if ( $r->taxclass ) { - $fromwhere .= " AND ( taxclass = ? ) "; + $fromwhere .= " AND taxclass = ? "; push @param, 'taxclass'; + $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass; } +# my $label = getlabel($r); +# $regions{$label}->{'label'} = $label; + my $nottax = 'pkgnum != 0'; - my $a = scalar_sql($r, \@param, + ## calculate total for this region + + my $t = scalar_sql($r, \@param, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere AND $nottax" ); - $total += $a; - $regions{$label}->{'total'} += $a; + $total += $t; + $regions{$label}->{'total'} += $t; + + ## calculate package-exemption for this region foreach my $e ( grep { $r->get($_.'tax') =~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { my $x = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax" ); - $exempt += $x; - $regions{$label}->{'exempt'} += $x; + $exempt_pkg += $x; + $regions{$label}->{'exempt_pkg'} += $x; } - my($t, $x) = (0, 0); + ## calculate customer-exemption for this region + + my($t, $x_cust) = (0, 0); foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { $t += scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" ); - $x += scalar_sql($r, \@param, + $x_cust += scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" ); } + $exempt_cust += $x_cust; + $regions{$label}->{'exempt_cust'} += $x_cust; + + ## calculate monthly exemption (texas tax) for this region + my($sday,$smon,$syear) = (localtime($beginning) )[ 3, 4, 5 ]; $monthly_exempt_warning=1 if $sday != 1 && $beginning; $smon++; $syear+=1900; @@ -97,23 +116,22 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my($eday,$emon,$eyear) = (localtime($eending) )[ 3, 4, 5 ]; $emon++; $eyear+=1900; - my $monthly_exemption = scalar_sql($r, [ 'taxnum' ], + my $x_monthly = scalar_sql($r, [ 'taxnum' ], "SELECT SUM(amount) FROM cust_tax_exempt where taxnum = ? ". " AND ( year > $syear OR ( year = $syear and month >= $smon ) )". " AND ( year < $eyear OR ( year = $eyear and month <= $emon ) )" ); - #warn $r->taxnum(). ": $monthly_exemption\n"; - if ( $monthly_exemption ) { - $t -= $monthly_exemption; - $x += $monthly_exemption; + if ( $x_monthly ) { + warn $r->taxnum(). ": $x_monthly\n"; + $t -= $x_monthly; } + $exempt_monthly += $x_monthly; + $regions{$label}->{'exempt_monthly'} += $x_monthly; + $taxable += $t; $regions{$label}->{'taxable'} += $t; - $exempt += $x; - $regions{$label}->{'exempt'} += $x; - $owed += $t * ($r->tax/100); $regions{$label}->{'owed'} += $t * ($r->tax/100); @@ -165,13 +183,16 @@ my @regions = map $regions{$_}, keys %regions; push @regions, { - 'label' => 'Total', - 'total' => $total, - 'exempt' => $exempt, - 'taxable' => $taxable, - 'rate' => '', - 'owed' => $owed, - 'tax' => $tax, + 'label' => 'Total', + 'url_param' => '', + 'total' => $total, + 'exempt_cust' => $exempt_cust, + 'exempt_pkg' => $exempt_pkg, + 'exempt_monthly' => $exempt_monthly, + 'taxable' => $taxable, + 'rate' => '', + 'owed' => $owed, + 'tax' => $tax, }; #-- @@ -180,7 +201,17 @@ sub getlabel { my $r = shift; my $label; - if ( $r->tax == 0 ) { + if ( + $r->tax == 0 + && ! scalar( qsearch('cust_main_county', { 'state' => $r->state, + 'county' => $r->county, + 'country' => $r->country, + 'tax' => { op=>'>', value=>0 }, + } + ) + ) + + ) { #kludge to avoid "will not stay shared" warning my $out = 'Out of taxable region(s)'; $label = $out; @@ -192,6 +223,7 @@ sub getlabel { $label = $r->country; $label = $r->state.", $label" if $r->state; $label = $r->county." county, $label" if $r->county; + $label = "$label (". $r->taxclass. ")" if $r->taxclass; #$label = $r->taxname. " ($label)" if $r->taxname; } return $label; @@ -210,30 +242,86 @@ sub scalar_sql { %> -<%= header( "Sales Tax Report - $pbeginning through ".($pending||'now'), - menubar( 'Main Menu'=>$p, ) ) %> -<%= table() %> +<% + +my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; + +%> + + +<%= header( "$agentname Sales Tax Report - ". + time2str('%h %o %Y through ', $beginning ). + ( $cgi->param('ending') == 4294967295 + ? 'now' + : time2str('%h %o %Y', $ending ) + ), + menubar( 'Main Menu'=>$p, ) + ) +%> + +<%= include('/elements/table-grid.html') %> + - - Sales - Rate - Tax owed - Tax invoiced + + Sales + Rate + Tax owed + Tax invoiced - Total - Non-taxable - Taxable + Total + Non-taxable
(tax-exempt customer) + Non-taxable
(tax-exempt package) + Non-taxable
(monthly exemption) + Taxable - <% foreach my $region ( @regions ) { %> + +<% my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor; +%> + + <% foreach my $region ( @regions ) { + + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } + + my $link = $baselink; + if ( $region->{'label'} ne 'Total' ) { + if ( $region->{'label'} eq $out ) { + $link .= ';out=1'; + } else { + $link .= ';'. $region->{'url_param'}; + } + } + %> - <%= $region->{'label'} %> - $<%= sprintf('%.2f', $region->{'total'} ) %> - $<%= sprintf('%.2f', $region->{'exempt'} ) %> - $<%= sprintf('%.2f', $region->{'taxable'} ) %> - <%= $region->{'rate'} %> - $<%= sprintf('%.2f', $region->{'owed'} ) %> - $<%= sprintf('%.2f', $region->{'tax'} ) %> + <%= $region->{'label'} %> + + $<%= sprintf('%.2f', $region->{'total'} ) %> + + + $<%= sprintf('%.2f', $region->{'exempt_cust'} ) %> + + + $<%= sprintf('%.2f', $region->{'exempt_pkg'} ) %> + + + $<%= sprintf('%.2f', $region->{'exempt_monthly'} ) %> + + + $<%= sprintf('%.2f', $region->{'taxable'} ) %> + + <%= $region->{'rate'} %> + + $<%= sprintf('%.2f', $region->{'owed'} ) %> + + + $<%= sprintf('%.2f', $region->{'tax'} ) %> + <% } %> diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index 85af212d7..38b665a5a 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -1,39 +1,13 @@ Tax Report Criteria - - - - +

Tax Report Criteria

- Return tax report for period: - - - - - - - - - - + <%= include( '/elements/tr-select-agent.html' ) %> + <%= include( '/elements/tr-input-beginning_ending.html' ) %>
From:
m/d/y
To:
m/d/y

-- cgit v1.2.1 From e7438cef2fa745d473d7770bb0f6c37ff2dfd1e8 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 22 Dec 2005 04:22:41 +0000 Subject: fix some ambiguous var names causing " "my" variable $t masks earlier declaration in same scope" errors --- httemplate/search/report_tax.cgi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 4edd08449..bf3fc74ff 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -91,10 +91,10 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { ## calculate customer-exemption for this region - my($t, $x_cust) = (0, 0); + my($taxable, $x_cust) = (0, 0); foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { - $t += scalar_sql($r, \@param, + $taxable += scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" ); @@ -123,17 +123,17 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { ); if ( $x_monthly ) { warn $r->taxnum(). ": $x_monthly\n"; - $t -= $x_monthly; + $taxable -= $x_monthly; } $exempt_monthly += $x_monthly; $regions{$label}->{'exempt_monthly'} += $x_monthly; - $taxable += $t; - $regions{$label}->{'taxable'} += $t; + $tot_taxable += $taxable; + $regions{$label}->{'taxable'} += $taxable; - $owed += $t * ($r->tax/100); - $regions{$label}->{'owed'} += $t * ($r->tax/100); + $owed += $taxable * ($r->tax/100); + $regions{$label}->{'owed'} += $taxable * ($r->tax/100); if ( defined($regions{$label}->{'rate'}) && $regions{$label}->{'rate'} != $r->tax.'%' ) { @@ -189,7 +189,7 @@ push @regions, { 'exempt_cust' => $exempt_cust, 'exempt_pkg' => $exempt_pkg, 'exempt_monthly' => $exempt_monthly, - 'taxable' => $taxable, + 'taxable' => $tot_taxable, 'rate' => '', 'owed' => $owed, 'tax' => $tax, -- cgit v1.2.1 From 113de1f1167d9bc194e467b14a9d2f7f673d687f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 22 Dec 2005 04:24:50 +0000 Subject: and s/$taxable/$tot_taxable/ in the declaration too --- httemplate/search/report_tax.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index bf3fc74ff..b73910a48 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -44,7 +44,7 @@ my $gotcust = " "; my $monthly_exempt_warning = 0; -my($total, $taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); +my($total, $tot_taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0 ); my $out = 'Out of taxable region(s)'; my %regions = (); -- cgit v1.2.1 From 9cbacc11da67edfe35756d569f7797dc0d3fed36 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Dec 2005 01:57:15 +0000 Subject: correct end date display for "now" --- httemplate/search/report_tax.cgi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index b73910a48..cf5306c21 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -3,6 +3,7 @@ my $user = getotaker; my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +warn("***** $beginning $ending\n"); my $from_join_cust = " FROM cust_bill_pkg @@ -251,7 +252,7 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; <%= header( "$agentname Sales Tax Report - ". time2str('%h %o %Y through ', $beginning ). - ( $cgi->param('ending') == 4294967295 + ( $ending == 4294967295 ? 'now' : time2str('%h %o %Y', $ending ) ), -- cgit v1.2.1 From 75e7d0189cb306f8ea01c4961f1e3cd02cd92675 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Dec 2005 02:31:09 +0000 Subject: fixup new line item report brainfart --- httemplate/search/cust_bill_pkg.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 875cbc3ac..f84293a9d 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -79,7 +79,7 @@ if ( $cgi->param('pkg_tax') ) { "SELECT COUNT(*), SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)"; } -$count_query += " FROM cust_bill_pkg $join_cust $join_pkg $where"; +$count_query .= " FROM cust_bill_pkg $join_cust $join_pkg $where"; my $query = { 'table' => 'cust_bill_pkg', -- cgit v1.2.1 From ac6c8883615cd02d768c3222e38b59c3a51b7e7a Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Dec 2005 03:07:32 +0000 Subject: correct "out of taxable region" flag on new line item report - NULLs need to be compared explicitly. apparantly NULL != NULL. bah SQL --- httemplate/search/cust_bill_pkg.cgi | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index f84293a9d..082ccc893 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -20,18 +20,21 @@ my $where = " if ( $cgi->param('out') ) { $where .= " - AND 0 = ( SELECT COUNT(*) FROM cust_main_county - WHERE ( cust_main_county.county = cust_main.county - OR cust_main_county.county IS NULL AND cust_main.county = '' - OR cust_main_county.county = '' AND cust_main.county IS NULL - ) - AND ( cust_main_county.state = cust_main.state - OR cust_main_county.state IS NULL AND cust_main.state = '' - OR cust_main_county.state = '' AND cust_main.state IS NULL - ) - AND cust_main_county.country = cust_main.country - AND cust_main_county.tax > 0 + AND 0 = ( + SELECT COUNT(*) FROM cust_main_county + WHERE ( cust_main_county.county = cust_main.county + OR ( cust_main_county.county IS NULL AND cust_main.county = '' ) + OR ( cust_main_county.county = '' AND cust_main.county IS NULL) + OR ( cust_main_county.county IS NULL AND cust_main.county IS NULL) ) + AND ( cust_main_county.state = cust_main.state + OR ( cust_main_county.state IS NULL AND cust_main.state = '' ) + OR ( cust_main_county.state = '' AND cust_main.state IS NULL ) + OR ( cust_main_county.state IS NULL AND cust_main.state IS NULL ) + ) + AND cust_main_county.country = cust_main.country + AND cust_main_county.tax > 0 + ) "; } elsif ( $cgi->param('country' ) ) { -- cgit v1.2.1 From a3493ac498ed57b754f776390fb20239a11e4a04 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Dec 2005 03:18:21 +0000 Subject: add switch to enable taxclass breakdown, report invoiced tax separately in that case --- httemplate/search/report_tax.cgi | 96 +++++++++++++++++++++++++++++++++------ httemplate/search/report_tax.html | 4 ++ 2 files changed, 86 insertions(+), 14 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index cf5306c21..bfc76d787 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -3,7 +3,6 @@ my $user = getotaker; my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); -warn("***** $beginning $ending\n"); my $from_join_cust = " FROM cust_bill_pkg @@ -45,6 +44,7 @@ my $gotcust = " "; my $monthly_exempt_warning = 0; +my $taxclass_flag = 0; my($total, $tot_taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0 ); my $out = 'Out of taxable region(s)'; @@ -54,7 +54,6 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my $label = getlabel($r); $regions{$label}->{'label'} = $label; - $regions{$label}->{'url_param'} = join(';', map "$_=".$r->$_(), qw( county state country ) ); my $fromwhere = $from_join_cust. $join_pkg. $where; @@ -63,7 +62,9 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { if ( $r->taxclass ) { $fromwhere .= " AND taxclass = ? "; push @param, 'taxclass'; - $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass; + $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass + if $cgi->param('show_taxclasses'); + $taxclass_flag = 1; } # my $label = getlabel($r); @@ -147,7 +148,7 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my $taxwhere = "$from_join_cust $where"; my @taxparam = @base_param; - +my %base_regions = (); #foreach my $label ( keys %regions ) { foreach my $r ( qsearch( 'cust_main_county', @@ -176,12 +177,26 @@ foreach my $r ( $tax += $x; $regions{$label}->{'tax'} += $x; + if ( $cgi->param('show_taxclasses') ) { + my $base_label = getlabel($r, 'no_taxclass'=>1 ); + $base_regions{$base_label}->{'label'} = $base_label; + $base_regions{$base_label}->{'url_param'} = + join(';', map "$_=".$r->$_(), qw( county state country ) ); + $base_regions{$base_label}->{'tax'} += $x; + } + } #ordering -my @regions = map $regions{$_}, - sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } - keys %regions; +my @regions = + map $regions{$_}, + sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } + keys %regions; + +my @base_regions = + map $base_regions{$_}, + sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } + keys %base_regions; push @regions, { 'label' => 'Total', @@ -200,6 +215,7 @@ push @regions, { sub getlabel { my $r = shift; + my %opt = @_; my $label; if ( @@ -224,7 +240,10 @@ sub getlabel { $label = $r->country; $label = $r->state.", $label" if $r->state; $label = $r->county." county, $label" if $r->county; - $label = "$label (". $r->taxclass. ")" if $r->taxclass; + $label = "$label (". $r->taxclass. ")" + if $r->taxclass + && $cgi->param('show_taxclasses') + && ! $opt{'no_taxclasses'}; #$label = $r->taxname. " ($label)" if $r->taxname; } return $label; @@ -263,11 +282,13 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; <%= include('/elements/table-grid.html') %> - - Sales - Rate - Tax owed - Tax invoiced + + Sales + Rate + Tax owed + <% unless ( $cgi->param('show_taxclasses') ) { %> + Tax invoiced + <% } %> Total @@ -299,6 +320,7 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; } } %> + <%= $region->{'label'} %> @@ -320,13 +342,59 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; $<%= sprintf('%.2f', $region->{'owed'} ) %> + <% unless ( $cgi->param('show_taxclasses') ) { %> + + $<%= sprintf('%.2f', $region->{'tax'} ) %> + + <% } %> + + + <% } %> + + + + +<% if ( $cgi->param('show_taxclasses') ) { %> + +
+ <%= include('/elements/table-grid.html') %> + + + Tax invoiced + + + <% #some false laziness w/above + foreach my $region ( @base_regions ) { + + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } + + my $link = $baselink; + if ( $region->{'label'} ne 'Total' ) { + if ( $region->{'label'} eq $out ) { + $link .= ';out=1'; + } else { + $link .= ';'. $region->{'url_param'}; + } + } + %> + + + <%= $region->{'label'} %> $<%= sprintf('%.2f', $region->{'tax'} ) %> + <% } %> - + + +<% } %> + <% if ( $monthly_exempt_warning ) { %>
diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index 38b665a5a..eeaccc1ab 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -8,6 +8,10 @@ <%= include( '/elements/tr-select-agent.html' ) %> <%= include( '/elements/tr-input-beginning_ending.html' ) %> + + + +
Show tax classes

-- cgit v1.2.1 From 1d9161282323473721a79ba8e03bf7590eefa6a5 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Dec 2005 03:41:28 +0000 Subject: add switch to enable taxclass breakdown, report invoiced tax separately in that case --- httemplate/search/report_tax.cgi | 44 ++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'httemplate/search') diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index bfc76d787..9062f0626 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -1,5 +1,8 @@ <% +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + my $user = getotaker; my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); @@ -283,8 +286,10 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; - Sales + Sales + Rate + Tax owed <% unless ( $cgi->param('show_taxclasses') ) { %> Tax invoiced @@ -292,9 +297,13 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; Total + Non-taxable
(tax-exempt customer) + Non-taxable
(tax-exempt package) + Non-taxable
(monthly exemption) + Taxable @@ -324,27 +333,33 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; <%= $region->{'label'} %> - $<%= sprintf('%.2f', $region->{'total'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'total'} ) %> + - - $<%= sprintf('%.2f', $region->{'exempt_cust'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'exempt_cust'} ) %> + - - $<%= sprintf('%.2f', $region->{'exempt_pkg'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'exempt_pkg'} ) %> + - - $<%= sprintf('%.2f', $region->{'exempt_monthly'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'exempt_monthly'} ) %> + = - $<%= sprintf('%.2f', $region->{'taxable'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'taxable'} ) %> + <%= $region->{'label'} eq 'Total' ? '' : ' X ' %> <%= $region->{'rate'} %> + <%= $region->{'label'} eq 'Total' ? '' : ' = ' %> - $<%= sprintf('%.2f', $region->{'owed'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'owed'} ) %> <% unless ( $cgi->param('show_taxclasses') ) { %> - $<%= sprintf('%.2f', $region->{'tax'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'tax'} ) %> <% } %> @@ -373,24 +388,31 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; } my $link = $baselink; - if ( $region->{'label'} ne 'Total' ) { + #if ( $region->{'label'} ne 'Total' ) { if ( $region->{'label'} eq $out ) { $link .= ';out=1'; } else { $link .= ';'. $region->{'url_param'}; } - } + #} %> <%= $region->{'label'} %> - $<%= sprintf('%.2f', $region->{'tax'} ) %> + <%= $money_char %><%= sprintf('%.2f', $region->{'tax'} ) %> <% } %> + + Total + + <%= $money_char %><%= sprintf('%.2f', $tax ) %> + + + <% } %> -- cgit v1.2.1