本文整理汇总了PHP中Zend_Currency::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Currency::setValue方法的具体用法?PHP Zend_Currency::setValue怎么用?PHP Zend_Currency::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Currency
的用法示例。
在下文中一共展示了Zend_Currency::setValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCurrency
/**
* @param mixed $currency
*/
public function setCurrency($price, $userCurrencyId = null)
{
$cy = new Application_Model_CurrencyMapper();
$currency_id = $cy->getDefaultCurrency()->id;
$code = $cy->find($currency_id)->code;
$currency = null;
if ($userCurrencyId) {
$userCode = $cy->find($userCurrencyId)->code;
$currency = new Zend_Currency(array('value' => 1, 'currency' => $userCode, 'display' => Zend_Currency::USE_SHORTNAME, 'position' => Zend_Currency::RIGHT, 'format' => '#0.# '));
$exService = new My_Class_ExchangeService();
$currency->setService($exService);
$currency->setValue($price, $code);
} else {
$currency = new Zend_Currency(array('value' => $price, 'currency' => $code, 'display' => Zend_Currency::USE_SHORTNAME, 'position' => Zend_Currency::RIGHT, 'format' => '#0.# '));
}
$this->currency = $currency;
}
示例2: formatAmount
/**
* Convenience method
* call $this->formatDate() in the view to access
* the helper
*
* @access public
* @return string
*/
public function formatAmount($amount, $currencyIso = NULL)
{
$formattedAmount = new Zend_Currency();
$formattedAmount->setValue($amount);
if (!is_null($currencyIso)) {
switch ($currencyIso) {
case 'EUR':
$locale = 'es_ES';
break;
case 'GBP':
$locale = 'en_GB';
break;
default:
$locale = 'en_US';
break;
}
$formattedAmount->setLocale($locale);
}
return $formattedAmount;
}
示例3: testSetValueWithoutLocale
/**
* @ZF-9519
*/
public function testSetValueWithoutLocale()
{
$currency = new Zend_Currency('RUB', 'ru_RU');
require_once 'Currency/ExchangeTest.php';
$this->assertEquals(null, $currency->getService());
$currency->setService(new ExchangeTest());
$this->assertTrue($currency->getService() instanceof Zend_Currency_CurrencyInterface);
$currency->setValue(100, 'USD');
$this->assertEquals(50, $currency->getValue());
$this->assertEquals('RUB', $currency->getShortName());
}
示例4: getRIGreaterAmount
/**
*
* @param int $riContract
* @return string
*/
public function getRIGreaterAmount($riContract)
{
$view = Zend_Layout::getMvcInstance()->getView();
$link = '<a href="%s" target="_blank">%s</a>';
$riContractNum = Fefop_Model_Mapper_Contract::buildNumRow($riContract);
$riLink = sprintf($link, $view->baseUrl('/fefop/ri-contract/edit/id/' . $riContract->id_ri_contract), $riContractNum);
$currency = new Zend_Currency();
return sprintf(self::RI_AMOUNT_GREATER, $riLink, $currency->setValue(Fefop_Model_Mapper_RIContract::LIMIT_AMOUNT)->toCurrency(), $currency->setValue($riContract->amount)->toCurrency());
}
示例5: _validateAmountMax
/**
*
* @param Zend_Db_Table_Row $rule
* @throws Exception
*/
protected function _validateAmountMax($rule)
{
$amount = $this->_getAmount();
if ((string) $amount > (string) $rule->value) {
if (!empty($rule->message)) {
$message = $rule->message;
} else {
$currency = new Zend_Currency();
$message = 'Folin hira %s liu folin hira masimu %s';
$message = sprintf($message, $currency->setValue($amount)->toCurrency(), $currency->setValue($rule->value)->toCurrency());
}
$this->_messageModel->addMessage($message, App_Message::ERROR);
if (!empty($rule->required)) {
throw new Exception($message);
}
}
}
示例6: toEntity
public function toEntity($state)
{
$currency = new Zend_Currency();
$currency->setValue($state[$this->getValueFieldName()], $state[$this->getCurrencyFieldName()]);
return $currency;
}
示例7: _saveTransaction
/**
*
* @param array $data
* @return int
*/
protected function _saveTransaction($data)
{
$dbFEFOPTransaction = App_Model_DbTable_Factory::get('FEFOPTransaction');
$dbFEFOPContractFund = App_Model_DbTable_Factory::get('FEFOPContractFund');
$where = array('fk_id_fefop_contract = ?' => $data['fk_id_fefop_contract']);
$contractFund = $dbFEFOPContractFund->fetchRow($where);
if (empty($contractFund)) {
$message = sprintf('Kontratu %s seidauk iha folin husi Fundu.', Fefop_Model_Mapper_Contract::buildNumById($data['fk_id_fefop_contract']));
$this->_message->addMessage($message, App_Message::ERROR);
throw new Exception($message);
}
$mapperBudgetCategory = new Fefop_Model_Mapper_Expense();
$expense = $mapperBudgetCategory->fetchRow($data['fk_id_budget_category']);
$data['fk_id_budget_category_type'] = $expense->fk_id_budget_category_type;
// If the value is already a transaction
if (!empty($data['id_fefop_transaction'])) {
$idTransaction = $data['id_fefop_transaction'];
$where = array('id_fefop_transaction = ?' => $idTransaction);
$row = $dbFEFOPTransaction->fetchRow($where);
}
if (empty($row)) {
$row = $dbFEFOPTransaction->createRow();
$data['fk_id_sysuser'] = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
}
$idContract = $data['fk_id_fefop_contract'];
$idExpense = $data['fk_id_budget_category'];
switch ($data['fk_id_fefop_type_transaction']) {
case self::TYPE_CONTRACT:
$mapperContract = new Fefop_Model_Mapper_Contract();
$contract = $mapperContract->detail($idContract);
$statusForbidden = array(Fefop_Model_Mapper_Status::CANCELLED, Fefop_Model_Mapper_Status::CEASED, Fefop_Model_Mapper_Status::REJECTED);
if (in_array($contract->id_fefop_status, $statusForbidden)) {
$message = sprintf('Kontratu %s ho status %s. Keta halo lansamentu', Fefop_Model_Mapper_Contract::buildNumById($idContract), $contract->status_description);
$this->_message->addMessage($message, App_Message::ERROR);
throw new Exception($message);
}
// Se custos acrescidos
if (Fefop_Model_Mapper_ExpenseType::ADDITIONALS == $data['fk_id_budget_category_type']) {
break;
}
$totalContract = $mapperContract->getTotalContract($idContract);
// Get financial total without additional costs
$totalFinancial = abs($this->getTotalContract($idContract, true));
// Sum up current transaction
$totalFinancial += abs($data['amount']) - (double) $row->amount;
// Check if the total financial is over the contract amount
if ($totalFinancial > $totalContract) {
$currency = new Zend_Currency();
$amount = $currency->setValue($totalContract)->toCurrency();
$message = sprintf('Total Lansamentu hotu-hotu keta liu Total Kontratu hotu-hotu. %s', $amount);
$this->_message->addMessage($message, App_Message::ERROR);
throw new Exception($message);
}
$totalExpenseContract = $mapperContract->getTotalExpenseContract($idContract, $idExpense);
$totalExpenseFinancial = abs($this->getTotalExpenseContract($idContract, $idExpense));
// Sum up current transaction
$totalExpenseFinancial += abs($data['amount']) - (double) $row->amount;
if ($totalExpenseFinancial > $totalExpenseContract) {
$currency = new Zend_Currency();
$amount = $currency->setValue($totalExpenseContract)->toCurrency();
$message = sprintf("Total Rubrika liu Total Rubrika iha Kontratu. %s", $amount);
$this->_message->addMessage($message, App_Message::INFO);
}
break;
case self::TYPE_REIMBURSEMENT:
$totalPaymentsExpense = abs($this->getTotalExpenseContract($idContract, $idExpense, self::TYPE_CONTRACT));
$totalReibursementExpense = abs($this->getTotalExpenseContract($idContract, $idExpense, self::TYPE_REIMBURSEMENT));
// Sum up current transaction
$totalReibursementExpense += abs($data['amount']) - (double) $row->amount;
if ($totalPaymentsExpense <= 0) {
$message = 'Keta halo lansamentu devolusan, seidauk iha lansamentu ba pagamentu ba Rúbrica nee';
$this->_message->addMessage($message, App_Message::ERROR);
throw new Exception($message);
}
if ($totalReibursementExpense > $totalPaymentsExpense) {
$currency = new Zend_Currency();
$amount = $currency->setValue($totalPaymentsExpense)->toCurrency();
$message = 'Keta halo lansamentu devolusan, folin hira nee liu pagamentu hotu ba Rúbrica nee: %s';
$this->_message->addMessage(sprintf($message, $amount), App_Message::ERROR);
throw new Exception($message);
}
break;
}
$row->setFromArray($data);
$row->save();
// Calculate Additional cost proportionality
$this->calcAdditionalCost($data['fk_id_fefop_contract']);
// Try to change contract status
$this->_tryUpdateStatusContract($data['fk_id_fefop_contract']);
return $row;
}
示例8: getFilters
//.........这里部分代码省略.........
}
if (!empty($this->_data['id_profocupationtimor'])) {
$row = App_Model_DbTable_Factory::get('PROFOcupationTimor')->find($this->_data['id_profocupationtimor'])->current();
$filters['ocupationtimor'] = $row->acronym . ' - ' . $row->ocupation_name_timor;
}
if (!empty($this->_data['id_fefpeduinstitution'])) {
$row = App_Model_DbTable_Factory::get('FefpEduInstitution')->find($this->_data['id_fefpeduinstitution'])->current();
$filters['institution'] = $row->institution;
}
if (!empty($this->_data['fk_id_user_inserted'])) {
$row = App_Model_DbTable_Factory::get('SysUser')->find($this->_data['fk_id_user_inserted'])->current();
$filters['user_inserted'] = $row->name;
}
if (!empty($this->_data['fk_id_user_removed'])) {
$row = App_Model_DbTable_Factory::get('SysUser')->find($this->_data['fk_id_user_removed'])->current();
$filters['user_removed'] = $row->name;
}
if (array_key_exists('status', $this->_data) && is_numeric($this->_data['status'])) {
$filters['status_description'] = $this->_data['status'] ? 'Loos' : 'Lae';
}
if (!empty($this->_data['date_registration_ini'])) {
$filters['date_registration_ini'] = $this->_data['date_registration_ini'];
}
if (!empty($this->_data['date_registration_fim'])) {
$filters['date_registration_fim'] = $this->_data['date_registration_fim'];
}
if (!empty($this->_data['num_year'])) {
$filters['num_year'] = $this->_data['num_year'];
}
if (!empty($this->_data['num_sequence'])) {
$filters['num_sequence'] = $this->_data['num_sequence'];
}
if (array_key_exists('minimum_amount', $this->_data) && array_key_exists('maximum_amount', $this->_data)) {
$min = new Zend_Currency('en_US');
$min->setValue($this->_data['minimum_amount']);
$max = new Zend_Currency('en_US');
$max->setValue($this->_data['maximum_amount']);
$filters['minmaxamount'] = $min . ' - ' . $max;
}
if (!empty($this->_data['id_fefop_status']) || !empty($this->_data['fk_id_fefop_status'])) {
$dbFEFOPStatus = App_Model_DbTable_Factory::get('FEFOPStatus');
if (!empty($this->_data['id_fefop_status'])) {
if (!is_array($this->_data['id_fefop_status'])) {
$row = $dbFEFOPStatus->find($this->_data['id_fefop_status'])->current();
$filters['fefop_status'] = $row->status_description;
} else {
$select = $dbFEFOPStatus->select()->from($dbFEFOPStatus, array('status_description'))->where('id_fefop_status IN(?)', $this->_data['id_fefop_status']);
$rows = $dbFEFOPStatus->fetchAll($select);
$filters['fefop_status'] = '';
foreach ($rows as $key => $row) {
$filters['fefop_status'] .= $row->status_description;
if ($rows->count() != ++$key) {
$filters['fefop_status'] .= ', ';
}
}
}
} else {
$row = $dbFEFOPStatus->find($this->_data['fk_id_fefop_status'])->current();
$filters['fefop_status'] = $row->status_description;
}
}
if (!empty($this->_data['id_budget_category_type'])) {
$row = App_Model_DbTable_Factory::get('BudgetCategoryType')->find($this->_data['id_budget_category_type'])->current();
$filters['budget_category_type'] = $row->description;
}
if (!empty($this->_data['type_fefopfund'])) {
if ('G' == $this->_data['type_fefopfund']) {
$filters['description_type_fefopfund'] = 'Governo';
} else {
$filters['description_type_fefopfund'] = 'Donor';
}
}
if (!empty($this->_data['id_beneficiary'])) {
$mapper = new Fefop_Model_Mapper_Contract();
$adapter = App_Model_DbTable_Abstract::getDefaultAdapter();
$select = $adapter->select()->from(array('b' => new Zend_Db_Expr('(' . $mapper->getSelectBeneficiary() . ')')), array('name'))->where('b.id = ?', $this->_data['id_beneficiary']);
$row = $adapter->fetchRow($select);
$filters['beneficiary'] = $row['name'];
}
if (!empty($this->_data['type_beneficiary'])) {
switch ($this->_data['type_beneficiary']) {
case 'fk_id_staff':
$type_beneficiary = 'Empreza Staff';
break;
case 'fk_id_fefpenterprise':
$type_beneficiary = 'Empreza';
break;
case 'fk_id_fefpeduinstitution':
$type_beneficiary = 'Inst Ensinu';
break;
case 'fk_id_perdata':
$type_beneficiary = 'Kliente';
break;
default:
$type_beneficiary = 'N/A';
}
$filters['type_beneficiary'] = $type_beneficiary;
}
return $filters;
}