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 #my $disable_counts = $conf->exists('config-disable_counts');
27 my $disable_counts = 0;
29 my $customers_sub = sub {
30 my $cust_class = shift;
32 my $cust_main_link = $p. 'search/cust_main.html?'.
33 'classnum='. $cust_class->classnum;
35 #false laziness w/agent.cgi
36 my $OUT = '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>';
39 qw( prospect inactive ordered active suspended cancelled );
40 my %PL = ( 'prospect' => 'prospects', );
41 #my %link = ( 'cancelled' => 'showcancelledcustomers=1&cancelled' );
42 my $statuscolor = FS::cust_main->statuscolors;
44 foreach my $status ( @cust_status ) {
45 my $meth = 'num_'. $status;
46 #my $link = exists($link{$status}) ? $link{$status} : $status;
50 unless ( $disable_counts ) {
51 $num = $cust_class->$meth();
52 $OUT .= '<TH ALIGN="right" WIDTH="40%">'.
53 '<FONT COLOR="#'. $statuscolor->{$status}. '">'.
54 $num. ' </FONT></TH>';
58 if ( $num || $disable_counts ) {
59 $OUT .= '<A HREF="'. $cust_main_link. "&status=$status". '">';
61 $OUT .= exists($PL{$status}) ? $PL{$status} : $status;
62 if ($num || $disable_counts ) {
76 my $count_query = 'SELECT COUNT(*) FROM cust_class';
78 my $link = [ $p.'edit/cust_class.html?', 'classnum' ];
79 my $header = [ '#', 'Class', 'Customers' ];
80 my $fields = [ 'classnum', 'classname', $customers_sub, ];
81 my $links = [ $link, $link ];
83 my $cat_query = 'SELECT COUNT(*) FROM cust_class where categorynum IS NOT NULL';
84 my $sth = dbh->prepare($cat_query)
85 or die "Error preparing $cat_query: ". dbh->errstr;
87 or die "Error executing $cat_query: ". $sth->errstr;
88 if ($sth->fetchrow_arrayref->[0]) {
89 push @$header, 'Category';
90 push @$fields, 'categoryname';
94 my $conf = new FS::Conf;
95 if ( $conf->exists('cust_class-tax_exempt') ) {
96 push @$header, 'Tax exempt';