summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cust_main.pm47
-rw-r--r--FS/MANIFEST4
-rw-r--r--FS/t/category_Common.t5
-rw-r--r--FS/t/class_Common.t5
-rw-r--r--httemplate/browse/pkg_category.html2
-rw-r--r--httemplate/edit/cust_main/top_misc.html9
-rw-r--r--httemplate/elements/select-cust_class.html18
-rw-r--r--httemplate/elements/tr-select-cust_class.html27
-rw-r--r--httemplate/view/cust_main/misc.html11
9 files changed, 124 insertions, 4 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 2c2984fa1..fdcd80178 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2307,6 +2307,53 @@ sub agent {
qsearchs( 'agent', { 'agentnum' => $self->agentnum } );
}
+=item cust_class
+
+Returns the customer class, as an FS::cust_class object, or the empty string
+if there is no customer class.
+
+=cut
+
+sub cust_class {
+ my $self = shift;
+ if ( $self->classnum ) {
+ qsearchs('cust_class', { 'classnum' => $self->classnum } );
+ } else {
+ return '';
+ }
+}
+
+=item categoryname
+
+Returns the customer category name, or the empty string if there is no customer
+category.
+
+=cut
+
+sub categoryname {
+ my $self = shift;
+ my $cust_class = $self->cust_class;
+ $cust_class
+ ? $cust_class->categoryname
+ : '';
+}
+
+=item classname
+
+Returns the customer class name, or the empty string if there is no customer
+class.
+
+=cut
+
+sub classname {
+ my $self = shift;
+ my $cust_class = $self->cust_class;
+ $cust_class
+ ? $cust_class->classname
+ : '';
+}
+
+
=item bill_and_collect
Cancels and suspends any packages due, generates bills, applies payments and
diff --git a/FS/MANIFEST b/FS/MANIFEST
index d4e80e694..b84ba525b 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -457,3 +457,7 @@ FS/cust_class.pm
t/cust_class.t
FS/cust_category.pm
t/cust_category.t
+FS/class_Common.pm
+t/class_Common.t
+FS/category_Common.pm
+t/category_Common.t
diff --git a/FS/t/category_Common.t b/FS/t/category_Common.t
new file mode 100644
index 000000000..b8bd9e230
--- /dev/null
+++ b/FS/t/category_Common.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::category_Common;
+$loaded=1;
+print "ok 1\n";
diff --git a/FS/t/class_Common.t b/FS/t/class_Common.t
new file mode 100644
index 000000000..9ac809b0b
--- /dev/null
+++ b/FS/t/class_Common.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::class_Common;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/browse/pkg_category.html b/httemplate/browse/pkg_category.html
index 2223445e1..a156c06da 100644
--- a/httemplate/browse/pkg_category.html
+++ b/httemplate/browse/pkg_category.html
@@ -22,7 +22,7 @@ die "access denied"
my $html_init =
qq!<A HREF="${p}browse/pkg_class.html">Package classes</A><BR><BR>!.
- 'Package categories define groups of package classes.<BR><BR>'.
+ 'Package categories define groups of package classes, used for sectioned invoices.<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';
diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html
index 041050664..7c9e0395c 100644
--- a/httemplate/edit/cust_main/top_misc.html
+++ b/httemplate/edit/cust_main/top_misc.html
@@ -23,6 +23,15 @@
% }
+%# class
+<% include('/elements/tr-select-cust_class.html',
+ 'curr_value' => $cust_main->classnum,
+ 'label' => "Class",
+ #'empty_label' => '(none)',
+ #'disable_empty' =>
+ )
+%>
+
%# referral (advertising source)
%my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
%if ( $custnum && ! $conf->exists('editreferrals') ) {
diff --git a/httemplate/elements/select-cust_class.html b/httemplate/elements/select-cust_class.html
new file mode 100644
index 000000000..94b935acb
--- /dev/null
+++ b/httemplate/elements/select-cust_class.html
@@ -0,0 +1,18 @@
+<% include( '/elements/select-table.html',
+ 'table' => 'cust_class',
+ 'name_col' => 'classname',
+ 'value' => $classnum,
+ 'empty_label' => '(none)',
+ 'hashref' => { 'disabled' => '' },
+ %opt,
+ )
+%>
+<%init>
+
+my %opt = @_;
+my $classnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'records'} = delete $opt{'cust_class'}
+ if $opt{'cust_class'};
+
+</%init>
diff --git a/httemplate/elements/tr-select-cust_class.html b/httemplate/elements/tr-select-cust_class.html
new file mode 100644
index 000000000..54a11d79e
--- /dev/null
+++ b/httemplate/elements/tr-select-cust_class.html
@@ -0,0 +1,27 @@
+% if ( scalar(@{ $opt{'cust_class'} }) == 0 ) {
+
+ <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'classnum' %>" VALUE="">
+
+% } else {
+
+ <TR>
+ <TD ALIGN="right"><% $opt{'label'} || 'Customer class' %></TD>
+ <TD>
+ <% include( '/elements/select-cust_class.html',
+ 'curr_value' => $classnum,
+ %opt
+ )
+ %>
+ </TD>
+ </TR>
+
+% }
+
+<%init>
+
+my %opt = @_;
+my $classnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'cust_class'} ||= [ qsearch( 'cust_class', { disabled=>'' } ) ];
+
+</%init>
diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html
index 71e8d6973..2cfe0263f 100644
--- a/httemplate/view/cust_main/misc.html
+++ b/httemplate/view/cust_main/misc.html
@@ -31,13 +31,18 @@
</TR>
%
% }
-%
+
+% #if ( $cust_main->classnum ) {
+ <TR>
+ <TD ALIGN="right">Class</TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main->classname || '(none)' %></TD>
+ </TR>
+% #}
+
% unless ( FS::part_referral->num_part_referral == 1 ) {
% my $referral = qsearchs('part_referral', {
% 'refnum' => $cust_main->refnum
% } );
-%
-
<TR>
<TD ALIGN="right">Advertising&nbsp;source</TD>