4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
12 FS::contact - Object methods for contact records
18 $record = new FS::contact \%hash;
19 $record = new FS::contact { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::contact object represents an example. FS::contact inherits from
32 FS::Record. The following fields are currently supported:
81 Creates a new example. To add the example to the database, see L<"insert">.
83 Note that this stores the hash reference, not a distinct copy of the hash it
84 points to. You can ask the object for a copy with the I<hash> method.
88 # the new method can be inherited from FS::Record, if a table method is defined
90 sub table { 'contact'; }
94 Adds this record to the database. If there is an error, returns the error,
95 otherwise returns false.
99 # the insert method can be inherited from FS::Record
103 Delete this record from the database.
107 # the delete method can be inherited from FS::Record
109 =item replace OLD_RECORD
111 Replaces the OLD_RECORD with this one in the database. If there is an error,
112 returns the error, otherwise returns false.
116 # the replace method can be inherited from FS::Record
120 Checks all fields to make sure this is a valid example. If there is
121 an error, returns the error, otherwise returns false. Called by the insert
126 # the check method should currently be supplied - FS::Record contains some
127 # data checking routines
133 $self->ut_numbern('contactnum')
134 || $self->ut_foreign_keyn('prospectnum', 'prospect_main', 'prospectnum')
135 || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
136 || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum')
137 || $self->ut_textn('last')
138 || $self->ut_textn('first')
139 || $self->ut_textn('title')
140 || $self->ut_textn('comment')
141 || $self->ut_enum('disabled', [ '', 'Y' ])
143 return $error if $error;
145 return "No prospect or customer!" unless $self->prospectnum || $self->custnum;
146 return "Prospect and customer!" if $self->prospectnum && $self->custnum;
148 return "One of first name, last name, or title must have a value"
149 if ! grep $self->$_(), qw( first last title);
156 my $data = $self->first. ' '. $self->last;
157 $data .= ', '. $self->title
159 $data .= ' ('. $self->comment. ')'
168 The author forgot to customize this manpage.
172 L<FS::Record>, schema.html from the base documentation.