This commit was generated by cvs2svn to compensate for changes in r11022,
[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 $html_init = 
23   'Package classes define groups of packages, for taxation, ordering '.
24   'convenience and reporting.<BR><BR>'.
25   qq!<A HREF="${p}edit/pkg_class.html"><I>Add a package class</I></A><BR><BR>!;
26
27 my $count_query = 'SELECT COUNT(*) FROM pkg_class';
28
29 my $link = [ $p.'edit/pkg_class.html?', 'classnum' ];
30
31 my $header = [ '#', 'Class' ];
32 my $fields = [ 'classnum', 'classname' ];
33 my $links  = [ $link, $link ];
34
35 my $cat_query = 'SELECT COUNT(*) FROM pkg_class where categorynum IS NOT NULL';
36 my $sth = dbh->prepare($cat_query)
37   or die "Error preparing $cat_query: ". dbh->errstr;
38 $sth->execute
39   or die "Error executing $cat_query: ". $sth->errstr;
40 if ($sth->fetchrow_arrayref->[0]) {
41   push @$header, 'Category';
42   push @$fields, 'categoryname';
43   push @$links,  $link;
44 }
45
46 </%init>