本文整理汇总了PHP中Currency::getDefaultCurrencyModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::getDefaultCurrencyModel方法的具体用法?PHP Currency::getDefaultCurrencyModel怎么用?PHP Currency::getDefaultCurrencyModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::getDefaultCurrencyModel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (!$this->userId) {
$this->userId = Yii::app()->user->id;
}
$info = TariffPlans::getTariffInfoByUserId($this->userId);
$this->render('userTariffInfoViewWidget', array('id' => $info['id'], 'name' => $info['name'], 'description' => $info['description'], 'limitObjects' => $info['limitObjects'], 'limitPhotos' => $info['limitPhotos'], 'price' => $info['price'], 'duration' => $info['duration'], 'showAddress' => $info['showAddress'], 'showPhones' => $info['showPhones'], 'currency' => Currency::getDefaultCurrencyModel()->name, 'userCountObjects' => TariffPlans::getCountUserObjects($this->userId), 'tariffDateStart' => $info['tariffDateStart'], 'tariffDateEnd' => $info['tariffDateEnd'], 'tariffStatus' => $info['tariffStatus'], 'tariffDateStartFormat' => $info['tariffDateStartFormat'], 'tariffDateEndFormat' => $info['tariffDateEndFormat'], 'isDefaultTariffPlan' => $info['id'] == TariffPlans::DEFAULT_TARIFF_PLAN_ID ? true : false));
}
示例2: setCurrency
function setCurrency()
{
if (isset($_GET['currency'])) {
setCurrencyCookie(CHtml::encode($_GET['currency']));
}
// Админ деактивирует валюту, а у пользователя есть кука с уже деактивированной валютой.
// Надо сбросить ему куку.
if (isset(Yii::app()->request->cookies['_currency'])) {
$charCode = Yii::app()->request->cookies['_currency']->value;
$activeCurrency = Currency::getActiveCurrency();
if (!isset($activeCurrency[$charCode])) {
setCurrencyCookie(Currency::getDefaultCurrencyModel()->char_code);
}
}
}
示例3: tc
<div id="price_fields">
<?php
echo CHtml::hiddenField('is_update', 0);
// if (issetModule('currency')) {
// echo '<div class="padding-bottom10"><small>' . tt('Price will be saved (converted) in the default currency on the site', 'apartments') . ' - ' . Currency::getDefaultCurrencyModel()->name . '</small></div>';
// }
if ($model->isPriceFromTo()) {
echo tc('price_from') . ' ' . $form->textField($model, 'price', array('class' => 'width100 noblock'));
echo ' ' . tc('price_to') . ' ' . $form->textField($model, 'price_to', array('class' => 'width100'));
} else {
echo $form->textField($model, 'price', array('class' => 'width100'));
}
if (issetModule('currency')) {
// Даем вводить ценую только в дефолтной валюте
echo ' ' . Currency::getDefaultCurrencyName();
$model->in_currency = Currency::getDefaultCurrencyModel()->char_code;
echo $form->hiddenField($model, 'in_currency');
// $form->dropDownList($model, 'in_currency', Currency::getActiveCurrencyArray(2), array('class' => 'width120'))
} else {
echo ' ' . param('siteCurrency', '$');
}
if ($model->type == Apartment::TYPE_RENT) {
$priceArray = Apartment::getPriceArray($model->type);
if (!in_array($model->price_type, array_keys($priceArray))) {
$model->price_type = Apartment::PRICE_PER_MONTH;
}
echo ' ' . $form->dropDownList($model, 'price_type', Apartment::getPriceArray($model->type), array('class' => 'width150'));
}
?>
</div>
示例4:
echo $form->dropDownList($model, 'paid_service_id', PaidServices::getListForEdit());
?>
<?php
echo $form->error($model, 'paid_service_id');
?>
</div>
<div class="rowold">
<?php
echo $form->labelEx($model, 'price');
?>
<?php
echo $form->textField($model, 'price');
?>
<span><?php
echo Currency::getDefaultCurrencyModel()->name;
?>
</span>
<?php
echo $form->error($model, 'price');
?>
</div>
<div class="rowold">
<?php
echo $form->labelEx($model, 'duration_days');
?>
<?php
echo $form->textField($model, 'duration_days');
?>
<?php
示例5: setDefault
public function setDefault()
{
@set_time_limit(0);
@ini_set('max_execution_time', 0);
if ($this->is_default || !$this->active) {
return false;
}
$packetNum = 100;
if ($this->convert_data) {
$char_code_from = Currency::getDefaultCurrencyModel()->char_code;
$char_code_to = $this->char_code;
//deb($char_code_from . ' - ' . $char_code_to); exit;
foreach ($this->_modelsWithCurrencyField as $modelName) {
$model = new $modelName();
$table = $model->tableName();
$modelCurrencyFields = $model->currencyFields();
foreach ($modelCurrencyFields as $field) {
$sql = "SELECT `id`, `{$field}` FROM {$table}";
$allIds = Yii::app()->db->createCommand($sql)->queryAll();
$i = 0;
$sqlArr = array();
foreach ($allIds as $item) {
if ($item[$field] <= 0) {
continue;
}
$convertValue = (int) $this->convert($item[$field], $char_code_from, $char_code_to);
$sqlArr[] = "UPDATE {$table} SET `{$field}`={$convertValue} WHERE id=" . $item['id'] . ";";
$i++;
if ($i >= $packetNum) {
$sql = implode("\n", $sqlArr);
//logs($sql);
Yii::app()->db->createCommand($sql)->execute();
$sqlArr = array();
$i = 0;
}
}
if ($sqlArr) {
$sql = implode("\n", $sqlArr);
//logs($sql);
Yii::app()->db->createCommand($sql)->execute();
}
}
}
}
$this->scenario = 'set_default';
$this->is_default = 1;
$this->update('is_default');
self::$_defaultCurrencyModel = null;
return true;
}
示例6: getDescriptionForBuy
public function getDescriptionForBuy()
{
$html = '';
$description = $this->getDescription();
if ($description) {
$html .= '<div class="buy_descr_tariff">' . $description . '</div>';
}
if ($this->price) {
$html .= '<div class="buy_price_tariff">' . tt('Price', 'tariffPlans') . ': <strong>' . $this->price . '</strong> ' . Currency::getDefaultCurrencyModel()->name . '</div>';
} else {
$html .= '<div class="buy_price_tariff">' . tt('Price', 'tariffPlans') . ': <span class="tariff_unlimited">' . tt('Price is free', 'tariffPlans') . '</span></div>';
}
if ($this->duration) {
$html .= '<div class="buy_duration_tariff">' . tt('Duration', 'tariffPlans') . ': <strong>' . $this->duration . '</strong> ' . tt('days', 'tariffPlans') . '</div>';
} else {
$html .= '<div class="buy_duration_tariff">' . tt('Duration', 'tariffPlans') . ': <span class="tariff_unlimited">' . tt('Unlimited', 'tariffPlans') . '</span></div>';
}
if ($this->limit_objects) {
$html .= '<div class="buy_objects_tariff">' . tt('Limit_objects', 'tariffPlans') . ': <strong>' . $this->limit_objects . '</strong></div>';
} else {
$html .= '<div class="buy_objects_tariff">' . tt('Limit_objects', 'tariffPlans') . ': <span class="tariff_unlimited">' . tt('Unlimited', 'tariffPlans') . '</span></div>';
}
if ($this->limit_photos) {
$html .= '<div class="buy_photos_tariff">' . tt('Limit_photos', 'tariffPlans') . ': <strong>' . $this->limit_photos . '</strong></div>';
} else {
$html .= '<div class="buy_photos_tariff">' . tt('Limit_photos', 'tariffPlans') . ': <span class="tariff_unlimited">' . tt('Unlimited', 'tariffPlans') . '</span></div>';
}
if ($this->show_address) {
$html .= '<div class="buy_on_map_tariff">' . tt('Show_address', 'tariffPlans') . ': <strong>' . tc('Yes') . '</strong></div>';
} else {
$html .= '<div class="buy_on_map_tariff">' . tt('Show_address', 'tariffPlans') . ': <strong>' . tc('No') . '</strong></div>';
}
if ($this->show_phones) {
$html .= '<div class="buy_on_map_tariff">' . tt('Show_phones', 'tariffPlans') . ': <strong>' . tc('Yes') . '</strong></div>';
} else {
$html .= '<div class="buy_on_map_tariff">' . tt('Show_phones', 'tariffPlans') . ': <strong>' . tc('No') . '</strong></div>';
}
return $html;
}
示例7: beforeSave
public function beforeSave()
{
if (!$this->square) {
$this->square = 0;
}
/***изменено - вставляем пустые значения */
if (!$this->title_ru) {
$this->title_ru = '';
}
if (!$this->description_ru) {
$this->description_ru = '';
}
if (!$this->description_near_ru) {
$this->description_near_ru = '';
}
if (!$this->address_ru) {
$this->address_ru = '';
}
if (!$this->date_up_search) {
$timestamp = '01/01/2100 00:00:00';
$timestamp = DateTime::createFromFormat('d/m/Y H:i:s', $timestamp);
$this->date_up_search = $timestamp->format('Y-m-d H:i:s');
}
if (!$this->is_special_offer) {
$this->is_special_offer = '';
}
if (!$this->is_free_from) {
$timestamp = '01/01/2000 00:00:00';
$timestamp = DateTime::createFromFormat('d/m/Y H:i:s', $timestamp);
$this->is_free_from = $timestamp->format('Y-m-d H:i:s');
}
if (!$this->is_free_to) {
$timestamp = '01/01/2100 00:00:00';
$timestamp = DateTime::createFromFormat('d/m/Y H:i:s', $timestamp);
$this->is_free_to = $timestamp->format('Y-m-d H:i:s');
}
if (!$this->exchange_to_ru) {
$this->exchange_to_ru = '';
}
if (!$this->note) {
$this->note = '';
}
if (!$this->phone) {
$this->phone = '';
}
if (!$this->sublocation_id) {
$this->sublocation_id = 0;
}
if (!$this->location_id) {
$this->location_id = '';
}
if (!$this->price_old) {
$this->price_old = 0;
}
/*************************/
if (!$this->land_square) {
$this->land_square = 0;
}
if ($this->isNewRecord) {
$this->owner_id = $this->owner_id ? $this->owner_id : Yii::app()->user->id;
$userInfo = User::model()->findByPk($this->owner_id, array('select' => 'isAdmin'));
if ($userInfo && $userInfo->isAdmin == 1) {
$this->owner_active = self::STATUS_ACTIVE;
}
if ($this->active != Apartment::STATUS_DRAFT) {
// if admin
if ($userInfo && $userInfo->isAdmin == 1) {
$this->active = Apartment::STATUS_ACTIVE;
} else {
if (param('useUseradsModeration')) {
$this->active = self::STATUS_MODERATION;
}
}
}
$maxSorter = Yii::app()->db->createCommand()->select('MAX(sorter) as maxSorter')->from($this->tableName())->queryScalar();
$this->sorter = $maxSorter + 1;
if ($this->obj_type_id == 0) {
$this->obj_type_id = Yii::app()->db->createCommand('SELECT MIN(id) FROM {{apartment_obj_type}}')->queryScalar();
}
}
if (!isFree()) {
$defaultCurrencyCharCode = Currency::getDefaultCurrencyModel()->char_code;
if ($defaultCurrencyCharCode != $this->in_currency) {
$this->price = (int) Currency::convert($this->price, $this->in_currency, $defaultCurrencyCharCode);
if (isset($this->price_to) && $this->price_to) {
$this->price_to = (int) Currency::convert($this->price_to, $this->in_currency, $defaultCurrencyCharCode);
}
}
}
switch ($this->type) {
case self::TYPE_SALE:
$this->price_type = self::PRICE_SALE;
break;
case self::TYPE_BUY:
$this->price_type = self::PRICE_BUY;
break;
case self::TYPE_RENTING:
$this->price_type = self::PRICE_RENTING;
break;
case self::TYPE_CHANGE:
//.........这里部分代码省略.........
示例8: tt
<?php
$this->pageTitle = Yii::app()->name . ' - ' . tt('Manage tariff plans', 'tariffPlans');
$this->menu = array(array('label' => tt('Add tariff plan'), 'url' => array('create')));
$this->adminTitle = tt('Manage tariff plans', 'tariffPlans');
$this->widget('CustomGridView', array('id' => 'tariff-plans-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove();}', 'columns' => array(array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnStatusHtml($data, "tariff-plans-grid", 1, TariffPlans::DEFAULT_TARIFF_PLAN_ID)', 'htmlOptions' => array('class' => 'infopages_status_column'), 'filter' => false, 'sortable' => false), 'name', array('name' => 'show_address', 'value' => '($data->show_address) ? tc("Yes") : tc("No")', 'sortable' => false, 'filter' => array(0 => tc('No'), 1 => tc('Yes'))), array('name' => 'show_phones', 'value' => '($data->show_phones) ? tc("Yes") : tc("No")', 'sortable' => false, 'filter' => array(0 => tc('No'), 1 => tc('Yes'))), array('name' => 'limit_objects', 'value' => '$data->getLimitObjectForGrid()', 'sortable' => false), array('name' => 'limit_photos', 'value' => '$data->getLimitPhotosForGrid()', 'sortable' => false), array('header' => tt('Price', 'tariffPlans') . ', (' . Currency::getDefaultCurrencyModel()->name . ')', 'name' => 'price', 'value' => '$data->getPriceForGrid()', 'sortable' => false), array('header' => tt('Duration', 'tariffPlans') . ', (' . tt('days') . ')', 'name' => 'duration', 'value' => '$data->getDurationForGrid()', 'sortable' => false), array('class' => 'bootstrap.widgets.TbButtonColumn', 'deleteConfirmation' => tt('Are you sure you want to delete this item? All user tariffs will also be deleted!'), 'template' => '{update}{delete}', 'buttons' => array('delete' => array('visible' => '$data->id != TariffPlans::DEFAULT_TARIFF_PLAN_ID'))))));
示例9: actionIndex
public function actionIndex()
{
if (Yii::app()->user->isGuest) {
throw404();
}
$this->setActiveMenu('my_payments');
$request = Yii::app()->request;
$ad_id = $request->getParam('id', 0);
$paid_id = $request->getParam('paid_id');
$isFancy = $request->getParam('isFancy', 0);
$paySubmit = $request->getParam('pay_submit');
$tariffId = $request->getParam('tariffid', 0);
if ($paySubmit) {
$optionId = $request->getParam('option_id');
$paySystemId = $request->getParam('pay_id');
$amount = $request->getParam('amount', 0);
$error = 0;
// Если это поплнение баланса
if ($paid_id == PaidServices::ID_ADD_FUNDS && $amount <= 0) {
$this->setActiveMenu('my_balance');
Yii::app()->user->setFlash('error', tc('Please specify the amount of the payment'));
$error = 1;
}
Yii::app()->getModule('payment');
$paysystem = Paysystem::model()->findByPk($paySystemId);
if (!$paysystem) {
throw404();
}
# покупка тарифного плана
if ($tariffId && issetModule('tariffPlans')) {
$tariffPlanInfo = TariffPlans::getFullTariffInfoById($tariffId);
$paidOption = new PaidOptions();
$paidOption->id = 0;
if (!$tariffPlanInfo || $tariffPlanInfo['active'] == TariffPlans::STATUS_INACTIVE) {
throw404();
}
if ($tariffPlanInfo['price'] && $tariffPlanInfo['price'] > 0) {
// Если оплата тарифа с баланса пользователя
if ($paySystemId == Paysystem::ID_BALANCE) {
$user = User::model()->findByPk(Yii::app()->user->id);
if ($user->balance < $tariffPlanInfo['price']) {
Yii::app()->user->setFlash('error', tc('Please refill the balance'));
$error = 2;
$this->redirect(array('/tariffPlans/main/index'));
}
}
} else {
# бесплатный тариф
Yii::app()->user->setFlash('error', tt('Selected tariff plan is free. Please contact the site administrator for transit to this tariff.', 'tariffPlans'));
$error = 2;
$this->redirect(array('/tariffPlans/main/index'));
}
} else {
if ($paid_id != PaidServices::ID_ADD_FUNDS) {
$ad = Apartment::model()->findByPk($ad_id);
$paidOption = PaidOptions::model()->findByPk($optionId);
if (!$ad || !$paidOption || !isset($paidOption->paidService)) {
throw404();
}
// Если оплата платной услуги с баланса пользователя
if ($paySystemId == Paysystem::ID_BALANCE) {
$user = User::model()->findByPk(Yii::app()->user->id);
if ($user->id != $ad->owner_id || $ad->deleted) {
throw404();
}
if ($user->balance < $paidOption->price) {
Yii::app()->user->setFlash('error', tc('Please refill the balance'));
$error = 2;
}
}
}
}
$paysystem->createPayModel();
if ($paysystem->payModel === null) {
throw404();
}
if ($error == 0) {
// Создаем платеж и ставим ему статус "Ожидает оплаты"
$payment = new Payments();
$payment->user_id = Yii::app()->user->id;
$payment->paid_id = $paid_id;
if ($paid_id != PaidServices::ID_ADD_FUNDS) {
$payment->paid_option_id = $paidOption->id;
}
$payment->apartment_id = $ad_id;
$payment->tariff_id = $tariffId;
if ($tariffId && issetModule('tariffPlans')) {
$payment->amount = $tariffPlanInfo['price'];
} else {
$payment->amount = $paid_id == PaidServices::ID_ADD_FUNDS ? $amount : $paidOption->price;
}
$payment->currency_charcode = Currency::getDefaultCurrencyModel()->char_code;
$payment->status = Payments::STATUS_WAITPAYMENT;
$payment->paysystem_id = $paysystem->id;
$payment->save();
/*echo '<pre>';
print_r($payment->getErrors());
echo '</pre>';
exit;*/
// Передаем платеж на обработку в модель платежки.
//.........这里部分代码省略.........