1 package FS::pkg_category;
2 use base qw( FS::category_Common );
5 use vars qw( @ISA $me $DEBUG );
6 use FS::Record qw( qsearch );
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
52 =item ticketing_queueid
58 Condense flag for invoice display, empty or 'Y'
63 Disabled flag, empty or 'Y'
73 Creates a new package category. To add the package category to the database,
78 sub table { 'pkg_category'; }
82 Adds this package category to the database. If there is an error, returns the
83 error, otherwise returns false.
87 Deletes this package category from the database. Only package categoryes with
88 no associated package definitions can be deleted. If there is an error,
89 returns the error, otherwise returns false.
91 =item replace [ OLD_RECORD ]
93 Replaces OLD_RECORD with this one in the database. If there is an error,
94 returns the error, otherwise returns false.
98 Checks all fields to make sure this is a valid package category. If there is an
99 error, returns the error, otherwise returns false. Called by the insert and
107 $self->ut_enum('condense', [ '', 'Y' ])
108 || $self->ut_snumbern('ticketing_queueid')
109 || $self->SUPER::check;
112 =item ticketing_queue
114 Returns the queue name corresponding with the id from the I<ticketing_queueid>
115 field, or the empty string.
119 sub ticketing_queue {
121 return 'Agent-specific queue' if $self->ticketing_queueid == -1;
122 return '' unless $self->ticketing_queueid;
123 FS::TicketSystem->queue($self->ticketing_queueid);
128 # Used by FS::Upgrade to migrate to a new database.
131 my ($class, %opts) = @_;
133 warn "$me upgrading $class\n" if $DEBUG;
136 qsearch('pkg_category', { weight => { op => '!=', value => '' } } );
138 unless( scalar(@pkg_category) ) {
139 my @pkg_category = qsearch('pkg_category', {} );
141 foreach ( sort { $a->description cmp $b->description } @pkg_category ) {
143 my $error = $_->replace;
144 die "error setting pkg_category weight: $error\n" if $error;
157 L<FS::category_Common>, L<FS::Record>