add optional fcc_ds0s to pkg_class, RT13057
[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     my $error = $self->ut_numbern('fcc_ds0s')
73         || $self->SUPER::check
74     ;
75     return $error if $error;
76
77     '';
78 }
79
80 =item insert
81
82 Adds this package class to the database.  If there is an error, returns the
83 error, otherwise returns false.
84
85 =item delete
86
87 Deletes this package class from the database.  Only package classes with no
88 associated package definitions can be deleted.  If there is an error, returns
89 the error, otherwise returns false.
90
91 =item replace [ OLD_RECORD ]
92
93 Replaces OLD_RECORD with this one in the database.  If there is an error,
94 returns the error, otherwise returns false.
95
96 =item check
97
98 Checks all fields to make sure this is a valid package class.  If there is an
99 error, returns the error, otherwise returns false.  Called by the insert and
100 replace methods.
101
102 =item pkg_category
103
104 =item category
105
106 Returns the pkg_category record associated with this class, or false if there
107 is none.
108
109 =cut
110
111 sub pkg_category {
112   my $self = shift;
113   $self->category;
114 }
115
116 =item categoryname
117
118 Returns the category name associated with this class, or false if there
119 is none.
120
121 =back
122
123 =head1 BUGS
124
125 =head1 SEE ALSO
126
127 L<FS::part_pkg>, L<FS::Record>
128
129 =cut
130
131 1;