1 package FS::cust_contact;
2 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
9 FS::cust_contact - Object methods for cust_contact records
15 $record = new FS::cust_contact \%hash;
16 $record = new FS::cust_contact { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::cust_contact object represents a contact's attachment to a specific
29 customer. FS::cust_contact inherits from FS::Record. The following fields are
54 =item selfservice_access
60 'Y' if the customer should get invoices sent to this address, null if not
64 'Y' if contact should get non-invoice email messages sent to this address,
75 Creates a new record. To add the record to the database, see L<"insert">.
77 Note that this stores the hash reference, not a distinct copy of the hash it
78 points to. You can ask the object for a copy with the I<hash> method.
82 # the new method can be inherited from FS::Record, if a table method is defined
84 sub table { 'cust_contact'; }
88 Adds this record to the database. If there is an error, returns the error,
89 otherwise returns false.
93 Delete this record from the database.
95 =item replace OLD_RECORD
97 Replaces the OLD_RECORD with this one in the database. If there is an error,
98 returns the error, otherwise returns false.
102 Checks all fields to make sure this is a valid record. If there is
103 an error, returns the error, otherwise returns false. Called by the insert
108 # the check method should currently be supplied - FS::Record contains some
109 # data checking routines
114 if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'E' || $self->selfservice_access eq 'P') {
115 $self->selfservice_access('Y');
120 $self->ut_numbern('custcontactnum')
121 || $self->ut_number('custnum')
122 || $self->ut_number('contactnum')
123 || $self->ut_numbern('classnum')
124 || $self->ut_textn('comment')
125 || $self->ut_enum('selfservice_access', [ '', 'Y' ])
126 || $self->ut_flag('invoice_dest')
127 || $self->ut_flag('message_dest')
129 return $error if $error;
134 =item contact_classname
136 Returns the name of this contact's class (see L<FS::contact_class>).
140 sub contact_classname {
142 my $contact_class = $self->contact_class or return '';
143 $contact_class->classname;
152 L<FS::contact>, L<FS::cust_main>, L<FS::Record>