backport fixes
[freeside.git] / FS / FS / part_svc_msgcat.pm
1 package FS::part_svc_msgcat;
2 use base qw( FS::Record );
3
4 use strict;
5 use FS::Locales;
6 use FS::part_svc;
7
8 =head1 NAME
9
10 FS::part_svc_msgcat - Object methods for part_svc_msgcat records
11
12 =head1 SYNOPSIS
13
14   use FS::part_svc_msgcat;
15
16   $record = new FS::part_svc_msgcat \%hash;
17   $record = new FS::part_svc_msgcat { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27 =head1 DESCRIPTION
28
29 An FS::part_svc_msgcat object represents localized labels of a service 
30 definition.  FS::part_svc_msgcat inherits from FS::Record.  The following
31 fields are currently supported:
32
33 =over 4
34
35 =item svcpartmsgnum
36
37 primary key
38
39 =item svcpart
40
41 Service definition
42
43 =item locale
44
45 locale
46
47 =item svc
48
49 Localized service name (customer-viewable)
50
51 =back
52
53 =head1 METHODS
54
55 =over 4
56
57 =item new HASHREF
58
59 Creates a new record.  To add the record to the database, see L<"insert">.
60
61 Note that this stores the hash reference, not a distinct copy of the hash it
62 points to.  You can ask the object for a copy with the I<hash> method.
63
64 =cut
65
66 # the new method can be inherited from FS::Record, if a table method is defined
67
68 sub table { 'part_svc_msgcat'; }
69
70 =item insert
71
72 Adds this record to the database.  If there is an error, returns the error,
73 otherwise returns false.
74
75 =cut
76
77 # the insert method can be inherited from FS::Record
78
79 =item delete
80
81 Delete this record from the database.
82
83 =cut
84
85 # the delete method can be inherited from FS::Record
86
87 =item replace OLD_RECORD
88
89 Replaces the OLD_RECORD with this one in the database.  If there is an error,
90 returns the error, otherwise returns false.
91
92 =cut
93
94 # the replace method can be inherited from FS::Record
95
96 =item check
97
98 Checks all fields to make sure this is a valid record.  If there is
99 an error, returns the error, otherwise returns false.  Called by the insert
100 and replace methods.
101
102 =cut
103
104 # the check method should currently be supplied - FS::Record contains some
105 # data checking routines
106
107 sub check {
108   my $self = shift;
109
110   my $error = 
111     $self->ut_numbern('svcpartmsgnum')
112     || $self->ut_foreign_key('svcpart', 'part_svc', 'svcpart')
113     || $self->ut_enum('locale', [ FS::Locales->locales ] )
114     || $self->ut_text('svc')
115   ;
116   return $error if $error;
117
118   $self->SUPER::check;
119 }
120
121 # 3.x stub
122 sub part_svc {
123   my $self = shift;
124   FS::part_svc->by_key($self->svcpart);
125 }
126
127 =back
128
129 =head1 BUGS
130
131 =head1 SEE ALSO
132
133 L<FS::part_svc>, L<FS::Record>, schema.html from the base documentation.
134
135 =cut
136
137 1;
138