本文整理汇总了PHP中Currency类的典型用法代码示例。如果您正苦于以下问题:PHP Currency类的具体用法?PHP Currency怎么用?PHP Currency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Currency类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testNiceFormatting
function testNiceFormatting() {
// Test a bunch of different data values and results in Nice() and Whole()
$tests = array(
// Test basic operation
'$50.00' => array('$50.00', '$50'),
// Test removal of junk text
'this is -50.29 dollars' => array('($50.29)', '($50)'),
'this is -50.79 dollars' => array('($50.79)', '($51)'),
'this is 50.79 dollars' => array('$50.79', '$51'),
// Test negative numbers
'-1000' => array('($1,000.00)','($1,000)'),
'-$2,000' => array('($2,000.00)', '($2,000)'),
// Test thousands comma
'5000' => array('$5,000.00', '$5,000'),
// Test scientific notation
'5.68434188608E-14' => array('$0.00', '$0'),
'5.68434188608E7' => array('$56,843,418.86', '$56,843,419'),
"Sometimes Es are still bad: 51 dollars, even though they\'re used in scientific notation" => array('$51.00', '$51'),
"What about 5.68434188608E7 in the middle of a string" => array('$56,843,418.86', '$56,843,419'),
);
foreach($tests as $value => $niceValues) {
$c = new Currency('MyField');
$c->setValue($value);
$this->assertEquals($niceValues[0], $c->Nice());
$this->assertEquals($niceValues[1], $c->Whole());
}
}
开发者ID:redema,项目名称:sapphire,代码行数:32,代码来源:CurrencyTest.php
示例2: display
/**
* @see DashletGenericChart::display()
*/
public function display()
{
global $current_user, $sugar_config;
require "modules/Charts/chartdefs.php";
$chartDef = $chartDefs['lead_source_by_outcome'];
require_once 'include/SugarCharts/SugarChartFactory.php';
$sugarChart = SugarChartFactory::getInstance();
$sugarChart->is_currency = true;
$currency_symbol = $sugar_config['default_currency_symbol'];
if ($current_user->getPreference('currency')) {
$currency = new Currency();
$currency->retrieve($current_user->getPreference('currency'));
$currency_symbol = $currency->symbol;
}
$subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
$sugarChart->setProperties('', $subtitle, $chartDef['chartType']);
$sugarChart->base_url = $chartDef['base_url'];
$sugarChart->group_by = $chartDef['groupBy'];
$sugarChart->url_params = array();
if (count($this->lsbo_ids) > 0) {
$sugarChart->url_params['assigned_user_id'] = array_values($this->lsbo_ids);
}
$sugarChart->getData($this->constuctQuery());
$sugarChart->data_set = $sugarChart->sortData($sugarChart->data_set, 'lead_source', true, 'sales_stage', true, true);
$xmlFile = $sugarChart->getXMLFileName($this->id);
$sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:31,代码来源:OpportunitiesByLeadSourceByOutcomeDashlet.php
示例3: add
/**
* @param money $amount
* @return money
*/
public function add(Money $amount)
{
if (!$this->currency->equals($amount->getCurrency())) {
throw new \InvalidArgumentException('Currency mismatch');
}
return new Money($this->currency, $this->amount + $amount->getValue());
}
开发者ID:rocketpastsix,项目名称:OOPExample,代码行数:11,代码来源:money.php
示例4: __construct
public function __construct($controller, $name = "PostagePaymentForm")
{
// Get delivery data and postage areas from session
$delivery_data = Session::get("Commerce.DeliveryDetailsForm.data");
$country = $delivery_data['DeliveryCountry'];
$postcode = $delivery_data['DeliveryPostCode'];
$postage_areas = $controller->getPostageAreas($country, $postcode);
// Loop through all postage areas and generate a new list
$postage_array = array();
foreach ($postage_areas as $area) {
$area_currency = new Currency("Cost");
$area_currency->setValue($area->Cost);
$postage_array[$area->ID] = $area->Title . " (" . $area_currency->Nice() . ")";
}
$postage_id = Session::get('Commerce.PostageID') ? Session::get('Commerce.PostageID') : 0;
// Setup postage fields
$postage_field = CompositeField::create(HeaderField::create("PostageHeader", _t('Commerce.Postage', "Postage")), OptionsetField::create("PostageID", _t('Commerce.PostageSelection', 'Please select your prefered postage'), $postage_array)->setValue($postage_id))->setName("PostageFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50");
// Get available payment methods and setup payment
$payment_methods = SiteConfig::current_site_config()->PaymentMethods();
// Deal with payment methods
if ($payment_methods->exists()) {
$payment_map = $payment_methods->map('ID', 'Label');
$payment_value = $payment_methods->filter('Default', 1)->first()->ID;
} else {
$payment_map = array();
$payment_value = 0;
}
$payment_field = CompositeField::create(HeaderField::create('PaymentHeading', _t('Commerce.Payment', 'Payment'), 2), OptionsetField::create('PaymentMethodID', _t('Commerce.PaymentSelection', 'Please choose how you would like to pay'), $payment_map, $payment_value))->setName("PaymentFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50");
$fields = FieldList::create(CompositeField::create($postage_field, $payment_field)->setName("PostagePaymentFields")->addExtraClass("units-row")->addExtraClass("line"));
$back_url = $controller->Link("billing");
$actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('doContinue', _t('Commerce.PaymentDetails', 'Enter Payment Details'))->addExtraClass('btn')->addExtraClass('commerce-action-next')->addExtraClass('btn-green'));
$validator = RequiredFields::create(array("PostageID", "PaymentMethod"));
parent::__construct($controller, $name, $fields, $actions, $validator);
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:34,代码来源:PostagePaymentForm.php
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = User::getByUsername('super');
$bobby = UserTestHelper::createBasicUser('bobby');
$sarah = UserTestHelper::createBasicUser('sarah');
self::$superUserId = $super->id;
self::$bobbyUserId = $bobby->id;
self::$sarahUserId = $sarah->id;
$currency = Currency::makeBaseCurrency();
assert($currency->code == 'USD');
// Not Coding Standard
self::$baseCurrencyId = $currency->id;
$currency = new Currency();
$currency->code = 'EUR';
$currency->rateToBase = 2;
assert($currency->save());
// Not Coding Standard
self::$eurCurrencyId = $currency->id;
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestRadioDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestMultiDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestTagCloud');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$loaded = ContactsModule::loadStartingData();
assert($loaded);
// Not Coding Standard
$contactStates = ContactState::getByName('New');
self::$newState = $contactStates[0];
$contactStates = ContactState::getByName('In progress');
self::$inProgressState = $contactStates[0];
self::$groupTest = new Group();
self::$groupTest->name = 'test';
$saved = self::$groupTest->save();
assert($saved);
// Not Coding Standard
$group = Group::getByName(Group::EVERYONE_GROUP_NAME);
$saved = $group->save();
assert($saved);
// Not Coding Standard
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:60,代码来源:WorkflowActionAttributeFormResolveValueTest.php
示例6: contains
/**
* {@inheritdoc}
*/
public function contains(Currency $currency)
{
if (null === self::$currencies) {
self::$currencies = $this->requireCurrencies();
}
return array_key_exists($currency->getCode(), self::$currencies);
}
开发者ID:barryvdh,项目名称:money,代码行数:10,代码来源:ISOCurrencies.php
示例7: display
public function display()
{
$currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
if ($GLOBALS['current_user']->getPreference('currency')) {
require_once 'modules/Currencies/Currency.php';
$currency = new Currency();
$currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
$currency_symbol = $currency->symbol;
}
$this->chartDefName = $this->which_chart[0];
//$chartDef = $this->chartDefs[$this->chartDefName];
$chartDef = array('type' => 'code', 'id' => 'Chart_invoices_by_month', 'label' => 'Invoices by Month', 'chartUnits' => 'Invoice Size in $1K', 'chartType' => 'stacked group by chart', 'groupBy' => array('m', 'state_in_chart'), 'base_url' => array('module' => 'reg_invoices', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search'), 'url_params' => array('state', 'date_closed'));
require_once 'include/SugarCharts/SugarChartFactory.php';
// Special chart config for RegInvoices
$sugarChart = SugarChartFactory::getInstance('Jit', 'RegInvoices');
$sugarChart->setProperties('', translate('LBL_FACT_SIZE', 'reg_invoices') . ' ' . $currency_symbol . '1' . translate('LBL_OPP_THOUSANDS', 'Charts'), $chartDef['chartType']);
$sugarChart->base_url = $chartDef['base_url'];
$sugarChart->is_currency = true;
$sugarChart->group_by = $chartDef['groupBy'];
$sugarChart->url_params = array();
$sugarChart->getData($this->constructQuery());
$this->sortData($sugarChart->data_set);
$xmlFile = $sugarChart->getXMLFileName($this->id);
$sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />';
}
开发者ID:pixprod,项目名称:Regoluna-Invoices-for-SugarCRM,代码行数:26,代码来源:RegInvoicesChartDashlet.php
示例8: test_formats_amount_3
public function test_formats_amount_3()
{
$eur = new Currency('EUR');
$this->assertEquals('560,00', $eur->format(new Decimal2('560.00')));
$this->assertEquals('-1.560,00', $eur->format(new Decimal2('-1560.00')));
$this->assertEquals('-100.000.000.000,00', $eur->format(new Decimal2('-100000000000.00')));
}
开发者ID:adispartadev,项目名称:money-math-php,代码行数:7,代码来源:CurrencyTest.php
示例9: handleUpdate
function handleUpdate()
{
global $current_user;
if ($current_user->is_admin) {
if (isset($_POST['id']) && !empty($_POST['id']) && isset($_POST['name']) && !empty($_POST['name']) && isset($_POST['rate']) && !empty($_POST['rate']) && isset($_POST['symbol']) && !empty($_POST['symbol'])) {
$ids = $_POST['id'];
$names = $_POST['name'];
$symbols = $_POST['symbol'];
$rates = $_POST['rate'];
$isos = $_POST['iso'];
$size = sizeof($ids);
if ($size != sizeof($names) || $size != sizeof($isos) || $size != sizeof($symbols) || $size != sizeof($rates)) {
return;
}
require_once 'modules/Currencies/Currency.php';
$temp = new Currency();
for ($i = 0; $i < $size; $i++) {
$temp->id = $ids[$i];
$temp->name = $names[$i];
$temp->symbol = $symbols[$i];
$temp->iso4217 = $isos[$i];
$temp->conversion_rate = $rates[$i];
$temp->save();
}
}
}
}
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:27,代码来源:ListCurrency.php
示例10: getConversionMultiplier
/**
* @param Currency $from
* @param Currency $to
* @return string
* @throws \RuntimeException
*/
public function getConversionMultiplier(Currency $from, Currency $to)
{
$rates = $this->getConversionRatesTable($from);
if (!isset($rates[$to->getCode()])) {
throw new \RuntimeException(sprintf('The target currency "%s" is not present in the conversion rates table.', $to->getCode()));
}
return $rates[$to->getCode()];
}
开发者ID:superbalist,项目名称:php-money,代码行数:14,代码来源:BaseCurrencyConversionService.php
示例11: orderByPrice
public function orderByPrice(Currency $currency, $direction = 'ASC')
{
if ('ASC' != $direction) {
$direction = 'DESC';
}
$currency->defineProductJoin($this->selectFilter);
$this->selectFilter->setOrder(new ARFieldHandle($currency->getJoinAlias(), 'price'), $direction);
}
开发者ID:GregerA,项目名称:livecart,代码行数:8,代码来源:ProductFilter.php
示例12: getInstance
/**
* Create an object or return existing one.
*
* <code>
* $currencyId = 1;
*
* $currency = Crowdfunding\Currency::getInstance(\JFactory::getDbo(), $currencyId);
* </code>
*
* @param \JDatabaseDriver $db
* @param int $id
*
* @return null|self
*/
public static function getInstance(\JDatabaseDriver $db, $id)
{
if (!isset(self::$instances[$id])) {
$item = new Currency($db);
$item->load($id);
self::$instances[$id] = $item;
}
return self::$instances[$id];
}
开发者ID:bharatthakkar,项目名称:CrowdFunding,代码行数:23,代码来源:Currency.php
示例13: convertToPHPValue
/**
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if (!array_key_exists($value, Intl::getCurrencyBundle()->getCurrencyNames())) {
throw new \RuntimeException(sprintf("'%d' is not a supported currency.", $value));
}
$currency = new Currency();
$currency->setLabel($value);
return $currency;
}
开发者ID:brother79,项目名称:brother-cms-bundle,代码行数:12,代码来源:CurrencyDoctrineType.php
示例14: display
function display()
{
global $app_list_strings;
$this->ss->assign('APP_LIST', $app_list_strings);
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'set_target') {
require_once 'modules/Campaigns/utils.php';
//call function to create campaign logs
$mess = track_campaign_prospects($this->bean);
$confirm_msg = "var ajax_C_LOG_Status = new SUGAR.ajaxStatusClass(); \n window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",1000); \n window.setTimeout('ajax_C_LOG_Status.hideStatus()', 1500); \n window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",2000); \n window.setTimeout('ajax_C_LOG_Status.hideStatus()', 5000); ";
$this->ss->assign("MSG_SCRIPT", $confirm_msg);
}
if ($this->bean->campaign_type == 'Email' || $this->bean->campaign_type == 'NewsLetter') {
$this->ss->assign("ADD_BUTTON_STATE", "submit");
$this->ss->assign("TARGET_BUTTON_STATE", "hidden");
} else {
$this->ss->assign("ADD_BUTTON_STATE", "hidden");
$this->ss->assign("DISABLE_LINK", "display:none");
$this->ss->assign("TARGET_BUTTON_STATE", "submit");
}
$currency = new Currency();
if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) {
$currency->retrieve($this->bean->currency_id);
if ($currency->deleted != 1) {
$this->ss->assign('CURRENCY', $currency->iso4217 . ' ' . $currency->symbol);
} else {
$this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
}
} else {
$this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
}
parent::display();
//We want to display subset of available, panels, so we will call subpanel
//object directly instead of using sugarview.
$GLOBALS['focus'] = $this->bean;
require_once 'include/SubPanel/SubPanelTiles.php';
$subpanel = new SubPanelTiles($this->bean, $this->module);
//get available list of subpanels
$alltabs = $subpanel->subpanel_definitions->get_available_tabs();
if (!empty($alltabs)) {
//iterate through list, and filter out all but 3 subpanels
foreach ($alltabs as $key => $name) {
if ($name != 'prospectlists' && $name != 'emailmarketing' && $name != 'tracked_urls') {
//exclude subpanels that are not prospectlists, emailmarketing, or tracked urls
$subpanel->subpanel_definitions->exclude_tab($name);
}
}
//only show email marketing subpanel for email/newsletter campaigns
if ($this->bean->campaign_type != 'Email' && $this->bean->campaign_type != 'NewsLetter') {
//exclude emailmarketing subpanel if not on an email or newsletter campaign
$subpanel->subpanel_definitions->exclude_tab('emailmarketing');
// Bug #49893 - 20120120 - Captivea (ybi) - Remove trackers subpanels if not on an email/newsletter campaign (useless subpannl)
$subpanel->subpanel_definitions->exclude_tab('tracked_urls');
}
}
//show filtered subpanel list
echo $subpanel->display();
}
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:57,代码来源:view.detail.php
示例15: perform_save
function perform_save(&$focus)
{
//US DOLLAR
if (isset($focus->amount) && !number_empty($focus->amount)) {
$currency = new Currency();
$currency->retrieve($focus->currency_id);
$focus->amount_usdollar = $currency->convertToDollar($focus->amount);
}
}
开发者ID:klr2003,项目名称:sourceread,代码行数:9,代码来源:SaveOverload.php
示例16: actionDate
public function actionDate($date = null)
{
$model = new Currency('search');
$model->unsetAttributes();
if (isset($_GET['Currency'])) {
$model->setAttributes($_GET['Currency']);
}
$model->date = date('Y-m-d', strtotime($date));
$this->render('index', ['baseUrl' => Yii::app()->urlManager->createUrl('currency/currencyAdmin/index'), 'refreshUrl' => Yii::app()->urlManager->createUrl('currency/currencyAdmin/parse'), 'date' => $date, 'model' => $model]);
}
开发者ID:VitProg,项目名称:nas-test-app,代码行数:10,代码来源:CurrencyAdminController.php
示例17: getConversionRatesTable
/**
* @param Currency $currency
* @return array
*/
public function getConversionRatesTable(Currency $currency)
{
switch ($currency->getCode()) {
case 'USD':
return array('USD' => '1', 'ZAR' => '12.07682');
default:
// ZAR
return array('USD' => '0.082776', 'ZAR' => '1');
}
}
开发者ID:superbalist,项目名称:php-money,代码行数:14,代码来源:MockCurrencyConversionService.php
示例18: perform_save
function perform_save(&$focus)
{
require_once 'modules/Currencies/Currency.php';
//US DOLLAR
if (isset($focus->price) && !number_empty($focus->price)) {
$currency = new Currency();
$currency->retrieve($focus->currency_id);
$focus->price_usdollar = $currency->convertToDollar(unformat_number($focus->price));
}
}
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:10,代码来源:SaveOverload.php
示例19: getAvailableCurrencyAsArray
/**
* Get available currency.
*
*/
public static function getAvailableCurrencyAsArray()
{
$table = new Currency();
$where = $table->select()->where("enabled=?", true);
$currencies = $table->fetchAll($where);
$arr = array();
foreach ($currencies as $currency) {
$arr[$currency->id] = $currency->display_cn;
}
return $arr;
}
开发者ID:BGCX262,项目名称:zufangzi-svn-to-git,代码行数:15,代码来源:Currency.php
示例20: Currency
/**
* Overriding display of value of currency because of currencies are not stored in app_list_strings
*
* @param array $layout_def
* @return string for display
*/
public function &displayListPlain($layout_def)
{
static $currencies;
$value = $this->_get_list_value($layout_def);
if (empty($currencies[$value])) {
$currency = new Currency();
$currency->retrieve($value);
$currencies[$value] = $currency->symbol . ' ' . $currency->iso4217;
}
return $currencies[$value];
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:17,代码来源:SugarWidgetFieldcurrency_id.php
注:本文中的Currency类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论