本文整理汇总了PHP中Currency::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::model方法的具体用法?PHP Currency::model怎么用?PHP Currency::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
public function actionUpdate($id)
{
$model = new SettingsForm();
if (isset($_POST['SettingsForm'])) {
$model->attributes = $_POST['SettingsForm'];
if ($model->validate() && $model->save()) {
$this->redirect(array('index'));
}
} else {
$model->loadDataFromStore($id);
}
$directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
$themes = array();
foreach ($directories as $directory) {
$themes[] = basename($directory);
}
$layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
$countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
$zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
$languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
$currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
$yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
$lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
$weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
$taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
$customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
$informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
// TODO: localisation
$orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
// TODO: localisation
$returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
$mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
$this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
}
示例2: run
public function run()
{
$this->log("Start parse");
$currenciesList = CHtml::listData(Currency::model()->findAll(), 'code', function ($data) {
return $data;
});
$url = "http://www.cbr.ru/scripts/XML_daily.asp";
// URL, XML документ, всегда содержит актуальные данные
$rate = null;
// загружаем полученный документ в дерево XML
if (!($xml = simplexml_load_file($url))) {
$this->log("XML loading error");
die('XML loading error');
}
foreach ($xml->Valute as $m) {
$code = strtolower($m->CharCode);
if (key_exists($code, $currenciesList)) {
$rate = (double) str_replace(",", ".", (string) $m->Value);
$this->log("Rate {$code} is: " . $rate);
if (!empty($rate)) {
$currency = $currenciesList[$code];
$currency->rate = $rate;
if ($currency->update(['rate'])) {
$this->log("Rate {$code} saved successfully");
} else {
$this->log("Rate {$code} not saved");
}
} else {
$this->log("Rate {$code} is empty");
}
}
}
$this->log("Finish parse");
}
示例3: updateStatusAd
public static function updateStatusAd()
{
if (Yii::app()->request->getIsAjaxRequest() || !issetModule('paidservices')) {
return false;
}
if (!oreInstall::isInstalled()) {
return false;
}
$data = Yii::app()->statePersister->load();
// Обновляем статусы 1 раз в сутки
if (isset($data['next_check_status'])) {
if ($data['next_check_status'] < time()) {
$data['next_check_status'] = time() + self::TIME_UPDATE;
Yii::app()->statePersister->save($data);
self::checkStatusAd();
self::clearApartmentsStats();
// обновляем курсы валют
Currency::model()->parseCbr();
}
} else {
$data['next_check_status'] = time() + self::TIME_UPDATE;
Yii::app()->statePersister->save($data);
self::checkStatusAd();
self::clearApartmentsStats();
}
}
示例4: run
public function run()
{
$models = Currency::model()->findAll();
if (empty($models)) {
return;
}
$this->render($this->view, ['models' => $models]);
}
示例5: updateStatusAd
public static function updateStatusAd()
{
if (Yii::app()->request->getIsAjaxRequest()) {
return false;
}
if (!oreInstall::isInstalled()) {
return false;
}
$data = Yii::app()->statePersister->load();
// Обновляем статусы 1 раз в сутки
if (isset($data['next_check_status'])) {
if ($data['next_check_status'] < time()) {
$data['next_check_status'] = time() + self::TIME_UPDATE;
Yii::app()->statePersister->save($data);
if (issetModule('paidservices')) {
self::checkStatusAd();
// обновляем курсы валют
Currency::model()->parseCbr();
}
self::clearDrafts();
self::clearApartmentsStats();
self::clearUsersSessions();
self::checkDateEndActivity();
self::deleteIPFromBlocklist();
}
} else {
$data['next_check_status'] = time() + self::TIME_UPDATE;
Yii::app()->statePersister->save($data);
if (issetModule('paidservices')) {
self::checkStatusAd();
// обновляем курсы валют
Currency::model()->parseCbr();
}
self::clearDrafts();
self::clearApartmentsStats();
self::clearUsersSessions();
self::checkDateEndActivity();
self::deleteIPFromBlocklist();
}
// Тарифные планы - 2 раза в сутки
if (issetModule('tariffPlans') && issetModule('paidservices')) {
if (isset($data['next_check_status_users_tariffs'])) {
if ($data['next_check_status_users_tariffs'] < time()) {
$data['next_check_status_users_tariffs'] = time() + self::TIME_UPDATE_TARIFF_PLANS;
Yii::app()->statePersister->save($data);
self::checkTariffPlansUsers();
}
} else {
$data['next_check_status_users_tariffs'] = time() + self::TIME_UPDATE_TARIFF_PLANS;
Yii::app()->statePersister->save($data);
self::checkTariffPlansUsers();
}
}
Yii::app()->cache->flush();
}
示例6: actionDelete
public function actionDelete($ids)
{
$ids = explode(',', $ids);
if (count($ids) > 0) {
foreach ($ids as $id) {
$currency = Currency::model()->findByPk($id);
$currency->delete();
}
}
$this->redirect(array('index'));
}
示例7: parse
public static function parse($date)
{
$date = date('Y-m-d', strtotime($date));
require_once 'sources/CurrencySourceBase.php';
/** @var CurrencyRaw[][] $data */
$data = [];
$codes = [];
foreach (static::$sources as $lang => $sourceClass) {
require_once 'sources/' . $sourceClass . '.php';
/** @var CurrencySourceBase $source */
$source = new $sourceClass();
$data[$lang] = $source->parse($date);
$codes = array_merge($codes, array_keys($data[$lang]));
}
// CVarDumper::dump($data, 3, 1);return;
if (isset($data['ru'][self::UAH_CODE])) {
$costRubUah = $data['ru'][self::UAH_CODE]->cost;
} else {
throw new Exception('Cost RUB:UAH not found');
}
$tr = Yii::app()->db->beginTransaction();
Currency::model()->deleteAll('date = :date', [':date' => $date]);
foreach ($codes as $code) {
try {
/** @var CurrencyRaw $ru */
/** @var CurrencyRaw $ua */
$ru = empty($data['ru']) == false && empty($data['ru'][$code]) == false ? $data['ru'][$code] : null;
$ua = empty($data['ua']) == false && empty($data['ua'][$code]) == false ? $data['ua'][$code] : null;
if (!$ru && !$ua) {
continue;
}
$currency = new Currency();
$currency->date = $date;
$currency->num_code = $code;
$currency->char_code = $ru ? $ru->char_code : $ua->char_code;
$currency->name_ru = $ru ? $ru->name : null;
$currency->name_ua = $ua ? $ua->name : null;
$currency->nominal_ru = $ru ? $ru->nominal : null;
$currency->nominal_ua = $ua ? $ua->nominal : null;
$currency->cost_rub = $ru ? $ru->cost / $currency->nominal_ru : null;
$currency->cost_uah = $ua ? $ua->cost / $currency->nominal_ua : null;
$currency->diff = $ru && $ua ? $currency->cost_uah / $costRubUah - $currency->cost_rub : null;
if ($currency->save(true) == false) {
// CVarDumper::dump([$currency->getAttributes(), $currency->errors], 3, 1);
// $tr->rollback();
// throw new Exception('Con not save currency in DB');
}
} catch (Exception $ex) {
continue;
}
}
$tr->commit();
return true;
}
示例8: actionActivate
public function actionActivate()
{
$id = (int) $_GET['id'];
$action = $_GET['action'];
if ($id) {
$model = Currency::model()->findByPk($id);
if ($model->is_default == 1 && $action != 'activate') {
Yii::app()->end();
}
}
parent::actionActivate();
}
示例9: init
public function init()
{
# php.ini - date.timezone
$this->generationDate = date('c', time());
# если нет модуля "Страна->регион->город" задаём строго
$this->country = 'Россия';
$this->region = 'Москва и московская область';
# валюта
$this->currency = 'RUR';
# param('siteCurrency', 'RUR');
if (!isFree()) {
$activeCurrencyId = Currency::getDefaultValuteId();
$activeCurrency = Currency::model()->findByPk($activeCurrencyId);
$this->currency = $activeCurrency && isset($activeCurrency->char_code) ? $activeCurrency->char_code : $this->currency;
}
}
示例10: updateAction
public function updateAction()
{
$model = new Gateway();
$this->performAjaxValidation($model);
// Uncomment the following line if AJAX validation is needed
if (isset($_POST['model']) && $_POST['model'] == 'Gateway') {
if (isset($_POST['ajax'])) {
$model->fillFromArray($_POST, FALSE);
$model->user_id_updated = $this->user->user_id;
$model->updated = 'NOW():sql';
$model->model_uset_id = $this->user->user_id;
if ($model->save()) {
Message::echoJsonSuccess(__('gateway_updated'));
} else {
Message::echoJsonError(__('gateway_no_updated'));
}
die;
}
$model->save();
$this->redirect();
die;
}
$id = AF::get($this->params, 'id', FALSE);
if (!$id) {
throw new AFHttpException(0, 'no_id');
}
if (!$model->cache()->findByPk($id)) {
throw new AFHttpException(0, 'incorrect_id');
}
$currencies = Currency::model()->cache()->findAllInArray();
$methods = Method::model()->cache()->findAllInArray();
$systems = PSystem::model()->cache()->findAllInArray();
$gateways = Gateway::model()->cache()->findAllInArray();
$pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
$models = AFActiveDataProvider::models('GatewayLimit', $this->params, $pagination);
$limits = $models->getLimitsByGatewayId($id);
Assets::js('jquery.form');
$this->addToPageTitle('Update Gateway');
$this->render('update', array('model' => $model, 'currencies' => $currencies, 'limits' => $limits, 'methods' => $methods, 'systems' => $systems, 'gateways' => $gateways));
}
示例11: newretentionAction
function newretentionAction()
{
$clearArray = array('campaign_id', 'detail_dates', 'detail_affiliates', 'detail_sid', 'simple', 'currency_id', 'country_id');
$this->filter($clearArray);
$filterFields = $this->params;
//AFActiveDataProvider::clearDateArray($this->params, array('r_dates'));
if (!isset($filterFields['circle']) || isset($filterFields['circle']) && !$filterFields['circle']) {
$filterFields['circle'] = 0;
}
if ($clearArray) {
foreach ($clearArray as $value) {
if (isset($filterFields[$value])) {
$filterFields[$value] = explode(',', $filterFields[$value]);
}
}
}
// build filter select datasources
$currencies = Currency::model()->cache()->findAllInArray();
$countries = Country::model()->cache()->findAllInArray();
$campaigns = isset($filterFields['campaign_id']) ? $filterFields['campaign_id'] : null;
$country_id = isset($filterFields['country_id']) ? $filterFields['country_id'] : null;
$currency_id = isset($filterFields['currency_id']) ? $filterFields['currency_id'] : null;
$groupDate = isset($filterFields['detail_dates']) ? false : true;
$groupAfid = isset($filterFields['detail_affiliates']) ? false : true;
$groupSid = isset($filterFields['detail_sid']) ? false : true;
$msql = SafeMySQL::getInstance();
$sql = 'SELECT campaign_id, campaign_name
FROM `campaigns`
ORDER BY `campaign_id`';
$campaignsFilterTemp = $msql->getAll($sql);
$campaignsFilter = array();
foreach ($campaignsFilterTemp as $v) {
$campaignsFilter[$v['campaign_id']] = $v;
}
unset($campaignsFilterTemp);
$sql = 'SELECT aff_id, aff_name
FROM `affiliates`
ORDER BY `aff_id`';
$affidsTemp = $msql->getAll($sql);
$affids = array();
foreach ($affidsTemp as $v) {
$affids[$v['aff_id']] = $v;
}
unset($affidsTemp);
$where = '';
if ($campaigns) {
$where .= $msql->parse(" AND `campaign_id` IN (?a)", $campaigns);
}
if ($currency_id) {
$where .= $msql->parse(" AND `campaign_id` IN ( select campaign_id from campaigns where currency_id in (?a))", $currency_id);
}
if ($country_id) {
$where .= $msql->parse(" AND `campaign_id` IN ( select campaign_id from campaigns where country_id in (?a))", $country_id);
}
if (!isset($filterFields['r_dates'])) {
$filterFields['r_dates'] = date('d.m.Y-d.m.Y');
}
$dates = explode('-', $filterFields['r_dates']);
if (isset($dates[0]) && isset($dates[1])) {
$dateStartT = explode('.', $dates[0]);
$dateStart = array_reverse($dateStartT);
$dateStart = implode('-', $dateStart);
$dateFinishT = explode('.', $dates[1]);
$dateFinish = array_reverse($dateFinishT);
$dateFinish = implode('-', $dateFinish);
$where .= $msql->parse(" AND DATE(`date`) BETWEEN ?s AND ?s", $dateStart, $dateFinish);
unset($dateStartT, $dateFinishT);
}
if (!isset($filterFields['report_date'])) {
$filterFields['report_date'] = date('d.m.Y');
}
$reportDateArray = explode('.', $filterFields['report_date']);
if (isset($reportDateArray[0]) && isset($reportDateArray[1]) && isset($reportDateArray[2])) {
$reportDate = array_reverse($reportDateArray);
$reportDate = implode('-', $reportDate);
$where .= $msql->parse("AND `id_date` <= ?s", $reportDate);
unset($reportDate, $reportDateArray);
}
$where .= $msql->parse("AND CAST(SUBSTR(`col_name`,2,1) AS UNSIGNED) <= ?i", (int) $filterFields['circle']);
$sql = "\n SELECT " . ($groupDate ? "'ALL' AS " : '') . "`date`, `campaign_id`, " . ($groupAfid ? "'ALL' AS " : '') . "`aff_id`, " . ($groupSid ? "'ALL' AS " : '') . "`sid`, `col_name`, SUM(`data`) AS `data`, `currency_id`\n FROM (\n SELECT `date`, `campaign_id`, `aff_id`, `sid`, `col_name`, `data`, `currency_id`\n FROM (\n SELECT `retention_history`.*, `campaigns`.`currency_id`\n FROM `retention_history`\n LEFT JOIN `campaigns` USING(`campaign_id`)\n WHERE 1 " . $where . "\n ORDER BY `id_date` DESC\n ) `t`\n GROUP BY `date`, `campaign_id`, `aff_id`, `col_name`\n ) `t2`\n GROUP BY " . ($groupDate ? '' : "`date`, ") . "`campaign_id`, " . ($groupAfid ? '' : "`aff_id`, ") . "`col_name`\n ";
$result = $msql->getAll($sql);
$report = array();
$reportCur = array();
$countR = 0;
foreach ($result as $row) {
if (isset($row['col_name'])) {
$colNameArr = explode('_', $row['col_name']);
if (isset($colNameArr[0])) {
$countCycles = (int) substr($colNameArr[0], 1, 1);
if ($countCycles > $countR) {
$countR = $countCycles;
}
}
}
if (!isset($report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']]['c' . ($row['col_name'][1] + 1) . '_gross'])) {
if (!isset($report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']])) {
$report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']] = array();
}
$report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']] += self::cycle_array($row['col_name'][1]);
}
//.........这里部分代码省略.........
示例12: array
echo $form->textField($model, 'taxno', array('size' => 10, 'maxlength' => 50));
?>
<?php
echo $form->error($model, 'taxno');
?>
</div>
<div class="row">
<?php
echo $form->labelEx($model, 'currencyid');
?>
<?php
echo $form->hiddenField($model, 'currencyid');
?>
<input type="text" name="currencyname" id="currencyname" style="width:100px" readonly value="<?php
echo Currency::model()->findByPk($model->currencyid) !== null ? Currency::model()->findByPk($model->currencyid)->currencyname : '';
?>
">
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'currency_dialog', 'options' => array('title' => Yii::t('app', 'Currency'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true)));
$this->widget('zii.widgets.grid.CGridView', array('id' => 'currency-grid', 'dataProvider' => $currency->Searchwstatus(), 'filter' => $currency, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("+",
array("name" => "send_absschedule",
"id" => "send_absschedule",
"onClick" => "$(\\"#currency_dialog\\").dialog(\\"close\\");
$(\\"#currencyname\\").val(\\"$data->currencyname\\");
$(\\"#Company_currencyid\\").val(\\"$data->currencyid\\");
"))'), array('name' => 'currencyid', 'visible' => false, 'value' => '$data->currencyid', 'htmlOptions' => array('width' => '1%')), 'currencyname', array('class' => 'CCheckBoxColumn', 'name' => 'recordstatus', 'selectableRows' => '0', 'header' => 'Record Status', 'checked' => '$data->recordstatus'))));
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
<input class="button" type="button" value="..." name="currency_button" onclick="$('#currency_dialog').dialog('open'); return false;">
<?php
示例13:
// echo $form->textField($model,'city_id');
?>
<?php echo $form->error($model,'city_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'expence_id'); ?>
<?php echo $form->textField($model,'expname',array('length'=>'30','readonly'=>'readonly')); ?>
<?php echo CHtml::button("...",array('onclick'=>'pickValue("expence");')); ?>
<?php echo $form->hiddenField($model,'expence_id'); ?>
<?php echo $form->error($model,'expence_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'currency_id'); ?>
<?php
$list = CHtml::listData(Currency::model()->findAll(),'id', 'name');
echo $form->DropDownList($model,'currency_id',$list);
// echo $form->textField($model,'currency_id');
?>
<?php echo $form->error($model,'currency_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'amount'); ?>
<?php echo $form->textField($model,'amount'); ?>
<?php echo $form->error($model,'amount'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($modelp,'name'); ?>
<?php echo $form->textField($modelp,'name',array('size'=>60,'maxlength'=>64)); ?>
<?php echo $form->error($modelp,'name'); ?>
示例14: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Currency the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Currency::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例15: actionUpload
public function actionUpload()
{
parent::actionUpload();
$folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
// folder for uploaded files
$file = $folder . basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
$row = 0;
if (($handle = fopen($file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($row > 0) {
$model = Company::model()->findByPk((int) $data[0]);
if ($model === null) {
$model = new Company();
}
$model->companyid = (int) $data[0];
$model->companyname = $data[1];
$model->address = $data[2];
$city = City::model()->findbyattributes(array('cityname' => $data[3]));
if ($city !== null) {
$model->cityid = $city->cityid;
}
$model->zipcode = $data[4];
$model->taxno = $data[5];
$currency = Currency::model()->findbyattributes(array('currencyname' => $data[6]));
if ($currency !== null) {
$model->currencyid = $currency->currencyid;
}
$model->recordstatus = (int) $data[7];
try {
if (!$model->save()) {
$this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
}
} catch (Exception $e) {
$this->messages = $this->messages . $e->getMessage();
}
}
$row++;
}
} else {
$this->messages = $this->messages . ' memory or harddisk full';
}
fclose($handle);
} else {
$this->messages = $this->messages . ' check your directory permission';
}
if ($this->messages == '') {
$this->messages = 'success';
}
echo $this->messages;
}