summaryrefslogtreecommitdiff
path: root/FS/FS/pkg_class.pm
diff options
context:
space:
mode:
authorivan <ivan>2009-10-29 01:08:33 +0000
committerivan <ivan>2009-10-29 01:08:33 +0000
commit9d77a21db3642ca66d9a0e545b804b7e6b4090ee (patch)
tree8323e01c8e25420222c97b4e0ea87f89b73203fd /FS/FS/pkg_class.pm
parentf274814c7cde3681578ca594a2b00475370e4c92 (diff)
customer classification, RT#6376
Diffstat (limited to 'FS/FS/pkg_class.pm')
-rw-r--r--FS/FS/pkg_class.pm62
1 files changed, 20 insertions, 42 deletions
diff --git a/FS/FS/pkg_class.pm b/FS/FS/pkg_class.pm
index 254282fbf..51d0455a5 100644
--- a/FS/FS/pkg_class.pm
+++ b/FS/FS/pkg_class.pm
@@ -1,13 +1,11 @@
package FS::pkg_class;
use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs qsearch );
+use FS::class_Common;
+use base qw( FS::class_Common );
use FS::part_pkg;
use FS::pkg_category;
-@ISA = qw( FS::Record );
-
=head1 NAME
FS::pkg_class - Object methods for pkg_class records
@@ -35,13 +33,21 @@ from FS::Record. The following fields are currently supported:
=over 4
-=item classnum - primary key (assigned automatically for new package classes)
+=item classnum
+
+primary key (assigned automatically for new package classes)
+
+=item classname
+
+Text name of this package class
-=item classname - Text name of this package class
+=item categorynum
-=item categorynum - Number of associated pkg_category (see L<FS::pkg_category>)
+Number of associated pkg_category (see L<FS::pkg_category>)
-=item disabled - Disabled flag, empty or 'Y'
+=item disabled
+
+Disabled flag, empty or 'Y'
=back
@@ -57,6 +63,7 @@ L<"insert">.
=cut
sub table { 'pkg_class'; }
+sub _target_table { 'part_pkg'; }
=item insert
@@ -69,18 +76,7 @@ Deletes this package class from the database. Only package classes with no
associated package definitions can be deleted. If there is an error, returns
the error, otherwise returns false.
-=cut
-
-sub delete {
- my $self = shift;
-
- return "Can't delete an pkg_class with part_pkg records!"
- if qsearch( 'part_pkg', { 'classnum' => $self->classnum } );
-
- $self->SUPER::delete;
-}
-
-=item replace OLD_RECORD
+=item replace [ OLD_RECORD ]
Replaces OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
@@ -91,20 +87,10 @@ Checks all fields to make sure this is a valid package class. If there is an
error, returns the error, otherwise returns false. Called by the insert and
replace methods.
-=cut
-
-sub check {
- my $self = shift;
-
- $self->ut_numbern('classnum')
- or $self->ut_text('classname')
- or $self->ut_foreign_keyn('categorynum', 'pkg_category', 'categorynum')
- or $self->SUPER::check;
-
-}
-
=item pkg_category
+=item category
+
Returns the pkg_category record associated with this class, or false if there
is none.
@@ -112,7 +98,7 @@ is none.
sub pkg_category {
my $self = shift;
- qsearchs('pkg_category', { 'categorynum' => $self->categorynum } );
+ $self->category;
}
=item categoryname
@@ -120,22 +106,14 @@ sub pkg_category {
Returns the category name associated with this class, or false if there
is none.
-=cut
-
-sub categoryname {
- my $pkg_category = shift->pkg_category;
- $pkg_category->categoryname if $pkg_category;
-}
-
=back
=head1 BUGS
=head1 SEE ALSO
-L<FS::Record>, L<FS::part_pkg>, schema.html from the base documentation.
+L<FS::part_pkg>, L<FS::Record>
=cut
1;
-