Clients extends AppModel
Client management
Table of Contents
Methods
| __construct() | Initialize Clients |
| add() | Add a client to the clients table |
| addCustomField() | Add custom client field |
| addDebitAccount() | Adds a client debit account type NOTE: if a debit account already exists for this client, it will be overwritten |
| addNote() | Add a note for the given client |
| create() | Creates a client account including user login, and contact. Sends client welcome email if configured to do so. |
| delete() | 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. |
| deleteCustomField() | Permanently removes a custom client field and all entries for that field |
| deleteCustomFieldValue() | Deletes a given client field value |
| deleteCustomFieldValues() | Deletes all custom field values for the given client |
| deleteDebitAccount() | Deletes a client debit account type |
| deleteNote() | Delete the given client note |
| deleteRestrictedPackages() | Removes all restricted package access for the given client |
| edit() | Edit a client from the clients table |
| editCustomField() | Edit custom client field |
| editNote() | Edit an existing note for a client |
| get() | Fetches a client with contact details of the primary account holder |
| getAll() | Fetches all clients |
| getAllStickyNotes() | Retrieves a list of all sticked notes attached to this client |
| getByUserId() | Fetches a client with contact details of the primary account holder |
| getCustomField() | Retrieves a single custom field |
| getCustomFields() | Retrieves a list of all custom client fields by company |
| getCustomFieldTypes() | Retrieve a list of all custom field types |
| getCustomFieldValues() | Fetches all custom field values assigned to a given client |
| getDebitAccount() | Retrieves the client debit account |
| getList() | Fetches a list of all clients |
| getListCount() | Return the total number of clients returned from Clients::getList(), useful in constructing pagination for the getList() method. |
| getMailLogEntry() | Fetches a specific email from the log for a given client |
| getMailLogList() | Fetches the mail logs for a given client |
| getMailLogListCount() | Retrieves the number of sent emails contained in the mail log |
| getNote() | Returns the note specified |
| getNoteList() | Returns all notes attached to a client |
| getNoteListCount() | Returns the count of all notes attached to a client |
| getRestrictedPackages() | Fetches all restricted package IDs accessible by the given client |
| getSearchCount() | Return the total number of clients returned from Clients::search(), useful in constructing pagination |
| getSetting() | 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. |
| getSettings() | 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. |
| getStatusCount() | Retrieves the number of clients given a client status |
| getStatusTypes() | Retrieves a list of client status types |
| isInstanceOf() | Checks if the given $field is a reference of $class |
| resetDebitAccountFailure() | Resets the debit account failure count for the given client's debit account. |
| search() | Search clients |
| setClientSettings() | Add multiple client settings, with rule validation. If duplicate key, update the setting |
| setCustomField() | Sets the given value for the given custom client field |
| setDebitAccountFailure() | Increments the debit account failure count for the given client's debit account. |
| setRestrictedPackages() | Sets restricted package access for a client |
| setSetting() | Add a client setting, if duplicate key update the setting |
| setSettings() | Add multiple client settings, if duplicate key update the setting |
| unsetSetting() | Delete a client setting |
| unsetSettings() | Deletes all client settings |
| unstickyNote() | Sets the given note as unstickied |
| usedCurrencies() | Retrieves a list of ISO 4217 currency codes used by the given client |
| validateAccountType() | Validates the client's 'primary_account_type' field |
| validateBillingContact() | Validates that the given contact ID is a primary or billing contact for the given client |
| validateClient() | Validate client information for add or edit |
| validateClientDeleteable() | Validates that the given client can be deleted |
| validateClientSettingIsEditable() | Validates that the given setting is editable by a client |
| validateCreation() | Validates that a client can be created with the given data |
| validateCreditLimits() | Validate credit limits for a client |
| validateCurrencyExists() | Validates a currency exists |
| validateFieldCompany() | Validates that the given field belongs to the same company as the client |
| validateFieldType() | Validates the client custom field type |
| validateLanguageExists() | Validates that the given language code exists for this company |
| validatePackages() | Validates that the given packages exist |
| validateRegex() | Determines whether the given regular expression is a valid PCRE |
| validateStatus() | Validates the client's 'status' field |
| validateUserId() | Validates the user ID belongs to $client_id |
| validateValues() | Validates client custom field values |
| fetchNotes() | Partially constructs the query required by both Clients::getNotes() and Clients::getNoteCount() |
| getAClient() | Partially constructs a query for fetching a single client |
| getAddRules() | Returns the rule set for adding clients |
| getClients() | Partially constructs the query required by both Clients::getList(), Clients::getListCount(), Clients::getAll() |
| getCustomFieldRules() | Returns the rule set for adding/editing client custom fields |
| getMailLog() | Partially constructs the query required by Clients::getMailLogList() and Clients::getMailLogListCount() |
| getNoteRules() | Returns the rule set for adding/editing client notes |
| saveSettings() | Saves client settings and performs logging |
| searchClients() | Partially constructs the query for searching clients |
| validateCustomField() | Validates a custom field |
| validateCustomFields() | Validates a set of custom fields |
Methods
__construct()
Initialize Clients
public
__construct() : mixed
add()
Add a client to the clients table
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
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)
Return values
int —The client ID, or void on faliure
addCustomField()
Add custom client field
public
addCustomField(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
Return values
int —The custom field ID, void on failure
addDebitAccount()
Adds a client debit account type NOTE: if a debit account already exists for this client, it will be overwritten
public
addDebitAccount(int $client_id, array<string|int, mixed> $vars) : mixed
Parameters
- $client_id : int
-
The ID of the client whose debit account to add a debit account to
- $vars : array<string|int, mixed>
-
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')
addNote()
Add a note for the given client
public
addNote(int $client_id, int $staff_id, array<string|int, mixed> $vars) : int
Parameters
- $client_id : int
-
The ID of the client to attach the note to
- $staff_id : int
-
The ID of the staff member attempting to create the note, null for system
- $vars : array<string|int, mixed>
-
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)
Return values
int —The ID for this note, void on failure
create()
Creates a client account including user login, and contact. Sends client welcome email if configured to do so.
public
create(array<string|int, mixed> $vars) : stdClass
Parameters
- $vars : array<string|int, mixed>
-
An array of client info including:
- username The username for this user. Must be unique across all companies for this installation.
- new_password The password for this user
- confirm_password The password for this user
- recovery_email The email to which password reset emails should be sent
- client_group_id The client group this user belongs to
- status The status of this client ('active', 'inactive',' 'fraud') (optional, default active)
- 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')
- custom An array of custom fields in key/value format where each key is the custom field ID and each value is the value
- settings An array of client settings including:
- default_currency
- language
- username_type
- tax_id
- tax_exempt
- send_registration_email 'true' to send client welcome email (default), 'false' otherwise
- send_registration_message 'true' to send client welcome message (default), 'false' otherwise
Tags
Return values
stdClass —A stdClass object representing the client, void on error
delete()
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.
public
delete(int $client_id) : mixed
Parameters
- $client_id : int
-
The client ID to permanently remove from the system
deleteCustomField()
Permanently removes a custom client field and all entries for that field
public
deleteCustomField(int $field_id) : mixed
Parameters
- $field_id : int
-
The ID of the custom field to delete
deleteCustomFieldValue()
Deletes a given client field value
public
deleteCustomFieldValue(int $client_field_id, int $client_id) : mixed
Parameters
- $client_field_id : int
-
The ID of the custom client field
- $client_id : int
-
The client ID the custom field value belongs to
deleteCustomFieldValues()
Deletes all custom field values for the given client
public
deleteCustomFieldValues(int $client_id) : mixed
Parameters
- $client_id : int
-
The ID of the client whose custom client values to delete
deleteDebitAccount()
Deletes a client debit account type
public
deleteDebitAccount(int $client_id) : bool
Parameters
- $client_id : int
-
The ID of the client whose debit account to delete
Return values
bool —True if the debit account was deleted, false otherwise
deleteNote()
Delete the given client note
public
deleteNote(int $note_id) : mixed
Parameters
- $note_id : int
-
The ID of the note to delete
deleteRestrictedPackages()
Removes all restricted package access for the given client
public
deleteRestrictedPackages(int $client_id) : mixed
Parameters
- $client_id : int
-
The ID of the client whose package access to remove
edit()
Edit a client from the clients table
public
edit(int $client_id, array<string|int, mixed> $vars) : mixed
Parameters
- $client_id : int
-
The client's ID
- $vars : array<string|int, mixed>
-
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')
editCustomField()
Edit custom client field
public
editCustomField(int $field_id, array<string|int, mixed> $vars) : int
Parameters
- $field_id : int
-
The ID of the custom field to update
- $vars : array<string|int, mixed>
Return values
int —The custom field ID, void on failure
editNote()
Edit an existing note for a client
public
editNote(int $note_id, array<string|int, mixed> $vars) : mixed
Parameters
- $note_id : int
-
The ID of the note
- $vars : array<string|int, mixed>
-
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)
get()
Fetches a client with contact details of the primary account holder
public
get(int $client_id[, bool $get_settings = true ]) : mixed
Parameters
- $client_id : int
-
The client ID to fetch
- $get_settings : bool = true
-
True to fetch settings for this client (default), false otherwise
Tags
Return values
mixed —An object containing client fields, false if the client does not exist.
getAll()
Fetches all clients
public
getAll([string $status = null ][, int $client_group_id = null ][, mixed $get_settings = false ]) : array<string|int, mixed>
Parameters
- $status : string = null
-
The status type of the clients to fetch ('active', 'inactive', 'fraud', default null for all)
- $client_group_id : int = null
-
The ID of the client group whose clients to fetch (optional, default null for all)
- $get_settings : mixed = false
Return values
array<string|int, mixed> —An array of stdClass objects representing each client, or false if no results
getAllStickyNotes()
Retrieves a list of all sticked notes attached to this client
public
getAllStickyNotes(int $client_id[, int $max_limit = null ]) : array<string|int, mixed>
Parameters
- $client_id : int
-
The client ID
- $max_limit : int = null
-
The maximum number of recent stickied notes to retrieve (optional, default all)
Return values
array<string|int, mixed> —A list of stdClass objects representing each note
getByUserId()
Fetches a client with contact details of the primary account holder
public
getByUserId(int $user_id[, bool $get_settings = false ]) : mixed
Parameters
- $user_id : int
-
The ID of the user
- $get_settings : bool = false
-
True to fetch settings for this client, false otherwise
Tags
Return values
mixed —An object containing client fields, false if the client does not exist.
getCustomField()
Retrieves a single custom field
public
getCustomField(int $field_id[, int $company_id = null ]) : mixed
Parameters
- $field_id : int
-
The custom field ID to fetch
- $company_id : int = null
-
The company ID (optional, default null)
Return values
mixed —An stdClass of key=>value pairs, or false if the custom field does not exist
getCustomFields()
Retrieves a list of all custom client fields by company
public
getCustomFields(int $company_id[, int $client_group_id = null ][, array<string|int, mixed> $options = null ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The company ID
- $client_group_id : int = null
-
The client group ID of fields to fetch (optional, default null for all)
- $options : array<string|int, mixed> = null
-
An array of options to filter results on including:
- show_client (1 to return only fields shown to clients, 0 to return all fields not shown to clients)
- read_only (1 to show only fields set to read-only, 0 to return only fields not set to read-only)
Return values
array<string|int, mixed> —An array of stdClass custom field objects
getCustomFieldTypes()
Retrieve a list of all custom field types
public
getCustomFieldTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —A key=>value array of custom field types
getCustomFieldValues()
Fetches all custom field values assigned to a given client
public
getCustomFieldValues(int $client_id) : mixed
Parameters
- $client_id : int
-
The client ID
Return values
mixed —An array of stdClass objects representing each custom field, or false if none exist
getDebitAccount()
Retrieves the client debit account
public
getDebitAccount(int $client_id) : mixed
Parameters
- $client_id : int
-
The ID of the client whose debit account to get
Return values
mixed —A stdClass object representing the client account type, or false if none exist
getList()
Fetches a list of all clients
public
getList([string $status = null ][, int $page = 1 ][, string $order_by = ['id_code' => 'ASC'] ][, array<string|int, mixed> $filters = [] ]) : array<string|int, mixed>
Parameters
- $status : string = null
-
The status type of the clients to fetch ('active', 'inactive', 'fraud', default null for all)
- $page : int = 1
-
The page to return results for (optional, default 1)
- $order_by : string = ['id_code' => 'ASC']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
- $filters : array<string|int, mixed> = []
-
A list of parameters to filter by, including:
- contact_name The (partial) name of the contact for which to fetch clients
- contact_email The (partial) email address of the contact for which to fetch clients
- contact_company The (partial) company name of the contact for which to fetch clients
- contact_country The contact country on which to filter clients
- client_group_id The client group ID on which to filter clients
- company_id The ID of the company whose clients to fetch (optional, default null for all)
- invoice_method The invoice delivery method on which to filter clients
- last_seen_start_date The start date of the "last seen" date range on which to filter clients
- last_seen_end_date The end date of the "last seen" date range on which to filter clients
Return values
array<string|int, mixed> —An array of stdClass objects representing each client, or false if no results
getListCount()
Return the total number of clients returned from Clients::getList(), useful in constructing pagination for the getList() method.
public
getListCount([string $status = null ][, array<string|int, mixed> $filters = [] ]) : int
Parameters
- $status : string = null
-
The status type of the clients to fetch ('active', 'inactive', 'fraud', default null for all)
- $filters : array<string|int, mixed> = []
-
A list of parameters to filter by, including:
- contact_name The (partial) name of the contact for which to fetch clients
- contact_email The (partial) email address of the contact for which to fetch clients
- contact_company The (partial) company name of the contact for which to fetch clients
- contact_country The contact country on which to filter clients
- client_group_id The client group ID on which to filter clients
- company_id The ID of the company whose clients to fetch (optional, default null for all)
- invoice_method The invoice delivery method on which to filter clients
- last_seen_start_date The start date of the "last seen" date range on which to filter clients
- last_seen_end_date The end date of the "last seen" date range on which to filter clients
Tags
Return values
int —The total number of clients
getMailLogEntry()
Fetches a specific email from the log for a given client
public
getMailLogEntry(int $client_id, int $email_log_id) : mixed
Parameters
- $client_id : int
-
The client ID
- $email_log_id : int
-
The email log ID of the email
Return values
mixed —An stdClass object representing the email log, or false if it doesn't exist
getMailLogList()
Fetches the mail logs for a given client
public
getMailLogList(int $client_id[, int $page = 1 ][, array<string|int, mixed> $order_by = ['date_sent' => 'DESC'] ][, int $sent = null ]) : mixed
Parameters
- $client_id : int
-
The client ID
- $page : int = 1
-
The page of results to fetch
- $order_by : array<string|int, mixed> = ['date_sent' => 'DESC']
-
The sort and order conditions (e.g. array("sort_field"=>"ASC"), optional)
- $sent : int = null
-
Whether or not the email was actually sent (1 or 0, optional, default null for either)
Return values
mixed —An array of stdClass objects representing client mail logs, or false if none exist
getMailLogListCount()
Retrieves the number of sent emails contained in the mail log
public
getMailLogListCount(int $client_id[, int $sent = null ]) : int
Parameters
- $client_id : int
-
The client ID
- $sent : int = null
-
Whether or not the email was actually sent (1 or 0, optional, default null for either)
Return values
int —The number of emails contained in the log
getNote()
Returns the note specified
public
getNote(int $note_id) : mixed
Parameters
- $note_id : int
-
The ID of the note to fetch
Return values
mixed —A stdClass object representing the note, false if the note does not exist
getNoteList()
Returns all notes attached to a client
public
getNoteList(int $client_id[, int $page = 1 ][, string $order_by = ['date_added' => 'DESC'] ]) : mixed
Parameters
- $client_id : int
-
The client to fetch notes for
- $page : int = 1
-
The page to return results for (optional, default 1)
- $order_by : string = ['date_added' => 'DESC']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
Return values
mixed —An array of stdClass note objects, false if no notes exist
getNoteListCount()
Returns the count of all notes attached to a client
public
getNoteListCount(int $client_id) : int
Parameters
- $client_id : int
-
The client ID
Tags
Return values
int —The number of notes belonging to this client
getRestrictedPackages()
Fetches all restricted package IDs accessible by the given client
public
getRestrictedPackages(int $client_id) : array<string|int, mixed>
Parameters
- $client_id : int
-
The ID of the client whose restricted packages to fetch
Return values
array<string|int, mixed> —A list of stdClass objects each representing a restricted package ID
getSearchCount()
Return the total number of clients returned from Clients::search(), useful in constructing pagination
public
getSearchCount(string $query) : mixed
Parameters
- $query : string
-
The value to search clients for
Tags
getSetting()
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.
public
getSetting(int $client_id, string $key) : mixed
Parameters
- $client_id : int
-
The client ID to retrieve settings for
- $key : string
-
The setting key of the setting to fetch
Return values
mixed —A stdClass object containg key/values for the settings, false if no record found
getSettings()
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.
public
getSettings(int $client_id) : mixed
Parameters
- $client_id : int
-
The client ID to retrieve settings for
Return values
mixed —An array of objects containg key/values for the settings, false if no records found
getStatusCount()
Retrieves the number of clients given a client status
public
getStatusCount([string $status = 'active' ][, array<string|int, mixed> $filters = [] ]) : int
Parameters
- $status : string = 'active'
-
The client status type (optional, default 'active')
- $filters : array<string|int, mixed> = []
-
A list of parameters to filter by, including:
- contact_name The (partial) name of the contact for which to fetch clients
- contact_email The (partial) email address of the contact for which to fetch clients
- contact_company The (partial) company name of the contact for which to fetch clients
- contact_country The contact country on which to filter clients
- client_group_id The client group ID on which to filter clients
- invoice_method The invoice delivery method on which to filter clients
- last_seen_start_date The start date of the "last seen" date range on which to filter clients
- last_seen_end_date The end date of the "last seen" date range on which to filter clients
Return values
int —The number of clients of type $status
getStatusTypes()
Retrieves a list of client status types
public
getStatusTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —Key=>value pairs of client status types
isInstanceOf()
Checks if the given $field is a reference of $class
public
isInstanceOf(mixed $field, mixed $class) : bool
Parameters
- $field : mixed
-
The value to check
- $class : mixed
-
The class or instance to check against
Return values
bool —True if the $field is an instance of $class, or false otherwise
resetDebitAccountFailure()
Resets the debit account failure count for the given client's debit account.
public
resetDebitAccountFailure(int $client_id[, string $type = null ][, int $account_id = null ]) : mixed
Parameters
- $client_id : int
-
The ID of the client to reset autodebit failure
- $type : string = null
-
The payment account type (ach, cc)
- $account_id : int = null
-
The payment account ID
search()
Search clients
public
search(string $query[, int $page = 1 ]) : array<string|int, mixed>
Parameters
- $query : string
-
The value to search clients for
- $page : int = 1
-
The page number of results to fetch (optional, default 1)
Return values
array<string|int, mixed> —An array of clients that match the search criteria
setClientSettings()
Add multiple client settings, with rule validation. If duplicate key, update the setting
public
setClientSettings(int $client_id, array<string|int, mixed> $vars) : mixed
Parameters
- $client_id : int
-
The ID for the specified client
- $vars : array<string|int, mixed>
-
A single dimensional array of key/value pairs of settings
setCustomField()
Sets the given value for the given custom client field
public
setCustomField(int $field_id, int $client_id, string $value) : mixed
Parameters
- $field_id : int
-
The ID of the custom client field
- $client_id : int
-
The client ID the custom field value belongs to
- $value : string
-
The value to assign to this client
setDebitAccountFailure()
Increments the debit account failure count for the given client's debit account.
public
setDebitAccountFailure(int $client_id[, string $type = null ][, int $account_id = null ]) : mixed
Removes the debit account if it exceeds the threshold for failures based on the "autodebit_attempts" setting.
Parameters
- $client_id : int
-
The ID of the client to set autodebit failure
- $type : string = null
-
The payment account type (ach, cc)
- $account_id : int = null
-
The payment account ID
setRestrictedPackages()
Sets restricted package access for a client
public
setRestrictedPackages(int $client_id, array<string|int, mixed> $package_ids) : mixed
Parameters
- $client_id : int
-
The ID of the client whose restricted package access to set
- $package_ids : array<string|int, mixed>
setSetting()
Add a client setting, if duplicate key update the setting
public
setSetting(int $client_id, string $key, string $value[, mixed $encrypted = null ]) : mixed
Parameters
- $client_id : int
-
The ID for the specified client
- $key : string
-
The key for this client setting
- $value : string
-
The value for this individual client setting
- $encrypted : mixed = null
-
True to encrypt $value, false to store unencrypted, null to encrypt if currently set to encrypt
setSettings()
Add multiple client settings, if duplicate key update the setting
public
setSettings(int $client_id, array<string|int, mixed> $vars[, array<string|int, mixed> $value_keys = null ]) : mixed
Parameters
- $client_id : int
-
The ID for the specified client
- $vars : array<string|int, mixed>
-
A single dimensional array of key/value pairs of settings
- $value_keys : array<string|int, mixed> = null
-
An array of key values to accept as valid fields
unsetSetting()
Delete a client setting
public
unsetSetting(int $client_id, string $key) : mixed
Parameters
- $client_id : int
-
The ID for the specified client
- $key : string
-
The key for this client setting
unsetSettings()
Deletes all client settings
public
unsetSettings(int $client_id) : mixed
Parameters
- $client_id : int
-
The ID for the specified client
unstickyNote()
Sets the given note as unstickied
public
unstickyNote(int $note_id) : mixed
Parameters
- $note_id : int
-
The note ID
usedCurrencies()
Retrieves a list of ISO 4217 currency codes used by the given client
public
usedCurrencies(int $client_id) : array<string|int, mixed>
Parameters
- $client_id : int
-
The ID of the client whose used currencies to fetch
Return values
array<string|int, mixed> —A list of ISO 4217 currency codes
validateAccountType()
Validates the client's 'primary_account_type' field
public
validateAccountType(string $type) : bool
Parameters
- $type : string
-
The primary account type
Return values
bool —True if validated, false otherwise
validateBillingContact()
Validates that the given contact ID is a primary or billing contact for the given client
public
validateBillingContact(int $contact_id, int $client_id) : mixed
Parameters
- $contact_id : int
-
The contact ID
- $client_id : int
-
The client ID
validateClient()
Validate client information for add or edit
public
validateClient(array<string|int, mixed> $vars[, bool $edit = false ][, bool $final_validation = false ]) : bool
Parameters
- $vars : array<string|int, mixed>
-
An array of user 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)
- $edit : bool = false
-
Whether this data is being validated for an edit (optional, default false)
- $final_validation : bool = false
-
Whether this is the final validation before add/edit (optional, default false)
Return values
bool —True if the client info is valid, false otherwise
validateClientDeleteable()
Validates that the given client can be deleted
public
validateClientDeleteable(int $client_id) : bool
Parameters
- $client_id : int
-
The ID of the client to delete
Return values
bool —True if the client may be deleted, false otherwise
validateClientSettingIsEditable()
Validates that the given setting is editable by a client
public
validateClientSettingIsEditable(string $value, string $key, int $client_id) : bool
Parameters
- $value : string
-
The value of the setting
- $key : string
-
The setting key (one of "client_set_currency", "client_set_invoice", or "client_set_lang")
- $client_id : int
-
The ID of the client to validate against
Return values
bool —True if the client may update the given setting, false otherwise
validateCreation()
Validates that a client can be created with the given data
public
validateCreation(array<string|int, mixed> $vars) : bool
Parameters
- $vars : array<string|int, mixed>
-
An array of client info including:
- username The username for this user. Must be unique across all companies for this installation.
- new_password The password for this user
- confirm_password The password for this user
- client_group_id The client group this user belongs to
- status The status of this client ('active', 'inactive',' 'fraud') (optional, default active)
- 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')
- custom An array of custom fields in key/value format where each key is the custom field ID and each value is the value
- settings An array of client settings including:
- default_currency
- language
- username_type
- tax_id
- tax_exempt
- send_registration_email 'true' to send client welcome email (default), 'false' otherwise
Tags
Return values
bool —True if the client can be created, false otherwise
validateCreditLimits()
Validate credit limits for a client
public
validateCreditLimits(array<string|int, mixed> $credit_limits, int $client_id) : array<string|int, mixed>|bool
Parameters
- $credit_limits : array<string|int, mixed>
-
Raw credit limits from form input
- $client_id : int
-
The client ID
Return values
array<string|int, mixed>|bool —Processed credit limits array on success, false on failure
validateCurrencyExists()
Validates a currency exists
public
validateCurrencyExists(string $code, int $company_id) : bool
Parameters
- $code : string
-
The currency code
- $company_id : int
-
The company ID
Return values
bool —True if the currency exists, false otherwise
validateFieldCompany()
Validates that the given field belongs to the same company as the client
public
validateFieldCompany(int $field_id, int $client_id) : bool
Parameters
- $field_id : int
-
The custom client field ID
- $client_id : int
-
The client ID
Return values
bool —True if the custom field ID company matches the client's company ID, false otherwise
validateFieldType()
Validates the client custom field type
public
validateFieldType(string $type) : bool
Parameters
- $type : string
-
The custom field type
Return values
bool —True if validated, false otherwise
validateLanguageExists()
Validates that the given language code exists for this company
public
validateLanguageExists(string $code, int $company_id) : mixed
Parameters
- $code : string
-
The language code in ISO 639-1 ISO 3166-1 alpha-2 concatenated format (i.e. "en_us")
- $company_id : int
-
The company ID
validatePackages()
Validates that the given packages exist
public
validatePackages(array<string|int, mixed> $package_ids) : bool
Parameters
- $package_ids : array<string|int, mixed>
-
The IDs of the packages to check
Return values
bool —True if the given packages exist, false otherwise
validateRegex()
Determines whether the given regular expression is a valid PCRE
public
validateRegex(string $regex) : bool
Parameters
- $regex : string
-
The regular expression to check
Return values
bool —True if the regular expression is valid, false otherwise
validateStatus()
Validates the client's 'status' field
public
validateStatus(string $status) : bool
Parameters
- $status : string
-
The status to check
Return values
bool —True if validated, false otherwise
validateUserId()
Validates the user ID belongs to $client_id
public
validateUserId(int $user_id, int $client_id) : bool
Parameters
- $user_id : int
-
The client's user ID
- $client_id : int
-
The client ID
Return values
bool —True if $user_id belongs to $client_id, false otherwise
validateValues()
Validates client custom field values
public
validateValues(mixed $values, string $type) : bool
Parameters
- $values : mixed
-
The values of the custom field
- $type : string
-
The type of custom field this is ('text', 'checkbox', 'select', 'textarea')
Return values
bool —True if values are in the expected format, false otherwise
fetchNotes()
Partially constructs the query required by both Clients::getNotes() and Clients::getNoteCount()
private
fetchNotes(int $client_id) : Record
Parameters
- $client_id : int
-
The ID of the client whose notes to fetch
Return values
Record —The partially constructed query Record object
getAClient()
Partially constructs a query for fetching a single client
private
getAClient() : Record
Return values
Record —A Record object representing the partial query for fetching a single client
getAddRules()
Returns the rule set for adding clients
private
getAddRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
The input vars
- $edit : bool = false
-
True to use as edit rules, or false otherwise
Return values
array<string|int, mixed> —Client rules
getClients()
Partially constructs the query required by both Clients::getList(), Clients::getListCount(), Clients::getAll()
private
getClients([array<string|int, mixed> $filters = [] ]) : Record
Parameters
- $filters : array<string|int, mixed> = []
-
A list of parameters to filter by, including:
- contact_name The (partial) name of the contact for which to fetch clients
- contact_email The (partial) email address of the contact for which to fetch clients
- contact_company The (partial) company name of the contact for which to fetch clients
- contact_country The contact country on which to filter clients
- client_group_id The ID of the client group whose clients to fetch (optional, default null for all)
- company_id The ID of the company whose clients to fetch (optional, default null for all)
- invoice_method The invoice delivery method on which to filter clients
- last_seen_start_date The start date of the "last seen" date range on which to filter clients
- last_seen_end_date The end date of the "last seen" date range on which to filter clients
- status The status type of the clients to fetch ('active', 'inactive', 'fraud', default null for all)
Return values
Record —The partially constructed query Record object
getCustomFieldRules()
Returns the rule set for adding/editing client custom fields
private
getCustomFieldRules(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
Return values
array<string|int, mixed> —Custom field rules
getMailLog()
Partially constructs the query required by Clients::getMailLogList() and Clients::getMailLogListCount()
private
getMailLog(int $client_id[, int $sent = null ]) : Record
Parameters
- $client_id : int
-
The client ID
- $sent : int = null
-
Whether or not the email was actually sent (1 or 0, optional, default null for either)
Return values
Record —The partially constructed query Record object
getNoteRules()
Returns the rule set for adding/editing client notes
private
getNoteRules() : array<string|int, mixed>
Return values
array<string|int, mixed> —Note rules
saveSettings()
Saves client settings and performs logging
private
saveSettings(int $client_id, array<string|int, mixed> $settings) : mixed
Parameters
- $client_id : int
-
The ID of the client whose settings to save
- $settings : array<string|int, mixed>
-
An array of settings, each containing an array that includes:
- key The key for this client setting
- value The value for this individual client setting. Set to NULL to delete this setting
- encrypted 1 if the value is encrypted, 0 if it is not, otherwise use the current setting's encryption status
Tags
searchClients()
Partially constructs the query for searching clients
private
searchClients(string $query) : Record
Parameters
- $query : string
-
The value to search clients for
Tags
Return values
Record —The partially constructed query Record object
validateCustomField()
Validates a custom field
private
validateCustomField(int $field_id, string $value[, int $client_id = null ]) : bool
Parameters
- $field_id : int
-
The ID of the custom client field
- $value : string
-
The value to assign to this client
- $client_id : int = null
-
The client ID the custom field value belongs to
Return values
bool —True if the custom field is valid, false otherwise
validateCustomFields()
Validates a set of custom fields
private
validateCustomFields(array<string|int, mixed> $vars[, mixed $client_id = null ]) : bool
Parameters
- $vars : array<string|int, mixed>
-
An array of client info including:
- client_group_id The client group this user belongs to
- custom An array of custom fields in key/value format where each key is the custom field ID and each value is the value
- $client_id : mixed = null
Return values
bool —True if the custom fields are valid, false otherwise