Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Accounts
  • ApiKeys
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • ModuleClientMeta
  • ModuleManager
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • Taxes
  • Themes
  • Transactions
  • Users

Class Currencies

Currency Management

Model
Extended by AppModel
Extended by Currencies
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/currencies.php

Methods summary

public
# __construct( )

Initialize Currencies

Initialize Currencies

Overrides

AppModel::__construct
public mixed
# getList( integer $company_id, integer $page = 1, string $order_by = array('code'=>"ASC") )

Fetches a list of all currencies for a given company

Fetches a list of all currencies for a given company

Parameters

$company_id
integer
$company_id The ID of the company to fetch currencies for
$page
integer
$page The page to return results for (optional, default 1)
$order_by
string
$order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)

Returns

mixed
An array of stdClass objects representing currencies, false if no currencies found
public integer
# getListCount( integer $company_id )

Returns the total number of currencies returned from Currencies::getList(), useful in constructing pagination for the getList() method.

Returns the total number of currencies returned from Currencies::getList(), useful in constructing pagination for the getList() method.

Parameters

$company_id
integer
$company_id The ID of the company to fetch currencies for

Returns

integer
The total number of currencies

See

Currencies::getList()
public mixed
# getAll( integer $company_id )

Fetches a full list of all currencies for a given company

Fetches a full list of all currencies for a given company

Parameters

$company_id
integer
$company_id The ID of the company to fetch currencies for

Returns

mixed
An array of stdClass objects representing all currencies, or false if no currencies found
public mixed
# get( string $currency_code, integer $company_id )

Fetches a currency using the given currency code

Fetches a currency using the given currency code

Parameters

$currency_code
string
$currency_code The ISO 4217 currency code to fetch on
$company_id
integer
$company_id The ID of the company whose currency to fetch

Returns

mixed
stdClass object representing the currency if it exists, false otherwise
public array
# getFormats( )

Returns an array containing every supported currency format with an example in key/value pairs

Returns an array containing every supported currency format with an example in key/value pairs

Returns

array
An array of currency formats in key/value pairs where the key is the format and the value is an example
public
# add( array $vars )

Adds a new currency

Adds a new currency

Parameters

$vars
array
$vars An array of currency info including: - code The ISO 4217 currency code - company_id The Company ID - format The format code to use for this currency - precision The decimal precision to use for this currency - prefix The prefix to use for this currency - suffix The suffix to use for this currency - exchange_rate The exchange rate in relation to the primary currency - exchange_updated The datetime the exchange_rate was last updated
public
# edit( string $currency_code, integer $company_id, array $vars )

Edits an existing currency

Edits an existing currency

Parameters

$currency_code
string
$currency_code The ISO 4217 currency code we are updating
$company_id
integer
$company_id The Company ID for this currency code
$vars
array
$vars An array of currency info including: - format The format code to use for this currency - precision The decimal precision to use for this currency - prefix The prefix to use for this currency - suffix The suffix to use for this currency - exchange_rate The exchange rate in relation to the primary currency - exchange_updated The datetime the exchange_rate was last updated
public
# delete( string $currency_code, integer $company_id )

Deletes an existing currency

Deletes an existing currency

Parameters

$currency_code
string
$currency_code The ISO 4217 currency code we are deleting
$company_id
integer
$company_id The Company ID for this currency code
public float
# convert( float $amount, string $from_currency, string $to_currency, integer $company_id )

Converts an amount from one currency to another using the exchange rate

Converts an amount from one currency to another using the exchange rate

Parameters

$amount
float
$amount The amount to convert
$from_currency
string
$from_currency The ISO 4217 currency code format representing $amount
$to_currency
string
$to_currency The ISO 4217 currency code to format to
$company_id
integer
$company_id The ID of the company

Returns

float
The $amount converted between currencies
public string
# toDecimal( string $value, string $currency, integer $company_id = null, integer $decimals = 2 )

Converts a currency value into a decimal representation based on ISO 31-0

Converts a currency value into a decimal representation based on ISO 31-0

Parameters

$value
string
$value A currency value
$currency
string
$currency The ISO 4217 currency code format representing $value
$company_id
integer
$company_id The company ID to fetch the currency for
$decimals
integer
$decimals The number of decimals points (precision)

Returns

string
The value in decimal format based on ISO 31-0

See

Currencies::toCurrency()
public string
# toCurrency( float $value, string $currency, integer $company_id = null, boolean $prefix = true, boolean $suffix = true, boolean $code = false, boolean $with_separator = true, integer $decimals = 2 )

Converts the given decimal value into a currency value.

Converts the given decimal value into a currency value.

Parameters

$value
float
$value The decimal value to convert
$currency
string
$currency The ISO 4217 currency code format to apply to $value
$company_id
integer
$company_id The company ID to fetch the currency for
$prefix
boolean
$prefix True to include the prefix symbol for this currency, false otherwise
$suffix
boolean
$suffix True to include the suffix symbol for this currency, false otherwise
$code
boolean
$code True to include the currency code for this currency, false otherwise
$with_separator
boolean
$with_separator True to include the separator for this currency, false otherwise
$decimals
integer
$decimals The number of decimal places (precision)

Returns

string
The value formatted for the specified currency

See

Currencies::toDecimal()
Currencies::toCurrencyValue()
public string
# toCurrencyValue( float $value, string $currency, boolean $with_separator = true, integer $company_id = null, integer $decimals = 2 )

Converts the given decimal value into a currency value excluding the prefix, suffix, and currency code symbols

Converts the given decimal value into a currency value excluding the prefix, suffix, and currency code symbols

Parameters

$value
float
$value The decimal value to convert
$currency
string
$currency The ISO 4217 currency code format to apply to $value
$with_separator
boolean
$with_separator True to include the separator for this currency, false otherwise
$company_id
integer
$company_id The company ID to fetch the currency for
$decimals
integer
$decimals The number of decimal places (precision)

Returns

string
The value formatted for the specified currency

See

Currencies::toCurrency()
public boolean
# validateCurrencyInUse( string $currency_code, integer $company_id )

Checks if a currency code is currently in use

Checks if a currency code is currently in use

Parameters

$currency_code
string
$currency_code The ISO 4217 currency code to check
$company_id
integer
$company_id The company ID whose currency to check

Returns

boolean
True if the currency code is in use, false otherwise
public boolean
# validateCurrencyIsDefault( string $currency_code, integer $company_id )

Checks if the given currency code is set as the default currency

Checks if the given currency code is set as the default currency

Parameters

$currency_code
string
$currency_code The ISO 4217 currency code to check
$company_id
integer
$company_id The company ID whose default currency to check

Returns

boolean
True if the currency is the default currency for this company, false otherwise
public boolean
# validateCurrencyFormat( string $format )

Validates a currency's 'format' field

Validates a currency's 'format' field

Parameters

$format
string
$format The format to check, (e.g. "#.###")

Returns

boolean
True if validated, false otherwise
public boolean
# validateCurrencyExists( string $code, integer $company_id )

Validates a currency exists

Validates a currency exists

Parameters

$code
string
$code The currency code
$company_id
integer
$company_id The company ID

Returns

boolean
True if the currency exists, false otherwise
public array
# getExchangeRateProcessors( )

Retrieves a list of exchange rate processors

Retrieves a list of exchange rate processors

Returns

array
A list of exchange rate processors
public
# updateRates( )

Updates all currency exchange rates for the current company using the configured processor.

Updates all currency exchange rates for the current company using the configured processor.

Methods inherited from AppModel

_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()

Methods inherited from Model

affectedRows(), begin(), commit(), getConnection(), lastInsertId(), makeDSN(), prepare(), query(), rollBack(), setAttribute(), setFetchMode()

Magic methods summary

Properties summary

Properties inherited from AppModel

$replacement_keys

Blesta API documentation generated by ApiGen 2.8.0