ClientGroups extends AppModel
Client group management
Table of Contents
Properties
| $setting_keys |
Methods
| __construct() | Initialize ClientGroups |
| add() | Add a client group using the supplied data |
| delete() | Delete a client group and all associated client group settings |
| edit() | Edit a client group using the supplied data |
| get() | Returns the given client group |
| getAll() | Fetches all custom client groups by company |
| getDefault() | Finds the default client group for the given company. |
| getList() | Fetches a list of all client groups |
| getListCount() | Return the total number of client groups returned from ClientGroups::getList(), useful in constructing pagination for the getList() method. |
| getSetting() | Fetch a specific setting that may apply to this client group. Settings are inherited in the order of 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 group. Settings are inherited in the order of 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. |
| setSetting() | Add a client group setting, if duplicate then update the value |
| setSettings() | Add multiple client group settings, if duplicate then update the value |
| unsetSetting() | Delete a client group setting |
| unsetSettings() | Deletes all client group settings |
| getClientGroups() | Partially constructs the query required by ClientGroups::getList(), ClientGroups::getListCount(), and ClientGroups::getAll() |
| getRules() | Returns the rule set for adding/editing groups |
Properties
$setting_keys
public
mixed
$setting_keys
= ['inv_days_before_renewal', 'autodebit_days_before_due', 'suspend_services_days_after_due', 'autodebit_attempts', 'service_renewal_attempts', 'first_renewal_attempt_threshold', 'first_renewal_attempt_spacing', 'second_renewal_attempt_threshold', 'second_renewal_attempt_spacing', 'service_provisioning_attempts', 'first_provisioning_attempt_threshold', 'first_provisioning_attempt_spacing', 'second_provisioning_attempt_threshold', 'second_provisioning_attempt_spacing', 'service_suspension_attempts', 'first_suspension_attempt_threshold', 'first_suspension_attempt_spacing', 'second_suspension_attempt_threshold', 'second_suspension_attempt_spacing', 'service_unsuspension_attempts', 'first_unsuspension_attempt_threshold', 'first_unsuspension_attempt_spacing', 'second_unsuspension_attempt_threshold', 'second_unsuspension_attempt_spacing', 'service_cancelation_attempts', 'first_cancelation_attempt_threshold', 'first_cancelation_attempt_spacing', 'second_cancelation_attempt_threshold', 'second_cancelation_attempt_spacing', 'client_set_invoice', 'inv_suspended_services', 'clients_cancel_services', 'clients_cancel_options', 'clients_renew_services', 'synchronize_addons', 'client_create_addons', 'auto_apply_credits', 'auto_paid_pending_services', 'client_change_service_term', 'client_change_service_package', 'delivery_methods', 'notice1', 'notice2', 'notice3', 'notice_pending_autodebit', 'send_payment_notices', 'send_cancellation_notice', 'autodebit', 'show_client_tax_id', 'client_prorate_credits', 'process_paid_service_changes', 'late_fee_total_amount', 'late_fees', 'cancel_service_changes_days', 'apply_inv_late_fees', 'inv_group_services', 'inv_append_descriptions', 'inv_lines_verbose_option_dates', 'void_invoice_canceled_service', 'void_inv_canceled_service_days', 'quotation_valid_days', 'quotation_dead_days', 'quotation_deposit_percentage', 'prevent_unverified_payments', 'unique_contact_emails', 'force_email_usernames', 'email_verification', 'required_contact_fields', 'shown_contact_fields', 'read_only_contact_fields', 'clients_increment', 'clients_start', 'clients_format', 'enable_gateway_restrictions', 'allowed_gateways', 'requeue_invoice_delivery_on_closed', 'payment_credit_enabled', 'payment_credit_limits']
Methods
__construct()
Initialize ClientGroups
public
__construct() : mixed
add()
Add a client group using the supplied data
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
A single dimensional array of keys including:
- name The name of this group
- description A description of this group (optional)
- company_id The company ID this group belongs to color The HTML color that represents this group (optional)
Return values
int —The client group ID created, or void on error
delete()
Delete a client group and all associated client group settings
public
delete(int $client_group_id) : mixed
Parameters
- $client_group_id : int
-
The ID for this client group
edit()
Edit a client group using the supplied data
public
edit(int $client_group_id, array<string|int, mixed> $vars) : mixed
Parameters
- $client_group_id : int
-
The ID of the group to be updated
- $vars : array<string|int, mixed>
-
A single dimensional array of keys including:
- name The name of this group
- description A description of this group (optional)
- company_id The company ID this group belongs to
- color The HTML color that represents this group (optional)
get()
Returns the given client group
public
get(int $client_group_id) : mixed
Parameters
- $client_group_id : int
-
The ID of the client group to fetch
Return values
mixed —A stdClass object representing the client group, false if it does not exist
getAll()
Fetches all custom client groups by company
public
getAll(int $company_id) : mixed
Parameters
- $company_id : int
-
The company ID to fetch client groups for
Return values
mixed —An array of stdClass objects representing all client groups for the given company
getDefault()
Finds the default client group for the given company.
public
getDefault(int $company_id) : mixed
Parameters
- $company_id : int
Return values
mixed —stdClass object representing the default client group, false if no such group exists
getList()
Fetches a list of all client groups
public
getList(int $company_id[, int $page = 1 ][, string $order_by = ['name' => 'ASC'] ]) : mixed
Parameters
- $company_id : int
-
The company ID
- $page : int = 1
-
The page to return results for (optional, default 1)
- $order_by : string = ['name' => 'ASC']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
Return values
mixed —An array of objects or false if no results.
getListCount()
Return the total number of client groups returned from ClientGroups::getList(), useful in constructing pagination for the getList() method.
public
getListCount(int $company_id) : int
Parameters
- $company_id : int
-
The ID of the company whose client group count to fetch
Tags
Return values
int —The total number of clients
getSetting()
Fetch a specific setting that may apply to this client group. Settings are inherited in the order of 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_group_id, string $key) : mixed
Parameters
- $client_group_id : int
-
The client group ID to retrieve settings for
- $key : string
-
The key name of the setting to fetch
Return values
mixed —A stdClass object containg key/values for the settings, false if no records found
getSettings()
Fetch all settings that may apply to this client group. Settings are inherited in the order of 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_group_id[, bool $ignore_inheritence = false ]) : mixed
Parameters
- $client_group_id : int
-
The client group ID to retrieve settings for
- $ignore_inheritence : bool = false
-
True to fetch only client group settings without inheriting from company or system settings (default false)
Return values
mixed —An array of objects containg key/values for the settings, false if no records found
setSetting()
Add a client group setting, if duplicate then update the value
public
setSetting(int $client_group_id, string $key, string $value[, mixed $encrypted = null ]) : mixed
Parameters
- $client_group_id : int
-
The ID for the specified client group
- $key : string
-
The key for this client group setting
- $value : string
-
The value for this client group setting
- $encrypted : mixed = null
-
True to encrypt $value, false to store unencrypted, null to encrypt if currently set to encrypt
setSettings()
Add multiple client group settings, if duplicate then update the value
public
setSettings(int $client_group_id, array<string|int, mixed> $vars[, array<string|int, mixed> $value_keys = null ]) : mixed
Parameters
- $client_group_id : int
-
The ID for the specified client group
- $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 group setting
public
unsetSetting(int $client_group_id, string $key) : mixed
Parameters
- $client_group_id : int
-
The ID for the specified client group
- $key : string
-
The key for this client group setting
unsetSettings()
Deletes all client group settings
public
unsetSettings(int $client_group_id) : mixed
Parameters
- $client_group_id : int
-
The ID for the specified client group
getClientGroups()
Partially constructs the query required by ClientGroups::getList(), ClientGroups::getListCount(), and ClientGroups::getAll()
private
getClientGroups(int $company_id) : Record
Parameters
- $company_id : int
-
The ID of the company whose client groups to fetch
Return values
Record —The partially constructed query Record object
getRules()
Returns the rule set for adding/editing groups
private
getRules() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of client group rules