ClientServices extends ClientController
Client portal services controller
Table of Contents
Methods
| addAddon() | Create an addon |
| addons() | List Addons |
| cancel() | Cancel Service |
| changeTerm() | Change service term |
| getAddonOptions() | AJAX - Retrieves the configurable options for a given addon |
| index() | List services |
| manage() | Manage service |
| manageOptions() | Builds a list of package options for a service that may be upgraded/downgraded |
| packageOptions() | AJAX Fetch all package options for the given pricing ID and service ID |
| preAction() | Pre-action |
| renew() | Renew Service |
| review() | Review page for updating package and package options |
| serviceInfo() | Service Info |
| updateTotals() | AJAX updates totals for input data changed for a service |
| upgrade() | Upgrades or downgrades a service by changing the package |
| authorized() | Verifies that the currently logged in user is authorized for the given Controller and Action (or current Controller/Action if none given). |
| hasPermission() | Verifies if the current user has permission to the given area |
| isStaffAsClient() | Checks whether the current user is a staff user and whether the user is currently logged into the client portal. |
| requireLogin() | {@inheritdoc} |
| requirePermission() | Verifies permissions for the given generic $area |
| setNav() | Sets the primary and secondary navigation links. Performs authorization checks on each navigational element. |
| buildTabs() | Builds and sets the sidebar tabs for the service management views |
| createCredit() | Creates an in house credit for the client |
| createInvoice() | Creates an invoice from the given line items |
| formatExtensionTabs() | Format module tabs into an array of tabs |
| formatReviewOptions() | Formats package options and their values into categories for current and new |
| formatServiceReview() | Formats package/term and package options into separate sections representing their current and new values/pricing |
| getAddonPackageList() | Retrieves a list of name/value pairs for addon packages |
| getAddonPackages() | Retrieves a list of all addon packages available to the client in the given package group |
| getAvailableOptions() | Fetches a list of package options that are addable or editable for this service |
| getCurrentMatchingOptions() | Retrieves a list of current options that match those available from the given package and term information |
| getPackageOptionFields() | Builds a partial template for the package options |
| getPackageTerms() | Returns an array of all pricing terms for the given package that optionally recur and do not match the given pricing IDs |
| getPlugin() | Retrieves an instance of the given plugin if it is enabled |
| getPricing() | Retrieves the matching pricing information from the given pricings |
| getSelectedOptionIds() | Fetches a set of available package option IDs for the given service that the user can add or update |
| getSettableOptions() | Retrieves a list of service options that can be set by the client for the given package and term information |
| getUpgradablePackages() | Returns an array of packages that can be upgraded/downgraded from the same package group |
| makeLineItems() | Creates a set of line items from the given presenter |
| pendingServiceChanges() | Retrieves a list of pending service changes for the given service |
| processModuleTab() | Processes and retrieves the module tab content for the given method |
| processPluginTab() | Processes and retrieves the plugin tab content for the given method |
| queueServiceChange() | Queue's a service change for later processing |
| queueServiceChanges() | Determines whether queuing service changes is enabled |
| setServiceTabMessages() | Sets messages to the view based on the given errors and messages provided |
| totals() | Builds and returns the totals partial |
| validateAddon() | Validates that the given data is valid for a client |
Methods
addAddon()
Create an addon
public
addAddon() : mixed
addons()
List Addons
public
addons() : mixed
cancel()
Cancel Service
public
cancel() : mixed
changeTerm()
Change service term
public
changeTerm() : mixed
getAddonOptions()
AJAX - Retrieves the configurable options for a given addon
public
getAddonOptions([array<string|int, mixed> $fields = [] ][, bool $return = false ][, array<string|int, mixed> $vars = [] ]) : mixed
Parameters
- $fields : array<string|int, mixed> = []
-
A list of addon fields (optional)
- $return : bool = false
-
True to return this partial view, false to output as json (optional, default false)
- $vars : array<string|int, mixed> = []
-
A list of input vars (optional)
Return values
mixed —False if addon fields are invalid; a partial view if $return is true; otherwise null
index()
List services
public
index() : mixed
manage()
Manage service
public
manage() : mixed
manageOptions()
Builds a list of package options for a service that may be upgraded/downgraded
public
manageOptions() : mixed
packageOptions()
AJAX Fetch all package options for the given pricing ID and service ID
public
packageOptions() : mixed
preAction()
Pre-action
public
preAction() : mixed
renew()
Renew Service
public
renew() : mixed
review()
Review page for updating package and package options
public
review() : mixed
serviceInfo()
Service Info
public
serviceInfo() : mixed
updateTotals()
AJAX updates totals for input data changed for a service
public
updateTotals() : mixed
upgrade()
Upgrades or downgrades a service by changing the package
public
upgrade() : mixed
authorized()
Verifies that the currently logged in user is authorized for the given Controller and Action (or current Controller/Action if none given).
protected
authorized([string $controller = null ][, string $action = null ][, stdClass $group = null ]) : bool
Will first check whether the Controller and Action is a permission value, and if so, checks to ensure the staff or client group user is authorized to access that resource
Parameters
- $controller : string = null
-
The controller to check authorization on, null will default to the current controller
- $action : string = null
-
The action to check authorization on, null will default to the current action
- $group : stdClass = null
-
The staff or client group to check authorization on, null will fetch the group of the current user
Return values
bool —Returns true if the user is authorized for that resource, false otherwise
hasPermission()
Verifies if the current user has permission to the given area
protected
hasPermission(string $area) : bool
Parameters
- $area : string
-
The generic area
Return values
bool —True if user has permission, false otherwise
isStaffAsClient()
Checks whether the current user is a staff user and whether the user is currently logged into the client portal.
protected
isStaffAsClient() : bool
Return values
bool —True if the user is a staff user logged in as a client, false otherwise
requireLogin()
{@inheritdoc}
protected
requireLogin([mixed $redirect_to = null ]) : mixed
Parameters
- $redirect_to : mixed = null
requirePermission()
Verifies permissions for the given generic $area
protected
requirePermission(string $area) : mixed
Parameters
- $area : string
-
The generic area
setNav()
Sets the primary and secondary navigation links. Performs authorization checks on each navigational element.
protected
setNav() : mixed
May cache nav results if possible for better performance.
buildTabs()
Builds and sets the sidebar tabs for the service management views
private
buildTabs(stdClass $service, stdClass $package, Module $module[, string|null $method = null ][, int|null $plugin_id = null ]) : mixed
Parameters
- $service : stdClass
-
An stdClass object representing the service
- $package : stdClass
-
An stdClass object representing the package used by the service
- $module : Module
-
An instance of the module used by the service
- $method : string|null = null
-
The method being called (i.e. the tab action, optional)
- $plugin_id : int|null = null
-
The ID of the plugin being called (optional)
createCredit()
Creates an in house credit for the client
private
createCredit(float $amount, string $currency) : int
Parameters
- $amount : float
-
The amount to credit
- $currency : string
-
The ISO 4217 currency code for the credit
Return values
int —$transaction_id The ID of the transaction for this credit
createInvoice()
Creates an invoice from the given line items
private
createInvoice(PresenterInterface $presenter, string $currency[, int $service_id = null ]) : array<string|int, mixed>
Parameters
- $presenter : PresenterInterface
-
An instance of the PresenterInterface
- $currency : string
-
The ISO-4217 currency code
- $service_id : int = null
-
The ID of the service the items are for (optional)
Return values
array<string|int, mixed> —An key/value array containing:
- invoice_id The ID of the invoice, if created
- errors An array of errors if the invoice could not be created
formatExtensionTabs()
Format module tabs into an array of tabs
private
formatExtensionTabs(stdClass $service, stdClass $package, Module $module[, string|null $method = null ][, int|null $plugin_id = null ]) : mixed
Parameters
- $service : stdClass
-
An stdClass object representing the service
- $package : stdClass
-
An stdClass object representing the package used by the service
- $module : Module
-
An instance of the module used by the service
- $method : string|null = null
-
The method being called (i.e. the tab action, optional)
- $plugin_id : int|null = null
-
The ID of the plugin being called (optional)
formatReviewOptions()
Formats package options and their values into categories for current and new
private
formatReviewOptions(stdClass $service[, array<string|int, mixed> $option_values = [] ][, int $pricing_id = null ]) : array<string|int, mixed>
Parameters
- $service : stdClass
-
An stdClass object representing the service
- $option_values : array<string|int, mixed> = []
-
A key/value array of the new service option IDs and their values
- $pricing_id : int = null
-
The new pricing ID (optional)
Tags
Return values
array<string|int, mixed> —A formatted array of all options
formatServiceReview()
Formats package/term and package options into separate sections representing their current and new values/pricing
private
formatServiceReview(stdClass $service[, array<string|int, mixed> $option_values = [] ][, int $pricing_id = null ]) : array<string|int, mixed>
Parameters
- $service : stdClass
-
An stdClass object representing the service
- $option_values : array<string|int, mixed> = []
-
A key/value array of the new service option IDs and their values
- $pricing_id : int = null
-
The new pricing ID (optional)
Return values
array<string|int, mixed> —A formatted array of all options
getAddonPackageList()
Retrieves a list of name/value pairs for addon packages
private
getAddonPackageList(array<string|int, mixed> $addons) : array<string|int, mixed>
Parameters
- $addons : array<string|int, mixed>
-
A list of package groups containing addon packages available to the client
Return values
array<string|int, mixed> —A list of name/value pairs
getAddonPackages()
Retrieves a list of all addon packages available to the client in the given package group
private
getAddonPackages(int $parent_group_id) : array<string|int, mixed>
Parameters
- $parent_group_id : int
-
The ID of the parent group to list packages for
Return values
array<string|int, mixed> —An array of addon package groups containing an array of addon packages
getAvailableOptions()
Fetches a list of package options that are addable or editable for this service
private
getAvailableOptions(stdClass $service) : array<string|int, mixed>
Parameters
- $service : stdClass
-
An stdClass object representing the service
Return values
array<string|int, mixed> —An array of all addable and editable package options for the service
getCurrentMatchingOptions()
Retrieves a list of current options that match those available from the given package and term information
private
getCurrentMatchingOptions(int $package_id, int $term, string $period, string $currency, array<string|int, mixed> $current_options[, array<string|int, mixed> $settable_options = [] ]) : array<string|int, mixed>
Parameters
- $package_id : int
-
The ID of the package whose options to use
- $term : int
-
The pricing term
- $period : string
-
The pricing period
- $currency : string
-
The ISO 4217 pricing currency code
- $current_options : array<string|int, mixed>
-
An array of current service options
- $settable_options : array<string|int, mixed> = []
-
An array of options that could be selected for modification
Return values
array<string|int, mixed> —A key/value array where the key is the option ID and the value is the selected option value
getPackageOptionFields()
Builds a partial template for the package options
private
getPackageOptionFields(int $package_id, int $term, string $period, string $currency, stdClass $vars[, string $convert_currency = null ][, array<string|int, mixed> $options = null ]) : mixed
Parameters
- $package_id : int
-
The ID of the package whose package options to fetch
- $term : int
-
The package option pricing term
- $period : string
-
The package option pricing period
- $currency : string
-
The ISO 4217 currency code for this pricing
- $vars : stdClass
-
An stdClass object containing input fields
- $convert_currency : string = null
-
The ISO 4217 currency code to convert the pricing to
- $options : array<string|int, mixed> = null
-
An array of filtering options (optional):
- addable Set to 1 to only include options that are addable by clients; 0 to only include options that are NOT addable by clients; otherwise every option is included
- editable Set to 1 to only include options that are editable by clients; 0 to only include options that are NOT editable by clients; otherwise every option is included
- allow An array of option IDs to include (i.e. white-list). An empty array would return no options. Not setting this 'option_ids' key will allow any option
- disallow An array of option IDs not to include (i.e. black-list). An empty array would allow all options.
- configoptions An array of key/value pairs currently in use where each key is the package option ID and each value is the option value
- new Set to 1 if this is for a new package, or 0 if this is for an existing package (default 1)
Return values
mixed —The partial template, or boolean false if no fields are available
getPackageTerms()
Returns an array of all pricing terms for the given package that optionally recur and do not match the given pricing IDs
private
getPackageTerms(stdClass $package[, array<string|int, mixed> $pricing_ids = [] ][, mixed $service = null ][, bool $remove_non_recurring_terms = true ][, bool $match_periods = false ][, bool $upgrade = false ]) : array<string|int, mixed>
Parameters
- $package : stdClass
-
A stdClass object representing the package to fetch the terms for
- $pricing_ids : array<string|int, mixed> = []
-
An array of pricing IDs to exclude (optional)
- $service : mixed = null
-
An stdClass object representing the service (optional)
- $remove_non_recurring_terms : bool = true
-
True to include only package terms that recur, or false to include all (optional, default true)
- $match_periods : bool = false
-
True to only set terms that match the period set for the $service (i.e. recurring periods -> recurring periods OR one-time -> one-time) $remove_non_recurring_terms should be set to false when this is true (optional, default false)
- $upgrade : bool = false
-
Whether these terms are being fetched for a package upgrade
Return values
array<string|int, mixed> —An array of key/value pairs where the key is the package pricing ID and the value is a string representing the price, term, and period.
getPlugin()
Retrieves an instance of the given plugin if it is enabled
private
getPlugin(int $plugin_id) : Plugin|null
Parameters
- $plugin_id : int
-
The ID of the plugin
Return values
Plugin|null —An instance of the plugin
getPricing()
Retrieves the matching pricing information from the given pricings
private
getPricing(array<string|int, mixed> $pricings, int $pricing_id) : mixed
Parameters
- $pricings : array<string|int, mixed>
-
An array of stdClass objects representing each pricing
- $pricing_id : int
-
The ID of the pricing to retrieve from the list
Return values
mixed —An stdClass object representing the pricing information, or null if not found
getSelectedOptionIds()
Fetches a set of available package option IDs for the given service that the user can add or update
private
getSelectedOptionIds(stdClass $service) : array<string|int, mixed>
Parameters
- $service : stdClass
-
An stdClass object representing the service
Tags
Return values
array<string|int, mixed> —A key/value array of available options where each key is the option ID
getSettableOptions()
Retrieves a list of service options that can be set by the client for the given package and term information
private
getSettableOptions(int $package_id, int $term, string $period, string $currency, array<string|int, mixed> $current_options[, array<string|int, mixed> $selected_options = [] ]) : array<string|int, mixed>
Parameters
- $package_id : int
-
The ID of the package whose options to use
- $term : int
-
The pricing term
- $period : string
-
The pricing period
- $currency : string
-
The ISO 4217 pricing currency code
- $current_options : array<string|int, mixed>
-
An array of current service options
- $selected_options : array<string|int, mixed> = []
-
A key/value list of option IDs and their selected values
Return values
array<string|int, mixed> —An array of stdClass objects representing each package option field that can be set by the client
getUpgradablePackages()
Returns an array of packages that can be upgraded/downgraded from the same package group
private
getUpgradablePackages(stdClass $package, string $type) : array<string|int, mixed>
Parameters
- $package : stdClass
-
The package from which to fetch other upgradable packages
- $type : string
-
The type of package group ("standard" or "addon")
Return values
array<string|int, mixed> —An array of stdClass objects representing packages in the same group
makeLineItems()
Creates a set of line items from the given presenter
private
makeLineItems(PresenterInterface $presenter[, int $service_id = null ]) : array<string|int, mixed>
Parameters
- $presenter : PresenterInterface
-
An instance of the PresenterInterface
- $service_id : int = null
-
The ID of the service the items are for (optional)
Tags
Return values
array<string|int, mixed> —An array of line items
pendingServiceChanges()
Retrieves a list of pending service changes for the given service
private
pendingServiceChanges(int $service_id) : array<string|int, mixed>
Parameters
- $service_id : int
-
The ID of the service
Return values
array<string|int, mixed> —An array of all pending service changes for the given service
processModuleTab()
Processes and retrieves the module tab content for the given method
private
processModuleTab(Module $module, string $method, stdClass $package, stdClass $service[, bool $partial = false ]) : string
Parameters
- $module : Module
-
The module instance
- $method : string
-
The method on the module to call to retrieve the tab content
- $package : stdClass
-
An stdClass object representing the package
- $service : stdClass
-
An stdClass object representing the service being managed
- $partial : bool = false
-
True to return the module tab as a partial view
Return values
string —The tab content
processPluginTab()
Processes and retrieves the plugin tab content for the given method
private
processPluginTab(int $plugin_id, string $method, stdClass $service) : string
Parameters
- $plugin_id : int
-
The ID of the plugin
- $method : string
-
The method on the plugin to call to retrieve the tab content
- $service : stdClass
-
An stdClass object representing the service being managed
Return values
string —The tab content
queueServiceChange()
Queue's a service change for later processing
private
queueServiceChange(int $service_id, int $invoice_id, array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
- $service_id : int
-
The ID of the service being queued
- $invoice_id : int
-
The ID of the invoice related to the service change
- $vars : array<string|int, mixed>
-
An array of all data to queue to successfully update a service
Return values
array<string|int, mixed> —An array of queue info, including:
- service_change_id The ID of the service change, if created
- errors An array of errors
queueServiceChanges()
Determines whether queuing service changes is enabled
private
queueServiceChanges() : bool
Return values
bool —True if queuing service changes is enabled, or false otherwise
setServiceTabMessages()
Sets messages to the view based on the given errors and messages provided
private
setServiceTabMessages([array<string|int, mixed>|bool|null $errors = null ][, array<string|int, mixed> $messages = null ]) : mixed
Parameters
- $errors : array<string|int, mixed>|bool|null = null
-
An array of error messages (optional)
- $messages : array<string|int, mixed> = null
-
An array of any other messages keyed by type (optional)
totals()
Builds and returns the totals partial
private
totals(PresenterInterface $presenter, string $currency[, PresenterInterface $recurPresenter = null ]) : string
Parameters
- $presenter : PresenterInterface
-
An instance of the PresenterInterface
- $currency : string
-
The ISO 4217 currency code
- $recurPresenter : PresenterInterface = null
-
An instance of the PresenterInterface representing a renewing service
Return values
string —The totals partial template
validateAddon()
Validates that the given data is valid for a client
private
validateAddon(int $service_id, int $package_group_id, int $price_id) : array<string|int, mixed>
Parameters
- $service_id : int
-
The ID of the parent service to which the addon is to be assigned
- $package_group_id : int
-
The ID of the package group
- $price_id : int
-
The ID of the addon's package pricing
Tags
Return values
array<string|int, mixed> —An array of fields including:
- valid True if the addon is valid; false otherwise
- parent_service An stdClass object representing the parent service of the addon (optional, only if valid is true)
- package An stdClass object representing the addon package (optional, only if valid is true)
- pricing An stdClass object representing the package pricing term (optional, only if valid is true)
- package_group An stdClass object representing the addon package group (optional, only if valid is true)
- module An stdClass object representing the module (optional, only if valid is true)
- currency The currency code