Methods summary
public
|
#
__construct( )
Initialize Packages
Overrides
|
public
integer
|
#
add( array $vars )
Adds a new package to the system
Adds a new package to the system
Parameters
- $vars
An array of package information including:
- module_id The ID of the module this package belongs to (optional, default NULL)
- names A list of names for the package in different languages
- lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us)
- name The name in the specified language
- descriptions A list of descriptions in text and html for the
package in different languages (optional, default NULL)
- lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us)
- text The text description in the specified language
- html The HTML description in the specified language
- qty The maximum quantity available in this package, if any (optional, default NULL)
- client_qty The maximum quantity available per client in this package, if any (optional, default NULL)
- module_row The module row this package belongs to (optional, default 0)
- module_group The module group this package belongs to (optional, default NULL)
- taxable Whether or not this package is taxable (optional, default 0)
- single_term Whether or not services derived from this package
should be canceled at the end of term (optional, default 0)
- status The status of this package, 'active', 'inactive', 'restricted' (optional, default 'active')
- company_id The ID of the company this package belongs to
- prorata_day The prorated day of the month (optional, default NULL)
- prorata_cutoff The day of the month pro rata should cut off (optional, default NULL)
- email_content A numerically indexed array of email content including:
- lang The language of the email content
- html The html content for the email (optional)
- text The text content for the email, will be created automatically from html if not given (optional)
- pricing A numerically indexed array of pricing info including:
- term The term as an integer 1-65535 (period should be given if this is set; optional, default 1)
- period The period, 'day', 'week', 'month', 'year', 'onetime' (optional, default 'month')
- price The price of this term (optional, default 0.00)
- price_renews The renewal price of this term (optional, default null)
- price_transfer The transfer price of this term (optional, default null)
- setup_fee The setup fee for this package (optional, default 0.00)
- cancel_fee The cancelation fee for this package (optional, default 0.00)
- currency The ISO 4217 currency code for this pricing
- groups A numerically indexed array of package group assignments (optional)
- option_groups A numerically indexed array of package option group assignments (optional)
- plugins A numerically-indexed array of valid plugin IDs to associate with the plugin (optional)
-
- A set of miscellaneous fields to pass, in addition to the above
fields, to the module when adding the package (optional)
Returns
integer The package ID created, void on error
|
public
|
#
edit( integer $package_id, array $vars )
Update an existing package ID with the data given
Update an existing package ID with the data given
Parameters
- $package_id
- The ID of the package to update
- $vars
An array of package information including:
- module_id The ID of the module this package belongs to (optional, default NULL)
- names A list of names for the package in different languages
- lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us)
- name The name in the specified language
- descriptions A list of descriptions in text and html for the
package in different languages (optional, default NULL)
- lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us)
- text The text description in the specified language
- html The HTML description in the specified language
- qty The maximum quantity available in this package, if any (optional, default NULL)
- client_qty The maximum quantity available per client in this package, if any (optional, default NULL)
- module_row The module row this package belongs to (optional, default 0)
- module_group The module group this package belongs to (optional, default NULL)
- taxable Whether or not this package is taxable (optional, default 0)
- single_term Whether or not services derived from this package
should be canceled at the end of term (optional, default 0)
- status The status of this package, 'active', 'inactive', 'restricted' (optional, default 'active')
- company_id The ID of the company this package belongs to (optional)
- prorata_day The prorated day of the month (optional)
- prorata_cutoff The day of the month pro rata should cut off (optional)
- email_content A numerically indexed array of email content including:
- lang The language of the email content
- html The html content for the email (optional)
- text The text content for the email, will be created automatically from html if not given (optional)
- pricing A numerically indexed array of pricing info including (required):
- id The pricing ID (optional, required if an edit else will add as new)
- term The term as an integer 1-65535 (period should be given
if this is set; optional, default 1), if term is empty will remove this pricing option
- period The period, 'day', 'week', 'month', 'year', 'onetime' (optional, default 'month')
- price The price of this term (optional, default 0.00)
- price_renews The renewal price of this term (optional, default null)
- price_transfer The transfer price of this term (optional, default null)
- setup_fee The setup fee for this package (optional, default 0.00)
- cancel_fee The cancelation fee for this package (optional, default 0.00)
- currency The ISO 4217 currency code for this pricing
- groups A numerically indexed array of package group assignments
(optional), if given will replace all package group assignments with those given
- option_groups A numerically indexed array of package option group assignments (optional)
- plugins A numerically-indexed array of valid plugin IDs to associate with the plugin (optional)
-
- A set of miscellaneous fields to pass, in addition to the above
fields, to the module when adding the package (optional)
|
public
|
#
delete( integer $package_id, boolean $remove_services = false )
Permanently removes the given package from the system. Packages can only
be deleted if no services exist for that package.
Permanently removes the given package from the system. Packages can only
be deleted if no services exist for that package.
Parameters
- $package_id
- The package ID to delete
- $remove_services
True to remove all canceled services related to the
package (optional, default false)
|
public
|
#
orderPackages( integer $package_group_id, array $package_ids )
Save the packages for the given group in the provided order
Save the packages for the given group in the provided order
Parameters
- $package_group_id
- The ID of the package group to order packages for
- $package_ids
- A numerically indexed array of package IDs
|
public
mixed
|
#
get( integer $package_id )
Fetches the given package
Fetches the given package
Parameters
- $package_id
- The package ID to fetch
Returns
mixed A stdClass object representing the package, false if no such package exists
|
public
mixed
|
#
getByPricingId( integer $package_pricing_id )
Fetches the given package by package pricing ID
Fetches the given package by package pricing ID
Parameters
- $package_pricing_id
- The package pricing ID to use to fetch the package
Returns
mixed A stdClass object representing the package, false if no such package exists
|
public
array
|
#
getAll( integer $company_id, array $order = ['name' => 'ASC'], string $status = null, string $type = null, array $filters = [] )
Fetch all packages belonging to the given company
Fetch all packages belonging to the given company
Parameters
- $company_id
- The ID of the company to fetch pages for
- $order
The sort order in key = value order, where 'key' is
the field to sort on and 'value' is the order to sort (asc or desc)
- $status
The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- $type
- The type of packages to retrieve ('standard', 'addon', default null for all)
- $filters
A list of package filters including:
- status The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- name The name or part of the name of the packages to fetch
- module_id The module ID to filter packages on
- hidden Whether or nor to include the hidden packages
Returns
array An array of stdClass objects each representing a package
|
public
array
|
#
getList( integer $page = 1, array $order_by = ['id_code' => 'asc'], string $status = null, array $filters = [] )
Fetches a list of all packages
Fetches a list of all packages
Parameters
- $page
- The page to return results for (optional, default 1)
- $order_by
- The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
- $status
The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- $filters
A list of package filters including: (optional)
- status The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- name The name or part of the name of the packages to fetch
- module_id The module ID to filter packages on
- hidden Whether or nor to include the hidden packages
Returns
array An array of stdClass objects each representing a package
|
public
array
|
#
search( string $query, integer $page = 1 )
Search packages
Parameters
- $query
- The value to search packages for
- $page
- The page number of results to fetch (optional, default 1)
Returns
array An array of packages that match the search criteria
|
public
|
#
getSearchCount( string $query )
Return the total number of packages returned from Packages::search(), useful
in constructing pagination
Return the total number of packages returned from Packages::search(), useful
in constructing pagination
Parameters
- $query
- The value to search services for
See
|
public
array
|
#
getPricingPeriods( boolean $plural = false )
Retrieves a list of package pricing periods
Retrieves a list of package pricing periods
Parameters
- $plural
- True to return language for plural periods, false for singular
Returns
array Key=>value pairs of package pricing periods
|
public
array
|
#
getStatusTypes( )
Retrieves a list of package status types
Retrieves a list of package status types
Returns
array Key=>value pairs of package status types
|
public
array
|
#
getProrataDays( )
Retrieves a list of acceptable pro rata day options
Retrieves a list of acceptable pro rata day options
Returns
array A set of key=>value pairs of pro rata days
|
public
boolean
|
#
isDateAfterProrataCutoff( string $date, integer $cutoff_day )
Determines whether the pro rata cutoff day has passed
Determines whether the pro rata cutoff day has passed
Parameters
- $date
- The date to check
- $cutoff_day
- The day of the month representing the cutoff day
Returns
boolean True if the given date is after the pro rata cutoff day, or false otherwise
|
public
mixed
|
#
getProrateDate( string $start_date, string $period, integer $pro_rata_day )
Retrieves the date to prorate a service to
Retrieves the date to prorate a service to
Parameters
- $start_date
- The date to start from
- $period
- The period associated with the service
- $pro_rata_day
- The day of the month to prorate to
Returns
mixed The prorated UTC end date; null if not prorating; or boolean false if it cannot be determined
|
public
boolean
|
#
isProrataDay( string $start_date, integer $pro_rata_day )
Determines whether the given start date is on the pro rata day
Determines whether the given start date is on the pro rata day
Parameters
- $start_date
- The start date
- $pro_rata_day
- The pro rata day of the month
Returns
boolean True if the given start date is the current pro rata day
for the company's timezone, or false otherwise
|
public
mixed
|
#
getDaysToProrate( string $start_date, string $period, integer $pro_rata_day )
Retrieves the number of days to prorate a service
Retrieves the number of days to prorate a service
Parameters
- $start_date
- The date to start from
- $period
- The period associated with the service
- $pro_rata_day
- The day of the month to prorate to
Returns
mixed The number of days to prorate, or boolean false if it cannot be determined
|
public
float
|
#
getProratePrice( float $amount, string $start_date, integer $term, string $period, integer $pro_rata_day, boolean $allow_all_recurring_periods = false, string $prorate_date = null )
Retrieves the price to prorate a value given the date, term, and period to prorate from
Retrieves the price to prorate a value given the date, term, and period to prorate from
Parameters
- $amount
- The total cost for the given term and period
- $start_date
- The start date to calculate the price from
- $term
- The term length
- $period
- The period type (e.g. "month", "year")
- $pro_rata_day
- The day of the month to prorate to
- $allow_all_recurring_periods
True to allow all recurring
periods, or false to limit to "month" and "year" only (optional, default false)
- $prorate_date
- The date to prorate to. Setting this value will ignore the $pro_rata_day (optional)
Returns
float The prorate price
|
public
mixed
|
#
getProrataDates( integer $pricing_id, string $prorate_from_date, string $date_to_prorate )
Gets a list of dates for proration
Gets a list of dates for proration
Parameters
- $pricing_id
- The ID of the pricing to get the package and period from
- $prorate_from_date
- The date to base proration on
- $date_to_prorate
- The date to prorate
Returns
mixed An array of dates for proration, false on failure
|
public
mixed
|
#
convertPricing( stdClass $pricing, string $currency, boolean $allow_conversion )
Convert pricing to the given currency if allowed
Convert pricing to the given currency if allowed
Parameters
- $pricing
- A stdClass object representing a package pricing
- $currency
- The ISO 4217 currency code to convert to
- $allow_conversion
- True to allow converion, false otherwise
Returns
mixed The stdClass object representing the converted pricing (if conversion allowed), null otherwise
|
public
integer
|
#
getListCount( string $status = null, array $filters = [] )
Return the total number of packages returned from Packages::getList(),
useful in constructing pagination for the getList() method.
Return the total number of packages returned from Packages::getList(),
useful in constructing pagination for the getList() method.
Parameters
- $status
The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- $filters
A list of package filters including:
- status The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- name The name or part of the name of the packages to fetch
- module_id The module ID to filter packages on
- hidden Whether or nor to include the hidden packages
Returns
integer The total number of packages
See
|
public
mixed
|
#
getAllGroups( integer $company_id, integer $package_id = null, string $type = null, array $filters = [] )
Fetches all package groups belonging to a company, or optionally, all package
groups belonging to a specific package
Fetches all package groups belonging to a company, or optionally, all package
groups belonging to a specific package
Parameters
- $company_id
- The company ID
- $package_id
- The package ID to fetch groups of (optional, default null)
- $type
- The type of group to fetch (null, standard, addon)
- $filters
A list of package groups filters including:
- hidden Whether or nor to include the hidden package groups
Returns
mixed An array of stdClass objects representing package groups, or false if none found
|
public
array
|
#
getAllAddonGroups( integer $parent_group_id )
Returns all addon package groups for the given package group.
Returns all addon package groups for the given package group.
Parameters
- $parent_group_id
- The ID of the parent package group
Returns
array A list of addon package groups
|
public
mixed
|
#
getAllPackagesByGroup( integer $package_group_id, string $status = null, array $filters = [] )
Fetches all packages belonging to a specific package group
Fetches all packages belonging to a specific package group
Parameters
- $package_group_id
- The ID of the package group
- $status
The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- $filters
A list of package filters including:
- status The status type of packages to retrieve
('active', 'inactive', 'restricted', default null for all)
- name The name or part of the name of the packages to fetch
- module_id The module ID to filter packages on
- hidden Whether or nor to include the hidden packages
Returns
mixed An array of stdClass objects representing packages, or false if none exist
|
public
array
|
#
getCompatiblePackages( integer $package_id, integer $module_id, string $type )
Get all compatible packages
Get all compatible packages
Parameters
- $package_id
- The ID of the package to fetch all compatible packages for
- $module_id
- The ID of the module to include compatible packages for
- $type
- The type of package group to include ("standard", "addon")
Returns
array An array of stdClass objects, each representing a compatible package and its pricing
|
public
boolean
|
#
validateServiceExists( integer $package_id, boolean $exclude_canceled = false )
Checks whether a service exists for a specific package ID
Checks whether a service exists for a specific package ID
Parameters
- $package_id
- The package ID to check
- $exclude_canceled
- True to exclude canceled services (optional, default false)
Returns
boolean True if a service exists for this package, false otherwise
|
public
boolean
|
#
validateHasChildren( integer $package_id, string $status = null )
Validates whether the services belonging to a specific package has children NOT of the given status
Validates whether the services belonging to a specific package has children NOT of the given status
Parameters
- $package_id
- The package ID to check
- $status
The status of children services to ignore
(e.g. "canceled") (optional, default null to not ignore any child services)
Returns
boolean True if the services belonging to this package has children not of the given status, false otherwise
|
public
boolean
|
#
validateStatus( string $status )
Validates the package 'status' field type
Validates the package 'status' field type
Parameters
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateTerm( integer $term, string $period )
Validates that the term is valid for the period. That is, the term must be > 0
if the period is something other than "onetime".
Validates that the term is valid for the period. That is, the term must be > 0
if the period is something other than "onetime".
Parameters
- $term
- The Term to validate
- $period
- The period to validate the term against
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validatePeriod( string $period )
Validates the pricing 'period' field type
Validates the pricing 'period' field type
Parameters
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateGroup( integer $group_id, integer $company_id )
Validates that the given group belongs to the given company ID
Validates that the given group belongs to the given company ID
Parameters
- $group_id
- The ID of the group to test
- $company_id
- The ID of the company to validate exists for the given group
Returns
boolean True if validated, false otherwise
|
public
boolean
|
#
validateOptionGroup( integer $option_group_id, integer $company_id )
Validates that the given group is valid
Validates that the given group is valid
Parameters
- $option_group_id
- The ID of the package option group to validate
- $company_id
- The ID of the company whose option group to validate
Returns
boolean True if the package option group is valid, or false otherwise
|
public
boolean
|
#
validatePriceInUse( string $term, integer $pricing_id )
Validates that the given price is in use
Validates that the given price is in use
Parameters
- $term
- The term of the price point, if non-empty no check is performed.
- $pricing_id
- The package pricing ID
Returns
boolean True if the price is in use, false otherwise
|
public
boolean
|
#
validateCurrency( string $currency, string $term, string $period )
Validates that the given currency is valid for adding/editing a package
Validates that the given currency is valid for adding/editing a package
Parameters
- $currency
- The ISO 4217 currency code for this pricing option
- $term
- The term for this pricing option
- $period
- The period type to validate the currency for
Returns
boolean True if the currency is valid, or false otherwise
|
public
|
#
validateParse( array $email_content )
Validate that the given email content parses template parsing
Validate that the given email content parses template parsing
Parameters
- $email_content
numerically-indexed array of template data to parse, containing:
- html The HTML version of the email content
- text The text version of the email content
|
public
boolean
|
#
validateModuleChange( integer $module_id, integer $package_id )
Validates whether the given package can be changed to the given module
Validates whether the given package can be changed to the given module
Parameters
- $module_id
- The new module ID
- $package_id
- The ID of the package
Returns
boolean True if the package can be changed to the module, or false otherwise
|
public
mixed
|
#
formatPricingTerm( integer $term, string $period )
Formats the pricing term
Parameters
- $term
- The term length
- $period
- The period of this term
Returns
mixed The term formatted in accordance to the period, if possible
|