% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>
FS::contact - Object methods for contact records
use FS::contact;
$record = new FS::contact \%hash;
$record = new FS::contact { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
An FS::contact object represents an specific contact person for a prospect or customer. FS::contact inherits from FS::Record. The following fields are currently supported:
primary key
prospectnum
custnum
locationnum
last
first
title
comment
empty or Y
empty or bcrypt
disabled
Creates a new contact. To add the contact to the database, see "insert".
Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the hash method.
Adds this record to the database. If there is an error, returns the error, otherwise returns false.
If the object has an emailaddress field, FS::contact_email records will be created for each (comma-separated) email address in that field. If any of these coincide with an existing email address, this contact will be merged with the contact with that address.
Then, if the object has any fields named phonetypenumN an FS::contact_phone record will be created for each of them. Those fields should contain phone numbers of the appropriate types (where N is the key of an FS::phone_type record identifying the type of number: daytime, night, etc.).
After inserting the record, if the object has a 'custnum' or 'prospectnum' field, an FS::cust_contact or FS::prospect_contact record will be created to link the contact to the customer. The following fields will also be included in that record, if they are set on the object: - classnum - comment - selfservice_access - invoice_dest
Delete this record from the database.
Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
Subroutine, takes a string and returns a list (suitable for assigning to a hash) with keys 'countrycode', 'phonenum' and 'extension'
(Should probably be moved to contact_phone.pm, hence the initial underscore.)
Used by insert & replace to update the fuzzy search cache
Checks all fields to make sure this is a valid contact. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
Returns a formatted string representing this contact, including name, title and comment.
Returns a formatted string representing this contact, with just the name.
Alternate search constructor (class method). Given an email address, returns the contact for that address. If that contact doesn't have selfservice access, or there isn't one, returns the empty string.
Alternate search constructor (class method). Given an email address and custnum, returns the contact for that address and custnum. If that contact doesn't have selfservice access, or there isn't one, returns the empty string.
Changes the contact's selfservice access password to NEW_PASSWORD. This does not check password policy rules (see is_password_allowed) and will return an error only if editing the record fails for some reason.
If NEW_PASSWORD is the same as the existing password, this does nothing.
Returns a list reference containing the set of contact fields used in the web interface for one-line editing (i.e. excluding contactnum, prospectnum, custnum and locationnum, as well as password fields, but including fields for contact_email and contact_phone records.)
FS::Record, schema.html from the base documentation.