Overview

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • auth
        • ldap
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
      • exchange
        • rates
          • currency
            • layer
          • fixer
          • open
            • exchange
              • rates
          • x
            • rates
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • perforated
            • invoice
          • quickbooks
            • invoice
          • templates
            • default
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • reports
        • aging
          • invoices
        • client
          • data
            • portability
        • custom
          • report
        • invoice
          • creation
        • package
          • revenue
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • core
      • Automation
        • Tasks
          • Common
          • Task
        • Type
          • Common
          • Cron
      • Pricing
        • ItemComparator
        • MetaItem
        • Modifier
          • Type
            • Description
              • Type
                • Discount
                • Option
                • Service
                • Tax
            • Discount
            • Price
            • Proration
        • Presenter
          • Build
            • Invoice
            • InvoiceData
            • Options
            • Service
            • ServiceChange
            • ServiceData
          • Collection
          • Format
            • Fields
            • Type
              • Discount
              • Item
              • Option
              • Options
              • Package
              • Pricing
              • Service
              • Tax
          • Items
            • Invoice
            • Service
          • Type
      • ServiceProviders
      • Util
        • Captcha
          • Captchas
          • Common
        • Common
          • Traits
        • Events
          • Common
          • Handlers
          • Observers
        • Filters
          • Common
        • GeoIp
        • Input
          • Fields
            • Common
        • Tax
        • Widgets
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • helpers
      • color
      • data
        • structure
  • None
  • PHP

Classes

  • Accounts
  • Actions
  • ApiKeys
  • Backup
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CouponTerms
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • EmailVerifications
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • MessageGroups
  • Messages
  • MessengerManager
  • ModuleClientMeta
  • ModuleManager
  • ModuleTypes
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • ServiceInvoices
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • SystemEvents
  • Taxes
  • Themes
  • Transactions
  • Users
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class Clients

Client management

Model
Extended by AppModel uses Blesta\Core\Util\Common\Traits\Container
Extended by Clients
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/clients.php
Methods summary
public
# __construct( )

Initialize Clients

Initialize Clients

Overrides

AppModel::__construct()
public stdClass
# create( array $vars )

Creates a client account including user login, and contact. Sends client welcome email if configured to do so.

Creates a client account including user login, and contact. Sends client welcome email if configured to do so.

Parameters

$vars

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

Returns

stdClass
A stdClass object representing the client, void on error

See

Users::add()
Clients::add()
Contacts::add()
public integer
# add( array $vars )

Add a client to the clients table

Add a client to the clients table

Parameters

$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
The client's ID
$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
The client ID to permanently remove from the system
public integer
# addCustomField( array $vars )

Add custom client field

Add custom client field

Parameters

$vars

array of custom field info 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 (optional, default 0)
  • type The type of field (one of: 'text','checkbox','select','textarea') (optional, default 'text')
  • values Values for the field (text; if 'type' is 'select', values must be a key=>value array of option=>value)
  • default The default value (optional, should be one of the given select/checkbox values, or any for text/textarea)
  • 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)
  • read_only Whether or not the field is read only (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

Edit custom client field

Parameters

$field_id
The ID of the custom field to update
$vars

array of custom field info 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 (optional)
  • type The type of field (optional, one of: 'text','checkbox','select','textarea')
  • values Values for the field (optional; text; if 'type' is 'select', values must be a key=>value array of option=>value)
  • default The default value (optional, should be one of the given select/checkbox values, or any for text/textarea)
  • regex Custom regex required by this field (optional)
  • show_client Whether or not to allow the client to updated this field (optional)
  • read_only Whether or not the field is read only (optional)
  • encrypted Whether or not to encrypt values associated with this custom field (optional)

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
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 array
# getCustomFields( integer $company_id, integer $client_group_id = null, array $options = null )

Retrieves a list of all custom client fields by company

Retrieves a list of all custom client fields by company

Parameters

$company_id
The company ID
$client_group_id
The client group ID of fields to fetch (optional, default null for all)
$options

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)

Returns

array
An array of stdClass custom field objects
public mixed
# getCustomField( integer $field_id, integer $company_id = null )

Retrieves a single custom field

Retrieves a single custom field

Parameters

$field_id
The custom field ID to fetch
$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
The ID of the custom client field
$client_id
The client ID the custom field value belongs to
$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
The ID of the custom client field
$client_id
The client ID the custom field value belongs to
public
# deleteCustomFieldValues( integer $client_id )

Deletes all custom field values for the given client

Deletes all custom field values for the given client

Parameters

$client_id
The ID of the client whose custom client values to delete
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
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
The ID of the client whose restricted package access to set
$package_ids
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
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
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
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
The ID of the client to attach the note to
$staff_id
The ID of the staff member attempting to create the note, null for system
$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
The ID of the note
$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
The note ID
public
# deleteNote( integer $note_id )

Delete the given client note

Delete the given client note

Parameters

$note_id
The ID of the note to delete
public mixed
# getNoteList( integer $client_id, integer $page = 1, array $order_by = ['date_added' => 'DESC'] )

Returns all notes attached to a client

Returns all notes attached to a client

Parameters

$client_id
The client to fetch notes for
$page
The page to return results for (optional, default 1)
$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
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
The client ID
$max_limit
The maximum number of recent stickied notes to retrieve (optional, default all)

Returns

array
A list of stdClass objects representing each note
public mixed
# getNote( integer $note_id )

Returns the note specified

Returns the note specified

Parameters

$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
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
The ID of the client whose debit account to add a debit account to
$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
The ID of the client whose debit account to delete

Returns

boolean
True if the debit account was deleted, false otherwise
public
# setDebitAccountFailure( integer $client_id, string $type = null, integer $account_id = null )

Increments the debit account failure count for the given client's debit account. Removes the debit account if it exceeds the threshold for failures based on the "autodebit_attempts" setting.

Increments the debit account failure count for the given client's debit account. Removes the debit account if it exceeds the threshold for failures based on the "autodebit_attempts" setting.

Parameters

$client_id
The ID of the client to set autodebit failure
$type
The payment account type (ach, cc)
$account_id
The payment account ID
public
# resetDebitAccountFailure( integer $client_id, string $type = null, integer $account_id = null )

Resets the debit account failure count for the given client's debit account.

Resets the debit account failure count for the given client's debit account.

Parameters

$client_id
The ID of the client to reset autodebit failure
$type
The payment account type (ach, cc)
$account_id
The payment account ID
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
The ID for the specified client
$vars
A single dimensional array of key/value pairs of settings
public
# setSettings( integer $client_id, array $vars, array $value_keys = null )

Add multiple client settings, if duplicate key update the setting

Add multiple client settings, if duplicate key update the setting

Parameters

$client_id
The ID for the specified client
$vars
A single dimensional array of key/value pairs of settings
$value_keys
An array of key values to accept as valid fields
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
The ID for the specified client
$key
The key for this client setting
$value
The value for this individual client setting
$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

Delete a client setting

Parameters

$client_id
The ID for the specified client
$key
The key for this client setting
public
# unsetSettings( integer $client_id )

Deletes all client settings

Deletes all client settings

Parameters

$client_id
The ID for the specified client
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
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, string $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
The client ID to retrieve settings for
$key
The setting key of the setting to fetch

Returns

mixed
A stdClass object containg key/values for the settings, false if no record 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
The client ID to fetch
$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

Contacts::get(), Clients::getByUserId()
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
The ID of the user
$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

Contacts::get(), Clients::getByUserId()
public array
# getList( string $status = null, integer $page = 1, string $order_by = ['id_code' => 'ASC'], array $filters = [] )

Fetches a list of all clients

Fetches a list of all clients

Parameters

$status

The status type of the clients to fetch ('active', 'inactive', 'fraud', default null for all)

$page
The page to return results for (optional, default 1)
$order_by
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
$filters

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

Returns

array
An array of stdClass objects representing each client, or false if no results
public integer
# getListCount( string $status = null, array $filters = [] )

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

The status type of the clients to fetch ('active', 'inactive', 'fraud', default null for all)

$filters

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

Returns

integer
The total number of clients

See

Clients::getList()
public array
# getAll( string $status = null, integer $client_group_id = null )

Fetches all clients

Fetches all clients

Parameters

$status

The status type of the clients to fetch ('active', 'inactive', 'fraud', default null for all)

$client_group_id
The ID of the client group whose clients to fetch (optional, 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

Search clients

Parameters

$query
The value to search clients for
$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
The value to search clients for

See

Clients::search()
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
The client ID
$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 = ['date_sent' => 'DESC'], integer $sent = null )

Fetches the mail logs for a given client

Fetches the mail logs for a given client

Parameters

$client_id
The client ID
$page
The page of results to fetch
$order_by
The sort and order conditions (e.g. array("sort_field"=>"ASC"), optional)
$sent
Whether or not the email was actually sent (1 or 0, optional, default null for either)

Returns

mixed
An array of stdClass objects representing client mail logs, or false if none exist
public integer
# getMailLogListCount( integer $client_id, integer $sent = null )

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
The client ID
$sent
Whether or not the email was actually sent (1 or 0, optional, default null for either)

Returns

integer
The number of emails contained in the log
public array
# usedCurrencies( integer $client_id )

Retrieves a list of ISO 4217 currency codes used by the given client

Retrieves a list of ISO 4217 currency codes used by the given client

Parameters

$client_id
The ID of the client whose used currencies to fetch

Returns

array
A list of ISO 4217 currency codes
public integer
# getStatusCount( string $status = 'active', array $filters = [] )

Retrieves the number of clients given a client status

Retrieves the number of clients given a client status

Parameters

$status
The client status type (optional, default 'active')
$filters

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

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
public boolean
# validateRegex( string $regex )

Determines whether the given regular expression is a valid PCRE

Determines whether the given regular expression is a valid PCRE

Parameters

$regex
The regular expression to check

Returns

boolean
True if the regular expression is valid, false otherwise
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
The contact ID
$client_id
The client ID
public boolean
# validateClientDeleteable( integer $client_id )

Validates that the given client can be deleted

Validates that the given client can be deleted

Parameters

$client_id
The ID of the client to delete

Returns

boolean
True if the client may be deleted, false otherwise
public boolean
# validateCurrencyExists( string $code, integer $company_id )

Validates a currency exists

Validates a currency exists

Parameters

$code
The currency code
$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
The value of the setting
$key
The setting key (one of "client_set_currency", "client_set_invoice", or "client_set_lang")
$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
The language code in ISO 639-1 ISO 3166-1 alpha-2 concatenated format (i.e. "en_us")
$company_id
The company ID
public boolean
# validateValues( mixed $values, string $type )

Validates client custom field values

Validates client custom field values

Parameters

$values
The values of the custom field
$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
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
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
The client's user ID
$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
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
The custom client field ID
$client_id
The client ID

Returns

boolean
True if the custom field ID company matches the client's company ID, false otherwise
public boolean
# validateClient( array $vars, boolean $edit = false, boolean $final_validation = false )

Validate client information for add or edit

Validate client information for add or edit

Parameters

$vars

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
Whether this data is being validated for an edit (optional, default false)
$final_validation
Whether this is the final validation before add/edit (optional, default false)

Returns

boolean
True if the client info is valid, false otherwise
public boolean
# validateCreation( array $vars )

Validates that a client can be created with the given data

Validates that a client can be created with the given data

Parameters

$vars

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

Returns

boolean
True if the client can be created, false otherwise

See

Users::validateUser()
Clients::validateClient()
Contacts::validateContact()
public boolean
# 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

Parameters

$field
The value to check
$class
The class or instance to check against

Returns

boolean
True if the $field is an instance of $class, or false otherwise
Methods inherited from AppModel
_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()
Methods used from Blesta\Core\Util\Common\Traits\Container
getFromContainer()
Properties inherited from AppModel
$logger, $replacement_keys
Blesta API documentation generated by ApiGen