add optional fcc_ds0s to pkg_class, RT13057
[freeside.git] / httemplate / browse / pkg_class.html
1 <% include( 'elements/browse.html',
2                  'title'       => 'Package classes',
3                  'html_init'   => $html_init,
4                  'name'        => 'package classes',
5                  'disableable' => 1,
6                  'disabled_statuspos' => 2,
7                  'query'       => { 'table'     => 'pkg_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 $conf = new FS::Conf;
23
24 my $html_init = 
25   'Package classes define groups of packages, for taxation, ordering '.
26   'convenience and reporting.<BR><BR>'.
27   qq!<A HREF="${p}edit/pkg_class.html"><I>Add a package class</I></A><BR><BR>!;
28
29 my $count_query = 'SELECT COUNT(*) FROM pkg_class';
30
31 my $link = [ $p.'edit/pkg_class.html?', 'classnum' ];
32
33 my $header = [ '#', 'Class' ];
34 my $fields = [ 'classnum', 'classname' ];
35 my $links  = [ $link, $link ];
36
37 if($conf->exists('cust_main-require_censustract')) {
38     push @{$fields}, 'fcc_ds0s';
39     push @{$header}, 'FCC form 477 voice-grade equivalents';
40     push @{$links}, '';
41 }
42
43 my $cat_query = 'SELECT COUNT(*) FROM pkg_class where categorynum IS NOT NULL';
44 my $sth = dbh->prepare($cat_query)
45   or die "Error preparing $cat_query: ". dbh->errstr;
46 $sth->execute
47   or die "Error executing $cat_query: ". $sth->errstr;
48 if ($sth->fetchrow_arrayref->[0]) {
49   push @$header, 'Category';
50   push @$fields, 'categoryname';
51   push @$links,  $link;
52 }
53
54 </%init>