public
|
#
__construct( )
Initialize Contacts
Overrides
|
public
integer
|
#
add( array $vars )
Add a contact with the fields given
Add a contact with the fields given
Parameters
- $vars
array $vars An array of variable contact info, including - client_id The client ID
this contact will be associated with - user_id The user ID this contact belongs
to if this contact has their own unique user record (optional) - contact_type
The type of contact, either 'primary' (default), 'billing', or 'other'
(optional) - contact_type_id The ID of the contact type if contact_type is
'other' (optional) - first_name The first name of this contact - last_name The
last name of this contact - title The business title for this contact (optional)
- company The company/organization this contact belongs to (optional) - email
This contact's email address - address1 This contact's address (optional) -
address2 This contact's address line two (optional) - city This contact's city
(optional) - state The 3-character ISO 3166-2 subdivision code, requires country
(optional) - zip The zip/postal code for this contact (optional) - country The
2-character ISO 3166-1 country code, required if state is given (optional) -
numbers An array of number data including (optional): - number The phone number
to add - type The type of phone number 'phone', 'fax' (optional, default
'phone') - location The location of this phone line 'home', 'work', 'mobile'
(optional, default 'home')
Returns
integer The contact ID, void on error
See
|
public
stdClass
|
#
edit( integer $contact_id, array $vars )
Edit the contact with the fields given, all fields optional
Edit the contact with the fields given, all fields optional
Parameters
- $contact_id
integer $contact_id The contact ID to update
- $vars
array $vars An array of variable contact info, including - user_id The user ID this
contact belongs to if this contact has their own unique user record (optional) -
contact_type The type of contact, either "primary" (default) or "other"
(optional) - contact_type_id The ID of the contact type if contact_type is
"other" (optional) - first_name The first name of this contact - last_name The
last name of this contact - title The business title for this contact (optional)
- company The company/organization this contact belongs to (optional) - email
This contact's email address - address1 This contact's address (optional) -
address2 This contact's address line two (optional) - city This contact's city
(optional) - state The 3-character ISO 3166-2 subdivision code, requires country
(optional) - zip The zip/postal code for this contact (optional) - country The
2-character ISO 3166-1 country code, required if state is given (optional) -
numbers An array of number data including (optional): - id The ID of the contact
number to update (if empty, will add as new) - number The phone number to add
(if empty, will remove this record) - type The type of phone number 'phone',
'fax' (optional, default 'phone') - location The location of this phone line
'home', 'work', 'mobile' (optional, default 'home')
Returns
stdClass
object represented the updated contact if successful, void otherwise
See
|
public
|
#
delete( integer $contact_id )
Permanently removes this contact from the system.
Permanently removes this contact from the system.
Parameters
- $contact_id
integer $contact_id The ID of the contact to remove from the system
|
public
mixed
|
#
get( integer $contact_id )
Fetch the contact with the given contact ID
Fetch the contact with the given contact ID
Parameters
- $contact_id
integer $contact_id The contact ID to fetch
Returns
mixed A stdClass contact object, or false if the contact does not exist
|
public
mixed
|
#
getByUserId( integer $user_id, integer $client_id )
Fetch the contact with the given contact ID
Fetch the contact with the given contact ID
Parameters
- $user_id
integer $user_id The contact user ID to fetch on
- $client_id
integer $client_id The contact client ID to fetch on
Returns
mixed A stdClass contact object, or false if the contact does not exist
|
public
mixed
|
#
getList( integer $client_id, integer $page = 1, array $order = array('last_name'=>"asc", 'first_name'=>"asc") )
Fetches a list of all contacts under a client
Fetches a list of all contacts under a client
Parameters
- $client_id
integer $client_id The client ID to fetch contacts for
- $page
integer $page The page to return results for
- $order
string $sort_by The field to sort by
Returns
mixed An array of objects or false if no results.
|
public
integer
|
#
getListCount( integer $client_id )
Return the total number of contacts returned from Contacts::getList(), useful
in constructing pagination for the getList() method.
Return the total number of contacts returned from Contacts::getList(), useful
in constructing pagination for the getList() method.
Parameters
- $client_id
integer $client_id The client ID to fetch contacts for
Returns
integer The total number of clients
See
|
public
array
|
#
getAll( integer $client_id, string $contact_type = null, array $order = array('last_name'=>"asc", 'first_name'=>"asc") )
Fetches a list of all contacts under a client
Fetches a list of all contacts under a client
Parameters
- $client_id
integer $client_id The client ID to fetch contacts for
- $contact_type
string $contact_type The contact type to fetch (i.e. "primary", "billing", or "other")
(optional, default all contact types)
- $order
array $order The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
array A list of stdClass objects representing each contact
|
public
array
|
#
getContactTypes( )
Retrieves a list of client contact types
Retrieves a list of client contact types
Returns
array Key=>value pairs of client contact types
|
public
mixed
|
#
getType( integer $contact_type_id )
Retrieve a single contact type
Retrieve a single contact type
Parameters
- $contact_type_id
integer $contact_type_id The contact type ID
Returns
mixed An stdClass object representing the contact type, or false if none exist
|
public
array
|
#
getTypes( integer $company_id = null )
Return all existing contact types in the system for the given company
Return all existing contact types in the system for the given company
Parameters
- $company_id
integer $company_id The company ID to fetch contact types for (optional)
Returns
array An array of stdClass objects representing contact types
|
public
integer
|
#
addType( array $vars )
Add a contact type
Parameters
- $vars
array $vars An array of contact type information including: - name The name of this
contact type - is_lang Whether or not 'name' is a language definition -
company_id The company ID to add the contact type under (optional)
Returns
integer The contact type ID created, void if error
|
public
|
#
editType( integer $contact_type_id, array $vars )
Update the contact type with the given data
Update the contact type with the given data
Parameters
- $contact_type_id
integer $contact_type_id The contact type ID to update
- $vars
array $vars An array of contact type information including: - name The name of this
contact type - is_lang Whether or not 'name' is a language definition
|
public
|
#
deleteType( integer $contact_type_id )
Delete a contact type and reset the type for all affected contacts to
null
Delete a contact type and reset the type for all affected contacts to
null
Parameters
- $contact_type_id
integer $contact_type_id The contact type ID
|
public
integer
|
#
addNumber( integer $contact_id, array $vars )
Adds a new number
Parameters
- $contact_id
integer $contact_id The contact ID to attach the number
- $vars
array $vars An array of number information including: - number The phone number to add
- type The type of phone number 'phone', 'fax' (optional, default 'phone') -
location The location of this phone line 'home', 'work', 'mobile' (optional,
default 'home')
Returns
integer The contact number ID of the number created, void if error
|
public
|
#
editNumber( integer $contact_number_id, array $vars )
Updates an existing number
Updates an existing number
Parameters
- $contact_number_id
integer $contact_number_id The number ID to update
- $vars
array $vars An array of number information including: - number The phone number to add
- type The type of phone number 'phone', 'fax' (optional, default 'phone') -
location The location of this phone line 'home', 'work', 'mobile' (optional,
default 'home')
|
public
|
#
deleteNumber( integer $contact_number_id )
Permanently removes a number from the system
Permanently removes a number from the system
Parameters
- $contact_number_id
integer $contact_number_id The Id of the number to delete
|
public
mixed
|
#
getNumber( integer $contact_number_id )
Fetches a specific number
Fetches a specific number
Parameters
- $contact_number_id
integer $contact_number_id The ID of the number to fetch
Returns
mixed A stdClass object representing the number, false if no such number exists
|
public
mixed
|
#
getNumbers( integer $contact_id, string $type = null, string $location = null, mixed $order = array("FIELD(location,'work','home','mobile')"=>"ASC") )
Fetches all numbers for the given contact and (optionally) type
Fetches all numbers for the given contact and (optionally) type
Parameters
- $contact_id
integer $contact_id The contact ID to fetch all numbers for
- $type
string $type The type of number to fetch ('phone', or 'fax', default null for all)
- $location
string $location The location of the number to fetch ('home', 'work', or 'mobile',
default null for all)
- $order
Returns
mixed An array of stdClass objects representing contact numbers, false if no records
found
|
public
array
|
#
getNumberTypes( )
Returns a list of contact number types
Returns a list of contact number types
Returns
array A key=>value list of contact number types
|
public
array
|
#
getNumberLocations( )
Returns a list of contact number locations
Returns a list of contact number locations
Returns
array A key=>value list of contact number locations
|
public
string
|
#
intlNumber( string $number, string $country, string $code_delimiter = "." )
Internationalizes the given format number (+NNN.NNNNNNNNNN)
Internationalizes the given format number (+NNN.NNNNNNNNNN)
Parameters
- $number
string $number The phone number
- $country
string $country The ISO 3166-1 alpha2 country code
- $code_delimiter
string $code_delimiter The delimiter to use between the country prefix and the number
Returns
string The number in +NNN.NNNNNNNNNN
|
public
|
#
setPermissions( integer $contact_id, array $vars )
Sets permissions for the given contact
Sets permissions for the given contact
Parameters
- $contact_id
integer $contact_id The ID of the contact to set permissions for
- $vars
array $vars A numerically indexed array of arrays containing: - area The area
|
public
array
|
#
getPermissions( integer $contact_id )
Fetch all permissions set for a contact
Fetch all permissions set for a contact
Parameters
- $contact_id
integer $contact_id The ID of the contact to set permissions for
Returns
array An array of stdClass objects, each representing a permission
|
public
boolean
|
#
hasPermission( integer $company_id, integer $contact_id, string $area )
Checks whether or not the contact has permissions for the given area
Checks whether or not the contact has permissions for the given area
Parameters
- $company_id
integer $company_id The ID of the company
- $contact_id
integer $contact_id The ID of the contact
- $area
string $area The area to check
Returns
boolean True if permission allowed, false otherwise
|
public
array
|
#
getPermissionOptions( integer $company_id )
Returns an array of key/value pairs of all available permission options
Returns an array of key/value pairs of all available permission options
Parameters
- $company_id
integer $company_id The ID of the company to fetch options under
Returns
array An array of key/value pairs
|
public
boolean
|
#
validateContactNumberType( string $type )
Validates the contact numbers 'type' field
Validates the contact numbers 'type' field
Parameters
- $type
string $type The type to check
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateContactNumberLocation( string $location )
Validates the contact numbers 'location' field
Validates the contact numbers 'location' field
Parameters
- $location
string $location The location to check
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateContactType( string $contact_type, integer $contact_id = null, integer $client_id = null )
Validates a contact's 'contact_type' field
Validates a contact's 'contact_type' field
Parameters
- $contact_type
string $contact_type The contact type to check
- $contact_id
integer $contact_id The ID of the contact being updated
- $client_id
integer $client_id The ID of the contact being added to
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateContactTypeId( integer $contact_type_id, string $contact_type, integer $client_id )
Validates a contact's 'contact_type_id' field
Validates a contact's 'contact_type_id' field
Parameters
- $contact_type_id
integer $contact_type_id The contact type ID to check
- $contact_type
string $contact_type The contact type
- $client_id
integer $client_id The ID of the client the contact's type is being set for
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateCountrySet( string $state, string $country )
Validates a country is set when a state is provided
Validates a country is set when a state is provided
Parameters
- $state
string $state The state
- $country
string $country The country
Returns
boolean True if a country is set, false otherwise
|
public
boolean
|
#
validateIsPrimary( integer $contact_id )
Validates whether this contact is the primary contact for a client
Validates whether this contact is the primary contact for a client
Parameters
- $contact_id
integer $contact_id The contact ID
Returns
boolean True if this contact is a client's primary billing contact, false otherwise
|
public
boolean
|
#
validateReceivesInvoices( string $contact_type = null, integer $contact_id = null )
Validates whether the given contact is the contact whom invoices are
addressed to and can be based on the given contact type
Validates whether the given contact is the contact whom invoices are
addressed to and can be based on the given contact type
Parameters
- $contact_type
string $contact_type The contact type of the contact (i.e. "primary", "billing",
"other"; optional)
- $contact_id
integer $contact_id The contact ID
Returns
boolean True if this contact is the contact whom invoices are addressed to, false
otherwise
|