1 <% include( 'elements/browse.html',
2 'title' => 'Customer classes',
3 'html_init' => $html_init,
4 'name' => 'customer classes',
6 'disabled_statuspos' => 2,
7 'query' => { 'table' => 'cust_class',
9 'order_by' => 'ORDER BY classnum',
11 'count_query' => $count_query,
20 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
23 'Customer classes define groups of customer for reporting.<BR><BR>'.
24 qq!<A HREF="${p}edit/cust_class.html"><I>Add a customer class</I></A><BR><BR>!;
26 #cust_class-disable_counts? or just migrate this to one config probably
27 #my $disable_counts = $conf->exists('agent-disable_counts');
28 my $disable_counts = 0;
30 my $customers_sub = sub {
31 my $cust_class = shift;
33 my $cust_main_link = $p. 'search/cust_main.html?'.
34 'classnum='. $cust_class->classnum;
36 #false laziness w/agent.cgi
37 my $OUT = '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>';
40 qw( prospect inactive ordered active suspended cancelled );
41 my %PL = ( 'prospect' => 'prospects', );
42 #my %link = ( 'cancelled' => 'showcancelledcustomers=1&cancelled' );
43 my $statuscolor = FS::cust_main->statuscolors;
45 foreach my $status ( @cust_status ) {
46 my $meth = 'num_'. $status;
47 #my $link = exists($link{$status}) ? $link{$status} : $status;
51 unless ( $disable_counts ) {
52 $num = $cust_class->$meth();
53 $OUT .= '<TH ALIGN="right" WIDTH="40%">'.
54 '<FONT COLOR="#'. $statuscolor->{$status}. '">'.
55 $num. ' </FONT></TH>';
59 if ( $num || $disable_counts ) {
60 $OUT .= '<A HREF="'. $cust_main_link. "&status=$status". '">';
62 $OUT .= exists($PL{$status}) ? $PL{$status} : $status;
63 if ($num || $disable_counts ) {
77 my $count_query = 'SELECT COUNT(*) FROM cust_class';
79 my $link = [ $p.'edit/cust_class.html?', 'classnum' ];
80 my $header = [ '#', 'Class', 'Customers' ];
81 my $fields = [ 'classnum', 'classname', $customers_sub, ];
82 my $links = [ $link, $link ];
84 my $cat_query = 'SELECT COUNT(*) FROM cust_class where categorynum IS NOT NULL';
85 my $sth = dbh->prepare($cat_query)
86 or die "Error preparing $cat_query: ". dbh->errstr;
88 or die "Error executing $cat_query: ". $sth->errstr;
89 if ($sth->fetchrow_arrayref->[0]) {
90 push @$header, 'Category';
91 push @$fields, 'categoryname';
95 my $conf = new FS::Conf;
96 if ( $conf->exists('cust_class-tax_exempt') ) {
97 push @$header, 'Tax exempt';