コード例 #1
0
ファイル: RateController.php プロジェクト: vidmed/go-change
 /**
  * Updates an existing Rate model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $currencies = Currency::getAssocCurrencies();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'currencies' => $currencies]);
     }
 }
コード例 #2
0
ファイル: Currency.php プロジェクト: quyettvq/luspel
 /**
  * function ::create ($data)
  */
 public static function create($data)
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = new Currency();
     if ($model->load($data)) {
         if ($log = new UserLog()) {
             $log->username = $username;
             $log->action = "Create";
             $log->object_class = "Currency";
             $log->created_at = $now;
             $log->is_success = 0;
             $log->save();
         }
         $model->created_at = $now;
         $model->created_by = $username;
         if ($model->save()) {
             if ($log) {
                 $log->object_pk = $model->id;
                 $log->is_success = 1;
                 $log->save();
             }
             return $model;
         }
         $model->getErrors();
         return $model;
     }
     return false;
 }
コード例 #3
0
ファイル: BaseController.php プロジェクト: quyettvq/luspel
 public function init()
 {
     parent::init();
     $this->languages_codeToName = ArrayHelper::map(Language::find()->all(), 'code', 'name');
     $this->languages_idToName = ArrayHelper::map(Language::find()->all(), 'id', 'name');
     $this->currencies_idToName = ArrayHelper::map(Currency::find()->all(), 'id', 'name');
     $this->parent_productCategories_idToSlug = ArrayHelper::map(ProductCategory::find()->where(['parent_id' => null])->all(), 'id', 'slug');
     foreach ($this->parent_productCategories_idToSlug as $id => $slug) {
         $this->productCategories_idToSlug[$slug] = ArrayHelper::map(ProductCategory::find()->where(['parent_id' => $id])->all(), 'id', 'slug');
     }
     is_array($this->productCategories_idToSlug) or $this->productCategories_idToSlug = array();
     $this->productCollections_idToSlug = ArrayHelper::map(ProductCollection::find()->all(), 'id', 'slug');
     I18n::$currency_params = ['exchange_rate' => 1, 'prefix' => '', 'suffix' => 'đ', 'thousand_separator' => '.', 'decimal_point' => ',', 'number_digits_after_decimal_point' => 0];
 }
コード例 #4
0
ファイル: CurrencySearch.php プロジェクト: quyettvq/luspel
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Currency::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'exchange_rate' => $this->exchange_rate, 'number_digits_after_decimal_point' => $this->number_digits_after_decimal_point, 'is_default' => $this->is_default, 'is_active' => $this->is_active, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'prefix', $this->prefix])->andFilterWhere(['like', 'suffix', $this->suffix])->andFilterWhere(['like', 'thousand_separator', $this->thousand_separator])->andFilterWhere(['like', 'decimal_point', $this->decimal_point])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'updated_by', $this->updated_by]);
     return $dataProvider;
 }
コード例 #5
0
ファイル: CurrencySearch.php プロジェクト: vidmed/go-change
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Currency::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'billing_id' => $this->billing_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #6
0
 /**
  * Finds the Currency model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Currency the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Currency::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #7
0
ファイル: Saleorder.php プロジェクト: nirantarnoy/st2
 public function getCurrencyicon()
 {
     return $this->hasOne(Currency::className(), ['recid' => 'currency']);
 }