5 use FS::Record qw( qsearchs qsearch );
9 @ISA = qw( FS::Record );
13 FS::pkg_class - Object methods for pkg_class records
19 $record = new FS::pkg_class \%hash;
20 $record = new FS::pkg_class { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::pkg_class object represents an package class. Every package definition
33 (see L<FS::part_pkg>) has, optionally, a package class. FS::pkg_class inherits
34 from FS::Record. The following fields are currently supported:
38 =item classnum - primary key (assigned automatically for new package classes)
40 =item classname - Text name of this package class
42 =item categorynum - Number of associated pkg_category (see L<FS::pkg_category>)
44 =item disabled - Disabled flag, empty or 'Y'
54 Creates a new package class. To add the package class to the database, see
59 sub table { 'pkg_class'; }
63 Adds this package class to the database. If there is an error, returns the
64 error, otherwise returns false.
68 Deletes this package class from the database. Only package classes with no
69 associated package definitions can be deleted. If there is an error, returns
70 the error, otherwise returns false.
77 return "Can't delete an pkg_class with part_pkg records!"
78 if qsearch( 'part_pkg', { 'classnum' => $self->classnum } );
83 =item replace OLD_RECORD
85 Replaces OLD_RECORD with this one in the database. If there is an error,
86 returns the error, otherwise returns false.
90 Checks all fields to make sure this is a valid package class. If there is an
91 error, returns the error, otherwise returns false. Called by the insert and
99 $self->ut_numbern('classnum')
100 or $self->ut_text('classname')
101 or $self->ut_foreign_keyn('categorynum', 'pkg_category', 'categorynum')
102 or $self->SUPER::check;
108 Returns the pkg_category record associated with this class, or false if there
115 qsearchs('pkg_category', { 'categorynum' => $self->categorynum } );
120 Returns the category name associated with this class, or false if there
126 my $pkg_category = shift->pkg_category;
127 $pkg_category->categoryname if $pkg_category;
136 L<FS::Record>, L<FS::part_pkg>, schema.html from the base documentation.