RT# 31208 Docs $FS::Record::qsearch_qualify_columns
[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                                     'addl_from' => ' LEFT JOIN pkg_category USING (categorynum)',
9                                     'hashref'   => {},
10                                     'order_by' => 'ORDER BY classnum',
11                                   },
12                  'count_query' => $count_query,
13                  'header'      => $header,
14                  'fields'      => $fields,
15                  'links'       => $links,
16              )
17 %>
18 <%init>
19
20 die "access denied"
21   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
22
23 local($FS::Record::qsearch_qualify_columns) = 1;
24
25 my $conf = new FS::Conf;
26
27 my $html_init = 
28   'Package classes define groups of packages, for taxation, ordering '.
29   'convenience and reporting.<BR><BR>'.
30   qq!<A HREF="${p}edit/pkg_class.html"><I>Add a package class</I></A><BR><BR>!;
31
32 my $count_query = 'SELECT COUNT(*) FROM pkg_class';
33
34 my $link = [ $p.'edit/pkg_class.html?', 'classnum' ];
35
36 my $header = [ '#', 'Class' ];
37 my $fields = [ 'classnum', 'classname' ];
38 my $links  = [ $link, $link ];
39
40 if($conf->exists('cust_main-require_censustract')) {
41     push @{$fields}, 'fcc_ds0s';
42     push @{$header}, 'FCC form 477 voice-grade equivalents';
43     push @{$links}, '';
44 }
45
46 my $cat_query = 'SELECT COUNT(*) FROM pkg_class where categorynum IS NOT NULL';
47 my $sth = dbh->prepare($cat_query)
48   or die "Error preparing $cat_query: ". dbh->errstr;
49 $sth->execute
50   or die "Error executing $cat_query: ". $sth->errstr;
51 if ($sth->fetchrow_arrayref->[0]) {
52   push @$header, 'Category';
53   push @$fields, 'categoryname';
54   push @$links,  [ $p.'edit/pkg_category.html?', 'categorynum' ]
55 }
56
57 </%init>