add customer fields option with agent, display_custnum, status and name, RT#73721
[freeside.git] / FS / FS / pkg_class.pm
1 package FS::pkg_class;
2
3 use strict;
4 use FS::class_Common;
5 use base qw( FS::class_Common );
6 use FS::part_pkg;
7 use FS::pkg_category;
8
9 =head1 NAME
10
11 FS::pkg_class - Object methods for pkg_class records
12
13 =head1 SYNOPSIS
14
15   use FS::pkg_class;
16
17   $record = new FS::pkg_class \%hash;
18   $record = new FS::pkg_class { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::pkg_class object represents an package class.  Every package definition
31 (see L<FS::part_pkg>) has, optionally, a package class. FS::pkg_class inherits
32 from FS::Record.  The following fields are currently supported:
33
34 =over 4
35
36 =item classnum
37
38 primary key (assigned automatically for new package classes)
39
40 =item classname
41
42 Text name of this package class
43
44 =item categorynum
45
46 Number of associated pkg_category (see L<FS::pkg_category>)
47
48 =item disabled
49
50 Disabled flag, empty or 'Y'
51
52 =item fcc_ds0s - Optional DS0 equivalency number for FCC form 477
53
54 =back
55
56 =head1 METHODS
57
58 =over 4
59
60 =item new HASHREF
61
62 Creates a new package class.  To add the package class to the database, see
63 L<"insert">.
64
65 =cut
66
67 sub table { 'pkg_class'; }
68 sub _target_table { 'part_pkg'; }
69
70 sub check {
71     my $self = shift;
72     $self->ut_numbern('fcc_ds0s')
73         || $self->SUPER::check;
74 }
75
76 =item insert
77
78 Adds this package class to the database.  If there is an error, returns the
79 error, otherwise returns false.
80
81 =item delete
82
83 Deletes this package class from the database.  Only package classes with no
84 associated package definitions can be deleted.  If there is an error, returns
85 the error, otherwise returns false.
86
87 =item replace [ OLD_RECORD ]
88
89 Replaces OLD_RECORD with this one in the database.  If there is an error,
90 returns the error, otherwise returns false.
91
92 =item check
93
94 Checks all fields to make sure this is a valid package class.  If there is an
95 error, returns the error, otherwise returns false.  Called by the insert and
96 replace methods.
97
98 =item pkg_category
99
100 =item category
101
102 Returns the pkg_category record associated with this class, or false if there
103 is none.
104
105 =cut
106
107 sub pkg_category {
108   my $self = shift;
109   $self->category;
110 }
111
112 =item categoryname
113
114 Returns the category name associated with this class, or false if there
115 is none.
116
117 =back
118
119 =head1 BUGS
120
121 =head1 SEE ALSO
122
123 L<FS::part_pkg>, L<FS::Record>
124
125 =cut
126
127 1;