summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorjeff <jeff>2008-06-19 03:18:19 +0000
committerjeff <jeff>2008-06-19 03:18:19 +0000
commitf13afe5e228a220311557e1ca6dacbf847c26baf (patch)
tree9cd6b6e511234d72dfa9e8dd8278a721e5ad03eb /httemplate
parent795a85c10d898120a2a6341c4df32fb60b069a64 (diff)
package categories (meta package classes) and grouping invoices by them
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/pkg_category.html33
-rw-r--r--httemplate/browse/pkg_class.html21
-rw-r--r--httemplate/edit/elements/edit.html3
-rw-r--r--httemplate/edit/pkg_category.html22
-rw-r--r--httemplate/edit/pkg_class.html5
-rw-r--r--httemplate/edit/process/pkg_category.html11
-rw-r--r--httemplate/elements/menu.html1
7 files changed, 92 insertions, 4 deletions
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!<A HREF="${p}browse/pkg_class.html">Package classes</A><BR><BR>!.
+ 'Package categories define groups of package classes, for reporting and '.
+ 'convenience purposes.<BR><BR>'.
+ qq!<A HREF="${p}edit/pkg_category.html"><I>Add a package category</I></A><BR><BR>!;
+
+my $count_query = 'SELECT COUNT(*) FROM pkg_category';
+
+my $link = [ $p.'edit/pkg_category.html?', 'categorynum' ];
+
+</%init>
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;
+}
+
</%init>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 04ca81c72..86eb2b3c7 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -106,7 +106,7 @@ Example:
'new_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; },
#run before display to return a different value
- 'value_callback' => sub { my( $columname, $value } ) = @_; },
+ 'value_callback' => sub { my( $columname, $value ) = @_; },
#XXX describe
'field_callback' => sub { },
@@ -212,6 +212,7 @@ Example:
% #select(-*)
% 'options' => $f->{'options'},
% 'labels' => $f->{'labels'},
+% 'empty_label' => $f->{'empty_label'},
% 'multiple' => $f->{'multiple'},
% 'disable_empty' => $f->{'disable_empty'},
% #select-reason
diff --git a/httemplate/edit/pkg_category.html b/httemplate/edit/pkg_category.html
new file mode 100644
index 000000000..fdc8da638
--- /dev/null
+++ b/httemplate/edit/pkg_category.html
@@ -0,0 +1,22 @@
+<% include( 'elements/edit.html',
+ 'name' => 'Package Category',
+ 'table' => 'pkg_category',
+ 'fields' => [
+ 'categoryname',
+ { field=>'disabled', type=>'checkbox', value=>'Y', },
+ ],
+ 'labels' => {
+ 'categorynum' => 'Category number',
+ 'categoryname' => 'Category name',
+ 'disabled' => 'Disable category',
+ },
+ 'viewall_dir' => 'browse',
+ )
+
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/edit/pkg_class.html b/httemplate/edit/pkg_class.html
index eddbfc16e..2e4e9d1cd 100644
--- a/httemplate/edit/pkg_class.html
+++ b/httemplate/edit/pkg_class.html
@@ -3,6 +3,10 @@
'table' => 'pkg_class',
'fields' => [
'classname',
+ (scalar(@category)
+ ? { field=>'categorynum', type=>'select-table', 'empty_label'=>'(none)', 'table'=>'pkg_category', 'name_col'=>'categoryname' }
+ : { field=>'categorynum', type=>'hidden' }
+ ),
{ field=>'disabled', type=>'checkbox', value=>'Y', },
],
'labels' => {
@@ -19,4 +23,5 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+my @category = qsearch('pkg_category', { 'disabled' => '' });
</%init>
diff --git a/httemplate/edit/process/pkg_category.html b/httemplate/edit/process/pkg_category.html
new file mode 100644
index 000000000..50cd5cb29
--- /dev/null
+++ b/httemplate/edit/process/pkg_category.html
@@ -0,0 +1,11 @@
+<% include( 'elements/process.html',
+ 'table' => 'pkg_category',
+ 'viewall_dir' => 'browse',
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index fcca775d8..9ace19ea3 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -262,6 +262,7 @@ $config_export_svc_pkg{'View/Edit package definitions'} = [ $fsurl.'browse/part_
if $curuser->access_right('Edit package definitions')
|| $curuser->access_right('Edit global package definitions');
if ( $curuser->access_right('Configuration') ) {
+ $config_export_svc_pkg{'View/Edit package categories'} = [ $fsurl.'browse/pkg_category.html', 'Package categories define groups of package classes, for reporting and convenience purposes.' ];
$config_export_svc_pkg{'View/Edit package classes'} = [ $fsurl.'browse/pkg_class.html', 'Package classes define groups of packages, for reporting and convenience purposes.' ];
$config_export_svc_pkg{'View/Edit cancel reason types'} = [ $fsurl.'browse/reason_type.html?class=C', 'Cancel reason types define groups of reasons, for reporting and convenience purposes.' ];
$config_export_svc_pkg{'View/Edit cancel reasons'} = [ $fsurl.'browse/reason.html?class=C', 'Cancel reasons explain why a service was cancelled.' ];