1 package FS::pkg_category;
4 use base qw( FS::category_Common );
5 use vars qw( @ISA $me $DEBUG );
6 use FS::Record qw( qsearch dbh );
11 $me = '[FS::pkg_category]';
15 FS::pkg_category - Object methods for pkg_category records
21 $record = new FS::pkg_category \%hash;
22 $record = new FS::pkg_category { 'column' => 'value' };
24 $error = $record->insert;
26 $error = $new_record->replace($old_record);
28 $error = $record->delete;
30 $error = $record->check;
34 An FS::pkg_category object represents an package category. Every package class
35 (see L<FS::pkg_class>) has, optionally, a package category. FS::pkg_category
36 inherits from FS::Record. The following fields are currently supported:
42 primary key (assigned automatically for new package categoryes)
46 Text name of this package category
54 Disabled flag, empty or 'Y'
64 Creates a new package category. To add the package category to the database,
69 sub table { 'pkg_category'; }
73 Adds this package category to the database. If there is an error, returns the
74 error, otherwise returns false.
78 Deletes this package category from the database. Only package categoryes with
79 no associated package definitions can be deleted. If there is an error,
80 returns the error, otherwise returns false.
82 =item replace [ OLD_RECORD ]
84 Replaces OLD_RECORD with this one in the database. If there is an error,
85 returns the error, otherwise returns false.
89 Checks all fields to make sure this is a valid package category. If there is an
90 error, returns the error, otherwise returns false. Called by the insert and
97 # Used by FS::Upgrade to migrate to a new database.
100 my ($class, %opts) = @_;
103 warn "$me upgrading $class\n" if $DEBUG;
106 qsearch('pkg_category', { weight => { op => '!=', value => '' } } );
108 unless( scalar(@pkg_category) ) {
109 my @pkg_category = qsearch('pkg_category', {} );
111 foreach ( sort { $a->description cmp $b->description } @pkg_category ) {
113 my $error = $_->replace;
114 die "error setting pkg_category weight: $error\n" if $error;
127 L<FS::category_Common>, L<FS::Record>