public
|
#
__construct( )
Initialize Clients
Overrides
|
public
integer
|
#
add( array $vars )
Add a client to the clients table
Add a client to the clients table
Parameters
- $vars
array $vars An array of client info including: - id_code The client's reference ID
code (for display purposes) - user_id The client's user ID - client_group_id The
client group this user belongs to - status The status of this client ('active',
'inactive',' 'fraud') (optional, default active)
Returns
integer The client ID, or void on faliure
|
public
|
#
edit( integer $client_id, array $vars )
Edit a client from the clients table
Edit a client from the clients table
Parameters
- $client_id
integer $client_id The client's ID
- $vars
array $vars An array of client info (all fields optional) including: - id_code The
client's reference ID code (for display purposes) - user_id The client's user ID
- client_group_id The client group this user belongs to - status The status of
this client ('active', 'inactive',' 'fraud')
|
public
|
#
delete( integer $client_id )
Permanently removes a client from the clients table. CAUTION: Deleting a
client will cause all invoices, services, transactions, etc. attached to that
client to become inaccessible.
Permanently removes a client from the clients table. CAUTION: Deleting a
client will cause all invoices, services, transactions, etc. attached to that
client to become inaccessible.
Parameters
- $client_id
integer $client_id The client ID to permanently remove from the system
|
public
integer
|
#
addCustomField( array $vars )
Add custom client field
Parameters
- $vars
array An array of custom field info including: - client_group_id The client group ID
the field will belong to (optional, default null) - name The name of the custom
field - is_lang Whether or not 'name' is a language definition (optional,
default 0) - type The type of field ('text','checkbox','select','textarea')
(optional, default 'text') - values Values for the field (comma separated for
select menus) - regex Custom regex required by this field (optional, default
null) - show_client Whether or not to allow the client to updated this field
(optional, default 0) - encrypted Whether or not to encrypt values associated
with this custom field (optional, default 0)
Returns
integer The custom field ID, void on failure
|
public
integer
|
#
editCustomField( integer $field_id, array $vars )
Edit custom client field
Parameters
- $field_id
integer $field_id The ID of the custom field to update
- $vars
array An array of custom field info (all optional) including: - client_group_id The
client group ID the field will belong to - name The name of the custom field -
is_lang Whether or not 'name' is a language definition - type The type of field
('text','checkbox','select','textarea') - values Values for the field. If type
is 'select', values must be a key=>value array of option=>value - regex
Custom regex required by this field (optional, default null) - show_client
Whether or not to allow the client to updated this field - encrypted Whether or
not to encrypt values associated with this custom field (optional, default 0)
Returns
integer The custom field ID, void on failure
|
public
|
#
deleteCustomField( integer $field_id )
Permanently removes a custom client field and all entries for that field
Permanently removes a custom client field and all entries for that field
Parameters
- $field_id
integer $field_id The ID of the custom field to delete
|
public
array
|
#
getCustomFieldTypes( )
Retrieve a list of all custom field types
Retrieve a list of all custom field types
Returns
array A key=>value array of custom field types
|
public
mixed
|
#
getCustomFields( integer $company_id, integer $client_group_id = null )
Retrieves a list of all custom client fields by company
Retrieves a list of all custom client fields by company
Parameters
- $company_id
integer $company_id The company ID
- $client_group_id
integer $client_group_id The client group ID of fields to fetch (optional, default null
for all)
Returns
mixed An array of stdClass custom field objects, false if no custom fields exist
|
public
mixed
|
#
getCustomField( integer $field_id, integer $company_id = null )
Retrieves a single custom field
Retrieves a single custom field
Parameters
- $field_id
integer $field_id The custom field ID to fetch
- $company_id
integer $company_id The company ID (optional, default null)
Returns
mixed An stdClass of key=>value pairs, or false if the custom field does not exist
|
public
|
#
setCustomField( integer $field_id, integer $client_id, string $value )
Sets the given value for the given custom client field
Sets the given value for the given custom client field
Parameters
- $field_id
integer $field_id The ID of the custom client field
- $client_id
integer $client_id The client ID the custom field value belongs to
- $value
string $value The value to assign to this client
|
public
|
#
deleteCustomFieldValue( integer $client_field_id, integer $client_id )
Deletes a given client field value
Deletes a given client field value
Parameters
- $client_field_id
integer $client_field_id The ID of the custom client field
- $client_id
integer $client_id The client ID the custom field value belongs to
|
public
mixed
|
#
getCustomFieldValues( integer $client_id )
Fetches all custom field values assigned to a given client
Fetches all custom field values assigned to a given client
Parameters
- $client_id
integer $client_id The client ID
Returns
mixed An array of stdClass objects representing each custom field, or false if none
exist
|
public
|
#
setRestrictedPackages( integer $client_id, array $package_ids )
Sets restricted package access for a client
Sets restricted package access for a client
Parameters
- $client_id
integer $client_id The ID of the client whose restricted package access to set
- $package_ids
array A list of package IDs to assign to this client
|
public
|
#
deleteRestrictedPackages( integer $client_id )
Removes all restricted package access for the given client
Removes all restricted package access for the given client
Parameters
- $client_id
integer $client_id The ID of the client whose package access to remove
|
public
array
|
#
getRestrictedPackages( integer $client_id )
Fetches all restricted package IDs accessible by the given client
Fetches all restricted package IDs accessible by the given client
Parameters
- $client_id
integer $client_id The ID of the client whose restricted packages to fetch
Returns
array A list of stdClass objects each representing a restricted package ID
|
public
boolean
|
#
validatePackages( array $package_ids )
Validates that the given packages exist
Validates that the given packages exist
Parameters
- $package_ids
array $package_ids The IDs of the packages to check
Returns
boolean True if the given packages exist, false otherwise
|
public
integer
|
#
addNote( integer $client_id, integer $staff_id, array $vars )
Add a note for the given client
Add a note for the given client
Parameters
- $client_id
integer $client_id The ID of the client to attach the note to
- $staff_id
integer $staff_id The ID of the staff member attempting to create the note
- $vars
array $vars An array of note info including: - title The title of the note -
description The description of the note - stickied Whether this note is sticked
or not (1 or 0, optional, default 0)
Returns
integer The ID for this note, void on failure
|
public
|
#
editNote( integer $note_id, array $vars )
Edit an existing note for a client
Edit an existing note for a client
Parameters
- $note_id
integer $note_id The ID of the note
- $vars
array $vars An array of note info (all optional) including: - title The title of the
note - description The description of the note - stickied Whether this note is
sticked or not (1 or 0, optional, default 0)
|
public
|
#
unstickyNote( integer $note_id )
Sets the given note as unstickied
Sets the given note as unstickied
Parameters
- $note_id
integer $note_id The note ID
|
public
|
#
deleteNote( integer $note_id )
Delete the given client note
Delete the given client note
Parameters
- $note_id
integer $note_id The ID of the note to delete
|
public
mixed
|
#
getNoteList( integer $client_id, integer $page = 1, array $order_by = array('date_added'=>"DESC") )
Returns all notes attached to a client
Returns all notes attached to a client
Parameters
- $client_id
integer $client_id The client to fetch notes for
- $page
integer $page The page to return results for (optional, default 1)
- $order_by
string $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
mixed An array of stdClass note objects, false if no notes exist
|
public
integer
|
#
getNoteListCount( integer $client_id )
Returns the count of all notes attached to a client
Returns the count of all notes attached to a client
Parameters
- $client_id
integer $client_id The client ID
Returns
integer The number of notes belonging to this client
See
Clients::getNotes()
|
public
array
|
#
getAllStickyNotes( integer $client_id, integer $max_limit = null )
Retrieves a list of all sticked notes attached to this client
Retrieves a list of all sticked notes attached to this client
Parameters
- $client_id
integer $client_id The client ID
- $max_limit
integer $max_limit The maximum number of recent stickied notes to retrieve (optional,
default all)
Returns
array A list of stdClass objects representing each note
|
private
Record
|
#
fetchNotes( mixed $client_id )
Partially constructs the query required by both Clients::getNotes() and
Clients::getNoteCount()
Partially constructs the query required by both Clients::getNotes() and
Clients::getNoteCount()
Returns
Record
The partially constructed query Record object
|
public
mixed
|
#
getNote( integer $note_id )
Returns the note specified
Returns the note specified
Parameters
- $note_id
integer $note_id The ID of the note to fetch
Returns
mixed A stdClass object representing the note, false if the note does not exist
|
public
mixed
|
#
getDebitAccount( integer $client_id )
Retrieves the client debit account
Retrieves the client debit account
Parameters
- $client_id
integer $client_id The ID of the client whose debit account to get
Returns
mixed A stdClass object representing the client account type, or false if none exist
|
public
|
#
addDebitAccount( integer $client_id, array $vars )
Adds a client debit account type NOTE: if a debit account already exists for
this client, it will be overwritten
Adds a client debit account type NOTE: if a debit account already exists for
this client, it will be overwritten
Parameters
- $client_id
integer $client_id The ID of the client whose debit account to add a debit account to
- $vars
array $vars A list of client account types including: - account_id The ID of the
account to add - type The type of account to add ('cc' or 'ach')
|
public
boolean
|
#
deleteDebitAccount( integer $client_id )
Deletes a client debit account type
Deletes a client debit account type
Parameters
- $client_id
integer $client_id The ID of the client whose debit account to delete
Returns
boolean True if the debit account was deleted, false otherwise
|
public
|
#
setClientSettings( integer $client_id, array $vars )
Add multiple client settings, with rule validation. If duplicate key, update
the setting
Add multiple client settings, with rule validation. If duplicate key, update
the setting
Parameters
- $client_id
integer $client_id The ID for the specified client
- $vars
array $vars A single dimensional array of key/value pairs of settings
|
public
|
#
setSettings( integer $client_id, array $vars )
Add multiple client settings, if duplicate key update the setting
Add multiple client settings, if duplicate key update the setting
Parameters
- $client_id
integer $client_id The ID for the specified client
- $vars
array $vars A single dimensional array of key/value pairs of settings
|
public
|
#
setSetting( integer $client_id, string $key, string $value, mixed $encrypted = null )
Add a client setting, if duplicate key update the setting
Add a client setting, if duplicate key update the setting
Parameters
- $client_id
integer $client_id The ID for the specified client
- $key
string $key The key for this client setting
- $value
string $value The value for this individual client setting
- $encrypted
mixed $encrypted True to encrypt $value, false to store unencrypted, null to encrypt
if currently set to encrypt
|
public
|
#
unsetSetting( integer $client_id, string $key )
Delete a client setting
Parameters
- $client_id
integer $client_id The ID for the specified client
- $key
string $key The key for this client setting
|
public
mixed
|
#
getSettings( integer $client_id )
Fetch all settings that may apply to this client. Settings are inherited in
the order of client_settings -> client_group_settings -> company_settings
-> settings where "->" represents the left item inheriting (and
overwriting in the case of duplicates) values found in the right item.
Fetch all settings that may apply to this client. Settings are inherited in
the order of client_settings -> client_group_settings -> company_settings
-> settings where "->" represents the left item inheriting (and
overwriting in the case of duplicates) values found in the right item.
Parameters
- $client_id
integer $client_id The client ID to retrieve settings for
Returns
mixed An array of objects containg key/values for the settings, false if no records
found
|
public
mixed
|
#
getSetting( integer $client_id, mixed $key )
Fetch a specific setting that may apply to this client. Settings are
inherited in the order of client_settings -> client_group_settings ->
company_settings -> settings where "->" represents the left item
inheriting (and overwriting in the case of duplicates) values found in the right
item.
Fetch a specific setting that may apply to this client. Settings are
inherited in the order of client_settings -> client_group_settings ->
company_settings -> settings where "->" represents the left item
inheriting (and overwriting in the case of duplicates) values found in the right
item.
Parameters
- $client_id
integer $client_id The client ID to retrieve settings for
- $key
Returns
mixed An array of objects containg key/values for the settings, false if no records
found
|
public
mixed
|
#
get( integer $client_id, boolean $get_settings = true )
Fetches a client with contact details of the primary account holder
Fetches a client with contact details of the primary account holder
Parameters
- $client_id
integer $client_id The client ID to fetch
- $get_settings
boolean $get_settings True to fetch settings for this client (default), false otherwise
Returns
mixed An object containing client fields, false if the client does not exist.
See
|
public
mixed
|
#
getByUserId( integer $user_id, boolean $get_settings = false )
Fetches a client with contact details of the primary account holder
Fetches a client with contact details of the primary account holder
Parameters
- $user_id
integer $user_id The ID of the user
- $get_settings
boolean $get_settings True to fetch settings for this client, false otherwise
Returns
mixed An object containing client fields, false if the client does not exist.
See
|
private
Record
|
#
getAClient( )
Partially constructs a query for fetching a single client
Partially constructs a query for fetching a single client
Returns
Record
A Record object representing the partial query for fetching a single client
|
public
array
|
#
getList( string $status = null, integer $page = 1, string $order_by = array('id_code'=>"ASC") )
Fetches a list of all clients
Fetches a list of all clients
Parameters
- $status
string $status The status type of the clients to fetch ('active', 'inactive', 'fraud',
default null for all)
- $page
integer $page The page to return results for (optional, default 1)
- $order_by
string $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
array An array of stdClass objects representing each client, or false if no results
|
public
integer
|
#
getListCount( string $status = null )
Return the total number of clients returned from Clients::getList(), useful
in constructing pagination for the getList() method.
Return the total number of clients returned from Clients::getList(), useful
in constructing pagination for the getList() method.
Parameters
- $status
string $status The status type of the clients to fetch ('active', 'inactive', 'fraud',
default null for all)
Returns
integer The total number of clients
See
|
public
array
|
#
getAll( string $status = null )
Fetches all clients
Parameters
- $status
string $status The status type of the clients to fetch ('active', 'inactive', 'fraud',
default null for all)
Returns
array An array of stdClass objects representing each client, or false if no results
|
public
array
|
#
search( string $query, integer $page = 1 )
Search clients
Parameters
- $query
string $query The value to search clients for
- $page
integer $page The page number of results to fetch (optional, default 1)
Returns
array An array of clients that match the search criteria
|
public
|
#
getSearchCount( string $query )
Return the total number of clients returned from Clients::search(), useful in
constructing pagination
Return the total number of clients returned from Clients::search(), useful in
constructing pagination
Parameters
- $query
string $query The value to search clients for
See
|
private
Record
|
#
searchClients( string $query )
Partially constructs the query for searching clients
Partially constructs the query for searching clients
Parameters
- $query
string $query The value to search clients for
Returns
Record
The partially constructed query Record object
See
|
private
Record
|
#
getClients( string $status = null )
Partially constructs the query required by both Clients::getList(),
Clients::getListCount(), Clients::getAll()
Partially constructs the query required by both Clients::getList(),
Clients::getListCount(), Clients::getAll()
Parameters
- $status
string $status The status type of the clients to fetch ('active', 'inactive', 'fraud',
default null for all)
Returns
Record
The partially constructed query Record object
|
public
mixed
|
#
getMailLogEntry( integer $client_id, integer $email_log_id )
Fetches a specific email from the log for a given client
Fetches a specific email from the log for a given client
Parameters
- $client_id
integer $client_id The client ID
- $email_log_id
integer $email_log_id The email log ID of the email
Returns
mixed An stdClass object representing the email log, or false if it doesn't exist
|
public
mixed
|
#
getMailLogList( integer $client_id, integer $page = 1, array $order_by = array('date_sent'=>"DESC") )
Fetches the mail logs for a given client
Fetches the mail logs for a given client
Parameters
- $client_id
integer $client_id The client ID
- $page
integer $page The page of results to fetch
- $order_by
array $order_by The sort and order conditions (e.g. array("sort_field"=>"ASC"),
optional)
Returns
mixed An array of stdClass objects representing client mail logs, or false if none
exist
|
public
integer
|
#
getMailLogListCount( integer $client_id )
Retrieves the number of sent emails contained in the mail log
Retrieves the number of sent emails contained in the mail log
Parameters
- $client_id
integer $client_id The client ID
Returns
integer The number of emails contained in the log
|
private
Record
|
#
getMailLog( integer $client_id )
Partially constructs the query required by Clients::getMailLogList() and
Clients::getMailLogListCount()
Partially constructs the query required by Clients::getMailLogList() and
Clients::getMailLogListCount()
Parameters
- $client_id
integer $client_id The client ID
Returns
Record
The partially constructed query Record object
|
public
integer
|
#
getStatusCount( string $status = "active" )
Retrieves the number of clients given a client status
Retrieves the number of clients given a client status
Parameters
- $status
string $status The client status type (optional, default 'active')
Returns
integer The number of clients of type $status
|
public
array
|
#
getStatusTypes( )
Retrieves a list of client status types
Retrieves a list of client status types
Returns
array Key=>value pairs of client status types
|
private
array
|
#
getAddRules( boolean $vars, array $edit = false )
Returns the rule set for adding clients
Returns the rule set for adding clients
Parameters
- $vars
boolean $edit True to use as edit rules, false otherwise
- $edit
array $vars The input vars
Returns
array Client rules
|
private
array
|
#
getCustomFieldRules( )
Returns the rule set for adding/editing client custom fields
Returns the rule set for adding/editing client custom fields
Returns
array Custom field rules
|
private
array
|
#
getNoteRules( )
Returns the rule set for adding/editing client notes
Returns the rule set for adding/editing client notes
Returns
array Note rules
|
public
|
#
validateBillingContact( integer $contact_id, integer $client_id )
Validates that the given contact ID is a primary or billing contact for the
given client
Validates that the given contact ID is a primary or billing contact for the
given client
Parameters
- $contact_id
integer $contact_id The contact ID
- $client_id
integer $client_id The client ID
|
public
boolean
|
#
validateCurrencyExists( string $code, integer $company_id )
Validates a currency exists
Validates a currency exists
Parameters
- $code
string $code The currency code
- $company_id
integer $company_id The company ID
Returns
boolean True if the currency exists, false otherwise
|
public
boolean
|
#
validateClientSettingIsEditable( string $value, string $key, integer $client_id )
Validates that the given setting is editable by a client
Validates that the given setting is editable by a client
Parameters
- $value
string $value The value of the setting
- $key
string $key The setting key (one of "client_set_currency", "client_set_invoice", or
"client_set_lang")
- $client_id
integer $client_id The ID of the client to validate against
Returns
boolean True if the client may update the given setting, false otherwise
|
public
|
#
validateLanguageExists( string $code, integer $company_id )
Validates that the given language code exists for this company
Validates that the given language code exists for this company
Parameters
- $code
string $code The language code in ISO 639-1 ISO 3166-1 alpha-2 concatenated format
(i.e. "en_us")
- $company_id
integer $company_id The company ID
|
public
boolean
|
#
validateValues( mixed $values, string $type )
Validates client custom field values
Validates client custom field values
Parameters
- $values
mixed $values The values of the custom field
- $type
string $type The type of custom field this is ('text', 'checkbox', 'select',
'textarea')
Returns
boolean True if values are in the expected format, false otherwise
|
public
boolean
|
#
validateStatus( string $status )
Validates the client's 'status' field
Validates the client's 'status' field
Parameters
- $status
string $status The status to check
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateAccountType( string $type )
Validates the client's 'primary_account_type' field
Validates the client's 'primary_account_type' field
Parameters
- $type
string $type The primary account type
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateUserId( integer $user_id, integer $client_id )
Validates the user ID belongs to $client_id
Validates the user ID belongs to $client_id
Parameters
- $user_id
integer $user_id The client's user ID
- $client_id
integer $client_id The client ID
Returns
boolean True if $user_id belongs to $client_id, false otherwise
|
public
boolean
|
#
validateFieldType( string $type )
Validates the client custom field type
Validates the client custom field type
Parameters
- $type
string $type The custom field type
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateFieldCompany( integer $field_id, integer $client_id )
Validates that the given field belongs to the same company as the client
Validates that the given field belongs to the same company as the client
Parameters
- $field_id
integer $field_id The custom client field ID
- $client_id
integer $client_id The client ID
Returns
boolean True if the custom field ID company matches the client's company ID, false
otherwise
|
public
|
#
isInstanceOf( mixed $field, mixed $class )
Checks if the given $field is a reference of $class
Checks if the given $field is a reference of $class
|