Blesta Source Documentation

ServiceChanges extends AppModel

Service upgrades/downgrades

Table of Contents

Methods

__construct() Initialize language
add() Queues a pending service change entry
cancel() Cancels all service changes for the given ID
delete() Deletes all service changes for the given ID
deleteByService() Deletes all service changes associated with the given service
edit() Updates a service change entry
get() Retrieves a service change
getAll() Retrieves a list of all service change entries of the given status
getList() Retrieves a list of all service change entries of the given status
getListCount() Returns the number of all service change entries of the given status
getPresenter() Retrieves a presenter representing a set of items, discounts, and taxes for a service change (i.e. upgrade/downgrade)
getStatuses() Retrieves a list of available service change statuses and their language
process() Processes the pending service change by updating the service
getRules() Retrieves validation rules for ::add
hasDayChanged() Determines whether the two given dates represent different days
objectToArray() Converts an object and any nested objects into arrays
Methods

add()

Queues a pending service change entry

public add(mixed $service_id, mixed $invoice_id, array<string|int, mixed> $vars) : int
Parameters
$service_id : mixed

The service ID

$invoice_id : mixed

The ID of the invoice

$vars : array<string|int, mixed>

An array of information including:

  • data An array of input data used later to process the service change
Return values
int

The service change ID on success, or void on failure

cancel()

Cancels all service changes for the given ID

public cancel(int $service_change_id[, bool $void_invoice = false ]) : mixed
Parameters
$service_change_id : int

The ID of the service changes to permanently delete

$void_invoice : bool = false

True to void the invoice associated to this service change

delete()

Deletes all service changes for the given ID

public delete(int $service_change_id[, bool $void_invoice = false ]) : mixed
Parameters
$service_change_id : int

The ID of the service changes to permanently delete

$void_invoice : bool = false

True to void the invoice associated to this service change

deleteByService()

Deletes all service changes associated with the given service

public deleteByService(int $service_id) : mixed
Parameters
$service_id : int

The ID of the service whose changes to permanently delete

edit()

Updates a service change entry

public edit(int $service_change_id, array<string|int, mixed> $vars) : mixed
Parameters
$service_change_id : int

The ID of the service change to update

$vars : array<string|int, mixed>

An array of fields to update:

  • status The service change status (one of: 'pending', 'canceled', 'error', 'completed')

get()

Retrieves a service change

public get(int $service_change_id) : mixed
Parameters
$service_change_id : int

The ID of the service change to update

Return values
mixed

An stdClass object representing the service change, or false otherwise

getAll()

Retrieves a list of all service change entries of the given status

public getAll([mixed $status = null ][, int $service_id = null ]) : array<string|int, mixed>
Parameters
$status : mixed = null

The status of the service changes to fetch, or null for all

$service_id : int = null

The ID of the service the service change belongs to (optional)

Return values
array<string|int, mixed>

A list of service change entries

getList()

Retrieves a list of all service change entries of the given status

public getList([int $page = 1 ][, array<string|int, mixed> $order_by = ['date_added' => 'DESC'] ][, mixed $status = null ][, int $service_id = null ][, array<string|int, mixed> $filters = [] ]) : array<string|int, mixed>
Parameters
$page : int = 1

The page to return results for (optional, default 1)

$order_by : array<string|int, mixed> = ['date_added' => 'DESC']

The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)

$status : mixed = null

The status of the service changes to fetch, or null for all

$service_id : int = null

The ID of the service change belongs to (optional)

$filters : array<string|int, mixed> = []

A list of parameters to filter by, including:

  • service_id The ID of the service (optional)
  • invoice_id The ID of the invoice (optional)
  • invoice The invoice number associated to the service change (optional)
  • date_added The date the service change was created (optional)
  • date_status The date the service change was updated (optional)
Return values
array<string|int, mixed>

A list of service change entries

getListCount()

Returns the number of all service change entries of the given status

public getListCount([mixed $status = null ][, int $service_id = null ][, array<string|int, mixed> $filters = [] ]) : int
Parameters
$status : mixed = null

The status of the service changes to fetch, or null for all

$service_id : int = null

The ID of the service the service change belongs to (optional)

$filters : array<string|int, mixed> = []

A list of parameters to filter by, including:

  • service_id The ID of the service (optional)
  • invoice_id The ID of the invoice (optional)
  • invoice The invoice number associated to the service change (optional)
  • date_added The date the service change was created (optional)
  • date_status The date the service change was updated (optional)
Return values
int

The number of service changes

getPresenter()

Retrieves a presenter representing a set of items, discounts, and taxes for a service change (i.e. upgrade/downgrade)

public getPresenter(int $service_id, array<string|int, mixed> $vars) : bool|ServiceChangePresenter
Parameters
$service_id : int

The ID of the service to change

$vars : array<string|int, mixed>

An array of input representing the new service changes:

  • configoptions An array of key/value pairs where each key is an option ID and each value is the selected value
  • pricing_id The ID of the new pricing selected
  • qty The service quantity
  • coupon_code A new coupon code to use
  • date_renews (optional) The new renew date, if it is changing from the service's current renew date
Return values
bool|ServiceChangePresenter

The presenter, otherwise false

getStatuses()

Retrieves a list of available service change statuses and their language

public getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of service change statuses and their language

process()

Processes the pending service change by updating the service

public process(int $service_change_id) : mixed
Parameters
$service_change_id : int

The ID of the pending service change to update

getRules()

Retrieves validation rules for ::add

private getRules(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

An array of input data for validation

Return values
array<string|int, mixed>

The input validation rules

hasDayChanged()

Determines whether the two given dates represent different days

private hasDayChanged(string|null $date1, string|null $date2) : bool
Parameters
$date1 : string|null

The date

$date2 : string|null

The date

Return values
bool

True if the dates given represent different days, otherwise false

objectToArray()

Converts an object and any nested objects into arrays

private objectToArray(stdClass $object) : array<string|int, mixed>
Parameters
$object : stdClass

An stdClass object

Return values
array<string|int, mixed>

An array representing the object and its fields

Tags
subpackage

app.models

copyright

Copyright (c) 2015, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results