1 package FS::cust_main_note;
4 use base qw( FS::otaker_Mixin FS::Record );
6 use FS::Record qw( qsearch qsearchs );
7 use FS::cust_note_class;
11 FS::cust_main_note - Object methods for cust_main_note records
15 use FS::cust_main_note;
17 $record = new FS::cust_main_note \%hash;
18 $record = new FS::cust_main_note { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::cust_main_note object represents a note attachted to a customer.
31 FS::cust_main_note inherits from FS::Record. The following fields are
58 Creates a new customer note. To add the note to the database, see L<"insert">.
60 Note that this stores the hash reference, not a distinct copy of the hash it
61 points to. You can ask the object for a copy with the I<hash> method.
65 # the new method can be inherited from FS::Record, if a table method is defined
67 sub table { 'cust_main_note'; }
71 Adds this record to the database. If there is an error, returns the error,
72 otherwise returns false.
76 # the insert method can be inherited from FS::Record
80 Delete this record from the database.
84 # the delete method can be inherited from FS::Record
86 =item replace OLD_RECORD
88 Replaces the OLD_RECORD with this one in the database. If there is an error,
89 returns the error, otherwise returns false.
93 # the replace method can be inherited from FS::Record
97 Checks all fields to make sure this is a valid example. If there is
98 an error, returns the error, otherwise returns false. Called by the insert
103 # the check method should currently be supplied - FS::Record contains some
104 # data checking routines
110 $self->ut_numbern('notenum')
111 || $self->ut_number('custnum')
112 || $self->ut_foreign_keyn('classnum', 'cust_note_class', 'classnum')
113 || $self->ut_numbern('_date')
114 || $self->ut_textn('otaker')
115 || $self->ut_anything('comments')
117 return $error if $error;
122 =item cust_note_class
124 Returns the customer note class, as an FS::cust_note_class object, or the empty
125 string if there is no note class.
129 sub cust_note_class {
131 if ( $self->classnum ) {
132 qsearchs('cust_note_class', { 'classnum' => $self->classnum } );
140 Returns the customer note class name, or the empty string if there is no
147 my $cust_note_class = $self->cust_note_class;
148 $cust_note_class ? $cust_note_class->classname : '';
152 #false laziness w/otaker_Mixin & cust_attachment
155 if ( scalar(@_) ) { #set
157 my($l,$f) = (split(', ', $otaker));
158 my $access_user = qsearchs('access_user', { 'username'=>$otaker } )
159 || qsearchs('access_user', { 'first'=>$f, 'last'=>$l } )
160 or croak "can't set otaker: $otaker not found!"; #confess?
161 $self->usernum( $access_user->usernum );
162 $otaker; #not sure return is used anywhere, but just in case
164 if ( $self->usernum ) {
165 $self->access_user->username;
166 } elsif ( length($self->get('otaker')) ) {
167 $self->get('otaker');
174 # Used by FS::Upgrade to migrate to a new database.
175 sub _upgrade_data { # class method
176 my ($class, %opts) = @_;
177 $class->_upgrade_otaker(%opts);
184 Lurking in the cracks.
188 L<FS::Record>, schema.html from the base documentation.