public
|
#
__construct( )
Initialize Services
Overrides
|
public
integer
|
#
getStatusCount( integer $client_id, string $status = "active" )
Returns the number of results available for the given status
Returns the number of results available for the given status
Parameters
- $client_id
integer $client_id The ID of the client to select status count values for
- $status
string $status The status value to select a count of ('active', 'canceled', 'pending',
'suspended')
Returns
integer The number representing the total number of services for this client with that
status
|
public
array
|
#
getList( integer $client_id = null, string $status = "active", integer $page = 1, array $order_by = array('date_added'=>"DESC") )
Returns a list of services for the given client and status
Returns a list of services for the given client and status
Parameters
- $client_id
integer $client_id The ID of the client to select services for
- $status
string $status The status to filter by
- $page
integer $page The page to return results for
- $order_by
array $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
array An array of stdClass objects representing services
|
public
integer
|
#
getListCount( integer $client_id, string $status = "active" )
Returns the total number of services for a client, useful in constructing
pagination for the getList() method.
Returns the total number of services for a client, useful in constructing
pagination for the getList() method.
Parameters
- $client_id
integer $client_id The client ID
- $status
string $status The status type of the services to fetch (optional, default 'active') -
'active', 'canceled', 'pending', 'suspended')
Returns
integer The total number of services
See
|
public
array
|
#
search( string $query, integer $page = 1 )
Search services
Parameters
- $query
string $query The value to search services for
- $page
integer $page The page number of results to fetch (optional, default 1)
Returns
array An array of services that match the search criteria
|
public
|
#
getSearchCount( string $query )
Return the total number of services returned from Services::search(), useful
in constructing pagination
Return the total number of services returned from Services::search(), useful
in constructing pagination
Parameters
- $query
string $query The value to search services for
See
|
public
array
|
#
getAllRenewing( integer $client_group_id )
Retrieves a list of services ready to be renewed for this client group
Retrieves a list of services ready to be renewed for this client group
Parameters
- $client_group_id
integer $client_group_id The client group ID to fetch renewing services from
Returns
array A list of stdClass objects representing services set ready to be renewed
|
public
array
|
#
getAllRenewablePaid( string $date )
Retrieves a list of renewable paid services
Retrieves a list of renewable paid services
Parameters
- $date
string $date The date after which to fetch paid renewable services
Returns
array A list of services that have been paid and may be processed
|
public
array
|
#
getAllPaidPending( )
Retrieves a list of paid pending services
Retrieves a list of paid pending services
Returns
array A list of services that have been paid and are still pending
|
public
array
|
#
getAllPendingSuspension( integer $client_group_id, string $suspension_date )
Retrieves a list of services ready to be suspended
Retrieves a list of services ready to be suspended
Parameters
- $client_group_id
integer $client_group_id The ID of the client group
- $suspension_date
string $suspension_date The date before which service would be considered suspended
Returns
array A list of stdClass objects representing services pending suspension
|
public
array
|
#
getAllPendingUnsuspension( integer $client_group_id )
Retrieves a list of paid suspended services ready to be unsuspended
Retrieves a list of paid suspended services ready to be unsuspended
Parameters
- $client_group_id
integer $client_group_id The ID of the client group
Returns
array A list of stdClass objects representing services pending unsuspension
|
public
array
|
#
getAllPendingCancelation( )
Retrieves a list of services ready to be canceled
Retrieves a list of services ready to be canceled
Returns
array A list of stdClass objects representing services pending cancelation
|
public
array
|
#
searchServiceFields( integer $module_id, string $key, string $value )
Searches services of the given module that contains the given service field
key/value pair.
Searches services of the given module that contains the given service field
key/value pair.
Parameters
- $module_id
integer $module_id The ID of the module to search services on
- $key
string $key They service field key to search
- $value
string $value The service field value to search
Returns
array An array of stdClass objects, each containing a service
|
private
Record
|
#
searchServices( string $query )
Partially constructs the query for searching services
Partially constructs the query for searching services
Parameters
- $query
string $query The value to search services for
Returns
Record
The partially constructed query Record object
See
|
private
Record
|
#
getServices( integer $client_id = null, string $status = "active" )
Partially constructs the query required by Services::getList() and others
Partially constructs the query required by Services::getList() and others
Parameters
- $client_id
integer $client_id The client ID (optional)
- $status
string $status The status type of the services to fetch (optional, default 'active') -
'active', 'canceled', 'pending', 'suspended' (or 'all' for all
active/canceled/pending/suspended)
Returns
Record
The partially constructed query Record object
|
public
mixed
|
#
getPricingInfo( integer $service_id, string $currency_code = null )
Fetches the pricing information for a service
Fetches the pricing information for a service
Parameters
- $service_id
integer $service_id The ID of the service whose pricing info te fetch
- $currency_code
string $currency_code The ISO 4217 currency code to convert pricing to (optional,
defaults to service's currency)
Returns
mixed An stdClass object representing service pricing fields, or false if none exist
|
public
mixed
|
#
get( integer $service_id )
Fetch a single service, including service field data
Fetch a single service, including service field data
Parameters
- $service_id
integer $service_id The ID of the service to fetch
Returns
mixed A stdClass object representing the service, false if no such service exists
|
public
integer
|
#
add( array $vars, array $packages = null, boolean $notify = false )
Adds a new service to the system
Adds a new service to the system
Parameters
- $vars
array $vars An array of service info including: - parent_service_id The ID of the
service this service is a child of (optional) - pricing_id The package pricing
schedule ID for this service - client_id The ID of the client to add the service
under - module_row_id The module row to add the service under (optional, default
module will decide) - coupon_id The ID of the coupon used for this service
(optional) - qty The quanity consumed by this service (optional, default 1) -
status The status of this service ('active','canceled','pending','suspended',
default 'pending') - date_added The date this service is added (default to
today's date UTC) - date_renews The date the service renews (optional, default
calculated by package term) - date_last_renewed The date the service last
renewed (optional) - date_suspended The date the service was last suspended
(optional) - date_canceled The date the service was last canceled (optional) -
use_module Whether or not to use the module when creating the service
('true','false', default 'true') - * Any other service field data to pass to the
module
- $packages
array $packages A numerically indexed array of packages ordered along with this
service to determine if the given coupon may be applied
- $notify
boolean $notify True to notify the client by email regarding this service creation,
false to not send any notification (optional, default false)
Returns
integer The ID of this service, void if error
|
public
integer
|
#
edit( integer $service_id, array $vars )
Edits a service. Only one module action may be performend at a time. For
example, you can't change the pricing_id and edit the module service fields in a
single request.
Edits a service. Only one module action may be performend at a time. For
example, you can't change the pricing_id and edit the module service fields in a
single request.
Parameters
- $service_id
integer $service_id The ID of the service to edit
- $vars
array $vars An array of service info: - parent_service_id The ID of the service this
service is a child of - pricing_id The package pricing schedule ID for this
service - client_id The ID of the client this service belongs to - module_row_id
The module row to add the service under - coupon_id The ID of the coupon used
for this service - qty The quanity consumed by this service - status The status
of this service ('active','canceled','pending','suspended') - date_added The
date this service is added - date_renews The date the service renews -
date_last_renewed The date the service last renewed - date_suspended The date
the service was last suspended - date_canceled The date the service was last
canceled - use_module Whether or not to use the module for this request
('true','false', default 'true') - * Any other service field data to pass to the
module
Returns
integer The ID of this service, void if error
|
private
|
#
sendNotificationEmail( stdClass $service, stdClass $package, integer $client_id )
Sends a service confirmation email
Sends a service confirmation email
Parameters
- $service
stdClass
$service An object representing the service created
- $package
stdClass
$package An object representing the package associated with the service
- $client_id
integer $client_id The ID of the client to send the notification to
|
private
array
|
#
getRelations( integer $service_id )
Fetches all relations (e.g. packages and services) for the given service
ID
Fetches all relations (e.g. packages and services) for the given service
ID
Parameters
- $service_id
integer $service_id The ID of the service to fetch relations for
Returns
array A array consisting of: - service The given service - package The service's
package - parent_service The parent service - parent_package The parent
service's package
|
public
|
#
cancel( integer $service_id, array $vars )
Schedule a service for cancellation. All cancellations requests are processed
by the cron.
Schedule a service for cancellation. All cancellations requests are processed
by the cron.
Parameters
- $service_id
integer $service_id The ID of the service to schedule cancellation
- $vars
array $vars An array of service info including: - date_canceled The date the service
is to be canceled. Possible values: - 'end_of_term' Will schedule the service to
be canceled at the end of the current term - date greater than now will schedule
the service to be canceled on that date - date less than now will immediately
cancel the service - use_module Whether or not to use the module when canceling
the service, if canceling now ('true','false', default 'true')
|
public
|
#
unCancel( integer $service_id )
Removes the scheduled cancellation for the given service
Removes the scheduled cancellation for the given service
Parameters
- $service_id
integer $service_id The ID of the service to remove scheduled cancellation from
|
public
|
#
suspend( integer $service_id, array $vars = array() )
Suspends a service
Parameters
- $service_id
integer $service_id The ID of the service to suspend
- $vars
array $vars An array of info including: - use_module Whether or not to use the module
when suspending the service ('true','false', default 'true') - staff_id The ID
of the staff member that issued the service suspension
|
public
|
#
unsuspend( integer $service_id, array $vars = array() )
Unsuspends a service
Parameters
- $service_id
integer $service_id The ID of the service to unsuspend
- $vars
array $vars An array of info including: - use_module Whether or not to use the module
when unsuspending the service ('true','false', default 'true') - staff_id The ID
of the staff member that issued the service unsuspension
|
public
|
#
renew( integer $service_id )
Processes the renewal for the given service by contacting the module (if
supported by the module), to let it know that the service should be renewed.
Note: This method does not affect the renew date of the service in Blesta, it
merely notifies the module; this action takes place after a service has been
paid not when its renew date is bumped.
Processes the renewal for the given service by contacting the module (if
supported by the module), to let it know that the service should be renewed.
Note: This method does not affect the renew date of the service in Blesta, it
merely notifies the module; this action takes place after a service has been
paid not when its renew date is bumped.
Parameters
- $service_id
integer $service_id The ID of the service to process the renewal for
|
public
array
|
#
getStatusTypes( )
Retrieves a list of service status types
Retrieves a list of service status types
Returns
array Key=>value pairs of status types
|
public
array
|
#
getActions( mixed $current_status = null )
Returns all action options that can be performed for a service.
Returns all action options that can be performed for a service.
Returns
array An array of key/value pairs where each key is the action that may be performed
and the value is the friendly name for the action
Parm
string $current_status Set to filter actions that may be performed if the
service is in the given state options include: - active - suspended - canceled
|
public
|
#
setFields( integer $service_id, array $vars )
Updates the field data for the given service, removing all existing data and
replacing it with the given data
Updates the field data for the given service, removing all existing data and
replacing it with the given data
Parameters
- $service_id
integer $service_id The ID of the service to set fields on
- $vars
array $vars A numerically indexed array of field data containing: - key The key for
this field - value The value for this key - encrypted Whether or not this field
should be encrypted ('true', 'false', default 'false')
|
public
|
#
addField( integer $service_id, array $vars )
Adds a service field for a particular service
Adds a service field for a particular service
Parameters
- $service_id
integer $service_id The ID of the service to add to
- $vars
array $vars An array of service field info including: - key The name of the value to
add - value The value to add - encrypted Whether or not to encrypt the value
when storing ('true', 'false', default 'false')
|
public
|
#
editField( integer $service_id, array $vars )
Edit a service field for a particular service
Edit a service field for a particular service
Parameters
- $service_id
integer $service_id The ID of the service to edit
- $vars
array $vars An array of service field info including: - key The name of the value to
edit - value The value to update with - encrypted Whether or not to encrypt the
value when storing ('true', 'false', default 'false')
|
public
array
|
#
getWelcomeEmailTags( )
Returns all default welcome email tags, which are set into the email that is
delivered when a service is provisioned.
Returns all default welcome email tags, which are set into the email that is
delivered when a service is provisioned.
Returns
array A multi-dimensional array of tags where the first dimension is the category and
the second is a numeric array of tags
|
public
string
|
#
getNextRenewDate( string $last_renew_date, integer $term, string $period, mixed $format = "Y-m-d H:i:s" )
Calculates the next renew date using a given date, term, and period
Calculates the next renew date using a given date, term, and period
Parameters
- $last_renew_date
string $last_renew_date The date the service last renewed. If never renewed this should
be the service add date
- $term
integer $term The term value relating to the given period
- $period
string $period The period (day, week, month, year, onetime)
- $format
Returns
string The date the service renews in UTC. In the event that the service does not renew
or the renew date can not be calculated null is returned
|
protected
array
|
#
getFields( integer $service_id )
Return all field data for the given service, decrypting fields where
neccessary
Return all field data for the given service, decrypting fields where
neccessary
Parameters
- $service_id
integer $service_id The ID of the service to fetch fields for
Returns
array An array of stdClass objects representing fields, containing: - key The service
field name - value The value for this service field - encrypted Whether or not
this field was originally encrypted (1 true, 0 false)
|
private
mixed
|
#
getModuleClassByPricingId( integer $package_pricing_id )
Returns info regarding the module belonging to the given
$package_pricing_id
Returns info regarding the module belonging to the given
$package_pricing_id
Parameters
- $package_pricing_id
integer $package_pricing_id The package pricing ID to fetch the module of
Returns
mixed A stdClass object containing module info and the package ID belonging to the
given $package_pricing_id, false if no such module exists
|
public
boolean
|
#
validateStatus( string $status )
Validates a service's 'status' field
Validates a service's 'status' field
Parameters
- $status
string $status The status type
Returns
boolean True if $status is valid, false otherwise
|
public
boolean
|
#
validateUseModule( string $use_module )
Validates whether to use a module when adding/editing a service
Validates whether to use a module when adding/editing a service
Parameters
- $use_module
string $use_module
Returns
boolean True if validated, false otherwise
|
public
|
#
validateEncrypted( string $encrypted )
Validates a service field's 'encrypted' field
Validates a service field's 'encrypted' field
Parameters
- $encrypted
string $encrypted Whether or not to encrypt
|
public
array
|
#
getFieldRules( )
Retrieves the rule set for adding/editing service fields
Retrieves the rule set for adding/editing service fields
Returns
array The rules
|
private
array
|
#
getRules( mixed $edit = false )
Retrieves the rule set for adding/editing services
Retrieves the rule set for adding/editing services
Returns
array The rules
|
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
|
public
array
|
#
validate( array $vars, array $packages = null )
Performs all validation necessary before adding a service
Performs all validation necessary before adding a service
Parameters
- $vars
array $vars An array of service info including: - parent_service_id The ID of the
service this service is a child of (optional) - pricing_id The package pricing
schedule ID for this service - client_id The ID of the client to add the service
under - module_row_id The module row to add the service under (optional, default
is first available) - coupon_id The ID of the coupon used for this service
(optional) - qty The quanity consumed by this service (optional, default 1) -
status The status of this service ('active','canceled','pending','suspended',
default 'pending') - date_added The date this service is added (default to
today's date UTC) - date_renews The date the service renews (optional, default
calculated by package term) - date_last_renewed The date the service last
renewed (optional) - date_suspended The date the service was last suspended
(optional) - date_canceled The date the service was last canceled (optional) -
use_module Whether or not to use the module when creating the service
('true','false', default 'true') - * Any other service field data to pass to the
module
- $packages
array $packages A numerically indexed array of packages ordered along with this
service to determine if the given coupon may be applied
Returns
array $vars An array of $vars, modified by error checking
See
|
public
|
#
validateService( stdClass $package, array $vars )
Validates service info, including module options, for creating a service. An
alternative to Services::validate()
Validates service info, including module options, for creating a service. An
alternative to Services::validate()
Parameters
- $package
stdClass
$package A stdClass object representing the package for the service
- $vars
array $vars An array of values to be evaluated, including: - client_id The ID of the
client the service is being added for - invoice_method The invoice method to use
when creating the service, options are: - create Will create a new invoice when
adding this service - append Will append this service to an existing invoice
(see 'invoice_id') - none Will not create any invoice - invoice_id The ID of the
invoice to append to if invoice_method is set to 'append' - pricing_id The ID of
the package pricing to use for this service - notify_order Whether or not to
send the order confirmation email for this service (string "true", or "false") -
status The status to use for this service, options are: - active - canceled -
pending - suspended - use_module Whether or not to use the module to provision
the service (string "true", or "false")
See
|
public
boolean
|
#
validateCoupon( integer $coupon_id, array $packages = null )
Verifies if the given coupon ID can be applied to the requested packages
Verifies if the given coupon ID can be applied to the requested packages
Parameters
- $coupon_id
integer $coupon_id The ID of the coupon to validate
- $packages
array An array of pacakges to confirm the coupon can be applied
Returns
boolean True if the coupon can be applied, false otherwise
|
public
boolean
|
#
validateDateCanceled( string $date )
Verifies that the given date value is valid for a cancel date
Verifies that the given date value is valid for a cancel date
Parameters
- $date
string $date The date to cancel a service or "end_of_term" to cancel at the end of the
term
Returns
boolean True if $date is valid, false otherwise
|