コード例 #1
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];
 }
コード例 #2
0
ファイル: LanguageSearch.php プロジェクト: BeforyDeath/tfa
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Language::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]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: LanguageSearch.php プロジェクト: quyettvq/luspel
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Language::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, 'is_default' => $this->is_default, 'is_active' => $this->is_active, 'default_currency_id' => $this->default_currency_id, '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', 'image', $this->image])->andFilterWhere(['like', 'image_path', $this->image_path])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'updated_by', $this->updated_by]);
     return $dataProvider;
 }
コード例 #4
0
ファイル: Language.php プロジェクト: quyettvq/luspel
 /**
  * function ::create ($data)
  */
 public static function create($data)
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = new Language();
     if ($model->load($data)) {
         if ($log = new UserLog()) {
             $log->username = $username;
             $log->action = "Create";
             $log->object_class = "Language";
             $log->created_at = $now;
             $log->is_success = 0;
             $log->save();
         }
         $model->created_at = $now;
         $model->created_by = $username;
         do {
             $path = FileUtils::generatePath($now);
         } while (file_exists(Yii::$app->params['images_folder'] . $path));
         $model->image_path = $path;
         $targetFolder = Yii::$app->params['images_folder'] . $model->image_path;
         $targetUrl = Yii::$app->params['images_url'] . $model->image_path;
         if (!empty($data['language-image'])) {
             $copyResult = FileUtils::copyImage(['imageName' => $model->image, 'fromFolder' => Yii::$app->params['uploads_folder'], 'toFolder' => $targetFolder, 'resize' => [[20, 20], [30, 30], [40, 40], [100, 100]], 'removeInputImage' => true]);
             if ($copyResult['success']) {
                 $model->image = $copyResult['imageName'];
             }
         }
         if ($model->save()) {
             if ($log) {
                 $log->object_pk = $model->id;
                 $log->is_success = 1;
                 $log->save();
             }
             return $model;
         }
         $model->getErrors();
         return $model;
     }
     return false;
 }
コード例 #5
0
ファイル: Customer.php プロジェクト: quyettvq/luspel
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLanguage()
 {
     return $this->hasOne(Language::className(), ['id' => 'language_id']);
 }
コード例 #6
0
 /**
  * Finds the Language model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Language the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Language::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #7
0
ファイル: _form.php プロジェクト: BeforyDeath/tfa
/* @var $model backend\models\Domain */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="domain-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'language_id')->dropdownList(\backend\models\Language::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Language:'])->label('Language Name');
?>

    <?php 
echo $form->field($model, 'group_id')->dropdownList(\backend\models\GroupDomain::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Group Domain:'])->label('Group Domain Name');
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>