enable CardFortress in test database, #71513
[freeside.git] / httemplate / browse / cust_class.html
1 <% include( 'elements/browse.html',
2                  'title'       => 'Customer classes',
3                  'html_init'   => $html_init,
4                  'name'        => 'customer classes',
5                  'disableable' => 1,
6                  'disabled_statuspos' => 2,
7                  'query'       => { 'table'     => 'cust_class',
8                                     'hashref'   => {},
9                                     'order_by' => 'ORDER BY classnum',
10                                   },
11                  'count_query' => $count_query,
12                  'header'      => $header,
13                  'fields'      => $fields,
14                  'links'       => $links,
15              )
16 %>
17 <%init>
18
19 die "access denied"
20   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
21
22 my $html_init = 
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>!;
25
26 my $count_query = 'SELECT COUNT(*) FROM cust_class';
27
28 my $link = [ $p.'edit/cust_class.html?', 'classnum' ];
29
30 my $header = [ '#', 'Class' ];
31 my $fields = [ 'classnum', 'classname' ];
32 my $links  = [ $link, $link ];
33
34 my $cat_query = 'SELECT COUNT(*) FROM cust_class where categorynum IS NOT NULL';
35 my $sth = dbh->prepare($cat_query)
36   or die "Error preparing $cat_query: ". dbh->errstr;
37 $sth->execute
38   or die "Error executing $cat_query: ". $sth->errstr;
39 if ($sth->fetchrow_arrayref->[0]) {
40   push @$header, 'Category';
41   push @$fields, 'categoryname';
42   push @$links,  $link;
43 }
44
45 my $conf = new FS::Conf;
46 if ( $conf->exists('cust_class-tax_exempt') ) {
47   push @$header, 'Tax exempt';
48   push @$fields, 'tax';
49   push @$links,  '';
50 }
51
52 </%init>