예제 #1
0
 public static function getCurs($valute)
 {
     $param = Setup::find()->where(['param_name' => $valute . date("d-m-Y", time())])->one();
     if ($param) {
         return $param->param_value;
     } else {
         $rates = new Exchange(time());
         $curs = $rates->GetRate($valute);
         // Обновить курс
         $model = new Setup();
         $model->param_name = (string) $valute . date("d-m-Y", time());
         $model->param_value = (string) $curs;
         //$model->validate();
         //vd($model->getErrors());
         $model->save();
         return $curs;
     }
 }
예제 #2
0
 private function getCommonDate()
 {
     $currCurency = Setup::getCurrCurency();
     $data['currCurency'] = $currCurency;
     $currLang = Setup::getCurrLang();
     $data['currLang'] = $currLang;
     $iP = Yii::$app->session->id;
     $modelWishList = WishList::getListByIp($iP);
     $quantityWishlist = $modelWishList ? count($modelWishList) : '';
     $data['quantityWishlist'] = $quantityWishlist;
     $data['modelWishList'] = $modelWishList;
     $modelCompareList = Compare::getListByIp($iP);
     $quantityCompareList = $modelCompareList ? count($modelCompareList) : '';
     $data['quantityCompareList'] = $quantityCompareList;
     $data['modelCompareList '] = $modelCompareList;
     $quantityInCart = Cart::getQountAllByIp($iP);
     $data['quantityInCart'] = $quantityInCart;
     return $data;
 }
예제 #3
0
 public function init()
 {
     parent::init();
     Yii::$app->language = Setup::getAndSetCurrLang();
 }
예제 #4
0
 public static function changeLangTo($lang)
 {
     $indef = isset(Yii::$app->user->id) ? Yii::$app->user->id : Yii::$app->session->id;
     //vd($indef);
     $model = self::find()->where(['user_id' => $indef, 'param_name' => 'lang', 'param_value' => [self::RU, self::EN]])->one();
     //vd($model);
     if ($model) {
         // сравнить и изменить
         if ($model->param_value != $lang) {
             $model->param_value = $lang;
             $model->updateAttributes(['param_value']);
             return $model->param_value;
         } else {
             return self::RU;
         }
     } else {
         //vd(4);
         $_model = new Setup();
         $_model->param_name = 'lang';
         $_model->param_value = (string) $lang;
         $_model->user_id = (string) $indef;
         //vd(yii::$app->user->id);
         //$_model->validate();
         //vd($_model->getErrors());
         $_model->save();
         return $lang;
     }
 }
예제 #5
0
 public function init()
 {
     parent::init();
     $countPostOnPage = Setup::find()->where(['param_name' => 'countPostOnPage'])->one();
 }