From f13afe5e228a220311557e1ca6dacbf847c26baf Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 19 Jun 2008 03:18:19 +0000 Subject: package categories (meta package classes) and grouping invoices by them --- httemplate/browse/pkg_category.html | 33 +++++++++++++++++++++++++++++++++ httemplate/browse/pkg_class.html | 21 ++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 httemplate/browse/pkg_category.html (limited to 'httemplate/browse') diff --git a/httemplate/browse/pkg_category.html b/httemplate/browse/pkg_category.html new file mode 100644 index 000000000..20bf1a8df --- /dev/null +++ b/httemplate/browse/pkg_category.html @@ -0,0 +1,33 @@ +<% include( 'elements/browse.html', + 'title' => 'Package categories', + 'html_init' => $html_init, + 'name' => 'package categories', + 'disableable' => 1, + 'disabled_statuspos' => 2, + 'query' => { 'table' => 'pkg_category', + 'hashref' => {}, + 'extra_sql' => 'ORDER BY categorynum', + }, + 'count_query' => $count_query, + 'header' => [ '#', 'Category' ], + 'fields' => [ 'categorynum', 'categoryname' ], + 'links' => [ $link, $link ], + ) +%> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $html_init = + qq!Package classes

!. + 'Package categories define groups of package classes, for reporting and '. + 'convenience purposes.

'. + qq!Add a package category

!; + +my $count_query = 'SELECT COUNT(*) FROM pkg_category'; + +my $link = [ $p.'edit/pkg_category.html?', 'categorynum' ]; + + diff --git a/httemplate/browse/pkg_class.html b/httemplate/browse/pkg_class.html index 4f02ca22d..75969dbe8 100644 --- a/httemplate/browse/pkg_class.html +++ b/httemplate/browse/pkg_class.html @@ -9,9 +9,9 @@ 'extra_sql' => 'ORDER BY classnum', }, 'count_query' => $count_query, - 'header' => [ '#', 'Class', ], - 'fields' => [ 'classnum', 'classname' ], - 'links' => [ $link, $link ], + 'header' => $header, + 'fields' => $fields, + 'links' => $links, ) %> <%init> @@ -28,4 +28,19 @@ my $count_query = 'SELECT COUNT(*) FROM pkg_class'; my $link = [ $p.'edit/pkg_class.html?', 'classnum' ]; +my $header = [ '#', 'Class' ]; +my $fields = [ 'classnum', 'classname' ]; +my $links = [ $link, $link ]; + +my $cat_query = 'SELECT COUNT(*) FROM pkg_class where categorynum IS NOT NULL'; +my $sth = dbh->prepare($cat_query) + or die "Error preparing $cat_query: ". dbh->errstr; +$sth->execute + or die "Error executing $cat_query: ". $sth->errstr; +if ($sth->fetchrow_arrayref->[0]) { + push @$header, 'Category'; + push @$fields, 'categoryname'; + push @$links, $link; +} + -- cgit v1.2.1