1 package FS::category_Common;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch );
9 FS::category_Common - Base class for category (group of classifications) classes
13 use base qw( FS::category_Common );
14 use FS::class_table; #should use this
16 #optional for non-standard names
17 sub _class_table { 'table_name'; } #default is to replace s/category/class/
21 FS::category_Common is a base class for classes which provide a categorization
22 (group of classifications) for other classes, such as pkg_category or
27 Deletes this category from the database. Only categories with no associated
28 classifications can be deleted. If there is an error, returns the error,
29 otherwise returns false.
36 return "Can't delete a ". $self->table.
37 " with ". $self->_class_table. " records!"
38 if qsearch( $self->_class_table, { 'categorynum' => $self->categorynum } );
45 Checks all fields to make sure this is a valid package category. If there is an
46 error, returns the error, otherwise returns false. Called by the insert and
54 $self->ut_numbern('categorynum')
55 or $self->ut_text('categoryname')
56 or $self->ut_snumbern('weight')
57 or $self->ut_enum('disabled', [ '', 'Y' ])
58 or $self->SUPER::check;
68 use vars qw( $_class_table );
70 return $_class_table if $_class_table;
72 $_class_table = $self->table;
73 $_class_table =~ s/category/cclass/ # s/_category$/_class/
74 or die "can't determine an automatic class table for $_class_table";