summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorjeff <jeff>2008-08-23 21:59:46 +0000
committerjeff <jeff>2008-08-23 21:59:46 +0000
commitef0d8db38d1ee28a65a7ecdc6e11c7a82c0a741b (patch)
tree78518afc3aa8623211251caedf78459167cd0877 /httemplate
parent8381e7232f90ac22b3f655cdccd0d39e2bde1d63 (diff)
add usage classes to rate details
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/rate_detail.html8
-rw-r--r--httemplate/browse/usage_class.html28
-rw-r--r--httemplate/edit/elements/edit.html12
-rwxr-xr-xhttemplate/edit/process/rate_region.cgi2
-rw-r--r--httemplate/edit/process/usage_class.html11
-rw-r--r--httemplate/edit/rate_detail.html8
-rw-r--r--httemplate/edit/rate_region.cgi16
-rw-r--r--httemplate/edit/usage_class.html25
-rw-r--r--httemplate/elements/menu.html1
9 files changed, 103 insertions, 8 deletions
diff --git a/httemplate/browse/rate_detail.html b/httemplate/browse/rate_detail.html
index 36e808f..23bc23f 100644
--- a/httemplate/browse/rate_detail.html
+++ b/httemplate/browse/rate_detail.html
@@ -17,6 +17,7 @@
'Included<BR>minutes',
'Charge per<BR>minute',
'Granularity',
+ 'Usage class',
],
'fields' => [
'regionname',
@@ -28,10 +29,11 @@
'&nbsp;<FONT SIZE="-1">(edit)</FONT>';
},
sub { $granularity{ shift->sec_granularity } },
+ 'classname',
],
- 'links' => [ '', '', $edit_link, $edit_link, '' ],
- 'link_onclicks' => [ '', '', $edit_onclick, $edit_onclick, '' ],
- 'align' => 'llrrc',
+ 'links' => [ '', '', $edit_link, $edit_link, '', '' ],
+ 'link_onclicks' => [ '', '', $edit_onclick, $edit_onclick, '', '' ],
+ 'align' => 'llrrcc',
)
%>
<%once>
diff --git a/httemplate/browse/usage_class.html b/httemplate/browse/usage_class.html
new file mode 100644
index 0000000..63fd2c5
--- /dev/null
+++ b/httemplate/browse/usage_class.html
@@ -0,0 +1,28 @@
+<% include( 'elements/browse.html',
+ 'title' => 'Usage classes',
+ 'html_init' => $html_init,
+ 'name' => 'usage classes',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 2,
+ 'query' => { 'table' => 'usage_class',
+ 'hashref' => {},
+ 'extra_sql' => 'ORDER BY classnum',
+ },
+ 'count_query' => 'SELECT COUNT(*) FROM usage_class',
+ 'header' => [ '#', 'Class' ],
+ 'fields' => [ 'classnum', 'classname' ],
+ 'links' => [ $link, $link ],
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $html_init =
+ 'Usage classes define groups of usage for taxation purposes.<BR><BR>'.
+ qq!<A HREF="${p}edit/usage_class.html"><I>Add a usage class</I></A><BR><BR>!;
+
+my $link = [ $p.'edit/usage_class.html?', 'classnum' ];
+
+</%init>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 47b2464..3896f17 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -3,8 +3,12 @@
Example:
include( 'elements/edit.html',
- 'name' =>
- 'table' =>
+ 'name_singular' => #singular name for the record
+ # (preferred, will be pluralized automatically)
+ 'name' => #name for the record
+ # (deprecated, will be pluralized simplistically)
+ 'table' =>
+
#? 'primary_key' => #required when the dbdef doesn't know...???
'labels' => {
'column' => 'Label',
@@ -616,9 +620,9 @@ my @menubar = ();
if ( $opt{'menubar'} ) {
@menubar = @{ $opt{'menubar'} };
} else {
+ my $items = $opt{'name'} ? $opt{'name'}.'s' : PL($opt{'name_singular'});
@menubar = (
- #eventually use Lingua::bs to pluralize
- "View all $opt{'name'}s" => $viewall_url,
+ "View all $items" => $viewall_url,
);
}
diff --git a/httemplate/edit/process/rate_region.cgi b/httemplate/edit/process/rate_region.cgi
index d839406..861a6dc 100755
--- a/httemplate/edit/process/rate_region.cgi
+++ b/httemplate/edit/process/rate_region.cgi
@@ -37,7 +37,7 @@ my @dest_detail = map {
new FS::rate_detail {
'ratenum' => $ratenum,
map { $_ => $cgi->param("$_$ratenum") }
- qw( min_included min_charge sec_granularity )
+ qw( min_included min_charge sec_granularity classnum )
};
} qsearch('rate', {} );
diff --git a/httemplate/edit/process/usage_class.html b/httemplate/edit/process/usage_class.html
new file mode 100644
index 0000000..cf50cb7
--- /dev/null
+++ b/httemplate/edit/process/usage_class.html
@@ -0,0 +1,11 @@
+<% include( 'elements/process.html',
+ 'table' => 'usage_class',
+ 'viewall_dir' => 'browse',
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/edit/rate_detail.html b/httemplate/edit/rate_detail.html
index 73d2d9b..4860593 100644
--- a/httemplate/edit/rate_detail.html
+++ b/httemplate/edit/rate_detail.html
@@ -8,6 +8,7 @@
'min_included' => 'Included minutes',
'min_charge' => 'Charge per minute',
'sec_granularity' => 'Granularity',
+ 'classnum' => 'Usage class',
},
'fields' => [
{ field=>'ratenum', type=>'hidden', },
@@ -23,6 +24,13 @@
labels => \%granularity,
disable_empty => 1,
},
+ { field =>'classnum',
+ type =>'select-table',
+ table =>'usage_class',
+ name_col =>'classname',
+ empty_label =>'(default)',
+ hashref =>{ disabled => '' },
+ },
],
)
diff --git a/httemplate/edit/rate_region.cgi b/httemplate/edit/rate_region.cgi
index 496e054..f24b9d6 100644
--- a/httemplate/edit/rate_region.cgi
+++ b/httemplate/edit/rate_region.cgi
@@ -57,6 +57,9 @@
<TH CLASS="grid" BGCOLOR="#cccccc">
<FONT SIZE=-1>Granularity</FONT>
</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">
+ <FONT SIZE=-1>Usage class</FONT>
+ </TH>
</TR>
% foreach my $rate ( qsearch('rate', {}) ) {
@@ -96,6 +99,19 @@
</SELECT>
</TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <% include( '/elements/select-table.html',
+ 'element_name' => "classnum$n",
+ 'table' => 'usage_class',
+ 'name_col' => 'classname',
+ 'empty_label' => '(default)',
+ 'hashref' => { disabled => '' },
+ 'curr_value' => ( $cgi->param("classnum$n") ||
+ $rate_detail->classnum ),
+ )
+ %>
+ </TD>
+
</TR>
% }
diff --git a/httemplate/edit/usage_class.html b/httemplate/edit/usage_class.html
new file mode 100644
index 0000000..ef4b1ff
--- /dev/null
+++ b/httemplate/edit/usage_class.html
@@ -0,0 +1,25 @@
+<% include( 'elements/edit.html',
+ 'name_singular' => 'Usage Class',
+ 'table' => 'usage_class',
+ 'fields' => [
+ 'classname',
+ { field=>'disabled',
+ type=>'checkbox',
+ value=>'Y',
+ },
+ ],
+ 'labels' => {
+ 'classnum' => 'Class number',
+ 'classname' => 'Class name',
+ 'disabled' => 'Disable class',
+ },
+ '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 321927e..d476e30 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -279,6 +279,7 @@ tie my %config_agent, 'Tie::IxHash',
tie my %config_billing_rates, 'Tie::IxHash',
'View/Edit rate plans' => [ $fsurl.'browse/rate.cgi', 'Manage rate plans' ],
'View/Edit regions and prefixes' => [ $fsurl.'browse/rate_region.html', 'Manage regions and prefixes' ],
+ 'View/Edit usage classes' => [ $fsurl.'browse/usage_class.html', 'Usage classes define groups of usage for taxation purposes.' ],
;
tie my %config_billing, 'Tie::IxHash';