public function actionUpdateAll()
 {
     if (\Yii::$app->request->isPost) {
         foreach (\skeeks\modules\cms\money\Currency::$currencies as $code => $data) {
             $currency = new \skeeks\modules\cms\money\Currency($code);
             if (!($currencyModel = Currency::find()->where(['code' => $code])->one())) {
                 $currencyModel = new Currency(['code' => $code, 'active' => Cms::BOOL_N, 'name_full' => $currency->getDisplayName(), 'name' => $currency->getDisplayName()]);
                 $currencyModel->save(false);
             } else {
                 if (!$currencyModel->name) {
                     $currencyModel->name = $currency->getDisplayName();
                 }
                 if (!$currencyModel->name_full) {
                     $currencyModel->name_full = $currency->getDisplayName();
                 }
                 $currencyModel->save(false);
             }
         }
     }
     return $this->render('update-all');
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCurrency()
 {
     return $this->hasOne(Currency::className(), ['code' => 'currency_code']);
 }
Пример #3
0
 * @author Semenov Alexander <*****@*****.**>
 * @link http://skeeks.com/
 * @copyright 2010 SkeekS (СкикС)
 * @date 27.03.2015
 */
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model \skeeks\cms\models\WidgetConfig */
?>


<?php 
echo $form->fieldSet(\Yii::t('skeeks/money', 'Main'));
?>

    <?php 
echo $form->fieldSelect($model, 'currencyCode', \yii\helpers\ArrayHelper::map(\skeeks\modules\cms\money\models\Currency::find()->active()->all(), 'code', function ($model) {
    return "{$model->name} [{$model->code}]";
}));
?>

    <?
        echo $form->field($model, 'markupOnUpdate');
    ?>
<?php 
echo $form->fieldSetEnd();
?>



Пример #4
0
 /**
  * @return \skeeks\modules\cms\money\models\Currency
  */
 public function fetchModel()
 {
     return \skeeks\modules\cms\money\models\Currency::find()->where(["code" => $this->currencyCode])->one();
 }
Пример #5
0
 /**
  * @return $this
  */
 public function processUpdateCourses()
 {
     $cbrf = new ExchangeRatesCBRF();
     $data = $cbrf->GetRates();
     if ($data['byChCode']) {
         foreach ($data['byChCode'] as $code => $value) {
             if ($currency = \skeeks\modules\cms\money\models\Currency::find()->where(['code' => $code])->one()) {
                 //TODO: хардкод (
                 if ($currency->code != "RUB") {
                     $currency->course = $value + $value * $this->markupOnUpdate / 100;
                     //+наценка
                 } else {
                     $currency->course = $value;
                     //+наценка
                 }
                 $currency->save(false);
             }
         }
     }
     return $this;
 }
Пример #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBaseRateCurrency()
 {
     return $this->hasOne(Currency::className(), ['code' => 'base_rate_currency_code']);
 }
Пример #7
0
?>
            </div>
        </div>


        <div class="row">
            <div class="col-md-3">
                <?php 
echo $form->field($model, 'price')->textInput();
?>

            </div>

            <div class="col-md-2">
                <?php 
echo $form->field($model, 'currency_code')->listBox(\yii\helpers\ArrayHelper::map(\skeeks\modules\cms\money\models\Currency::find()->active()->all(), 'code', 'code'), ['size' => 1]);
?>
            </div>

            <div class="col-md-3">
                <?php 
echo $form->field($model, 'notes')->textInput()->label('Примечание к цене');
?>
            </div>
        </div>

    <?php 
echo $form->fieldSetEnd();
?>

    <?php 
Пример #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPurchasingCurrency()
 {
     return $this->hasOne(Currency::className(), ['code' => 'purchasing_currency']);
 }